diff --git a/README.md b/README.md index 05a805e..fac54d6 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ also obviously install python, version 3.9 or greater is required
  • install pipx
  • install OR update cyan: pipx install --force https://github.com/asdfzxcvbn/pyzule-rw/archive/main.zip
  • add cyan to PATH: pipx ensurepath
  • -
  • if you want to inject dylibs and ARE NOT ON iOS: pipx inject cyan lief
  • +
  • if you want to inject dylibs ON AARCH64 LINUX: pipx inject cyan lief
  • if you want to change app icons (iOS NOT supported): pipx inject cyan Pillow
  • diff --git a/cyan/tbhtypes/executable.py b/cyan/tbhtypes/executable.py index 1de3643..a7ad879 100644 --- a/cyan/tbhtypes/executable.py +++ b/cyan/tbhtypes/executable.py @@ -18,6 +18,7 @@ class Executable: ldid = f"{specific}/ldid" lipo = f"{specific}/lipo" otool = f"{specific}/otool" + idylib = f"{specific}/insert_dylib" starters = ("\t/Library/", "\t@rpath", "\t@executable_path") common = { @@ -42,10 +43,10 @@ class Executable: self.bn = os.path.basename(path) self.inj: Optional = None # type: ignore - if self.specific.endswith("iOS"): - self.inj_func = self.ios_inject + if os.path.isfile(self.idylib): + self.inj_func = self.idyl_inject else: - self.inj_func = self.insert_cmd + self.inj_func = self.lief_inj def is_encrypted(self) -> bool: proc = subprocess.run( @@ -177,7 +178,7 @@ class Executable: stderr=subprocess.DEVNULL ) - def insert_cmd(self, cmd: str) -> None: + def lief_inj(self, cmd: str) -> None: if self.inj is None: # type: ignore try: lief.logging.disable() # type: ignore @@ -186,17 +187,22 @@ class Executable: 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: - subprocess.run( + def idyl_inject(self, cmd: str) -> None: + proc = subprocess.run( [ - f"{self.specific}/insert_dylib", - "--weak", "--inplace", "--no-strip-codesig", "--all-yes", + self.idylib, "--weak", "--inplace", "--strip-codesig", "--all-yes", 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: self.remove_signature() diff --git a/cyan/tbhutils.py b/cyan/tbhutils.py index 1b76a2e..0b142a0 100644 --- a/cyan/tbhutils.py +++ b/cyan/tbhutils.py @@ -106,11 +106,12 @@ def get_tools_dir() -> tuple[str, str]: # thank god i dont have to use importlib, # it's the WORST standard library package prior to 3.12 install_dir = os.path.dirname(__file__) + specific_dir = f"{install_dir}/tools/{system}/{mach}" - return ( - install_dir, - f"{install_dir}/tools/{system}/{mach}" - ) + if not os.path.isdir(specific_dir): + sys.exit(f"[!] cyan is not supported on: {system} {mach}") + + return (install_dir, specific_dir) def delete_if_exists(path: str, bn: str) -> bool: diff --git a/cyan/tools/Darwin/arm64/insert_dylib b/cyan/tools/Darwin/arm64/insert_dylib new file mode 100755 index 0000000..b716afc Binary files /dev/null and b/cyan/tools/Darwin/arm64/insert_dylib differ diff --git a/cyan/tools/Darwin/x86_64/insert_dylib b/cyan/tools/Darwin/x86_64/insert_dylib new file mode 100755 index 0000000..a8cbf48 Binary files /dev/null and b/cyan/tools/Darwin/x86_64/insert_dylib differ diff --git a/cyan/tools/Linux/x86_64/insert_dylib b/cyan/tools/Linux/x86_64/insert_dylib new file mode 100755 index 0000000..fab6003 Binary files /dev/null and b/cyan/tools/Linux/x86_64/insert_dylib differ