@@ -72,7 +72,7 @@ def main():
7272 [+] ./ioshook -p com.apple.AppStore / [-n 'App Store'] -s trace_class.js
7373 Example for spawn or attach app with -m(--method) options:
7474 [+] ./ioshook -p com.apple.AppStore / [-n 'App Store'] -m app-static
75- Example dump decrypt ipa with -d(--dump) and -o(--output) options:
75+ Example dump decrypt ipa with -d(--dump-app ) and -o(--output) options:
7676 [+] ./ioshook -p com.apple.AppStore / [-n 'App Store'] -d -o App_dump_name
7777 Example dump memory of application with --dump-memory and -s(--string) options:
7878 [+] ./ioshook -n 'App Store' --dump-memory --string
@@ -84,7 +84,7 @@ def main():
8484 parser = optparse .OptionParser (usage , add_help_option = False )
8585 info = optparse .OptionGroup (parser ,"Information" )
8686 quick = optparse .OptionGroup (parser ,"Quick Method" )
87- dump = optparse .OptionGroup (parser ,"Dump decrypt IPA" )
87+ dumpapp = optparse .OptionGroup (parser ,"Dump decrypt IPA" )
8888 hexscan = optparse .OptionGroup (parser ,"HexByte Scan IPA" )
8989 dumpmemory = optparse .OptionGroup (parser ,"Dump memory of Application" )
9090 reflutter = optparse .OptionGroup (parser ,"reFlutter" )
@@ -97,9 +97,11 @@ def main():
9797 #Using options -n(--name) for attach script to application is running
9898 parser .add_option ("-n" , "--name" , dest = "name" ,
9999 help = '''Name of the target app''' , metavar = "NAME" , action = "store" , type = "string" )
100-
100+ parser .add_option ("--pid" , dest = "pid" ,
101+ help = '''PID of the target app''' , metavar = "PID" , action = "store" , type = "string" )
102+ #Using options -s(--script) for load script to application
101103 parser .add_option ("-s" , "--script" , dest = "script" ,
102- help = '''Frida Script Hooking''' , metavar = "SCIPRT .JS" )
104+ help = '''Frida Script Hooking''' , metavar = "SCRIPT .JS" )
103105
104106 parser .add_option ("-c" , "--check-version" , action = "store_true" , help = '''Check iOSHook for the newest version''' , dest = "checkversion" )
105107 parser .add_option ("-u" , "--update" , action = "store_true" , help = '''Update iOSHook to the newest version''' , dest = "update" )
@@ -122,8 +124,8 @@ def main():
122124 info .add_option ("--logcat" , action = "store_true" , help = "Show system log of device" , dest = "logcat" )
123125 info .add_option ("--shell" , "--ssh" , action = "store_true" , help = "Get the shell of connect device" , dest = "shell" )
124126 #Dump decrypt IPA using the code of the AloneMonkey's repo frida-ios-dump - Link: https://github.com/AloneMonkey/frida-ios-dump
125- dump .add_option ("-d" , "--dump" , action = "store_true" , help = "Dump decrypt application.ipa" , dest = "dumpapp" )
126- dump .add_option ("-o" , "--output" , action = "store" , dest = "output_ipa" , help = "Specify name of the decrypted IPA" , metavar = "OUTPUT_IPA" , type = "string" )
127+ dumpapp .add_option ("-d" , "--dump-app " , action = "store_true" , help = "Dump decrypt application.ipa" , dest = "dumpapp" )
128+ dumpapp .add_option ("-o" , "--output" , action = "store" , dest = "output_ipa" , help = "Specify name of the decrypted IPA" , metavar = "OUTPUT_IPA" , type = "string" )
127129
128130 #Dump memory of application using the code of Nightbringer21's repo fridump - Link: https://github.com/Nightbringer21/fridump
129131 dumpmemory .add_option ("--dump-memory" , action = "store" , help = "Dump memory of application" , dest = "dumpmemory" )
@@ -137,7 +139,7 @@ def main():
137139 #reFlutter of application using the code of ptswarm's repo reFlutter - Link: https://github.com/ptswarm/reFlutter
138140 reflutter .add_option ("--reflutter" , action = "store" , help = "File Flutter.ipa" , dest = "flutterfile" )
139141
140- parser .add_option_group (dump )
142+ parser .add_option_group (dumpapp )
141143 parser .add_option_group (dumpmemory )
142144 parser .add_option_group (hexscan )
143145 parser .add_option_group (info )
@@ -178,9 +180,9 @@ def main():
178180 if re .search (description_pattern , line ):
179181 description = re .sub (r'\n' , '' , line [16 :])
180182 if re .search (mode_pattern , line ):
181- mode = re .sub ('\s+' , '' , line [9 :])
183+ mode = re .sub (r '\s+' , '' , line [9 :])
182184 if re .search (version_pattern , line ):
183- version = re .sub ('\s+' , '' , line [12 :])
185+ version = re .sub (r '\s+' , '' , line [12 :])
184186 print ('|%d|%s|%s|%s|%s|' % (i , mode , file_name , description , version ))
185187 else :
186188 logger .error ('[x_x] Path frida-script not exists!' )
@@ -221,7 +223,7 @@ def main():
221223
222224 #Spawning application and load script with output
223225
224- #Attaching script to application
226+ #Attaching script to application with name
225227 elif options .name and options .script :
226228 check .deviceConnected ()
227229 if not os .path .isfile (options .script ):
@@ -250,7 +252,36 @@ def main():
250252 sys .stdin .read ()
251253 else :
252254 logger .error ('[x_x] Script not found!' )
253-
255+ #Attaching script to application with pid
256+ elif options .pid and options .script :
257+ check .deviceConnected ()
258+ if not os .path .isfile (options .script ):
259+ logger .warning ('[!] Script ' + options .script + ' not found. Try suggestion in frida-script!' )
260+ findingScript = suggestion_script (options .script )
261+ if (findingScript == False ):
262+ logger .error ('[x_x] No matching suggestions!' )
263+ sys .exit (0 )
264+ logger .info ('[*] iOSHook suggestion use ' + findingScript )
265+ answer = input ('[?] Do you want continue? (y/n): ' ) or "y"
266+ if answer == "y" :
267+ options .script = APP_FRIDA_SCRIPTS + findingScript
268+ elif answer == "n" :
269+ sys .exit (0 )
270+ else :
271+ logger .error ('[x_x] Nothing done. Please try again!' )
272+ sys .exit (0 )
273+ if os .path .isfile (options .script ):
274+ logger .info ('[*] Attaching PID: ' + options .pid )
275+ logger .info ('[*] Script: ' + options .script )
276+ time .sleep (2 )
277+ process = frida .get_usb_device ().attach (int (options .pid ))
278+ hook = open (options .script , 'r' )
279+ script = process .create_script (hook .read ())
280+ script .load ()
281+ sys .stdin .read ()
282+ else :
283+ logger .error ('[x_x] Script not found!' )
284+
254285 #Static Analysis Application
255286 elif options .name and options .method == "app-static" :
256287 check .deviceConnected ()
@@ -360,18 +391,31 @@ def main():
360391 elif (options .package or options .name ) and options .dumpapp :
361392 check .deviceConnected ()
362393 check .iproxyInstalled ()
394+ ARRAY_SSH_USER = APP_SSH ['user' ]
395+ ARRAY_SSH_PWD = APP_SSH ['password' ]
396+ SSH_IP = APP_SSH ['ip' ]
397+ SSH_PORT = APP_SSH ['port' ]
398+ choose_ssh_user = input ('[?] Choose SSH user ({0} / {1}): ' .format (ARRAY_SSH_USER [0 ], ARRAY_SSH_USER [1 ]))
399+ if choose_ssh_user in ARRAY_SSH_USER :
400+ SSH_USER = choose_ssh_user
401+ else :
402+ logger .error ("[x_x] SSH user not found in list!" )
403+ input_ssh_user = input ('[?] Input your SSH user: ' )
404+ SSH_USER = input_ssh_user
405+ choose_ssh_pwd = input ('[?] Choose SSH password ({0} / {1}): ' .format (ARRAY_SSH_PWD [0 ], ARRAY_SSH_PWD [1 ]))
406+ if choose_ssh_pwd in ARRAY_SSH_PWD :
407+ SSH_PWD = choose_ssh_pwd
408+ else :
409+ logger .error ("[x_x] SSH password not found in list!" )
410+ input_ssh_pwd = input ('[?] Input your SSH password: ' )
411+ SSH_PWD = input_ssh_pwd
412+
363413 logger .info ('[*] Dumping...' )
364414 util = APP_UTILS ['Dump Decrypt Application' ]
365415 if options .name is None :
366- if options .output_ipa is None :
367- cmd = shlex .split ("python3 " + util + " " + options .package )
368- else :
369- cmd = shlex .split ("python3 " + util + " " + options .package + " -o " + options .output_ipa )
416+ cmd = shlex .split ("python3 " + util + " -u " + SSH_USER + " -p " + SSH_PWD + " -H " + SSH_IP + " -P " + str (SSH_PORT ) + " " + options .package + " -o " + str (options .output_ipa ))
370417 else :
371- if options .output_ipa is None :
372- cmd = shlex .split ("python3 " + util + " " + "'" + options .name + "'" )
373- else :
374- cmd = shlex .split ("python3 " + util + " " + "'" + options .name + "'" + " -o " + options .output_ipa )
418+ cmd = shlex .split ("python3 " + util + " -u " + SSH_USER + " -p " + SSH_PWD + " -H " + SSH_IP + " -P " + str (SSH_PORT ) + " " + options .name + " -o " + str (options .output_ipa ))
375419 completed_process = subprocess .call (cmd )
376420 sys .exit (0 )
377421
@@ -399,6 +443,7 @@ def main():
399443 logger .info ("[*] Please use with command: ./ioshook --hexbyte-scan patch --file " + options .scanfile + " --address patchAddress,patchBytes,patchDistance" )
400444 elif (options .scanfile and options .pattern ):
401445 logger .info ("[*] Please use with command: ./ioshook --hexbyte-scan scan --file " + options .scanfile + " --address " + options .addpatternress )
446+
402447 #refluter ipa
403448 elif options .flutterfile :
404449 if (os .path .isfile (options .flutterfile )):
@@ -412,6 +457,7 @@ def main():
412457 else :
413458 logger .error ("[x_x] File " + options .flutterfile + " not found!" )
414459 sys .exit (0 )
460+
415461 #ios system log
416462 elif options .logcat :
417463 check .deviceConnected ()
@@ -423,9 +469,16 @@ def main():
423469 elif options .shell :
424470 check .deviceConnected ()
425471 check .iproxyInstalled ()
426- SSH_USER = APP_SSH ['user' ]
472+ ARRAY_SSH_USER = APP_SSH ['user' ]
427473 SSH_IP = APP_SSH ['ip' ]
428474 SSH_PORT = APP_SSH ['port' ]
475+ choose_ssh_user = input ('[?] Choose SSH user ({0} / {1}): ' .format (ARRAY_SSH_USER [0 ], ARRAY_SSH_USER [1 ]))
476+ if choose_ssh_user in ARRAY_SSH_USER :
477+ SSH_USER = choose_ssh_user
478+ else :
479+ logger .error ("[x_x] SSH user not found in list!" )
480+ input_ssh_user = input ('[?] Input your SSH user: ' )
481+ SSH_USER = input_ssh_user
429482 logger .info ("[*] Open SSH Shell on device - Default password is `alpine` " )
430483 cmd = shlex .split ("ssh " + SSH_USER + "@" + SSH_IP + " -p " + str (SSH_PORT ))
431484 completed_process = subprocess .call (cmd )
@@ -446,9 +499,10 @@ def main():
446499 logger .error ("[x_x] Timed out while waiting for device to appear." )
447500 except frida .TransportError :
448501 logger .error ("[x_x] The application may crash or lose connection." )
449- except (frida .ProcessNotFoundError ,
450- frida .InvalidOperationError ):
451- logger .error ("[x_x] Unable to find process with name " + options .name + ". You need run app first.!!" )
502+ except frida .ProcessNotFoundError :
503+ logger .error ("[x_x] Unable to find process with PID " + str (options .pid ) + " or with name " + str (options .name ) + ". You need run app first.!!" )
504+ except frida .InvalidOperationError :
505+ logger .error ("[x_x] Invalid operation. Please check your command." )
452506 #EXCEPTION FOR OPTIONPARSING
453507
454508 #EXCEPTION FOR SYSTEM
0 commit comments