Merge pull request #6 from palmerc/master

Module initialisation check
This commit is contained in:
Alone_Monkey 2018-02-07 23:11:08 +08:00 committed by GitHub
commit fd6f736729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -1,3 +1,5 @@
Module.ensureInitialized('Foundation');
var O_RDONLY = 0; var O_RDONLY = 0;
var O_WRONLY = 1; var O_WRONLY = 1;
var O_RDWR = 2; var O_RDWR = 2;
@ -193,6 +195,7 @@ function dumpModule(name) {
if (modules == null) { if (modules == null) {
modules = getAllAppModules(); modules = getAllAppModules();
} }
var targetmod = null; var targetmod = null;
for (var i = 0; i < modules.length; i++) { for (var i = 0; i < modules.length; i++) {
if (modules[i].path.indexOf(name) != -1) { if (modules[i].path.indexOf(name) != -1) {

14
dump.py
View File

@ -239,7 +239,6 @@ def create_dir(path):
def open_target_app(device, name_or_bundleid): def open_target_app(device, name_or_bundleid):
print 'Start the target app {}'.format(name_or_bundleid) print 'Start the target app {}'.format(name_or_bundleid)
pid = -1
display_name = '' display_name = ''
bundle_identifier = '' bundle_identifier = ''
for application in get_applications(device): for application in get_applications(device):
@ -249,18 +248,17 @@ def open_target_app(device, name_or_bundleid):
try: try:
pid = device.spawn([bundle_identifier]) pid = device.spawn([bundle_identifier])
session = device.attach(pid)
device.resume(pid) device.resume(pid)
time.sleep(3)
except Exception as e: except Exception as e:
print 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) print 'Dumping {} to {}'.format(display_name, TEMP_DIR)
session = device.attach(pid)
script = load_js_file(session, DUMP_JS) script = load_js_file(session, DUMP_JS)
script.post('dump') script.post('dump')
finished.wait() finished.wait()
@ -293,13 +291,15 @@ if __name__ == '__main__':
ssh.connect(Host, port=Port, username=User, password=Password) ssh.connect(Host, port=Port, username=User, password=Password)
create_dir(PAYLOAD_PATH) 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: if output_ipa is None:
output_ipa = display_name output_ipa = display_name
output_ipa = re.sub('\.ipa$', '', output_ipa) output_ipa = re.sub('\.ipa$', '', output_ipa)
if pid > 0: if pid > 0:
start_dump(device, pid, 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: except paramiko.AuthenticationException as e:
print e print e
exit_code = 1 exit_code = 1