diff --git a/README.md b/README.md index 425f3c3..5fb2537 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ this is pretty much just a hobby project that i'll work on when i'm bored. pyzul cyan is pretty much "v1.0" now i guess. injection works and is stable, and iOS (should..) have all the right fixes for running cyan, however a bug in python3.9 from procursus prevents it from running. +so to reaffirm this, **iOS is currently not supported until an updated python for iOS gets released** + to install on linux + macos, make sure you have python 3.9 or later, `bash`, `zip`, and `lief` to install lief: `pip install lief` diff --git a/cyan/__main__.py b/cyan/__main__.py index c11cbb2..faf2f11 100755 --- a/cyan/__main__.py +++ b/cyan/__main__.py @@ -27,11 +27,20 @@ def main() -> None: help="a tweak to inject/item to be added to the bundle" ) + parser.add_argument( + "-c", "--compress", metavar="level", type=int, default=6, + help="the compression level of the ipa (0-9, defaults to 6)", + action="store", choices=range(0, 10) + ) parser.add_argument( "--ignore-encrypted", action="store_true", help="skip main binary encryption check" ) + parser.add_argument( + "-v", "--version", action="version", version="cyan v1.0b" + ) + from cyan import logic logic.main(parser) diff --git a/cyan/logic.py b/cyan/logic.py index cd80e50..a7b4d29 100644 --- a/cyan/logic.py +++ b/cyan/logic.py @@ -42,24 +42,16 @@ def main(parser: ArgumentParser) -> None: if args.f is not None: app.executable.inject(args.f, tmpdir) - # done! - if OUTPUT_IS_IPA: - print("[*] generating ipa..") - - run( - ["bash", f"{tbhtypes.Executable.install_dir}/tools/compressIPA.sh"], - env={ - "TMPDIR": tmpdir, - "OUTPUT": args.o - } - ) - - print(f"[*] generated ipa at {args.o}") - else: - # create subdirectories if necessary - if "/" in args.o: + # create subdirectories if necessary + if "/" in args.o: os.makedirs(os.path.dirname(args.o), exist_ok=True) + # done ! + if OUTPUT_IS_IPA: + print("[*] generating ipa..") + tbhutils.make_ipa(tmpdir, args.o, args.compress) + print(f"[*] generated ipa at {args.o}") + else: if os.path.isdir(args.o): shutil.rmtree(args.o) diff --git a/cyan/tbhutils.py b/cyan/tbhutils.py index 81d65e6..2e7fda8 100644 --- a/cyan/tbhutils.py +++ b/cyan/tbhutils.py @@ -5,7 +5,7 @@ import zipfile import platform import plistlib import subprocess -from glob import glob +from glob import glob, iglob from argparse import Namespace from importlib import resources # type: ignore from typing import Optional, Any @@ -150,3 +150,14 @@ def extract_deb(deb: str, tweaks: dict[str, str], tmpdir: str) -> None: print(f"[*] extracted {os.path.basename(deb)}") del tweaks[os.path.basename(deb)] + +def make_ipa(tmpdir: str, output: str, level: int) -> None: + # ensure names are written as Payload/... + os.chdir(tmpdir) + + with zipfile.ZipFile( + output, "w", zipfile.ZIP_DEFLATED, compresslevel=level + ) as zf: + for f in iglob("Payload/**", recursive=True): + zf.write(f) + diff --git a/cyan/tools/compressIPA.sh b/cyan/tools/compressIPA.sh deleted file mode 100644 index 1738878..0000000 --- a/cyan/tools/compressIPA.sh +++ /dev/null @@ -1,5 +0,0 @@ -cd $TMPDIR -mkdir -p `dirname $OUTPUT` -rm $OUTPUT &> /dev/null -zip -r $OUTPUT Payload > /dev/null - diff --git a/setup.py b/setup.py index 458505a..6fa2170 100644 --- a/setup.py +++ b/setup.py @@ -7,8 +7,8 @@ setup( author="zx", author_email="hi@zxcvbn.fyi", packages=["cyan", "cyan.tbhtypes"], - # install_requires=["lief"], - python_requires=">=3.9", + install_requires=["lief"], + python_requires=">=3.10", include_package_data=True, entry_points={ "console_scripts": ["cyan=cyan.__main__:main"],