From df3ec4ba2bdfe14fba64540fc1886a03a6dca025 Mon Sep 17 00:00:00 2001 From: zx Date: Fri, 6 Sep 2024 00:04:23 -0400 Subject: [PATCH] feat: remove watch apps --- README.md | 9 +++++++++ cyan/__main__.py | 5 +++++ cyan/logic.py | 3 +++ cyan/tbhtypes/app_bundle.py | 26 ++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/README.md b/README.md index 6c773b7..821af58 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,12 @@ so to reaffirm this, **iOS is currently not supported until an updated python fo easiest install ever, just `pip install -U git+https://github.com/asdfzxcvbn/pyzule-rw.git#egg=cyan` +## todo + +[] refactor: dont prepare, just copy and fix as you go +[] feat: plist operations (-u, -n, -v, -b, -m, -d, -l, -r) +[x] feat: remove watch app +[] feat: fakesign +[] feat: thin binaries +[] feat: plugin operations (-q, -e) + diff --git a/cyan/__main__.py b/cyan/__main__.py index faf2f11..fee9f7b 100755 --- a/cyan/__main__.py +++ b/cyan/__main__.py @@ -27,6 +27,11 @@ def main() -> None: help="a tweak to inject/item to be added to the bundle" ) + parser.add_argument( + "-w", "--no-watch", action="store_true", + help="remove all watch apps" + ) + parser.add_argument( "-c", "--compress", metavar="level", type=int, default=6, help="the compression level of the ipa (0-9, defaults to 6)", diff --git a/cyan/logic.py b/cyan/logic.py index f425f77..586a2d1 100644 --- a/cyan/logic.py +++ b/cyan/logic.py @@ -41,6 +41,9 @@ def main(parser: ArgumentParser) -> None: if args.f is not None: app.executable.inject(args.f, tmpdir) + if args.no_watch: + app.remove_watch_apps() + # create subdirectories if necessary if "/" in args.o: os.makedirs(os.path.dirname(args.o), exist_ok=True) diff --git a/cyan/tbhtypes/app_bundle.py b/cyan/tbhtypes/app_bundle.py index 738f662..ae771a5 100644 --- a/cyan/tbhtypes/app_bundle.py +++ b/cyan/tbhtypes/app_bundle.py @@ -1,3 +1,6 @@ +import os +import shutil + from cyan.tbhutils import get_plist from .executable import Executable @@ -12,3 +15,26 @@ class AppBundle: path ) + def remove(self, name: str) -> bool: + path = f"{self.path}/{name}" + if not os.path.exists(path): + return False + + try: + shutil.rmtree(path) + except NotADirectoryError: + os.remove(path) + + return True + + def remove_watch_apps(self) -> None: + removed = False + for name in ("Watch", "WatchKit", "com.apple.WatchPlaceholder"): + if self.remove(name): + removed = True + + if removed: + print("[*] removed watch app") + else: + print("[?] watch app not present") +