Skip to content

Commit

Permalink
Fixed error in generating stager for HTTP Hop listener (BC-SECURITY#740)
Browse files Browse the repository at this point in the history
* fixed http hop obfuscation

* changelog
  • Loading branch information
Cx01N committed Dec 9, 2023
1 parent f9864d9 commit 03f4191
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Security** in case of vulnerabilities.

## [Unreleased]
- Fixed error in generating stager for HTTP Hop listener (@Cx01N)

## [5.8.1] - 2023-11-30

Expand Down
16 changes: 7 additions & 9 deletions empire/server/listeners/http_hop.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,28 +411,26 @@ def generate_stager(
)

staging_key = staging_key.encode("UTF-8")
unobfuscated_stager = listener_util.remove_lines_comments(stager)
stager = listener_util.remove_lines_comments(stager)

if obfuscate:
obfuscated_stager = self.mainMenu.obfuscationv2.obfuscate(
unobfuscated_stager, obfuscation_command=obfuscation_command
)
obfuscated_stager = self.mainMenu.obfuscationv2.obfuscate_keywords(
obfuscated_stager
stager = self.mainMenu.obfuscationv2.obfuscate(
stager, obfuscation_command=obfuscation_command
)
stager = self.mainMenu.obfuscationv2.obfuscate_keywords(stager)

# base64 encode the stager and return it
# There doesn't seem to be any conditions in which the encrypt flag isn't set so the other
# if/else statements are irrelevant
if encode:
return helpers.enc_powershell(obfuscated_stager)
return helpers.enc_powershell(stager)
elif encrypt:
RC4IV = os.urandom(4)
return RC4IV + encryption.rc4(
RC4IV + staging_key, obfuscated_stager.encode("UTF-8")
RC4IV + staging_key, stager.encode("UTF-8")
)
else:
return obfuscated_stager
return stager

if language in ["python", "ironpython"]:
template_path = [
Expand Down

0 comments on commit 03f4191

Please sign in to comment.