Skip to content

Commit dd36c30

Browse files
committed
Disguise auxiliary module: ensure launch_background_processes() launches 64-bit processes on both bitnesses of Python
1 parent e1ad9f9 commit dd36c30

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

analyzer/windows/modules/auxiliary/disguise.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import re
1010
import subprocess
11-
from ctypes import byref, sizeof
11+
from ctypes import byref, sizeof, c_void_p
1212
from random import randint
1313
from uuid import uuid4
1414
from winreg import (
@@ -257,8 +257,28 @@ def add_persistent_route(self, gateway: str):
257257
self.run_as_system(["C:\\Windows\\System32\\ROUTE.exe", "-p", "change", "0.0.0.0", "mask", "0.0.0.0", gateway])
258258

259259
def launch_background_processes(self):
260-
notepad_path = os.path.join(os.environ["SystemRoot"], "System32", "notepad.exe")
261-
self._launch_background_process(notepad_path)
260+
try:
261+
total_processes = int(self.options.get("background_processes", 1))
262+
except (TypeError, ValueError):
263+
total_processes = 1
264+
total_processes = max(0, min(total_processes, 10))
265+
266+
if total_processes > 0:
267+
if sizeof(c_void_p) == 4:
268+
system32 = os.path.join(os.environ["SystemRoot"], "Sysnative")
269+
else:
270+
system32 = os.path.join(os.environ["SystemRoot"], "System32")
271+
notepad_path = os.path.join(system32, "notepad.exe")
272+
calc_path = os.path.join(system32, "calc.exe")
273+
process_pool = [notepad_path, calc_path]
274+
275+
# Always launch notepad first.
276+
self._launch_background_process(notepad_path)
277+
278+
for _ in range(total_processes - 1):
279+
selected_process = process_pool[randint(0, len(process_pool) - 1)]
280+
self._launch_background_process(selected_process)
281+
# self.log_notepad_process_tree()
262282

263283
def _launch_background_process(self, process_path):
264284
try:
@@ -324,30 +344,11 @@ def log_notepad_process_tree(self):
324344
log.error("Failed to collect notepad process info: %s", e.output)
325345

326346
def start(self):
327-
try:
328-
total_processes = int(self.options.get("background_processes", 1))
329-
except (TypeError, ValueError):
330-
total_processes = 1
331-
total_processes = max(0, min(total_processes, 10))
332-
333-
if total_processes > 0:
334-
system32 = os.path.join(os.environ["SystemRoot"], "System32")
335-
notepad_path = os.path.join(system32, "notepad.exe")
336-
calc_path = os.path.join(system32, "calc.exe")
337-
process_pool = [notepad_path, calc_path]
338-
339-
# Always launch notepad first.
340-
self._launch_background_process(notepad_path)
341-
342-
for _ in range(total_processes - 1):
343-
selected_process = process_pool[randint(0, len(process_pool) - 1)]
344-
self._launch_background_process(selected_process)
345-
# self.log_notepad_process_tree()
346-
347347
if self.config.windows_static_route:
348348
log.info("Config for route is: %s", str(self.config.windows_static_route))
349349
self.add_persistent_route(self.config.windows_static_route_gateway)
350350

351+
self.launch_background_processes()
351352
self.change_productid()
352353
self.set_office_mrus()
353354
self.ramnit()

0 commit comments

Comments
 (0)