chore: use insert_dylib on more platforms

This commit is contained in:
zx
2024-09-13 18:07:00 -04:00
parent 4375b7f880
commit 52b3b11a1a
6 changed files with 22 additions and 15 deletions

View File

@@ -33,7 +33,7 @@ also obviously install python, version 3.9 or greater is required
<li>install <a href="https://github.com/pypa/pipx?tab=readme-ov-file#install-pipx">pipx</a></li> <li>install <a href="https://github.com/pypa/pipx?tab=readme-ov-file#install-pipx">pipx</a></li>
<li>install OR update cyan: <code>pipx install --force https://github.com/asdfzxcvbn/pyzule-rw/archive/main.zip</code></li> <li>install OR update cyan: <code>pipx install --force https://github.com/asdfzxcvbn/pyzule-rw/archive/main.zip</code></li>
<li>add cyan to PATH: <code>pipx ensurepath</code></li> <li>add cyan to PATH: <code>pipx ensurepath</code></li>
<li><b>if you want to inject dylibs and ARE NOT ON iOS</b>: <code>pipx inject cyan lief</code></li> <li><b>if you want to inject dylibs ON AARCH64 LINUX</b>: <code>pipx inject cyan lief</code></li>
<li><b>if you want to change app icons (iOS NOT supported)</b>: <code>pipx inject cyan Pillow</code></li> <li><b>if you want to change app icons (iOS NOT supported)</b>: <code>pipx inject cyan Pillow</code></li>
</ol> </ol>
</details> </details>

View File

@@ -18,6 +18,7 @@ class Executable:
ldid = f"{specific}/ldid" ldid = f"{specific}/ldid"
lipo = f"{specific}/lipo" lipo = f"{specific}/lipo"
otool = f"{specific}/otool" otool = f"{specific}/otool"
idylib = f"{specific}/insert_dylib"
starters = ("\t/Library/", "\t@rpath", "\t@executable_path") starters = ("\t/Library/", "\t@rpath", "\t@executable_path")
common = { common = {
@@ -42,10 +43,10 @@ class Executable:
self.bn = os.path.basename(path) self.bn = os.path.basename(path)
self.inj: Optional = None # type: ignore self.inj: Optional = None # type: ignore
if self.specific.endswith("iOS"): if os.path.isfile(self.idylib):
self.inj_func = self.ios_inject self.inj_func = self.idyl_inject
else: else:
self.inj_func = self.insert_cmd self.inj_func = self.lief_inj
def is_encrypted(self) -> bool: def is_encrypted(self) -> bool:
proc = subprocess.run( proc = subprocess.run(
@@ -177,7 +178,7 @@ class Executable:
stderr=subprocess.DEVNULL stderr=subprocess.DEVNULL
) )
def insert_cmd(self, cmd: str) -> None: def lief_inj(self, cmd: str) -> None:
if self.inj is None: # type: ignore if self.inj is None: # type: ignore
try: try:
lief.logging.disable() # type: ignore lief.logging.disable() # type: ignore
@@ -186,17 +187,22 @@ class Executable:
self.inj = lief.parse(self.path) # type: ignore self.inj = lief.parse(self.path) # type: ignore
self.inj.add(lief.MachO.DylibCommand.weak_lib(cmd)) # type: ignore try:
self.inj.add(lief.MachO.DylibCommand.weak_lib(cmd)) # type: ignore
except AttributeError:
sys.exit("[!] couldn't add LC (lief), did you use a valid app?")
def ios_inject(self, cmd: str) -> None: def idyl_inject(self, cmd: str) -> None:
subprocess.run( proc = subprocess.run(
[ [
f"{self.specific}/insert_dylib", self.idylib, "--weak", "--inplace", "--strip-codesig", "--all-yes",
"--weak", "--inplace", "--no-strip-codesig", "--all-yes",
cmd, self.path cmd, self.path
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ], capture_output=True, text=True
) )
if proc.returncode != 0:
sys.exit(f"[!] couldn't add LC (insert_dylib), error:\n{proc.stderr}")
def fix_dependencies(self, tweaks: dict[str, str], need: set[str]) -> None: def fix_dependencies(self, tweaks: dict[str, str], need: set[str]) -> None:
self.remove_signature() self.remove_signature()

View File

@@ -106,11 +106,12 @@ def get_tools_dir() -> tuple[str, str]:
# thank god i dont have to use importlib, # thank god i dont have to use importlib,
# it's the WORST standard library package prior to 3.12 # it's the WORST standard library package prior to 3.12
install_dir = os.path.dirname(__file__) install_dir = os.path.dirname(__file__)
specific_dir = f"{install_dir}/tools/{system}/{mach}"
return ( if not os.path.isdir(specific_dir):
install_dir, sys.exit(f"[!] cyan is not supported on: {system} {mach}")
f"{install_dir}/tools/{system}/{mach}"
) return (install_dir, specific_dir)
def delete_if_exists(path: str, bn: str) -> bool: def delete_if_exists(path: str, bn: str) -> bool:

Binary file not shown.

Binary file not shown.

Binary file not shown.