forked from EmpireProject/Empire
-
-
Notifications
You must be signed in to change notification settings - Fork 585
/
Copy pathAssembly.Covenant.py
executable file
·45 lines (37 loc) · 1.42 KB
/
Assembly.Covenant.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import yaml
from empire.server.common.empire import MainMenu
from empire.server.core.module_models import EmpireModule
class Module:
@staticmethod
def generate(
main_menu: MainMenu,
module: EmpireModule,
params: dict,
obfuscate: bool = False,
obfuscation_command: str = "",
):
base64_assembly = params["File"].get_base64_file()
compiler = main_menu.pluginsv2.get_by_id("csharpserver")
if compiler.status != "ON":
return None, "csharpserver plugin not running"
# Convert compiler.yaml to python dict
compiler_dict: dict = yaml.safe_load(module.compiler_yaml)
# delete the 'Empire' key
del compiler_dict[0]["Empire"]
# convert back to yaml string
compiler_yaml: str = yaml.dump(compiler_dict, sort_keys=False)
file_name = compiler.do_send_message(
compiler_yaml, module.name, confuse=obfuscate
)
if file_name == "failed":
return None, "module compile failed"
script_file = (
main_menu.installPath
+ "/csharp/Covenant/Data/Tasks/CSharp/Compiled/"
+ (params["DotNetVersion"]).lower()
+ "/"
+ file_name
+ ".compiled"
)
script_end = f",{base64_assembly}, {params['Parameters']}"
return f"{script_file}|{script_end}", None