From 511cb4bbe355755ef1894fc463edc4631639763d Mon Sep 17 00:00:00 2001 From: zx Date: Mon, 16 Sep 2024 20:07:23 -0400 Subject: [PATCH] chore: use `unzip` and `zip` when available --- README.md | 2 + cyan/extras/Cephei.framework/Info.plist | 10 +++++ cyan/extras/CepheiPrefs.framework/Info.plist | 11 +++++ cyan/extras/CepheiUI.framework/Info.plist | Bin 391 -> 778 bytes cyan/tbhtypes/executable.py | 7 +++- cyan/tbhutils.py | 40 ++++++++++++++----- 6 files changed, 60 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f4190a5..826df9c 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ first, make sure you have [ar](https://command-not-found.com/ar) and [tar](https also obviously install python, version 3.9 or greater is required +the `zip` and `unzip` commands are *optional* dependencies, they may [fix issues when extracting certain IPAs with chinese characters](https://github.com/asdfzxcvbn/pyzule-rw/wiki/file-does-not-exist-(executable)-%3F), etc +
linux/WSL/macOS instructions
diff --git a/cyan/extras/Cephei.framework/Info.plist b/cyan/extras/Cephei.framework/Info.plist index 5fbbb2d..c1212d1 100644 --- a/cyan/extras/Cephei.framework/Info.plist +++ b/cyan/extras/Cephei.framework/Info.plist @@ -4,24 +4,34 @@ CFBundleDevelopmentRegion English + CFBundleExecutable Cephei + CFBundleIdentifier ws.hbang.common + CFBundleInfoDictionaryVersion 6.0 + CFBundleName Cephei + CFBundlePackageType BNDL + CFBundleShortVersionString 1.0.0 + CFBundleSignature ???? + CFBundleVersion 1.0 + DTPlatformName iphoneos + HBPackageIdentifier ws.hbang.common diff --git a/cyan/extras/CepheiPrefs.framework/Info.plist b/cyan/extras/CepheiPrefs.framework/Info.plist index 3b60382..773a200 100644 --- a/cyan/extras/CepheiPrefs.framework/Info.plist +++ b/cyan/extras/CepheiPrefs.framework/Info.plist @@ -4,26 +4,37 @@ CFBundleDevelopmentRegion English + CFBundleExecutable CepheiPrefs + CFBundleIdentifier ws.hbang.common.prefs + CFBundleInfoDictionaryVersion 6.0 + CFBundleName Cephei + CFBundlePackageType BNDL + CFBundleShortVersionString 1.0.0 + CFBundleSignature ???? + CFBundleVersion 1.0 + DTPlatformName iphoneos + HBPackageIdentifier ws.hbang.common + NSPrincipalClass HBDemoRootListController diff --git a/cyan/extras/CepheiUI.framework/Info.plist b/cyan/extras/CepheiUI.framework/Info.plist index 1ae90bae9c3b8816f2bf73ddbca422f743544852..bf601a1757d1b76299f2fd6a50155778bf1977eb 100644 GIT binary patch literal 778 zcmb7?QEP)R6osGXugLOV)4hx_GRvwK1nFej!5&k+)lf}BOl$r3i)~@d&cX7Qa2R)W{ty^uGD2GlPDcrwI#7+jbF^kT0|8aSNvEQRRpQKo` z=Ktsk%lE8=tXDVMbA?RL10JIeuQ&~x@=`E!&^M_IyCzd7redRRBte$c b%NFcGP)TT(0P^m}?T~tJF>LykbJ8~SLx8Md` zf>Uq=#6eggEE+SLU;ak^#-3@Guw2>pC#tNiZ)|Q=w|92;YWsDo)@Zf@>!^3#E%+>< zUM!@#r!r@PdrC4M1y<8E-5KSI%^8&wg9ap}fz>cak42oQLTc7F%;j_8uuy3uk;~Hk z==j5gsJW2oO7TCW|3bq;k!hkGE#nxHa6uyKFEdT+hL*0tIyA(gPc#u(s^57>BRz3+ zhHY%?KRo9+o)RA6P^78gc;t?IG>a)4xqe5NcY*CO%VNQ)$o=lXx$*SXhdz(=;$o;m q8?N9MCXm4^yumwsz!!YO4{D)fbb?M1M(5}f{;Gmj2?u4CfjYl_ Optional[str]: if not ( @@ -81,7 +84,15 @@ def get_app(path: str, tmpdir: str, is_ipa: bool) -> str: elif not any(name.endswith(".app/Info.plist") for name in names): sys.exit("[!] no Info.plist, invalid app") - ipa.extractall(tmpdir) + # using unzip fixes extraction errors in ipas with chinese chars, etc + if HAS_UNZIP: + subprocess.run( + ["unzip", path, "-d", tmpdir], + stdout=subprocess.DEVNULL + ) + else: + ipa.extractall(tmpdir) + app = glob(f"{payload}/*.app")[0] except (KeyError, IndexError): sys.exit("[!] couldn't find either Payload or app folder, invalid ipa") @@ -180,14 +191,25 @@ def make_ipa(tmpdir: str, output: str, level: int) -> None: os.chdir(tmpdir) weird = 0 - with zipfile.ZipFile( - output, "w", zipfile.ZIP_DEFLATED, compresslevel=level - ) as zf: - for f in iglob("Payload/**", recursive=True): - try: - zf.write(f) - except ValueError: - weird += 1 + if HAS_ZIP: + try: + os.remove(output) # zip command updates zipfiles by default + except FileNotFoundError: + pass + + subprocess.run( + ["zip", f"-{level}", "-r", output, "Payload"], + stdout=subprocess.DEVNULL + ) + else: + with zipfile.ZipFile( + output, "w", zipfile.ZIP_DEFLATED, compresslevel=level + ) as zf: + for f in iglob("Payload/**", recursive=True): + try: + zf.write(f) + except ValueError: + weird += 1 if weird != 0: print(f"[?] was unable to zip {weird} file(s) due to timestamps")