Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on Windows and other non-POSIX systems #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from scp import SCPClient
from tqdm import tqdm
import traceback
import tempfile

IS_PY2 = sys.version_info[0] < 3
if IS_PY2:
Expand All @@ -38,9 +39,7 @@
Port = 2222
KeyFileName = None

TEMP_DIR = tempfile.gettempdir()
PAYLOAD_DIR = 'Payload'
PAYLOAD_PATH = os.path.join(TEMP_DIR, PAYLOAD_DIR)
PAYLOAD_PATH = os.path.join(tempfile.mkdtemp(), 'Payload')
file_dict = {}

finished = threading.Event()
Expand Down Expand Up @@ -85,9 +84,10 @@ def generate_ipa(path, display_name):
if key != 'app':
shutil.move(from_dir, to_dir)

target_dir = './' + PAYLOAD_DIR
zip_args = ('zip', '-qr', os.path.join(os.getcwd(), ipa_filename), target_dir)
subprocess.check_call(zip_args, cwd=TEMP_DIR)
IPA_PATH = os.path.join(os.getcwd(), ipa_filename)
shutil.make_archive(IPA_PATH, 'zip', os.path.dirname(PAYLOAD_PATH))
# make_archive suffixes with .zip, remove that
os.rename(IPA_PATH+".zip", IPA_PATH)
shutil.rmtree(PAYLOAD_PATH)
except Exception as e:
print(e)
Expand Down Expand Up @@ -120,11 +120,7 @@ def progress(filename, size, sent):
scp.get(scp_from, scp_to)

chmod_dir = os.path.join(PAYLOAD_PATH, os.path.basename(dump_path))
chmod_args = ('chmod', '655', chmod_dir)
try:
subprocess.check_call(chmod_args)
except subprocess.CalledProcessError as err:
print(err)
os.chmod(chmod_dir, 0o655)

index = origin_path.find('.app/')
file_dict[os.path.basename(dump_path)] = origin_path[index + 5:]
Expand All @@ -138,11 +134,7 @@ def progress(filename, size, sent):
scp.get(scp_from, scp_to, recursive=True)

chmod_dir = os.path.join(PAYLOAD_PATH, os.path.basename(app_path))
chmod_args = ('chmod', '755', chmod_dir)
try:
subprocess.check_call(chmod_args)
except subprocess.CalledProcessError as err:
print(err)
os.chmod(chmod_dir, 0o755)

file_dict['app'] = os.path.basename(app_path)

Expand Down Expand Up @@ -277,7 +269,7 @@ def open_target_app(device, name_or_bundleid):


def start_dump(session, ipa_name):
print('Dumping {} to {}'.format(display_name, TEMP_DIR))
print('Dumping {} to {}'.format(display_name, PAYLOAD_PATH))

script = load_js_file(session, DUMP_JS)
script.post('dump')
Expand Down