Skip to content

Instantly share code, notes, and snippets.

@hirakujira
Last active June 19, 2022 17:02
Show Gist options
  • Save hirakujira/878a9c8605f949f8c71f7810a4180194 to your computer and use it in GitHub Desktop.
Save hirakujira/878a9c8605f949f8c71f7810a4180194 to your computer and use it in GitHub Desktop.
Replace IPA url of AltStore to jailbreak IPAs
#! /usr/local/bin/python3
import os, shutil, time
import binascii
os.system("killall AltServer")
print ('Please choose jailbreak you want to install')
print ('1. Unc0ver\n2. Chimera\n3. Pangu\n4. Phoenix\n5. Home Depot\n6. h3lix\n')
jailbreak = input("")
# and use with statement (always do this to avoid leaked file descriptors, unflushed files)
with open('/Applications/AltServer.app/Contents/MacOS/AltServer', 'rb') as f:
# Slurp the whole file and efficiently convert it to hex all at once
hexdata = str(binascii.hexlify(f.read()))
replace_str = ""
original_str = '663030302E6261636B626C617A6562322E636F6D2F66696C652F616C7473746F72652F616C7473746F72652E697061'
if os.path.exists('/Applications/AltServer.app/Contents/MacOS/AltServerPatch'):
with open('/Applications/AltServer.app/Contents/MacOS/AltServerPatch', 'r') as patch:
original_str = patch.read()
patch.close()
# unc0ver
if jailbreak == 1:
replace_str = '732E686972616B752E74772F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F324F32744C416E'
elif jailbreak == 2:
replace_str = '6368696D6572612E73682F646F776E6C6F6164732F696F732F2F2F2F312E332E392D31322E302D31322E342E697061'
elif jailbreak == 3:
replace_str = '6767696E696E2E64652F6A622F2F2F2F2F2F2F2F4E76776153746F6E652F4E76776153746F6E655F312E312E697061'
elif jailbreak == 4:
replace_str = '6767696E696E2E64652F6A622F2F2F2F2F2F2F2F2F2F2F2F2F2F2F50686F656E69782F50686F656E6978352E697061'
elif jailbreak == 5:
replace_str = '6767696E696E2E64652F6A622F486F6D654465706F742F2F2F2F2F4D697874617065506C617965725243332E697061'
elif jailbreak == 6:
replace_str = '6767696E696E2E64652F6A622F68336C69782F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F68336C69782D5243362E697061'
else:
print("Please enter the number of jailbreak tool")
hexdata = hexdata.replace(
original_str.lower(),
replace_str.lower()
)
with open('/Applications/AltServer.app/Contents/MacOS/AltServerPatch', 'w') as fo:
fo.write(replace_str)
fo.close()
f.close()
with open('/Applications/AltServer.app/Contents/MacOS/AltServer2', 'wb') as fout:
fout.write(binascii.unhexlify(hexdata))
fout.close()
os.remove("/Applications/AltServer.app/Contents/MacOS/AltServer")
os.chmod('/Applications/AltServer.app/Contents/MacOS/AltServer2', 0755)
shutil.move("/Applications/AltServer.app/Contents/MacOS/AltServer2", "/Applications/AltServer.app/Contents/MacOS/AltServer")
print('All Done!')
@BartmanEH
Copy link

Thank you! I'm not a git expert--is there an easy way to pull changes from AltStore master/develop and merge them into my local cloned repository of your jailbreak branch?

@hirakujira
Copy link
Author

If you go to this page https://github.com/hirakujira/AltStore-Jailbreak/tree/jailbreak and click "Download Zip", it will download my source code which is already in jailbreak branch. You can find my hacks in AppDelegate.swift

And.. No, there's no easy way to merge that because I "removed" a lot of code which is not related with my approach (sideloading an IPA). If you are not an expert, I don't recommend you use the latest code, because it includes more codes / builds, which also means you have more issue need to fix.

@BartmanEH
Copy link

I've successfully modified your version to add my URL as an option and I have also successfully modified the AltStore original to use my URL hardcoded instead of the default AltStore URL so I have two ways to get this done. Now that I can compile and build these, I have lots of options. Thanks for your help.

@santiargy
Copy link

I have not been able to get the new altdeploy patcher to work. When I put the URL of where the ipa is hosted, it says it cannot find it. Did sideloading work for you?

@BartmanEH
Copy link

I have not been able to get the new altdeploy patcher to work. When I put the URL of where the ipa is hosted, it says it cannot find it. Did sideloading work for you?

Some patchers are limited to 55 character URLs. Try using a URL shortener like Rebrandly.

@hirakujira
Copy link
Author

I have not been able to get the new altdeploy patcher to work. When I put the URL of where the ipa is hosted, it says it cannot find it. Did sideloading work for you?

Your URL should can be reached without any requirement of login/verification. One option is using one drive.
https://www.reddit.com/r/jailbreak/comments/ejtw9x/release_install_jailbreak_via_patched_altserver/

@santiargy
Copy link

santiargy commented Feb 20, 2020 via email

@santiargy
Copy link

Hi again. I am adding a few pictures showing that I am using Redbrandly, File is on OneDrive with Viewing Allowed (link works, file starts downloading when you use the link), and the different messages that I get until the last one saying The app could not be found. I would appreciate if you can give me any clues. Or maybe even test the URL if I were to share it...? Thanks!!!

IMG_7781
IMG_7776
IMG_7777
IMG_7778
IMG_7779
IMG_7780

@BartmanEH
Copy link

@santiargy, it's not really practical for us to test your URL. If you followed the thread above, you'll see that the author and I are on MacOS and merely mentioned AltServer Patcher (for Windows) in passing as an alternative to the work we were doing on MacOS. In the end I'm modifying the source code for MacOS and compiling my own version of AltServer for my purposes. Maybe post in the AltServer Patcher Reddit thread and ask for help there. Alternatively you may have better luck trying a newer version of the patcher. This new version has a more user-friendly interface and may work better for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment