Commit Graph

187 Commits

Author SHA1 Message Date
Lakr
ae599d5b3b Add kernel patch testing scripts and targets
Introduce a set of tools for fast and batch testing of kernel JB patches: add testing_batch.sh, testing_do_patch.sh, testing_do_save.sh and testing_kernel_patch.py (plus a results _summary). Update the Makefile with new targets (testing_do_save, testing_kernel_patch, testing_do_patch, testing_batch) and PHONY entries to wire them into the build/test workflow. Modify kernel_jb.py to enable the amfi cdhash-in-trustcache patch (A1) and mark the amfi execve kill-path patch as causing PANIC (A2). These changes allow restoring a base kernel backup, applying single patches quickly, running per-patch DFU boots (with timeout/panic detection), and collecting logs for batch runs.
2026-03-04 19:51:48 +08:00
Lakr
9bb53b7368 Add testing_do script and Makefile target
Introduce a new zsh helper script (scripts/testing_do.sh) and a Makefile target (testing_do) to automate the testing DFU workflow. The script sets strict error handling, kills any existing vphone-cli, runs fw_prepare, fw_patch_jb and testing_ramdisk_build, sends the ramdisk in the background, boots DFU, and tracks/cleans up child processes on exit. This simplifies and sequences the steps required to prepare, patch, send and boot the test ramdisk.
2026-03-04 19:18:24 +08:00
Lakr
1dd9566dfe Disable kernel JB patches, enable kernelcache
Uncomment the kernelcache (JB) component in JB_COMPONENTS so the kernelcache patcher is included. In KernelJBPatcher, comment out a large set of patch registration calls across Groups A, B and C and annotate them (A1..C24) to keep the original patch list for reference while preventing them from being applied. No functional patch logic was modified, only registration calls were disabled and formatting adjusted.
2026-03-04 19:12:09 +08:00
Lakr
03cb2a8389 fix TXM selector24 bypass: return 0xA1 (PASS) instead of NOP/fail
The original selector24 patches (NOP ldr + NOP bl) broke the hash flags
extraction, causing the consistency check to fail. The second attempt
(return 0x130A1) also failed because the return code semantics were
inverted — byte 1 != 0 means FAIL, not success.

Correct approach: insert `mov w0, #0xa1; b <epilogue>` after the prologue.
0xA1 has byte 1 = 0 which the caller checks via `tst w0, #0xff00` as PASS.

Update AGENTS.md

move selector24 bypass from txm_jb.py to txm_dev.py, delete TXMJBPatcher

Selector24 CS validation bypass now applies to both dev and JB variants
via txm_dev.py. The separate txm_jb.py patcher is removed since it had
no other patches. Dev boot chain: 47→49 patches.

Create txm_fullchain_analysis.md
2026-03-04 18:56:07 +08:00
Lakr
557486845c Merge pull request #99 from TastyHeadphones/codex/cfw-install-ssh-ready-preflight
cfw_install: preflight ramdisk SSH readiness before remote steps
2026-03-04 18:29:27 +08:00
Lakr
c137671aeb Update AGENTS.md 2026-03-04 18:28:58 +08:00
Lakr
ec2a071fa4 fix testing ramdisk copy: boots fine, no panic 2026-03-04 18:14:37 +08:00
Lakr
11e6fc8eaa use base ramdisk + real trustcache for testing ramdisk
Extract stock ramdisk from restore directory, mount it to build a real
trustcache from its Mach-O binaries, then sign both. Empty trustcache
would be rejected by the boot chain.
2026-03-04 18:10:18 +08:00
Lakr
53bb0a308e add empty ramdisk + trustcache to testing ramdisk build/send
Boot chain requires all 8 steps (iBSS, iBEC, SPTM, TXM, trustcache,
ramdisk, DeviceTree, SEP, kernel). Ramdisk and trustcache are now
included as valid but empty artifacts.
2026-03-04 18:08:40 +08:00
Lakr
2096f9cefe Refactor TXM patching and fw_patch_jb flow
Separate dev vs JB TXM patches and streamline fw_patch_jb. fw_patch_dev now calls patch_txm and uses TXMPatcher as TXMDevPatcher; txm_dev.py doc/comments clarify it is dev-only and removes the trustcache bypass from the dev finder. fw_patch_jb was reorganized: COMPONENTS and JB_COMPONENTS lists define base and JB-only patches, the previous subprocess call to run fw_patch.py was removed, and component discovery/patching is unified (with updated messages). txm_jb now only implements the JB-exclusive selector24 extension, relying on dev patches being applied separately.
2026-03-04 17:45:02 +08:00
tastyheadphones
ca198f10b7 cfw_install: preflight ramdisk SSH readiness before remote steps 2026-03-04 18:36:06 +09:00
Lakr
4692a9bee4 add testing ramdisk: boot chain only (no rootfs, kernel will panic)
Sign patched firmware components (iBSS/iBEC/SPTM/DeviceTree/SEP/TXM/
kernelcache) into IMG4 without ramdisk or trustcache. Useful for
verifying boot chain patches in isolation.
2026-03-04 17:28:06 +08:00
Lakr
62b1564e20 refactor: split patchers into base/mixin modules and format scripts 2026-03-04 15:19:17 +08:00
Lakr
e695526840 Merge pull request #93 from jalyfeng/bugfix/jb
support input for vphone window
2026-03-04 13:39:23 +08:00
Lakr
641d5b5a79 Create txm_return_mechanism.md 2026-03-04 13:34:02 +08:00
Lakr
55a53e7179 Merge pull request #73 from p1atdev/ssh-retry
Add SSH retry logic to cfw_install and cfw_install_jb scripts
2026-03-04 11:07:30 +08:00
Lakr
fa054ca719 Add Git LFS instructions and fix Makefile help alignment
- Add git-lfs to brew deps and document git lfs install/pull steps
  in both English and Chinese READMEs
