From 0808fd8c1b5b4ce7e48a91d94ab2672610902837 Mon Sep 17 00:00:00 2001 From: zx Date: Thu, 31 Oct 2024 14:35:22 -0400 Subject: [PATCH] feat: manually modified dylib support (#6) --- cyan/__main__.py | 2 +- cyan/tbhtypes/executable.py | 59 ++++++++++++++++++++++++-------- cyan/tbhtypes/main_executable.py | 14 ++++---- setup.py | 2 +- 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/cyan/__main__.py b/cyan/__main__.py index a2b16d7..23e3c92 100755 --- a/cyan/__main__.py +++ b/cyan/__main__.py @@ -99,7 +99,7 @@ def main() -> None: ) parser.add_argument( - "--version", action="version", version="cyan v1.3" + "--version", action="version", version="cyan v1.4b" ) from cyan import logic diff --git a/cyan/tbhtypes/executable.py b/cyan/tbhtypes/executable.py index 2e535d6..55b3eea 100644 --- a/cyan/tbhtypes/executable.py +++ b/cyan/tbhtypes/executable.py @@ -14,16 +14,31 @@ class Executable: idylib = f"{specific}/insert_dylib" starters = ("\t/Library/", "\t@rpath", "\t@executable_path") - common = { - # substrate could show up as - # CydiaSubstrate.framework, libsubstrate.dylib, EVEN CydiaSubstrate.dylib - # AND PROBABLY EVEN MORE !!!! IT'S CRAZY. - "CydiaSubstrate.framework": "CydiaSubstrate.framework", - "Orion.framework": "Orion.framework", - "Cephei.framework": "Cephei.framework", - "CepheiUI.framework": "CepheiUI.framework", - "CepheiPrefs.framework": "CepheiPrefs.framework" + # substrate could show up as + # CydiaSubstrate.framework, libsubstrate.dylib, EVEN CydiaSubstrate.dylib + # AND PROBABLY EVEN MORE !!!! IT'S CRAZY. + common = { + "ubstrate.": { + "name": "CydiaSubstrate.framework", + "path": "@rpath/CydiaSubstrate.framework/CydiaSubstrate" + }, + "orion.": { + "name": "Orion.framework", + "path": "@rpath/Orion.framework/Orion" + }, + "cephei.": { + "name": "Cephei.framework", + "path": "@rpath/Cephei.framework/Cephei" + }, + "cepheiui.": { + "name": "CepheiUI.framework", + "path": "@rpath/CepheiUI.framework/CepheiUI" + }, + "cepheiprefs.": { + "name": "CepheiPrefs.framework", + "path": "@rpath/CepheiPrefs.framework/CepheiPrefs" + } } def __init__(self, path: str): @@ -64,14 +79,33 @@ class Executable: stderr=subprocess.DEVNULL ) - def fix_dependencies(self, tweaks: dict[str, str], need: set[str]) -> None: + def fix_common_dependencies(self, needed: set[str]) -> None: self.remove_signature() for dep in self.get_dependencies(): - for cname in (tweaks | self.common): + for common, info in self.common.items(): + if common in dep.lower() and dep != info["path"]: + self.change_dependency(dep, info["path"]) + print( + f"[*] fixed common dependency in {self.bn}: " + f"{dep} -> {info['path']}" + ) + + needed.add(common) + + # orion has a *weak* dependency to substrate, + # but will still crash without it. nice !!!!!!!!!!! + if common == "orion.": + needed.add("ubstrate.") + + def fix_dependencies(self, tweaks: dict[str, str]) -> None: + for dep in self.get_dependencies(): + for cname in tweaks: if cname in dep: # i wonder if there's a better way to do this? if cname.endswith(".framework"): + # nah, not gonna parse the plist, + # i've never seen a framework with a "mismatched" name npath = f"@rpath/{cname}/{cname[:-10]}" else: npath = f"@rpath/{cname}" @@ -80,9 +114,6 @@ class Executable: self.change_dependency(dep, npath) print(f"[*] fixed dependency in {self.bn}: {dep} -> {npath}") - if cname in self.common: - need.add(cname) - def get_dependencies(self) -> list[str]: proc = subprocess.run( [self.otool, "-L", self.path], diff --git a/cyan/tbhtypes/main_executable.py b/cyan/tbhtypes/main_executable.py index 09d7384..ac0a8e9 100644 --- a/cyan/tbhtypes/main_executable.py +++ b/cyan/tbhtypes/main_executable.py @@ -58,6 +58,8 @@ class MainExecutable(Executable): os.chdir(cwd) # i fucking hate jailbroken iOS utils. needed: set[str] = set() + + # inject/fix user things for bn, path in tweaks.items(): if bn.endswith(".appex"): fpath = f"{PLUGINS_DIR}/{bn}" @@ -65,7 +67,10 @@ class MainExecutable(Executable): shutil.copytree(path, fpath) elif bn.endswith(".dylib"): path = shutil.copy2(path, tmpdir) - Executable(path).fix_dependencies(tweaks, needed) + + e = Executable(path) + e.fix_common_dependencies(needed) + e.fix_dependencies(tweaks) fpath = f"{FRAMEWORKS_DIR}/{bn}" existed = tbhutils.delete_if_exists(fpath, bn) @@ -87,13 +92,8 @@ class MainExecutable(Executable): if not existed: print(f"[*] injected {bn}") - # orion has a *weak* dependency to substrate, - # but will still crash without it. nice !!!!!!!!!!! - if "Orion.framework" in needed: - needed.add("CydiaSubstrate.framework") - for missing in needed: - real = self.common[missing] # "real" name, thanks substrate! + real = self.common[missing]["name"] # e.g. "Orion.framework" ip = f"{FRAMEWORKS_DIR}/{real}" existed = tbhutils.delete_if_exists(ip, real) shutil.copytree(f"{self.install_dir}/extras/{real}", ip) diff --git a/setup.py b/setup.py index 94e6598..a544d4c 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name="cyan", - version="1.3", + version="1.4b", description="finally, pyzule doesn't suck", author="zx", author_email="zx@hrzn.email",