forked from BC-SECURITY/Empire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bypass module and fixed module obfuscation (BC-SECURITY#711)
* added bypass module and fixed module obfuscation * Update empire/server/modules/powershell/management/invoke_bypass.py Co-authored-by: Vincent Rose <[email protected]> * reformat --------- Co-authored-by: Vincent Rose <[email protected]>
- Loading branch information
Showing
4 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
empire/server/modules/powershell/management/invoke_bypass.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Dict | ||
|
||
from empire.server.core.db.base import SessionLocal | ||
from empire.server.core.module_models import EmpireModule | ||
|
||
|
||
class Module: | ||
@staticmethod | ||
def generate( | ||
main_menu, | ||
module: EmpireModule, | ||
params: Dict, | ||
obfuscate: bool = False, | ||
obfuscation_command: str = "", | ||
): | ||
script = "" | ||
|
||
with SessionLocal.begin() as db: | ||
for name in params["Bypasses"].split(): | ||
bypass = main_menu.bypassesv2.get_by_name(db, name) | ||
if bypass: | ||
script += bypass.code | ||
|
||
script = main_menu.modulesv2.finalize_module( | ||
script=script, | ||
script_end="", | ||
obfuscate=obfuscate or params["Obfuscate"], | ||
obfuscation_command=obfuscation_command | ||
if obfuscation_command != "" | ||
else params["ObfuscateCommand"], | ||
) | ||
return script |
43 changes: 43 additions & 0 deletions
43
empire/server/modules/powershell/management/invoke_bypass.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Invoke-Script | ||
authors: | ||
- name: "Anthony Rose" | ||
handle: "@Cx01N" | ||
link: "https://twitter.com/Cx01N_" | ||
description: Run a bypasses from the server. | ||
software: '' | ||
tactics: | ||
- TA0005 | ||
techniques: | ||
- T1562 | ||
background: true | ||
output_extension: | ||
needs_admin: false | ||
opsec_safe: true | ||
language: powershell | ||
min_language_version: '2' | ||
comments: [] | ||
options: | ||
- name: Agent | ||
description: Agent to run module on. | ||
required: true | ||
value: '' | ||
- name: Bypasses | ||
description: Bypasses as a space separated list to be prepended to the launcher. | ||
required: true | ||
value: mattifestation etw | ||
- name: Obfuscate | ||
description: Obfuscate the launcher powershell code, uses the ObfuscateCommand | ||
for obfuscation types. For powershell only. | ||
required: false | ||
value: 'False' | ||
strict: true | ||
suggested_values: | ||
- True | ||
- False | ||
- name: ObfuscateCommand | ||
description: The Invoke-Obfuscation command to use. Only used if Obfuscate switch | ||
is True. For powershell only. | ||
required: false | ||
value: Token\All\1 | ||
advanced: | ||
custom_generate: true |