From 81979014753431dfb508ad0591c4e925d67d8120 Mon Sep 17 00:00:00 2001 From: Cameron Lowell Palmer Date: Wed, 7 Feb 2018 13:46:15 +0100 Subject: [PATCH 1/4] Added exception for when no valid connection exists --- dump.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dump.py b/dump.py index 33d7cc7..c2776f8 100755 --- a/dump.py +++ b/dump.py @@ -300,7 +300,9 @@ if __name__ == '__main__': output_ipa = display_name output_ipa = re.sub('\.ipa$', '', output_ipa) start_dump(device, pid, output_ipa) - + except paramiko.ssh_exception.NoValidConnectionsError as e: + print e + exit_code = 1 except paramiko.AuthenticationException as e: print e exit_code = 1 From 43ff89b1867ba35b485b9ab3a985f81ff4d52361 Mon Sep 17 00:00:00 2001 From: Cameron Lowell Palmer Date: Wed, 7 Feb 2018 14:38:26 +0100 Subject: [PATCH 2/4] Fixed the order of frida calls to avoid problems with slow launching apps --- dump.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dump.py b/dump.py index c2776f8..f64dd96 100755 --- a/dump.py +++ b/dump.py @@ -250,18 +250,17 @@ def open_target_app(device, name_or_bundleid): try: pid = device.spawn([bundle_identifier]) + session = device.attach(pid) device.resume(pid) - time.sleep(1) except Exception as e: print e - return pid, display_name, bundle_identifier + return session, display_name, bundle_identifier -def start_dump(device, pid, ipa_name): +def start_dump(session, ipa_name): print 'Dumping {} to {}'.format(display_name, TEMP_DIR) - session = device.attach(pid) script = load_js_file(session, DUMP_JS) script.post('dump') finished.wait() @@ -295,11 +294,11 @@ if __name__ == '__main__': ssh.connect(Host, port=Port, username=User, password=Password) create_dir(PAYLOAD_PATH) - (pid, display_name, bundle_identifier) = open_target_app(device, name_or_bundleid) + (session, display_name, bundle_identifier) = open_target_app(device, name_or_bundleid) if output_ipa is None: output_ipa = display_name output_ipa = re.sub('\.ipa$', '', output_ipa) - start_dump(device, pid, output_ipa) + start_dump(session, output_ipa) except paramiko.ssh_exception.NoValidConnectionsError as e: print e exit_code = 1 From 1b14d653c24270109f06df35733c6aea24e43691 Mon Sep 17 00:00:00 2001 From: Cameron Lowell Palmer Date: Wed, 7 Feb 2018 15:42:33 +0100 Subject: [PATCH 3/4] Remove the unused pid value --- dump.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dump.py b/dump.py index f64dd96..1528edb 100755 --- a/dump.py +++ b/dump.py @@ -240,7 +240,6 @@ def create_dir(path): def open_target_app(device, name_or_bundleid): print 'Start the target app {}'.format(name_or_bundleid) - pid = -1 display_name = '' bundle_identifier = '' for application in get_applications(device): From 078cd04dce4d5748232801828a9163cd72e9642b Mon Sep 17 00:00:00 2001 From: Cameron Lowell Palmer Date: Wed, 7 Feb 2018 15:43:15 +0100 Subject: [PATCH 4/4] Call Module.ensureInitialized(name) to make sure calling APIs is safe --- dump.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dump.js b/dump.js index 4c48062..cc04abe 100644 --- a/dump.js +++ b/dump.js @@ -193,6 +193,7 @@ function dumpModule(name) { if (modules == null) { modules = getAllAppModules(); } + var targetmod = null; for (var i = 0; i < modules.length; i++) { if (modules[i].path.indexOf(name) != -1) { @@ -207,7 +208,8 @@ function dumpModule(name) { var modbase = modules[i].base; var modsize = modules[i].size; var newmodname = modules[i].name; - var newmodpath = getDocumentDir() + "/" + newmodname; + Module.ensureInitialized(newmodname); + var newmodpath = getDocumentDir() + "/" + newmodname + ".fid"; var oldmodpath = modules[i].path;