feat: manually modified dylib support (#6)

This commit is contained in:
zx
2024-10-31 14:35:22 -04:00
parent 8c873a84c8
commit 0808fd8c1b
4 changed files with 54 additions and 23 deletions

View File

@@ -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

View File

@@ -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"
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],

View File

@@ -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)

View File

@@ -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",