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

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

View File

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

View File

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

View File

@@ -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']}",

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