From 7543bb3d8d3371e7f2f8f1de84ce92437d23e102 Mon Sep 17 00:00:00 2001 From: zx Date: Mon, 28 Oct 2024 17:27:02 -0400 Subject: [PATCH] fix: can't extract entitlements with `codesign` (ProcursusTeam/ldid#45) this issue was originally reported in #8 --- cyan/tbhtypes/executable.py | 1 - cyan/tbhtypes/main_executable.py | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cyan/tbhtypes/executable.py b/cyan/tbhtypes/executable.py index b83c026..2e535d6 100644 --- a/cyan/tbhtypes/executable.py +++ b/cyan/tbhtypes/executable.py @@ -36,7 +36,6 @@ class Executable: ) self.path = path - self.bn = os.path.basename(path) def is_encrypted(self) -> bool: diff --git a/cyan/tbhtypes/main_executable.py b/cyan/tbhtypes/main_executable.py index 24d4d8a..09d7384 100644 --- a/cyan/tbhtypes/main_executable.py +++ b/cyan/tbhtypes/main_executable.py @@ -121,12 +121,14 @@ class MainExecutable(Executable): return os.path.getsize(output) > 0 def merge_entitlements(self, entitlements: str) -> None: - self.sign_with_entitlements(entitlements) - print("[*] merged new entitlements") + if self.sign_with_entitlements(entitlements): + print("[*] merged new entitlements") + else: + print("[!] failed to merge new entitlements, are they valid?") def sign_with_entitlements(self, entitlements: str) -> bool: return subprocess.run( - [self.ldid, f"-S{entitlements}", "-M", self.path] + [self.ldid, f"-S{entitlements}", "-M", "-Cadhoc", self.path] ).returncode == 0 def lief_inject(self, cmd: str) -> None: