feat: remove uisupporteddevices

This commit is contained in:
zx
2024-09-06 00:18:16 -04:00
parent c899ec7c22
commit dc21719157
7 changed files with 45 additions and 15 deletions

View File

@@ -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 [] 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 [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: plugin operations (-q, -e)
[] feat: .cyan files (lol rip .pyzule files)

View File

@@ -27,6 +27,10 @@ def main() -> None:
help="a tweak to inject/item to be added to the bundle" 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( parser.add_argument(
"-w", "--no-watch", action="store_true", "-w", "--no-watch", action="store_true",
help="remove all watch apps" help="remove all watch apps"

View File

@@ -41,6 +41,8 @@ def main(parser: ArgumentParser) -> None:
if args.f is not None: if args.f is not None:
app.executable.inject(args.f, tmpdir) app.executable.inject(args.f, tmpdir)
if args.remove_supported_devices:
app.plist.remove_uisd()
if args.no_watch: if args.no_watch:
app.remove_watch_apps() app.remove_watch_apps()

View File

@@ -1,10 +1,12 @@
from .app_bundle import AppBundle from .app_bundle import AppBundle
from .executable import Executable from .executable import Executable
from .leaving_cm import LeavingCM from .leaving_cm import LeavingCM
from .plist import Plist
__all__ = [ __all__ = [
"AppBundle", "AppBundle",
"Executable", "Executable",
"LeavingCM" "LeavingCM",
"Plist"
] ]

View File

@@ -1,14 +1,13 @@
import os import os
import shutil import shutil
from cyan.tbhutils import get_plist
from .executable import Executable from .executable import Executable
from .plist import Plist
class AppBundle: class AppBundle:
def __init__(self, path: str, plist_path: str): def __init__(self, path: str, plist_path: str):
self.path = path self.path = path
self.plist = get_plist(plist_path) self.plist = Plist(plist_path)
self.executable = Executable( self.executable = Executable(
f"{path}/{self.plist['CFBundleExecutable']}", f"{path}/{self.plist['CFBundleExecutable']}",

30
cyan/tbhtypes/plist.py Normal file
View File

@@ -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")

View File

@@ -3,12 +3,11 @@ import sys
import shutil import shutil
import zipfile import zipfile
import platform import platform
import plistlib
import subprocess import subprocess
from typing import Optional
from glob import glob, iglob from glob import glob, iglob
from argparse import Namespace from argparse import Namespace
from importlib import resources # type: ignore from importlib import resources # type: ignore
from typing import Optional, Any
from tempfile import TemporaryDirectory 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: def delete_if_exists(path: str, bn: str) -> bool:
is_file = os.path.isfile(path) is_file = os.path.isfile(path)