Skip to content

Commit 736db4d

Browse files
update force_ps32 if/then for readability (and add Ruff ignore - blame Neff!)
1 parent 6213c64 commit 736db4d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

nxc/helpers/powershell.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ def create_ps_command(ps_command, force_ps32=False, obfs=False, custom_amsi=None
148148
else:
149149
amsi_bypass = ""
150150

151-
# https://stackoverflow.com/a/60155248
152-
command = amsi_bypass + f"$functions = {{function Command-ToExecute{{{amsi_bypass + ps_command}}}}}; if ($Env:PROCESSOR_ARCHITECTURE -eq 'AMD64'){{$job = Start-Job -InitializationScript $functions -ScriptBlock {{Command-ToExecute}} -RunAs32; $job | Wait-Job | Receive-Job }} else {{IEX '$functions'; Command-ToExecute}}" if force_ps32 else f"{amsi_bypass} {ps_command}"
151+
# for readability purposes, we do not do a one-liner
152+
if force_ps32:
153+
# https://stackoverflow.com/a/60155248
154+
command = amsi_bypass + f"$functions = {{function Command-ToExecute{{{amsi_bypass + ps_command}}}}}; if ($Env:PROCESSOR_ARCHITECTURE -eq 'AMD64'){{$job = Start-Job -InitializationScript $functions -ScriptBlock {{Command-ToExecute}} -RunAs32; $job | Wait-Job | Receive-Job }} else {{IEX '$functions'; Command-ToExecute}}"
155+
else:
156+
command = f"{amsi_bypass} {ps_command}"
153157

154158
nxc_logger.debug(f"Generated PS command:\n {command}\n")
155159

0 commit comments

Comments
 (0)