mirror of
https://github.com/NohamR/pyzule-rw.git
synced 2026-10-11 02:49:40 +00:00
chore: move write_entitlements() to MainExecutable
the func is only used in `MainExecutable`, so we should move it there to make it a bit more "clean"
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
build/
|
build/
|
||||||
*.egg-info
|
*.egg-info/
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Executable:
|
|||||||
if os.path.isfile(self.idylib):
|
if os.path.isfile(self.idylib):
|
||||||
self.inj_func = self.idyl_inject
|
self.inj_func = self.idyl_inject
|
||||||
else:
|
else:
|
||||||
self.inj_func = self.lief_inj
|
self.inj_func = self.lief_inject
|
||||||
|
|
||||||
def is_encrypted(self) -> bool:
|
def is_encrypted(self) -> bool:
|
||||||
proc = subprocess.run(
|
proc = subprocess.run(
|
||||||
@@ -65,17 +65,6 @@ class Executable:
|
|||||||
def fakesign(self) -> bool:
|
def fakesign(self) -> bool:
|
||||||
return subprocess.run([self.ldid, "-S", "-M", self.path]).returncode == 0
|
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:
|
def thin(self) -> bool:
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
[self.lipo, "-thin", "arm64", self.path, "-output", self.path],
|
[self.lipo, "-thin", "arm64", self.path, "-output", self.path],
|
||||||
@@ -88,7 +77,7 @@ class Executable:
|
|||||||
stderr=subprocess.DEVNULL
|
stderr=subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
|
|
||||||
def lief_inj(self, cmd: str) -> None:
|
def lief_inject(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
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MainExecutable(Executable):
|
|||||||
FRAMEWORKS_DIR = f"{self.bundle_path}/Frameworks"
|
FRAMEWORKS_DIR = f"{self.bundle_path}/Frameworks"
|
||||||
has_entitlements = self.write_entitlements(ENT_PATH)
|
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()
|
self.remove_signature()
|
||||||
|
|
||||||
if any(t.endswith(".appex") for t in tweaks):
|
if any(t.endswith(".appex") for t in tweaks):
|
||||||
@@ -95,6 +95,17 @@ class MainExecutable(Executable):
|
|||||||
self.sign_with_entitlements(ENT_PATH)
|
self.sign_with_entitlements(ENT_PATH)
|
||||||
print("[*] restored entitlements")
|
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:
|
def merge_entitlements(self, entitlements: str) -> None:
|
||||||
self.sign_with_entitlements(entitlements)
|
self.sign_with_entitlements(entitlements)
|
||||||
print("[*] merged new entitlements")
|
print("[*] merged new entitlements")
|
||||||
|
|||||||
Reference in New Issue
Block a user