diff --git a/README.md b/README.md index 5614cd7..60dae68 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ easiest install ever, just `pip install -U git+https://github.com/asdfzxcvbn/pyz [] refactor: dont prepare, just copy and fix as you go -[] feat: plist operations (-u, -n, -v, -b, -m, -d, -l, -r) +[1] feat: plist operations (-u, -n, -v, -b, -m, -d, -l, -r) [x] feat: remove watch app @@ -28,3 +28,5 @@ easiest install ever, just `pip install -U git+https://github.com/asdfzxcvbn/pyz [] feat: plugin operations (-q, -e) +[] feat: .cyan files (lol rip .pyzule files) + diff --git a/cyan/__main__.py b/cyan/__main__.py index fee9f7b..c98ad04 100755 --- a/cyan/__main__.py +++ b/cyan/__main__.py @@ -27,6 +27,10 @@ def main() -> None: help="a tweak to inject/item to be added to the bundle" ) + parser.add_argument( + "-u", "--remove-supported-devices", action="store_true", + help="remove UISupportedDevices" + ) parser.add_argument( "-w", "--no-watch", action="store_true", help="remove all watch apps" diff --git a/cyan/logic.py b/cyan/logic.py index 586a2d1..204781f 100644 --- a/cyan/logic.py +++ b/cyan/logic.py @@ -41,6 +41,8 @@ def main(parser: ArgumentParser) -> None: if args.f is not None: app.executable.inject(args.f, tmpdir) + if args.remove_supported_devices: + app.plist.remove_uisd() if args.no_watch: app.remove_watch_apps() diff --git a/cyan/tbhtypes/__init__.py b/cyan/tbhtypes/__init__.py index 2a3e38c..3741132 100644 --- a/cyan/tbhtypes/__init__.py +++ b/cyan/tbhtypes/__init__.py @@ -1,10 +1,12 @@ from .app_bundle import AppBundle from .executable import Executable from .leaving_cm import LeavingCM +from .plist import Plist __all__ = [ "AppBundle", "Executable", - "LeavingCM" + "LeavingCM", + "Plist" ] diff --git a/cyan/tbhtypes/app_bundle.py b/cyan/tbhtypes/app_bundle.py index ae771a5..6cabe96 100644 --- a/cyan/tbhtypes/app_bundle.py +++ b/cyan/tbhtypes/app_bundle.py @@ -1,14 +1,13 @@ import os import shutil -from cyan.tbhutils import get_plist from .executable import Executable - +from .plist import Plist class AppBundle: def __init__(self, path: str, plist_path: str): self.path = path - self.plist = get_plist(plist_path) + self.plist = Plist(plist_path) self.executable = Executable( f"{path}/{self.plist['CFBundleExecutable']}", diff --git a/cyan/tbhtypes/plist.py b/cyan/tbhtypes/plist.py new file mode 100644 index 0000000..982b9ab --- /dev/null +++ b/cyan/tbhtypes/plist.py @@ -0,0 +1,30 @@ +import sys +import plistlib +from typing import Any + +class Plist: + def __init__(self, path: str): + try: + with open(path, "rb") as f: + self.data: dict[str, Any] = plistlib.load(f) + except Exception: + sys.exit(f"[!] couldn't read {path}") + + self.path = path + + def __getitem__(self, key: str) -> Any: + return self.data.get(key, None) + + def remove(self, key: str) -> bool: + try: + del self.data[key] + return True + except KeyError: + return False + + def remove_uisd(self) -> None: + if self.remove("UISupportedDevices"): + print("[*] removed UISupportedDevices") + else: + print("[?] no UISupportedDevices") + diff --git a/cyan/tbhutils.py b/cyan/tbhutils.py index 2e7fda8..402df2e 100644 --- a/cyan/tbhutils.py +++ b/cyan/tbhutils.py @@ -3,12 +3,11 @@ import sys import shutil import zipfile import platform -import plistlib import subprocess +from typing import Optional from glob import glob, iglob from argparse import Namespace from importlib import resources # type: ignore -from typing import Optional, Any from tempfile import TemporaryDirectory @@ -97,14 +96,6 @@ def get_tools_dir() -> tuple[str, str]: ) -def get_plist(path: str) -> dict[str, Any]: - try: - with open(path, "rb") as f: - return plistlib.load(f) - except Exception: - sys.exit(f"[!] couldn't read {path}") - - def delete_if_exists(path: str, bn: str) -> bool: is_file = os.path.isfile(path)