- Fix continuation line alignment in make help (off by one)
- Add missing blank line before VM management section
2026-03-03 13:09:31 +08:00
zqxwce
6e3ecc6879 rpcserver: Add rpcserver daemon (#62)
Add rpc-project rpcserver_ios LaunchDaemon to CFW install, update
cfw_input.tar.zst with the plist, and add iproxy 5910 + rpcclient
to README.

Co-authored-by: zqxwce <yyyyyy6yyyyyy6@gmail.com>
2026-03-03 02:47:19 +08:00
Lakr
b6d67221ff Fix CFW install docs: iproxy needs its own terminal (#58)
iproxy 2222 22 is a blocking command, so it can't share a terminal
with make cfw_install. Clarify that a third terminal is needed and
note the "Running server" output as the cue to proceed.

Closes #58
2026-03-03 02:42:34 +08:00
zqxwce
575f130fd2 cfw_install: Fix vphoned build (#60)
Update vphoned build step to compile all split source files instead of
just vphoned.m. Tracks all .m files for staleness checking and passes
them to clang with the correct -I include path.

Co-authored-by: zqxwce <yyyyyy6yyyyyy6@gmail.com>
2026-03-03 02:39:58 +08:00
tastyheadphones
8a17f167da setup_machine: preflight VM storage lock holders before boot (#56)
Add a VM storage lock preflight in setup_machine.sh before both
`make boot` and `make boot_dfu`. Detects active lock holders for
nvram.bin, machineIdentifier.bin, Disk.img, and SEPStorage via lsof,
prints PID/PPID/command details, and supports optional automatic
recovery with AUTO_KILL_VM_LOCKS=1.

Fixes #55.

Co-authored-by: tastyheadphones <tastyheadphones@icloud.com>
2026-03-03 02:37:35 +08:00
Lakr
fa65403002 Merge pull request #53 from zqxwce/feature/ipsw-dir
fw_prepare: Move ipsws to dedicated directory to avoid repeated downloads
2026-03-03 02:34:37 +08:00
Lakr
8c7d9911a2 Clean up location passthrough PR: consistent formatting and logging 2026-03-02 19:28:53 +08:00
Lakr
c0f0efa492 Merge pull request #51 from SongXiaoXi/main
feat: add host location passthrough to guest VM
2026-03-02 18:36:38 +08:00
Lakr
e5fdad341f Skip vsock control connection in DFU mode
No guest OS is running in DFU, so attempting to connect causes
endless "Connection reset by peer, retrying..." log spam.
2026-03-02 18:36:12 +08:00
Lakr
4c74692ac2 Merge pull request #48 from SongXiaoXi/main
Add vphoned — vsock-based host↔guest control channel
2026-03-02 13:01:44 +08:00
Lakr
d179b4f6be Merge PR #45 (unlock VM) and PR #46 (tool compat fallbacks)
- Add `unlock` tool: C program dispatching IOHIDEvent to wake/unlock screen
- Rework serial port to pipes for programmatic command injection
- Auto-unlock on non-DFU boot via serial console after 8s delay
- Add "Unlock" menu item, `make unlock`/`make unlock_deploy` targets
- Defer to native VZVirtualMachineView touch on macOS 16+
- Add sshpass resolver with bundled/host fallback and arch checks
- Add gtar resolver with bundled/host/tar fallback and arch checks
- Prevent host-arch mismatches from breaking cfw_install and ramdisk_build

Closes #45, closes #46
Fixes #38, fixes #41

Co-authored-by: webcpu <liang@unchartedworks.com>
Co-authored-by: tastyheadphones <tastyheadphones@icloud.com>
2026-03-02 10:46:20 +08:00
Lakr
1d7ae7fe55 Merge pull request #42 from zqxwce/main 2026-03-02 11:24:30 +09:00
Lakr
63dca45383 Update fw_patch_jb.py 2026-03-02 00:56:40 +08:00
root
db13bedc2e WIP: Update kernel_jb.py JB patcher logic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 09:29:07 -05:00
Lakr
154d5064ec Add JB install pipeline and update docs
Add jailbreak extension patchers and targets:
- kernel_jb.py: 22 dynamic kernel patches (trustcache, execve cs_flags,
  sandbox ops, task/VM, kcall10 syscall hook, ~160 total modifications)
- txm_jb.py: 13 TXM patches (CS validation, get-task-allow, debugger
  entitlement, dev mode bypass)
- iboot_jb.py: iBSS nonce generation skip
- cfw.py: launchd jetsam patch, dylib injection commands
- fw_patch_jb.py: orchestrator running base + JB extension patches
- cfw_install_jb.sh: JB install phases (launchd jetsam fix, procursus
  bootstrap + Sileo deployment)

3 kernel patches still WIP (nvram_verify_permission, thid_should_crash,
hook_cred_label_update_execve) — strategies documented in
researchs/kernel_jb_remaining_patches.md.

All base (non-JB) code paths verified unaffected — kernel.py produces
identical 25 patches, cfw.py base commands unchanged.

Add Linux venv setup script; tweak Makefile help

Add scripts/setup_venv_linux.sh to create a Python virtualenv on Debian/Ubuntu (or dnf-based) systems, install system packages and Python requirements, and verify core imports (capstone, keystone, pyimg4). Also update Makefile help text to mark the fw_patch_jb target as WIP. This simplifies local development setup on Linux and clarifies that the JB extension patches are a work in progress.

Update AGENTS.md: mark cfw_install_jb.sh as complete
2026-03-01 15:01:32 +09:00
Lakr
7741821698 Merge pull request #30 from xatuke/patch-1
Enhance README with restore and boot instructions
2026-03-01 11:46:29 +09:00
Lakr
8200cd5a55 Update README.md 2026-03-01 02:47:52 +09:00
Lakr
d9e66ae30d Merge pull request #15 from cocoa-xu/cx-fix-make-venv-keystone 2026-02-28 13:01:57 +09:00
Lakr
e65e78d090 Update README.md
Update README.md

Add Simplified Chinese README and link

Add README_zh-Hans.md containing a full Simplified Chinese translation of the project README and update README.md to include a link/badge to the new Chinese README. This makes the documentation accessible to zh-Hans readers.
2026-02-28 03:38:14 +09:00
Lakr
e9d5c5e458 Merge pull request #7 from missaustraliana/main 2026-02-27 10:53:30 +09:00
Lakr
ddd9b9d83c Add vphone CLI, ObjC wrappers, and scripts
Introduce a new vphone virtual iPhone project:

- Add VPhoneObjC (.m/.h) providing Objective-C wrappers around private Virtualization.framework APIs (PV=3 hardware model creation, bootloader ROM setting, NVRAM helpers, PL011 serial port, SEP coprocessor, debug/panic devices, and production-mode toggle).
- Add Swift CLI and VM implementation (VPhoneCLI.swift, VPhoneVM.swift, VPhoneHardwareModel.swift) to configure and boot a PV=3 VM, capture serial console, start in DFU, and manage SEP/storage. Includes validation and minimal device config (graphics, storage, networking).
- Add helper scripts (build_and_sign.sh, boot.sh, boot_dfu.sh) to build, codesign with entitlements, and launch the VM.
- Add vphone.entitlements enabling the required private virtualization entitlements.

Notes: this targets macOS 15+ and requires appropriate entitlements and disabled SIP/AMFI to use private virtualization APIs.

Create .gitignore

Update README.md

Update README.md

Update README.md

README: add demo image and fix formatting

Add demo.png and embed it in the README; clean up markdown and code snippet formatting, remove stray backticks/bold markers, normalize list bullets, fix a resource path (vrevm), tidy whitespace/trailing chars, and add an Acknowledgements section. These changes improve readability and correctness of the setup instructions.

Create LICENSE

Create README.md

Add Package.swift; use interactive serial console

Add a Swift Package manifest for vphone-cli (macOS v14) with targets VPhoneObjC and vphone-cli, dependency on swift-argument-parser, and necessary linker/swift settings. Modify VPhoneVM to remove the intermediate Pipe-based serial capture: attach the PL011 serial port directly to FileHandle.standardInput/standardOutput for an interactive console, remove the readabilityHandler-based console capture and related plumbing, and update log/print messages accordingly.

Add CFW installer and patching tools

Add scripts and input archive to install a custom firmware (CFW) on vphone via an SSH ramdisk. Includes:
- Scripts/install_cfw.sh: zsh installer that extracts Cryptex DMGs from a restore, mounts device filesystems, copies Cryptexes, installs GPU driver and iosbinpack64, patches system binaries, injects LaunchDaemons and configures persistent SSH/VNC. Idempotent, caches decrypted DMGs and signs patched binaries with provided tools.
- Scripts/patch_cfw.py: Python tool using capstone/keystone to locate and patch binaries (seputil, launchd_cache_loader, mobileactivationd), parse BuildManifest for Cryptex paths, and inject daemon plists.
- Scripts/cfw_input.tar.zst: bundled input resources (Cryptexs, daemons, signing cert, and helper tools).
The installer requires ipsw, aea, python3 with capstone/keystone-engine and is designed to be safe to re-run. Intended to automate CFW deployment and runtime patches on the target device.

Add ramdisk build and deployment scripts

Add Scripts/build_ramdisk.py to build a signed SSH ramdisk for vphone600 from a patched restore set: it extracts firmware components, patches iBEC boot-args, repacks/signs IM4P/IMG4 artifacts (iBSS, iBEC, TXM, kernel, DeviceTree, SEP, trustcache, ramdisk) using an IM4M from an SHSH blob. Include a prepackaged ramdisk_input.tar.zst with tooling/resources and a helper Scripts/ramdisk_send.sh to load the generated IMG4 files to a device via irecovery in the correct order. The Python script expects firmware patched by patch_firmware.py and requires keystone-engine, capstone, pyimg4, and the pyimg4 CLI; usage and temp/output directories are documented at the top of the script.

Add firmware prepare and patch scripts

Add two tools for building and modifying a hybrid restore image for vphone600:

Scripts/prepare_firmware.sh
- Bash helper to download an iPhone IPSW and a cloudOS IPSW, extract them, merge cloudOS boot components into the iPhone restore directory, and generate hybrid BuildManifest.plist and Restore.plist tailored for vresearch101/vphone600 use-cases.
- Produces a ready Restore directory. Usage: ./prepare_firmware.sh [iphone_ipsw_url] [cloudos_url]

Scripts/patch_firmware.py
- Python tool that runs after prepare_firmware.sh to patch boot-chain components (AVPBooter, iBSS, iBEC, LLB, TXM, kernelcache).
- Auto-detects IM4P vs raw payloads, supports recompressing/repacking IM4P (preserving PAYP metadata when required), and applies a variety of binary patches (image4 callback bypass, serial labels, boot-args injection, trustcache/ DGST bypasses, many kernelcache fixes).
- Implements assembler/disassembler helpers (keystone/capstone) and multiple heuristics for locating patch sites.
- Usage: python3 patch_firmware.py [vm_directory]
- Dependencies: keystone-engine, capstone, pyimg4 (pip install keystone-engine capstone pyimg4)

These scripts automate preparing a hybrid restore and applying the required boot-chain patches for research devices.

Update demo.png

Create boot_sweet.sh

Add multi-touch support and VM window

Enable multi-touch input and a GUI VM window: add ObjC helpers to configure a _VZUSBTouchScreenConfiguration, create _VZTouch objects via KVC (workaround for init crash), build _VZMultiTouchEvent instances, and send/get multi-touch devices. Expose these APIs in the VPhoneObjC header and invoke VPhoneConfigureMultiTouch from VPhoneVM before VM start. Add a VPhoneVMWindow implementing a touch-enabled VZVirtualMachineView that maps mouse/right-click/drag events to multi-touch phases (with edge detection for swipe aim) and a window controller to show the VM. Also update the CLI to present the window in GUI mode.
2026-02-27 00:56:38 +09:00