forked from EmpireProject/Empire
-
-
Notifications
You must be signed in to change notification settings - Fork 585
/
Copy pathinvoke_script.py
37 lines (31 loc) · 1.05 KB
/
invoke_script.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
from empire.server.common.empire import MainMenu
from empire.server.core.module_models import EmpireModule
from empire.server.utils.module_util import handle_error_message
class Module:
@staticmethod
def generate(
main_menu: MainMenu,
module: EmpireModule,
params: dict,
obfuscate: bool = False,
obfuscation_command: str = "",
):
script_path = params["ScriptPath"]
script_cmd = params["ScriptCmd"]
script = ""
if script_path != "":
try:
with open(f"{script_path}") as data:
script = data.read()
except Exception:
return handle_error_message(
"[!] Could not read script source path at: " + str(script_path)
)
script += "\n"
script += f"{script_cmd}"
return main_menu.modulesv2.finalize_module(
script=script,
script_end="",
obfuscate=obfuscate,
obfuscation_command=obfuscation_command,
)