diff --git a/.gitignore b/.gitignore index 1c9077a..7e14034 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ __pycache__/ build/ -*.egg-info +*.egg-info/ diff --git a/cyan/tbhtypes/executable.py b/cyan/tbhtypes/executable.py index 964a084..5d0975d 100644 --- a/cyan/tbhtypes/executable.py +++ b/cyan/tbhtypes/executable.py @@ -49,7 +49,7 @@ class Executable: if os.path.isfile(self.idylib): self.inj_func = self.idyl_inject else: - self.inj_func = self.lief_inj + self.inj_func = self.lief_inject def is_encrypted(self) -> bool: proc = subprocess.run( @@ -65,17 +65,6 @@ class Executable: def fakesign(self) -> bool: return subprocess.run([self.ldid, "-S", "-M", self.path]).returncode == 0 - def write_entitlements(self, output: str) -> bool: - with open(output, "wb") as entf: - proc = subprocess.run( - [self.ldid, "-e", self.path], - capture_output=True - ) - - entf.write(proc.stdout) - - return os.path.getsize(output) > 0 - def thin(self) -> bool: return subprocess.run( [self.lipo, "-thin", "arm64", self.path, "-output", self.path], @@ -88,7 +77,7 @@ class Executable: stderr=subprocess.DEVNULL ) - def lief_inj(self, cmd: str) -> None: + def lief_inject(self, cmd: str) -> None: if self.inj is None: # type: ignore try: lief.logging.disable() # type: ignore diff --git a/cyan/tbhtypes/main_executable.py b/cyan/tbhtypes/main_executable.py index ca1ab01..9f560ff 100644 --- a/cyan/tbhtypes/main_executable.py +++ b/cyan/tbhtypes/main_executable.py @@ -16,7 +16,7 @@ class MainExecutable(Executable): FRAMEWORKS_DIR = f"{self.bundle_path}/Frameworks" has_entitlements = self.write_entitlements(ENT_PATH) - # iirc, injecting doesnt work (sometimes) if the file isn't signed + # iirc, injecting doesnt work (sometimes) if the file is signed self.remove_signature() if any(t.endswith(".appex") for t in tweaks): @@ -95,6 +95,17 @@ class MainExecutable(Executable): self.sign_with_entitlements(ENT_PATH) print("[*] restored entitlements") + def write_entitlements(self, output: str) -> bool: + with open(output, "wb") as entf: + proc = subprocess.run( + [self.ldid, "-e", self.path], + capture_output=True + ) + + entf.write(proc.stdout) + + return os.path.getsize(output) > 0 + def merge_entitlements(self, entitlements: str) -> None: self.sign_with_entitlements(entitlements) print("[*] merged new entitlements")