Compare commits

...
166 Commits
Author SHA1 Message Date
staturnz fe6a3a8c13 chore: dry-run only for now 2023-06-04 18:25:35 -05:00
staturnz 1a3e99640b Merge branch 'main' into gui 2023-06-04 18:23:06 -05:00
flower f80e2a8849 Update build.yml 2023-06-03 16:06:40 -07:00
flower a30e2ef32a ci: remove symlink for now 2023-05-29 11:21:39 -07:00
flower 2825ccaf17 ci: attempt to fix finish-build symlink v5 2023-05-29 11:03:00 -07:00
flower e1e0304b98 ci: attempt to fix finish-build symlink v4 2023-05-29 11:00:41 -07:00
flower 5f4ef51da9 ci: attempt to fix finish-build symlink v3 2023-05-29 10:48:41 -07:00
flower 98f7d032eb ci: attempt to fix finish-build symlink v2 2023-05-29 10:33:52 -07:00
flower 5b32d61a1e ci: attempt to fix finish-build symlink 2023-05-29 10:15:30 -07:00
flower fd80f9e63f feat: "latest" symlink 2023-05-29 09:53:58 -07:00
flower 52ff0b2e62 feat: different destinations for run_number (#393)
* chore: create separate dirs

* chore: fix up naming

* feat: Update embed to include actor

* fix: fixup embed

* fix: attempt to fix embed v3
2023-05-29 09:03:00 -07:00
Nick Chan aa0c3a77b3 deps: patch mbedtls 3.4.0 take 2 2023-05-27 23:51:40 +08:00
Nick Chan a5fbf1b18b deps: update MbedTLS to 3.4.0
96% tests passed, 5 tests failed out of 113

Total Test time (real) =  84.57 sec

The following tests FAILED:
	 42 - debug-suite (Failed)
	 80 - pkcs7-suite (Failed)
	109 - ssl-suite (Failed)
	112 - x509parse-suite (Failed)
	113 - x509write-suite (Failed)
2023-05-27 20:56:58 +08:00
flower 7d3bf14ea6 chore: Remove changes from embed 2023-05-24 14:41:14 -07:00
flower a8325474cf chore: Update README.md 2023-05-21 03:03:04 -07:00
flower 8a09d2670a chore: s/16.4.1/16.5 2023-05-21 02:37:56 -07:00
Nick Chan 30d8241e2d s/16.4.1/16.5 2023-05-20 00:59:04 +08:00
staturnz e33d50860b chore: update ramdisk download url 2023-05-17 23:49:23 -05:00
fenfenS 3b4340525d usb_libusb.c: initialize variable stuff.handle (#392)
initialize stuff.handle, or function FoundDevice would return directly.
2023-05-18 01:58:02 +08:00
staturnz e6033f31cc chore: update readme links 2023-05-17 08:11:00 -05:00
flower c14d93b008 ci: actual branch name 2023-05-14 20:44:10 -07:00
flower ed48d4fcb4 ci: change field 2023-05-14 20:30:24 -07:00
flower 2541330a07 ci: change embed design 2023-05-14 20:27:03 -07:00
flower 58aaf508fc ci: fix timestamp v3 2023-05-14 20:03:55 -07:00
flower e6644c0601 ci: fix timestamp v2 2023-05-14 19:49:57 -07:00
flower 194f568363 ci: fix timestamp 2023-05-14 19:15:47 -07:00
Nebula 963fbb6ed8 ci: other discord alert changes 2023-05-14 21:29:59 -04:00
Nebula 88185b7a88 ci: add timestamp to discord alert 2023-05-14 21:27:03 -04:00
Nebula 3c6213774b ci: hate 2023-05-14 21:15:28 -04:00
Nebula c35d199809 ci: Discord build message improvements 2023-05-14 21:04:38 -04:00
Nebula 67ca5a9d24 ci: do not trigger discord alert on PR 2023-05-14 20:11:12 -04:00
Nebula 8edc991786 ci: add Discord build message 2023-05-14 20:09:06 -04:00
Nick Chan f59ef6dcee 0xallie
[palera1n/palera1n] New comment on commit 1ca25ce
usedqq
2023-05-01 01:31:05 +08:00
Nick Chan 1ca25ceca8 clarify about clean fakefs and /var 2023-05-01 01:28:59 +08:00
Nick Chan 0a0410d506 -C, --clean-fakefs 2023-05-01 01:20:11 +08:00
Nick Chan 5f8b503ae3 skill issue 2023-04-30 01:20:39 +08:00
Nick Chan 9e253f98f4 -D_XOPEN_SOURCE=500 2023-04-30 01:10:08 +08:00
0x6ff d17af1fbc7 chore: fix inconsistencies inside control files for .deb creation (#388)
* chore: fix inconsistency

* chore: fix inconsistency 2
2023-04-29 12:48:34 -04:00
Nick Chan f3920b883d remove _GNU_SOURCE 2023-04-28 11:08:34 +08:00
Tom E 1abfdf5441 might or might not have accidentally deleted this 2023-04-27 17:34:19 -04:00
Tom E 1c3613c669 Fix the A9 and lower restart bug. 2023-04-27 16:29:23 -04:00
Nick Chan 627f9b3363 reserved kerninfo values 2023-04-27 23:10:28 +08:00
ねむい 388ae6f296 update palera1n.1: PongoOS url 2023-04-27 15:57:42 +09:00
ねむい 24a09bc44d Update readme: apple silicon macs 2023-04-27 15:57:30 +09:00
Nick Chan 5ea3237772 update credits 2023-04-26 14:07:26 +08:00
Nick Chan 9c094fc19f fix some compiler warnings 2023-04-25 02:00:00 +08:00
Nick Chan 2912dfd8c0 update palera1n.1 2023-04-25 00:11:18 +08:00
Nick Chan a3fa59eaa8 sneak 2023-04-24 03:43:25 +08:00
Nick Chan 290bcb143e Revert "fix: limd-glue FTBFS with latest libplist"
This reverts commit 1422d45a9f.
2023-04-22 22:19:00 +08:00
Nick Chan bb9fdde26e Revert "fix harder"
This reverts commit fe565b97ad.
2023-04-22 22:18:52 +08:00
justtryingthingsout a9e72b579e Add more error checking and improved readability 2023-04-20 20:47:37 +08:00
Nick Chan fe565b97ad fix harder 2023-04-19 11:29:40 +08:00
Nick Chan 1422d45a9f fix: limd-glue FTBFS with latest libplist 2023-04-19 11:22:38 +08:00
Nick Chan 869f0fc070 s/16.4/16.4.1/ 2023-04-18 19:21:46 +08:00
0x6ff cc1a865a86 chore: elaborate on ignoring non arm64 device (#382)
people don't read.
to save people from asking in the Discord what "Ignoring non-arm64 device.." means, elaborate.
2023-04-15 15:33:07 -04:00
Nick Chan 5ce2196268 docs: mention another bug 2023-04-09 16:01:38 +08:00
staturnz e5a618682f headers and packaging stuff 2023-04-07 09:59:14 -05:00
staturnz cee71af2a6 main ui code
main ui code, moving over from old repo
2023-04-06 15:45:00 -05:00
azreal fe50b7c966 Update dfuhelper.c grammer (#380) 2023-04-06 13:28:48 +08:00
staturnz 0278d19df8 gui build stuff 2023-04-05 22:19:57 -05:00
Nebula e02d977c5d chore: add new patreon 2023-04-05 21:50:19 -04:00
ねむい d82965f140 disable verbose boot if bootargs has 'serial=' str 2023-03-31 01:24:56 +09:00
Nick Chan 2623569d67 bakepale sounds better 2023-03-30 12:34:37 +08:00
Nick Chan 2637758372 s/16\.3\.1/16.4/g 2023-03-30 07:01:17 +08:00
Nick Chan 87a2f6b60b baked palera1n 2023-03-29 19:43:55 +08:00
Nick Chan 5e1291d7c4 add long only option in synposis 2023-03-29 18:52:02 +08:00
Nick Chan 1214aed3a7 make tui a build option 2023-03-29 18:46:01 +08:00
Nick Chan e96cd19295 remove a warning even if it is still true atm 2023-03-29 18:02:11 +08:00
Nick Chan f37643b93e ifdef ROOTFUL 2023-03-29 12:22:58 +08:00
Nick Chan 2a9f65c870 debug libusbmuxd 2023-03-28 23:38:54 +08:00
Nick Chan 11b594bec6 fixes 2023-03-28 23:17:29 +08:00
Nick Chan 047b334752 changes 2023-03-28 20:43:19 +08:00
Nick Chan c2bb49287a plush features 2023-03-28 12:43:46 +08:00
Nick Chan 2d932dd26b fix POSIX 2002 C 2023-03-25 13:40:45 +08:00
Nick Chan 03e6739bc9 stop defining _DARWIN_C_SOURCE 2023-03-25 13:36:03 +08:00
junepark678 b360e8dd02 add lto and debug symbols so we can generate the .dSYM (#376)
* add lto and debug symbols so we can generate the .DSYM

* add lto and debug symbols so we can generate the .DSYM

* fix pythonplayer moment
2023-03-23 22:13:21 +08:00
junepark678 d72e95fccc Make unrelated PRs not rebuild (#375)
(this isn’t tested, and there’s no way for me to know if it works)
2023-03-22 19:16:40 +08:00
junepark678 60f241e0db fixing discord links (proofread pass 1) (#374)
* fixing discord links (proofread pass 1)

* fix readme text (thanks ploosh)
2023-03-22 07:04:51 -04:00
junepark678 9a7d6151ae add logo that you can actually read for light mode users (#373) 2023-03-22 07:04:22 -04:00
Nick Chan ac34d4d2be revert adding version number
that would result in debs piling up on my server
i should just rename them when copying them over to
the release folder
2023-03-22 18:33:51 +08:00
junepark678 8cae820cb8 add guide to readme (#372) 2023-03-22 18:26:48 +08:00
Nick Chan b89fd2b915 use ~ 2023-03-22 18:26:22 +08:00
Nick Chan 4070ed9da9 2023-03-22 18:09:51 +08:00
Nick Chan 6c7f666bb3 fix @itsnebulalol moment
DONT PUT MACOS BUILD INTO AN IOS DEB
2023-03-22 17:47:35 +08:00
Nick Chan 36fc50d2f1 actually commit the macos control 2023-03-22 15:24:11 +08:00
Nick Chan 15b2372daa Do not depend usbmuxd on macOS 2023-03-22 15:22:56 +08:00
Nick Chan b7b52febe3 Depend usbmuxd 2023-03-22 15:18:07 +08:00
Nick Chan a29a279693 remove ohio 2023-03-22 12:11:04 +08:00
Nebula b693f1af29 fix: procursus bins go into $prefix/bin, chmod too 2023-03-21 20:29:45 -04:00
Nebula 41f7909597 fix: remove v from version string 2023-03-21 20:05:24 -04:00
Nebula 52167fc32d fix: i think this is better 2023-03-21 19:54:45 -04:00
Nebula a060fe7374 chore: edit deb names 2023-03-21 19:47:30 -04:00
Nebula f6450e0a5d fix: im going to cry 2023-03-21 19:29:29 -04:00
Nebula 6dec16ff2b fix: linux ARCH_NAME 2023-03-21 19:23:24 -04:00
Nebula 8807f4775f fix: version in control 2023-03-21 19:17:17 -04:00
Nebula 4b0457b6ee fix: macos deb building 2023-03-21 19:09:57 -04:00
Nebula 6e05ecd1f9 chore: add mandoc to linux build 2023-03-21 18:59:32 -04:00
Nebula 16cbb134aa fix: macos deb builds, actually this time 2023-03-21 18:45:24 -04:00
Nebula f267c3e714 fix: linux deb build (I hate this) 2023-03-21 18:32:23 -04:00
Nebula e4f46c4276 fix: i dont know anymore 2023-03-21 18:26:49 -04:00
Nebula 67b9b86940 fix: linux deb build and possibly macos 2023-03-21 18:11:41 -04:00
Nebula 3f73bd0b31 fix: github moment? 2023-03-21 17:51:42 -04:00
Nebula 8aca098801 fix: build linux debs 2023-03-21 17:49:16 -04:00
Nebula 831794f5eb chore: add deb creation to workflow 2023-03-21 17:38:26 -04:00
Nick Chan 5eb0a08727 credits goes to stderr 2023-03-21 09:46:47 +08:00
Nick Chan 4572ed5984 more doc fixes 2023-03-21 00:10:34 +08:00
Nick Chan e81a06513a update docs/palera1n.1 2023-03-20 23:47:21 +08:00
Nick Chan c17107da40 Add -S, --no-colors 2023-03-15 16:43:25 +08:00
Nick Chan a8a7fbdae8 test for /var/run/usbmuxd 2023-03-14 09:32:20 +08:00
Tom E 2990d9ab75 download jbinit from artifacts 2023-03-13 17:41:46 -04:00
flower 132eb393d0 patron :pleading: 2023-03-13 11:54:18 -07:00
Nebula 8f81f9b523 chore: add old releases to readme 2023-03-13 14:51:55 -04:00
Nebula b28e882b9c chore: update readme 2023-03-13 14:44:39 -04:00
Nick Chan f5cc175adc s/16\.3/16.3.1/g 2023-03-08 18:10:17 +08:00
Nick Chan 2a7df193ce support checkra1n clones being passed into -i 2023-03-08 16:49:18 +08:00
Tom E d974100585 i hate ariez. 2023-03-06 16:50:12 -05:00
azreal 9bf956e2da Update README.md (#24) 2023-03-04 18:02:35 -05:00
Nick Chan bb1bef3676 just remove configurationProvider 2023-02-26 21:16:58 +08:00
Nick Chan da21a56783 we do not crash on no usb ports anymore 2023-02-25 03:54:27 +08:00
Nick Chan 749578716a fix pythonplayer moment 2023-02-25 00:09:07 +08:00
alexia 9153d71626 Add instructions on wait time and stage 2 for fakefs/bindfs 2023-02-24 23:37:20 +08:00
junepark678 fae5eaf07e Fix errors when compiling on newer compilers (prototype definitions fix) 2023-02-24 23:28:35 +08:00
alexia df0c0f346d dfuhelper: make current step bold (#21) 2023-02-20 20:45:01 -05:00
Nick Chan 75ae960d1a fix FORCE_HELPER 2023-02-20 20:41:43 +08:00
Nick Chan 06be39a71c fix x86 dev build 2023-02-20 20:40:04 +08:00
Nick Chan 01bcc332cb fix iOS 13 palera1n-ios 2023-02-20 20:00:33 +08:00
Nick Chan f519162c61 pongo fetch stdout changes to resemble pongoterm 2023-02-20 16:29:37 +08:00
Nick Chan 21786017b0 support 15.0-16.3 2023-02-20 15:39:22 +08:00
iCrazeiOS 79c45399b8 corrected capitalisation (#20)
literally unusable
2023-02-19 22:36:40 -05:00
Nick Chan 6f34b90e15 bump _POSIX_C_SOURCE to 200112L 2023-02-16 23:38:03 +08:00
BananaOnGitHub 520d79b399 Update README.md 2023-02-15 16:21:56 +08:00
alexia 7f68777418 Fix dfuhelper arg name in help and man page 2023-02-15 16:21:35 +08:00
Nick Chan 05eb1d791b even more libusb stuff 2023-02-15 16:11:41 +08:00
Nick Chan cad3a8d233 libusb stuff 2023-02-15 15:10:04 +08:00
Nick Chan fe970cfe2c fix crash on no usb ports 2023-02-15 14:13:52 +08:00
Nick Chan d4052bfe6e make libusb error errors 2023-02-15 13:54:01 +08:00
Nick Chan 4836b08998 fix palera1n-ios build 2023-02-15 12:56:25 +08:00
Nick Chan fa7e58f45f Security and SystemConfiguration is not required for non-libusb 2023-02-15 12:50:04 +08:00
Nick Chan 0aec2f123d fix pythonplayer moments 2023-02-15 12:46:15 +08:00
Nebula 025baf4d74 🇫🇷 2023-02-14 21:09:19 -05:00
Nebula 49f0f74338 add --device-info to palera1n.1 2023-02-14 21:05:13 -05:00
Nebula fd75256cbd add --device-info 2023-02-14 20:05:56 -05:00
Nick Chan 4b4bc0c97e select xcode 2023-02-15 01:24:25 +08:00
Nick Chan 118d826f40 use macos-12 in actions 2023-02-15 01:22:36 +08:00
Nick Chan bfbdc82d22 fix some recovery/dfu detection problems 2023-02-15 01:18:03 +08:00
Nick Chan 6edcf92e7d simplify locking 2023-02-15 01:18:03 +08:00
Nick Chan 79d258814e Add TSAN builds 2023-02-15 01:18:03 +08:00
Tom E 87dae1a7e2 the plush 2023-02-14 07:04:48 -05:00
Nick Chan 4043f8534f more usage examples 2023-02-14 07:30:39 +08:00
Nick Chan 9df5f68590 silence some more USB errors on boot 2023-02-14 01:37:00 +08:00
alexia 623cd45286 Fix download_deps.sh 2023-02-13 20:43:41 +08:00
Nick Chan 366a81407b fix pythonplayer moment 2023-02-13 19:11:55 +08:00
BananaOnGitHub 471d828d5e nick chan deserves credit + small fixing (#8)
* nick chan deserves credit

* small fixing
2023-02-13 17:36:58 +08:00
Nick Chan 5d48b7b38f move release name into makefile 2023-02-13 14:16:29 +08:00
Nick Chan b67c7beb3c change BAKERAIN_DEVELOPER to BAKERAIN_DEVELOPE_R 2023-02-13 11:07:42 +08:00
Nick Chan 86e41f1895 Fixed "fixed credits" 2023-02-13 10:58:32 +08:00
Nebula 3fd35cdb94 fixed credits 2023-02-12 21:55:19 -05:00
Nick Chan f00cac7672 credit changes 2023-02-13 10:46:33 +08:00
Tom E 5420853a88 new kpf url (makefile) 2023-02-12 14:01:40 -05:00
Tom E fe3b52f020 use new kpf url (cmake) 2023-02-12 14:00:49 -05:00
Nick Chan d07875981a Add -B, remove -C 2023-02-13 02:22:12 +08:00
Nick Chan 9a93f9e340 uaf fix 2023-02-12 23:11:27 +08:00
flower 1e4906bb5a Update README.md 2023-02-12 17:12:33 +08:00
flower 50d3c47369 Update README.md 2023-02-12 17:12:33 +08:00
flower feda997a99 Update README.md 2023-02-12 17:12:33 +08:00
Nick Chan 992f54c4e1 copy palera1n.1 to ready 2023-02-12 15:33:40 +08:00
40 changed files with 2415 additions and 962 deletions

No files matched your search

+207 -45
View File
@@ -11,12 +11,20 @@ on:
- 'CMakeLists.txt'
- '.github/workflows/build.yml'
pull_request:
paths:
- 'src/**'
- 'docs/**'
- 'patches/**'
- 'include/**'
- 'Makefile'
- 'CMakeLists.txt'
- '.github/workflows/build.yml'
workflow_dispatch:
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -29,7 +37,11 @@ jobs:
run: |
make -j$(nproc) docs
mkdir ready
cp docs/*.html docs/mandoc.css ready
cp docs/*.html docs/mandoc.css docs/palera1n.1 ready
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
@@ -40,9 +52,9 @@ jobs:
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
dryRun: true
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref_name }}/${{ github.run_number }}"
build-darwin:
strategy:
@@ -59,10 +71,10 @@ jobs:
- arch: arm64
gnu_triple: aarch64-apple-darwin
os: iphoneos
minos: 14.0
runs-on: macos-latest
minos: 7.0
runs-on: macos-12
env:
MBEDTLS_VERSION: 3.3.0
MBEDTLS_VERSION: 3.4.0
READLINE_VERSION: 8.2
SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23
@@ -106,6 +118,10 @@ jobs:
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
- name: Select correct Xcode
run: |
sudo xcode-select -s /Applications/Xcode_14.2.app
- name: Setup environment
run: |
mkdir sysroot
@@ -116,7 +132,7 @@ jobs:
echo "CC=$(xcrun --find cc)" >> $GITHUB_ENV
echo "CXX=$(xcrun --find c++)" >> $GITHUB_ENV
echo "CPP=$(xcrun --find cc) -E" >> $GITHUB_ENV
echo "CFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
echo "CFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Os -g -flto=full -Wl,-object_path_lto,lto.o" >> $GITHUB_ENV
echo "CPPFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
echo "CXXFLAGS=-stdlib=libc++ -g -Os -isysroot ${{ env.SDK }} -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
echo "LDFLAGS=-g -Wl,-dead_strip -arch ${{ matrix.arch }} -isysroot ${{ env.SDK }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
@@ -127,6 +143,13 @@ jobs:
mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
- name: Prepare iPhoneOS environment
if: matrix.os == 'iphoneos'
run: |
echo "FAKE_PLATFORM=2" >> $GITHUB_ENV
echo "FAKE_SDK=7.0" >> $GITHUB_ENV
echo "FAKE_MINOS=7.0" >> $GITHUB_ENV
- name: Prepare headers
if: matrix.os != 'macosx'
run: |
@@ -293,26 +316,23 @@ jobs:
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.dylib' -delete
find dep_root -name '*.la' -delete
mkdir build
cd build
cmake .. -DSTATIC=1 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_C_COMPILER="${{ env.CC }}" \
-DCMAKE_C_FLAGS='${{ env.CFLAGS }}' \
-DCMAKE_FIND_ROOT_PATH="${{ env.DESTDIR }}" \
-DCMAKE_INSTALL_PREFIX="${{ env.PREFIX }}" \
-DSTATIC=1
make -j$(sysctl -n hw.ncpu)
cd ..
gmake -j$(sysctl -n hw.ncpu)
mkdir -p ready
mv build/src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
mv src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
dsymutil palera1n-${{ matrix.os }}-${{ matrix.arch }}
strip palera1n-${{ matrix.os }}-${{ matrix.arch }}
ldid -s palera1n-${{ matrix.os }}-${{ matrix.arch }}
if [ "${{ matrix.os }}" == "macosx" ]; then
ldid -S palera1n-${{ matrix.os }}-${{ matrix.arch }}
else
ldid -Ssrc/usb.xml palera1n-${{ matrix.os }}-${{ matrix.arch }}
fi
mkdir -p ready
tar -zcf ready/dep_root-${{ matrix.os }}-${{ matrix.arch }}.tgz dep_root
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
@@ -322,9 +342,9 @@ jobs:
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
dryRun: true
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref }}/${{ github.run_number }}"
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} build
if: ${{ github.event_name != 'pull_request' }}
@@ -341,12 +361,24 @@ jobs:
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
path: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
retention-days: 1
darwin-dist:
if: ${{ github.event_name != 'pull_request' }}
runs-on: macos-latest
needs: build-darwin
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Procursus
uses: beerpiss/[email protected]
with:
packages: sed coreutils
cache: true
mirror: 'https://procursus.itsnebula.net/'
- name: Download all Darwin artifacts
uses: actions/download-artifact@v3
@@ -365,6 +397,92 @@ jobs:
zip -r9 ready/palera1n-ios.dSYM.zip palera1n-iphoneos-arm64.dSYM
zip -r9 ready/palera1n-macos.dSYM.zip palera1n-macos.dSYM
- name: Build debs
run: |
make -j$(sysctl -n hw.ncpu) docs
version=$(git describe --dirty --tags --abbrev=7 | sed 's|^v||' | sed 's|-beta|~beta|')
# Darwin x86_64
mkdir -p stage/DEBIAN
mkdir -p stage/opt/procursus/bin
mkdir -p stage/opt/procursus/usr/share/man/man1
cp packaging/control.macosx stage/DEBIAN/control
gsed 's|@DEB_ARCH@|darwin-amd64|g' -i stage/DEBIAN/control
gsed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
ginstall -Dm644 ready/palera1n-macos-x86_64 stage/opt/procursus/bin/palera1n
ginstall -Dm644 docs/palera1n.1 stage/opt/procursus/usr/share/man/man1/palera1n.1
chmod +x stage/opt/procursus/bin/palera1n
dpkg-deb -Zzstd -b stage palera1n_darwin-amd64.deb
mv palera1n*.deb ready/
rm -rf stage
# Darwin arm64
mkdir -p stage/DEBIAN
mkdir -p stage/opt/procursus/bin
mkdir -p stage/opt/procursus/usr/share/man/man1
cp packaging/control.macosx stage/DEBIAN/control
gsed 's|@DEB_ARCH@|darwin-arm64|g' -i stage/DEBIAN/control
gsed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
ginstall -Dm644 ready/palera1n-macos-arm64 stage/opt/procursus/bin/palera1n
ginstall -Dm644 docs/palera1n.1 stage/opt/procursus/usr/share/man/man1/palera1n.1
chmod +x stage/opt/procursus/bin/palera1n
dpkg-deb -Zzstd -b stage palera1n_darwin-arm64.deb
mv palera1n*.deb ready/
rm -rf stage
# iPhoneOS
mkdir -p stage/DEBIAN
mkdir -p stage/usr/bin
mkdir -p stage/usr/share/man/man1
cp packaging/control stage/DEBIAN/control
gsed 's|@DEB_ARCH@|iphoneos-arm|g' -i stage/DEBIAN/control
gsed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
ginstall -Dm644 ready/palera1n-ios stage/usr/bin/palera1n
ginstall -Dm644 docs/palera1n.1 stage/usr/share/man/man1/palera1n.1
chmod +x stage/usr/bin/palera1n
dpkg-deb -Zzstd -b stage palera1n_iphoneos-arm.deb
mv palera1n*.deb ready/
rm -rf stage
# iPhoneOS (rootless)
mkdir -p stage/DEBIAN
mkdir -p stage/var/jb/usr/bin
mkdir -p stage/var/jb/usr/share/man/man1
cp packaging/control stage/DEBIAN/control
gsed 's|@DEB_ARCH@|iphoneos-arm64|g' -i stage/DEBIAN/control
gsed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
ginstall -Dm644 ready/palera1n-ios stage/var/jb/usr/bin/palera1n
ginstall -Dm644 docs/palera1n.1 stage/var/jb/usr/share/man/man1/palera1n.1
chmod +x stage/var/jb/usr/bin/palera1n
dpkg-deb -Zzstd -b stage palera1n_iphoneos-arm64.deb
mv palera1n*.deb ready/
rm -rf stage
- name: Save build tag
run: echo "$(git describe --dirty --tags --abbrev=7 | sed 's|-dirty||')" > build-tag.txt
- name: Upload build tag
uses: actions/upload-artifact@v3
with:
name: build-tag
path: build-tag.txt
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
@@ -374,9 +492,9 @@ jobs:
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
dryRun: true
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref }}/${{ github.run_number }}"
build-Linux:
strategy:
@@ -388,7 +506,7 @@ jobs:
- aarch64-linux-musl
runs-on: ubuntu-latest
env:
MBEDTLS_VERSION: 3.3.0
MBEDTLS_VERSION: 3.4.0
LIBUSB_VERSION: 1.0.26
READLINE_VERSION: 8.2
SLANG_VERSION: 2.3.3
@@ -405,7 +523,7 @@ jobs:
- name: Install build dependencies (packages)
run: |
sudo apt-get remove -y libssl-dev libreadline-dev
sudo apt-get install -y pkg-config autoconf automake autopoint
sudo apt-get install -y pkg-config autoconf automake autopoint mandoc
sudo pip3 install jsonschema jinja2
- name: Download toolchain checksum
@@ -433,15 +551,19 @@ jobs:
case ${{ matrix.triple }} in
i486-linux-musl)
echo "CHECKRA1N_NAME=linux-x86" >> $GITHUB_ENV
echo "ARCH_NAME=i386" >> $GITHUB_ENV
;;
x86_64-linux-musl)
echo "CHECKRA1N_NAME=linux-x86_64" >> $GITHUB_ENV
echo "ARCH_NAME=amd64" >> $GITHUB_ENV
;;
armel-linux-musleabi)
echo "CHECKRA1N_NAME=linux-armel" >> $GITHUB_ENV
echo "ARCH_NAME=armel" >> $GITHUB_ENV
;;
aarch64-linux-musl)
echo "CHECKRA1N_NAME=linux-arm64" >> $GITHUB_ENV
echo "ARCH_NAME=arm64" >> $GITHUB_ENV
;;
esac
echo "PKG_CONFIG_PATH=$(pwd)/sysroot/usr/local/lib/pkgconfig" >> $GITHUB_ENV
@@ -455,6 +577,7 @@ jobs:
echo "CROSS_COMPILE=${{ matrix.triple }}-" >> $GITHUB_ENV
mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
- name: Download dependencies (source code)
run: |
curl -LOOOOOOO \
@@ -632,31 +755,47 @@ jobs:
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.so' -delete
find dep_root -name '*.la' -delete
mkdir build
cd build
CC="${{ matrix.triple }}-gcc" cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \
-DCMAKE_FIND_ROOT_PATH=${{ env.DESTDIR }}${{ env.PREFIX }} \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_C_FLAGS="-I${{ env.DESTDIR }}${{ env.PREFIX }}/include \
-L${{ env.DESTDIR }}${{ env.PREFIX }}/lib -Wl,-rpath,${{ env.PREFIX }}/lib" -DSTATIC=1
make -j$(nproc) CC="${{ matrix.triple }}-gcc"
CC="${{ matrix.triple }}-gcc" make -j$(nproc)
- name: Seperate debug symbols
run: |
${{ matrix.triple }}-objcopy --only-keep-debug build/src/palera1n palera1n.debug
${{ matrix.triple }}-strip --strip-debug --strip-unneeded build/src/palera1n
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug build/src/palera1n
${{ matrix.triple }}-objcopy --only-keep-debug src/palera1n palera1n.debug
${{ matrix.triple }}-strip --strip-debug --strip-unneeded src/palera1n
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug src/palera1n
chmod -x palera1n.debug
- name: Prepare artifact
run: |
mkdir ready
mv palera1n.debug ready/palera1n-${{ env.CHECKRA1N_NAME }}.debug
mv build/src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
mv src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
tar -zcf ready/dep_root_${{ matrix.triple }}.tgz dep_root
- name: Build debs
run: |
version=$(git describe --dirty --tags --abbrev=7 | sed 's|^v||' | sed 's|-beta|~beta|')
make -j$(nproc) docs
mkdir -p stage/DEBIAN
mkdir -p stage/usr/bin
mkdir -p stage/usr/share/man/man1
cp packaging/control stage/DEBIAN/control
sed 's|@DEB_ARCH@|${{ env.ARCH_NAME }}|g' -i stage/DEBIAN/control
sed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
install -Dm644 ready/palera1n-${{ env.CHECKRA1N_NAME }} stage/usr/bin/palera1n
install -Dm644 docs/palera1n.1 stage/usr/share/man/man1/palera1n.1
chmod +x stage/usr/bin/palera1n
dpkg-deb -b stage palera1n_${{ env.ARCH_NAME }}.deb
mv palera1n*.deb ready/
rm -rf stage
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
@@ -666,6 +805,29 @@ jobs:
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
dryRun: true
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref }}/${{ github.run_number }}"
finish-build:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs: [build-docs, build-darwin, darwin-dist, build-Linux]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
- name: Download build tag
uses: actions/download-artifact@v3
with:
name: build-tag
- name: Send Discord build message
run: |
COMMITMESSAGE=`git log --pretty=format:'- \`%h\` %s' -1 --reverse` &&
(curl "${{ secrets.DISCORD_WEBHOOK }}" -sS -H "Content-Type:application/json" -X POST -d "{\"content\":null,\"embeds\":[{\"title\":\"[palera1n:${{ steps.branch-name.outputs.ref_branch }}] Nightly Build ${{ github.run_number }}\",\"url\":\"https://github.com/palera1n/palera1n/actions/runs/${GITHUB_RUN_ID}\",\"color\":2829617,\"fields\":[{\"name\":\"Build tag\",\"value\":\"- \`$(cat build-tag.txt | sed 's|\n||')\`\"},{\"name\":\"Destination\",\"value\":\"- https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}\"},{\"name\":\"Documentation\",\"value\":\"- [palera1n.1.html](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n.1.html)\"},{\"name\":\"Main Artifacts\",\"value\":\"- [palera1n-ios](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-ios)\n- [palera1n-linux-arm64](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-arm64)\n- [palera1n-linux-armel](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-armel)\n- [palera1n-linux-x86](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/$${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-x86)\n- [palera1n-linux-x86_64](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-x86_64)\n- [palera1n-macos-universal](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-macos-universal)\"}],\"footer\":{\"text\":\"${{ github.actor }}\", \"icon_url\": \"https://github.com/${{ github.actor }}.png\",\"timestamp\":\"$(date -u +"%FT%TZ")\"}}],\"username\":\"GitHub Actions\",\"avatar_url\":\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"}")
+3
View File
@@ -20,3 +20,6 @@ docs/*.html
build
src/*.dmg.c
.idea
src/stage2/
src/libcheckra1nhelper.dylib*
src/Pongo.bin
-22
View File
@@ -1,22 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(palera1n)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_CXX_STANDARD 99)
set(SRC ${CMAKE_CURRENT_SOURCE_DIR})
set(DEP ${SRC}/dep_root)
set(CMAKE_C_STANDARD 99)
set(STATIC 0)
set(CMAKE_SUPPRESS_REGENERATION ON)
set(CMAKE_BUILD_TYPE BUILD_TYPE)
add_custom_target(distclean
COMMAND sh -c "find src -name '*.o' -type f -delete"
COMMAND sh -c "find src -perm -u+x -type f -delete"
)
#add_custom_target(distclean
# COMMAND sh -c "rm -rf *"
# )
add_subdirectory(src)
add_subdirectory(docs)
+38 -10
View File
@@ -1,12 +1,16 @@
NAME = bakepale
SRC = $(shell pwd)
DEP = $(SRC)/dep_root
STRIP = strip
CC ?= cc
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC)
CFLAGS += -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=199506L -D_DARWIN_C_SOURCE
CXX ?= c++
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) -D_XOPEN_SOURCE=500
CFLAGS += -Wall -Wextra -Wno-unused-parameter -DPALERAIN_VERSION=\"2.0.0\"
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=200112L
CXXFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) -std=c++11
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread -lm
ifeq ($(TARGET_OS),)
TARGET_OS = $(shell uname -s)
endif
@@ -16,22 +20,34 @@ ifeq (,$(findstring version-min=, $(CFLAGS)))
CFLAGS += -mmacosx-version-min=10.8
endif
LDFLAGS += -Wl,-dead_strip
LIBS += -framework CoreFoundation -framework SystemConfiguration -framework IOKit -framework Security
LIBS += -framework CoreFoundation -framework IOKit
else
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += -static -no-pie -Wl,--gc-sections
endif
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
ifeq ($(DEV_BUILD),1)
ifeq ($(TUI),1)
LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
ifeq ($(TARGET_OS),Linux)
LIBS += $(DEP)/lib/libgpm.a
endif
endif
ifeq ($(GUI),1)
LIBS += $(DEP)/lib/libguira1n.a
ifeq ($(TARGET_OS),Darwin)
LIBS += -framework Foundation -framework AppKit
CXXFLAGS += -x objective-c++
endif
endif
ifeq ($(DEV_BUILD),1)
CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
ifeq ($(ASAN),1)
BUILD_STYLE=ASAN
CFLAGS += -fsanitize=address,undefined -fsanitize-address-use-after-return=runtime
else ifeq ($(TSAN),1)
BUILD_STYLE=TSAN
CFLAGS += -fsanitize=thread,undefined
else
BUILD_STYLE = DEVELOPMENT
endif
@@ -39,13 +55,25 @@ else
CFLAGS += -Os -g
BUILD_STYLE = RELEASE
endif
LIBS += -lc
ifneq ($(BAKERAIN_DEVELOPE_R),)
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
endif
BUILD_DATE := $(shell LANG=C date)
BUILD_NUMBER := $(shell git rev-list --count HEAD)
BUILD_TAG := $(shell git describe --dirty --tags --abbrev=7)
BUILD_WHOAMI := $(shell whoami)
BUILD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BUILD_COMMIT := $(shell git rev-parse HEAD)
CFLAGS += -DBUILD_STYLE=\"$(BUILD_STYLE)\" -DBUILD_DATE="\"$(BUILD_DATE)\"" -DBUILD_WHOAMI=\"$(BUILD_WHOAMI)\" -DBUILD_TAG=\"$(BUILD_TAG)\"
CFLAGS += -DBUILD_STYLE="\"$(BUILD_STYLE)\"" -DBUILD_DATE="\"$(BUILD_DATE)\""
CFLAGS += -DBUILD_WHOAMI="\"$(BUILD_WHOAMI)\"" -DBUILD_TAG="\"$(BUILD_TAG)\""
CFLAGS += -DBUILD_NUMBER="\"$(BUILD_NUMBER)\"" -DBUILD_BRANCH="\"$(BUILD_BRANCH)\""
CFLAGS += -DBUILD_COMMIT="\"$(BUILD_COMMIT)\""
export SRC DEP CC CFLAGS LDFLAGS LIBS TARGET_OS DEV_BUILD BUILD_DATE BUILD_TAG BUILD_WHOAMI BUILD_STYLE
export SRC DEP CC CXX CFLAGS CXXFLAGS LDFLAGS LIBS TARGET_OS DEV_BUILD BUILD_DATE BUILD_TAG BUILD_WHOAMI BUILD_STYLE BUILD_NUMBER BUILD_BRANCH
all: palera1n
@@ -57,13 +85,13 @@ clean:
$(MAKE) -C docs clean
download-deps:
$(MAKE) -C src checkra1n-macos checkra1n-linux-arm64 checkra1n-linux-armel checkra1n-linux-x86 checkra1n-linux-x86_64 checkra1n-kpf-pongo ramdisk.dmg binpack.dmg
$(MAKE) -C src checkra1n-macos checkra1n-linux-arm64 checkra1n-linux-armel checkra1n-linux-x86 checkra1n-linux-x86_64 checkra1n-kpf-pongo ramdisk.dmg binpack.dmg Pongo.bin
docs:
$(MAKE) -C docs
distclean: clean
rm -rf palera1n-* palera1n*.dSYM src/checkra1n-* src/checkra1n-kpf-pongo src/ramdisk.dmg src/binpack.dmg
rm -rf palera1n-* palera1n*.dSYM src/checkra1n-* src/checkra1n-kpf-pongo src/ramdisk.dmg src/binpack.dmg src/Pongo.bin
.PHONY: all palera1n clean docs distclean
+60 -82
View File
@@ -1,97 +1,75 @@
<h1 align="center">
palera1n
</h1>
<picture>
<source media="(prefers-color-scheme: light)" srcset="https://cdn.discordapp.com/attachments/1028398976640229380/1088049124441604136/IMG_0033.png">
<img align="left" height="120" src="https://cdn.discordapp.com/attachments/1017854329887129611/1073858292159352862/thing.png" alt="palera1n logo" style="float: left;"/>
</picture>
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/made%20with-love-E760A4.svg" alt="Made with love"></img>
</a>
<a href="https://github.com/palera1n/palera1n-c/blob/main/LICENSE" target="_blank">
<img src="https://img.shields.io/github/license/palera1n/palera1n-c.svg" alt="License"></img>
</a>
<a href="https://github.com/palera1n/palera1n-c/graphs/contributors" target="_blank">
<img src="https://img.shields.io/github/contributors/palera1n/palera1n-c.svg" alt="Contributors"></img>
</a>
<a href="https://github.com/palera1n/palera1n-c/commits/main" target="_blank">
<img src="https://img.shields.io/github/commit-activity/w/palera1n/palera1n-c.svg" alt="Commits"></img>
</a>
<img src="https://img.shields.io/github/search/palera1n/palera1n-c/goto.svg" alt="goto counter"></img>
<a href="https://dsc.gg/palera1n" target="_blank">
<img src="https://img.shields.io/discord/1028398973452570725?label=discord" alt="Discord"></img>
</a>
</p>
<br clear="both"/>
<p align="center">
iOS 15.0-16.3 work in progress, semi-tethered checkm8 jailbreak
</p>
## Information
- Guides to palera1n can be found [here](https://ios.cfw.guide/installing-palera1n).
- Full documentation can be also found [here](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/palera1n.1.html).
# BEFORE YOU USE
## Warnings
- We are **NOT** responsible for any data loss, or the result of a device being bricked. The user of this program accepts responsibility should something happen to their device. While nothing should happen, jailbreaking has risks in itself.
- If your device is stuck in recovery, please run futurerestore `--exit-recovery`, or use `irecovery -n`.
This is mainly for ROOTLESS, and is NOT READY. It was made public so you can contribute and explore the code. This is not the final product.
- palera1n will never work in VirtualBox, VMware or any virtual machine that doesn't support PCI passthrough.
This version of palera1n supports booting fakefs setups with the `-f` option. No arguments required.
## Requirements
- A checkm8 vulnerable iOS device on iOS 15.x or 16.x (`A8` - `A11`)
- If using rootful, you will need **5-10GB of space** for the fakefs. This means 16GB devices cannot use the full fakefs creation. However, you can change the arguments to `-Bf` to create a fakefs with bind mounts, so it uses a smaller size, at the expense having unwritable parts in rarely-written paths, and then boot it
- On `A11`, **you must disable your passcode while in the jailbroken state** (on iOS 16, you need to **reset your device** before proceeding with palera1n).
This version of palera1n is able to create fakefs with the `-c` option, however as of right now if the `/jbin/loader.app`
doesn't exist (which is true for any fakefs created with this version of palera1n), the loader that appears would be rootless.
- **USB-A** cables are recommended to use, USB-C may have issues with palera1n and getting into DFU mode.<details><summary>Technical explanation</summary>The BootROM will only enter DFU if it detects USB voltage, which boils down to checking whether a certain pin is asserted from the Tristar chip. The Tristar does this based on the cable's accessory ID, and apparently USB-A and USB-C cables have different accessory IDs, and the one of the USB-C cables makes the Tristar not assert the USB voltage pin.</details>
Loader app does appear on rootless, and you can use the SSH server listening at 127.0.0.1:44 (IPv4) or ::1:44 (IPv6).
- A Linux or macOS computer
- AMD CPUs (not AMD Mobile) have an issue [with (likely) their USB controllers] that causes them to have a very low success rate with checkm8. It is not recommended that you use them with palera1n.
- If your device does not successfully jailbreak, try a computer with an Intel or other CPU
- Apple Silicon Macs with USB-C
- USB-C port on Apple Silicon Macs may require manual unplugging and replugging of the lightning cable after checkm8 exploit.
- This problem may be solved by connecting via USBHub.
If the device is previously jailbroken, the jailbreak environment is automatically prepared.
You can use the `-s` option to skip this behaviour.
## Need help?
Usbmuxd is only required for starting in normal mode, it is not required when started from recovery or DFU mode. (Usbmuxd is preinstalled with macOS)
Make sure you provide full details on your device, such as:
- iDevice
- iOS Version
- Passcode enabled?
- Logs, if panicked then send latest `panic-full` log from your iDevice.
You can obtain the latest build of palera1n-c [here](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/).
Using `-VvL` would help with debugging.
# This is a work in progress.
Join the [Support Discord](https://dsc.gg/palera1n), and create a thread in [#support](https://discord.com/channels/1028398973452570725/1028730487700738130) or ask in [#general](https://discord.com/channels/1028398973452570725/1028398976640229380).
Read this throughly, feel free to ask questions, know the risks. If you want to ask questions, either:
## Credits
<details><summary>Credits</summary>
<p>
1. Ask in the [palera1n Discord](https://discord.gg/4S3yUMxuQH)
2. Ask in the r/jailbreak Discord #palera1n channel
Please, please, please, provide necessary info:
- iOS version and device (eg. iPhone 7+ 15.1, iPhone 6s 15.3.1)
- Computer's OS and version (eg. Ubuntu 22.04, macOS 13.0)
- The command you ran
**DO NOT** harass tweak devs if tweaks don't work. Refer to [here](https://github.com/itsnebulalol/ios15-tweaks) for compatiblity.
# Patreons
Thank you so much to our Patreons that make the future development possible! You may sub [here](https://patreon.com/palera1n), if you'd like to. If you subscribe, please message [Nebula](https://twitter.com/itsnebulalol) in any way preferred to have you put here.
<a href="https://github.com/samh06"><img width=64 src="https://user-images.githubusercontent.com/18669106/206333607-881d7ca1-f3bf-4e18-b620-25de0c527315.png"></img></a>
<a href="https://havoc.app"><img width=64 src="https://docs.havoc.app/img/standard_icon.png"></img></a>
<a href="https://twitter.com/yyyyyy_public"><img width=64 src="https://pbs.twimg.com/profile_images/1429332550112079876/dQQgsURc_400x400.jpg"></img></a>
<a href="https://twitter.com/0xSp00kyb0t"><img width=64 src="https://pbs.twimg.com/profile_images/1603601553226620935/1t4yD1bD_400x400.jpg"></img></a>
<a href="https://chariz.com"><img width=64 src="https://chariz.com/img/favicon.png"></img></a>
<a href="https://twitter.com/stars6220"><img width=64 src="https://pbs.twimg.com/profile_images/1606990218925670400/Y4JBl6OS_400x400.jpg"></img></a>
<a href="https://github.com/beast9265"><img width=64 src="https://avatars.githubusercontent.com/u/79794946?v=4"></img></a>
# What does this do?
It boots the device with patches for the jailbreak.
**WARNING**: I am NOT responsible for any data loss. The user of this program accepts responsibility should something happen to their device. While nothing should happen, jailbreaking has risks in itself. If your device is stuck in recovery, please run `futurerestore --exit-recovery`, or use `irecovery -n`.
On A11, you **must disable your passcode while in the jailbroken state**. We don't have an A11 SEP exploit yet.
<!--# Usage
See the [wiki](https://github.com/palera1n/palera1n-c/wiki).-->
# Credits
- [Nebula](https://github.com/itsnebulalol), palera1n owner and Python rewrite lead developer
- [Nathan](https://github.com/verygenericname)
- [Mineek](https://github.com/mineek)
- [Nick Chan](https://github.com/asdfugil)
- [Amy](https://github.com/elihwyma) for the [Pogo](https://github.com/elihwyma/Pogo) app
- [Lakhan Lothiyi](https://github.com/llsc12) for older palera1n loader app
- [checkra1n](https://github.com/checkra1n) for the base of the kpf
- [the Procursus Team](https://github.com/ProcursusTeam) for the amazing [bootstrap](https://github.com/ProcursusTeam/Procursus)
- [F121](https://github.com/F121Live) for helping test
- [Tom](https://github.com/guacaplushy) for a couple patches and bugfixes
- [Nick Chan](https://github.com/asdfugil) general help with patches and jbinit
- [Serena](https://github.com/SerenaKit) for helping with boot ramdisk
- [Évelyne](https://github.com/evelyneee) for ElleKit, rootless tweak injection
- [Évelyne](https://github.com/evelyneee) for [ElleKit](https://github.com/evelyneee/ellekit), rootless tweak injection
- [Sam Bingner](https://github.com/sbingner) for [Substitute](https://github.com/sbingner/substitute), rootful tweak injection
</details>
</p>
<br>
<p align="center">
Thank you so much to our Patreons that make the future development possible! You may sub <a href="https://patreon.com/palera1n">here</a>, if you'd like to.</br>
</p>
<p align="center">
<a href="https://github.com/samh06"><img width=64 style="border-radius: 25%;" src="https://user-images.githubusercontent.com/18669106/206333607-881d7ca1-f3bf-4e18-b620-25de0c527315.png"></img></a>
<a href="https://havoc.app"><img width=64 style="border-radius: 25%;" src="https://docs.havoc.app/img/standard_icon.png"></img></a>
<a href="https://twitter.com/yyyyyy_public"><img width=64 style="border-radius: 25%;" src="https://cdn.discordapp.com/attachments/1054239098006683688/1072587455779328040/image.png?size=400"></img></a>
<a href="https://twitter.com/0xSp00kyb0t"><img width=64 style="border-radius: 25%;" src="https://pbs.twimg.com/profile_images/1603601553226620935/1t4yD1bD_400x400.jpg"></img></a>
<a href="https://chariz.com"><img width=64 src="https://chariz.com/img/favicon.png"></img></a>
<a href="https://twitter.com/stars6220"><img width=64 style="border-radius: 25%;" src="https://pbs.twimg.com/profile_images/1621062976982728706/pWVZQ-NO_400x400.jpg"></img></a>
<a href="https://github.com/TheFunnyMan16"><img width=64 style="border-radius: 25%;" src="https://cdn.discordapp.com/attachments/1050068822473842778/1082867264807772281/IMG_3942.jpg">
<a href="https://github.com/beast9265"><img width=64 style="border-radius: 25%;" src="https://avatars.githubusercontent.com/u/79794946?v=4"></img></a>
<a href="https://twitter.com/0x7FF7"><img width=64 style="border-radius: 25%;" src="https://pbs.twimg.com/profile_images/1630818481191919618/8MWaJ1F7_400x400.jpg"></img></a>
<a href="https://sideloadly.io/"><img width=64 style="border-radius: 25%;" src="https://sideloadly.io/icon.png"></img></a>
<a href="https://blog.stevesec.com/"><img width=64 style="border-radius: 25%;" src="https://blog.stevesec.com/img/avatar.jpg"></img>
<a href="https://github.com/0xilis/"><img width=64 style="border-radius: 25%;" src="https://github.com/0xilis.png"></img></a>
</p>
-4
View File
@@ -1,4 +0,0 @@
add_custom_target(
docs
COMMAND sh -c "mandoc -T html -O style=mandoc.css palera1n.1 > palera1n.1.html"
)
+67 -28
View File
@@ -2,25 +2,25 @@
.\" Copyright (c) 2023 Nick Chan
.\" SPDX-License-Identifier: MIT
.\"
.Dd "06 February 2023"
.Dt "Nick Chan utilities manual" 1 "palera1n"
.Dd "20 March 2023"
.Dt palera1n 1
.Os
.Sh NAME
.Nm palera1n
.Nd iOS 15+ arm64 iOS/iPadOS jailbreaking tool
.Nd iOS 15.0-16.5 arm64 iOS/iPadOS jailbreaking tool
.Sh SYNOPSIS
.Nm
.Op Fl cCdDEfhlnLOpRsvV
.Op Fl cCdDEfhIlLnpRsSvV
.Op Fl e Ar Boot arguments
.Op Fl k Ar Pongo image
.Op Fl o Ar overlay file
.Op Fl r Ar ramdisk file
.Op Fl K Ar KPF file
.Op Fl i Ar checkra1n file
.Op Fl -version
.Op Fl -force-revert
.Sh DESCRIPTION
.Nm
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15+,
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.5,
utilizing the
.Em checkm8
bootROM exploit.
@@ -48,8 +48,11 @@ On iOS 16, the passcode must be off since restore, and
from settings app counts as a restore.
A backup may be used in this case.
.Pp
In the remainder of this document, the term "iOS" and "iPadOS" will be used interchangably
as the difference is negligible as far as the jailbreak is concerened.
.Pp
.Sh SUPPORTED DEVICES
As described above, arm64 iOS/iPadOS 15+ devices are supported, here is an explicit
As described above, arm64 iOS 15.0-16.5 devices are supported, here is an explicit
list of supported devicecs:
.Bl -tag -compact
@@ -99,19 +102,32 @@ files. As a result, using the loader app to install the jailbreak environment
is not supported when this option is used together with
.Fl f , -fakefs
\[char46]
.It Fl B , -setup-fakefs-partial
Like
.Fl c , -setup-fakefs
but the size of the created fakefs is smaller at the expense of having unwritable
parts in rarely-written paths. When jailbreaking 16 GB devices, this option must be used
when setting up fakefs for rootful, as they do not have enough storage for full fakefs.
This option currently does not work on iOS 16.
.It Fl c , -setup-fakefs
When used with
.Fl f , -fakefs ,
Create the new APFS volume required for rootful. Will fail if one already exists.
.It Fl C , -setup-fakefs-forced
When used with
.Fl f , -fakefs ,
behaves like
.Fl c , -setup-fakefs ,
but existing fakefs, if exists, will be overwritten instead.
creates the new APFS volume required for rootful. Will fail if one already exists.
.It Fl C , -clean-fakefs
This reverts the fakefs to the
.Em orig-fs
snapshot that is created when the fakefs
is first created, then the device will continue to boot jailbroken. This option
allows resetting the rootful environment without deleting the entire fakefs.
Note that this option will not work if the fakefs is created in an older version
of palera1n that does not create the
.Em orig-fs
snapshot on the fakefs. This option will also remove some jailbreak files inside
of /var. The files in /var will not be deleted when a userspace reboot is done
with this flag set.
.It Fl d , -demote
Set the effective production fuse to 0, so as to enable hardware debugging features.
.It Fl D , -dfuhelper-only
.It Fl D , -dfuhelper
Execute the DFU helper to guide the user into putting the device into DFU mode
then exit.
.It Fl e , -boot-args Ar boot arguments
@@ -123,9 +139,9 @@ and cannot be overriden. Additionally, the
.Em wdt=-1
argument is used during fakefs setup.
.It Fl E , -enter-recovery
Exit after entering recovery mode.q
Exit after entering recovery mode.
.It Fl f , -fakefs
Jailbreak in rootful mode.
Proceed in rootful mode. This applies to both full fakefs and partial fakefs.
.It Fl h , -help
Prints help text.
.It Fl i , -checkra1n-file Ar checkra1n file
@@ -139,10 +155,10 @@ Override the kernel patchfinder PongoOS module. The module is required to suppor
root filesystem in paleinfo with
.Em rootfs
command. If in doubt, use
.Sy https://github.com/guacaplushy/PongoOS
.Sy https://github.com/palera1n/PongoOS
iOS15 branch or your own fork of it.
.It Fl l , -rootless
Jailbreak in rootless mode, this is the default when neither
Proceed in rootless mode, this is the default when neither
.Fl l , -rootless
and
.Fl f , -fakefs
@@ -162,8 +178,6 @@ at the root of it, as well as a dmg named
.Em loader.dmg
at the root of it. Otherwise, the device will not boot. It is also expected that it
contains a shell, a ssh server, and various command line utilities.
.It Fl O , -disable-ohio
Disable ohio (disable analytics)
.It Fl p , -pongo-shell
Exit after booting into a clean PongoOS shell
.It Fl P , -pongo-full
@@ -184,14 +198,18 @@ specified (see
.Sy FILES
section below) will be executed. The loader app and the built in SSH server can still be used,
as well as any jailbreak-specific apps you have installed.
.It Fl S , -no-colors
Disable colors on the command line. External programs like checkra1n clones may still output colors.
.It Fl v , -debug-logging
Enable debug logging. The option may be repeated for extra verbosity.
.It Fl V , -verbose-boot
Boots the device in verbose mode, allowing boot logs to be seen.
.It Fl I , -device-info
Prints info about device and exits.
.El
.Sh ENVIRONMENTAL VARIABLES
.Bl -tag -width -indent
.It TMPDIR
.It Ev TMPDIR
This environmental variable should contain the a directory for temporary
files. Without the
.Fl i , -override-checkra1n
@@ -206,7 +224,7 @@ To (re-)jailbreak in rootless mode:
To setup fakefs for rootful mode:
.Pp
.Dl "palera1n -fc"
.Ppq
.Pp
After the device has rebooted, follow the following example.
.Pp
To re-jailbreak in rootful mode:
@@ -225,6 +243,10 @@ To verbose boot in rootful mode:
.Pp
.Dl "palera1n -Vf"
.Pp
To create a partial fakefs with bind mounts:
.Pp
.Dl "palera1n -Bf"
.Pp
To exit recovery mode:
.Pp
.Dl "palera1n -n"
@@ -232,7 +254,7 @@ To exit recovery mode:
.Sh CAVEATS
.Pp
.Em -v
is not a real XNU boot argument. It is intercepted by iBoot. However, since XNU
is not a real XNU boot argument. It is interpreted by iBoot. However, since XNU
boot arguments are set in PongoOS, which is ran after iBoot has ran, it does nothing.
To verbose boot, use the
.Fl V , -verbose-boot
@@ -247,11 +269,16 @@ version of the Procursus fork of
before they can be ran on a device jailbroken with
.Nm
\[char46]
.Sh POST INSTLLATION
.Pp
When using rootful mode, the
.Fl f , -fakefs
flag must be specified at all times. It does not matter whether you want to create fakefs,
create partial fakefs, rejailbreak or remove jailbreak.
.Sh POST INSTALLATION
The palera1n loader app will take up to 30 seconds to appear on the homescreen after the
device has booted. If it does not appear, you can try using the shortcut:
.Pp
.Sy https://www.icloud.com/shortcuts/8cd5f489c8854ee0ab9ee38f2e62f87d
.Lk https://www.icloud.com/shortcuts/8cd5f489c8854ee0ab9ee38f2e62f87d
.Pp
to open it. After opening the loader app, press install to install a bootstrap as well as
the
@@ -292,14 +319,26 @@ has been mounted.
.Nm
may crash if the machine it is running on:
.Pp
.Dl "- Has no USB ports"
.Pp
.Dl "- Has non-compliant USB devices plugged in"
.Pp
The exploit may also work less reliably on some hosts, like AMD desktops, or some MediaTek devices.
.Pp
The device may randomly crash and reboot due to launchd exiting with code 7.
.Sh NOTES
.Nm
injects a dylib into launchd to allow the
.Sy launchctl runstats
command to be used on the device.
.Sh DEPRECATED AND REMOVED FUNCTIONALITY
There was an option in
.Nm
to force create the fakefs even when one already exists (which would overwrite
the existing fakefs), by setting the palerain_option_setup_rootful_forced flag
in palera1n flags. This option was removed because using
.Fl -force-revert
and
.Fl c
at the same time has exactly the same effect.
.Sh SEE ALSO
.Xr launchd 8
.Xr launchd.plist 5
Regular → Executable
+3 -3
View File
@@ -1,12 +1,12 @@
curl -LOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.3.0.tar.gz \
https://github.com/libusb/libusb/releases/download/1.0.26/libusb-1.0.26.tar.bz2 \
https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-8.2.tar.gz \
https://www.jedsoft.org/releases/slang/slang-2.3.3.tar.bz2 \
https://releases.pagure.org/newt/newt-0.52.23.tar.gz \
https://github.com/rpm-software-management/popt/archive/master-release.tar.gz
tar xf master.tar.gz
tar xf v3.3.0.tar.gz
tar xf libusb-1.0.26.tar.bz2
tar xf readline-8.2.tar.gz
tar xf slang-2.3.3.tar.bz2
@@ -17,4 +17,4 @@ git clone --depth=1 https://github.com/libimobiledevice/libplist
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
+33
View File
@@ -0,0 +1,33 @@
#ifndef COMMON_H
#define COMMON_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
extern "C" {
#include <palerain.h>
#include <gui.h>
}
#define DISCONNECTED 0
#define NORMAL 1
#define RECOVERY 2
#define DFU 3
#define rest(a) std::this_thread::sleep_for(std::chrono::seconds(a))
#define FLOAT_TO_INT(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5))
void guifree(void);
void dfuhelper();
void send_alert(const char *title, const char *msg);
extern devinfo_t dev;
extern bool waiting_for_device;
extern bool unsupported_device;
extern bool supported_device;
extern bool recovery_wait;
extern bool jailbreak;
extern bool enter_dfu;
extern bool dfu_helper;
extern int device_status;
#endif
+55
View File
@@ -0,0 +1,55 @@
#ifndef DESIGN_H
#define DESIGN_H
#define set_pos(a,b) ImGui::SetCursorPos(ImVec2(a,b))
#define font(a) ImGui::PushFont(io.Fonts->Fonts[a])
#define btn_text_on colors[ImGuiCol_Text] = ImVec4{.05f, .05f, .05f, 1.0f}
#define btn_text_off colors[ImGuiCol_Text] = ImVec4{1.0f, 1.0f, 1.0f, 1.0f}
#define dfu_text_light colors[ImGuiCol_Text] = ImVec4{1.0f, 1.0f, 1.0f, 1.0f}
#define dfu_text_dark colors[ImGuiCol_Text] = ImVec4{1.0f, 1.0f, 1.0f, 0.3f}
#define size(x,y) ImVec2(x,y)
#define pos(x,y) ImVec2(x,y)
/* Fonts we have loaded into memory */
#define SF_Reg 0
#define SF_Med 2
#define SF_Bold 1
#define SF_Sm_Bold 3
#define Hack 4
#define SF_RoundBold 5
#define SF_RegMed 6
#define SF_BoldLarge 7
#define WHITE ImVec4{1.0f, 1.0f, 1.0f, 1.0f}
void ImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle);
void draw_box(ImVec2 location, ImVec2 size, ImVec4 color, float radius);
void reset_design(void);
void reset_views(void);
bool is_hovered(const char* id, int w, int h);
bool is_pressed(const char* id, int w, int h);
void anim_btn(const char* id, ImVec2 size, ImVec2 size_to, ImVec2 pos, ImVec2 pos_to);
void anim_box(const char* id, ImVec2 size, ImVec2 size_to, ImVec2 pos, ImVec2 pos_to);
void label(const char *text, ImVec2 location, ImVec4 color, int font);
void rotate_image(const char *image, ImVec2 pos, ImVec2 size, float angle, float speed);
std::string addstr2(const char *str1, const char *str2);
std::string addstr3(const char *str1, const char *str2, const char *str3);
std::string addstr4(const char *str1, const char *str2, const char *str3, const char *str4);
void image_btn_style_alt(void);
void init_style(void);
void init_colors(void);
ImVec4 hex_color(int hex, float alpha);
ImColor hex_imcolor(int hex, float alpha);
void image_btn_style();
extern float btn_w;
extern float btn_h;
extern float btn_x;
extern float btn_y;
extern float box_w;
extern float box_h;
extern float box_x;
extern float box_y;
#endif
+36
View File
@@ -0,0 +1,36 @@
#ifndef GUI_H
#define GUI_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#define WINDOW_X 0
#define WINDOW_Y 0
#define WINDOW_SIZE_X 550
#define WINDOW_SIZE_Y 300
#define WINDOW_TITLE "palera1n"
#define WINDOW_RESIZE false
#define WINDOW_RESTORE true
#define WINDOW_ALLOW_FULLSCREEN false
#define WINDOW_BORDERLESS false
#define WINDOW_DECORATIONS true
#define IDLE false
#define TARGET_FPS 60
#define CONFIG_FILE "palera1n.ini"
#define EMBED_ASSETS true
#define ASSETS_DIRECTORY "assets"
#define NORMAL_MODE 1
#define RECOVERY_MODE 2
#define DFU_MODE 3
#define NONE 4
#define PONGO_MODE 5
int palera1n(int argc, char *argv[]);
#endif
+13 -13
View File
@@ -58,6 +58,14 @@
#define palerain_option_jbinit_log_to_file (1 << 1) /* log to /cores/jbinit.log */
#define palerain_option_setup_rootful (1 << 2) /* create fakefs */
#define palerain_option_setup_rootful_forced (1 << 3) /* create fakefs over an existing one */
#define palerain_option_setup_partial_root (1 << 4) /* fakefs creating should be partial */
#define palerain_option_checkrain_is_clone (1 << 5) /* supplied checkra1n is checkra1n clone */
#define palerain_option_rootless_livefs (1 << 6) /* mount root livefs on rootless */
/* reserved values */
// #define palerain_option_no_ssv (1 << 7) /* no signed system volume */
// #define palerain_option_force_fakefs (1 << 8) /* force fakefs, even without SSV */
// #define palerain_option_rootless (1 << 9) /* rootless jailbreak */
#define palerain_option_clean_fakefs (1 << 10) /* clean fakefs, but does not delete it */
#ifdef DEV_BUILD
#define palerain_option_test1 (1 << 29)
@@ -67,18 +75,20 @@
// palerain host options
#define host_option_dfuhelper_only (1 << 0) /* dfuhelper only */
#define host_option_pongo_exit (1 << 1) /* boot to clean pongo shell */
#ifdef DEV_BUILD
#ifdef TUI
#define host_option_tui (1 << 2) /* use terminal user interface */
#else
#define host_option_res1 (1 << 2) /* reserved */
#endif
#define host_option_demote (1 << 3) /* Demote effective production fuse status */
#define host_option_no_ohio (1 << 4) /* Disable Ohio (Analytics) */
// (1 << 4) is removed
#define host_option_pongo_full (1 << 5) /* Boot to pongo with default images and options */
#define host_option_palerain_version (1 << 6) /* Print version */
#define host_option_exit_recovery (1 << 7) /* Exit recovery mode */
#define host_option_reboot_device (1 << 8) /* Reboot device in normal mode */
#define host_option_enter_recovery (1 << 9) /* Enter recovery mode */
#define host_option_device_info (1 << 10) /* Print device info */
#define host_option_no_colors (1 << 11) /* no colors */
#define PALEINFO_MAGIC 'PLSH'
#define PALEINFO_CIGAM 'HSLP'
@@ -117,18 +127,8 @@ struct kpfinfo {
options = (checkrain_option_t)(options & ~option); \
} while (0);
static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_option_t opt)
static inline bool checkrain_options_enabled(checkrain_option_t flags, checkrain_option_t opt)
{
if(flags == checkrain_option_failure)
{
switch(opt)
{
case checkrain_option_safemode:
return true;
default:
return false;
}
}
return (flags & opt) != 0;
}
+23 -16
View File
@@ -2,7 +2,7 @@
#define PALERAIN_H
#if defined(__APPLE__)
#define _DARWIN_C_SOURCE 1
#define NSIG __DARWIN_NSIG
#endif
#include "xxd-embedded.h"
@@ -31,6 +31,7 @@
#define USB_RET_SUCCESS LIBUSB_SUCCESS
#define USB_RET_NOT_RESPONDING LIBUSB_ERROR_OTHER
#define USB_RET_IO LIBUSB_ERROR_IO
#define USB_RET_NO_DEVICE LIBUSB_ERROR_NO_DEVICE
typedef int usb_ret_t;
typedef libusb_device_handle *usb_device_handle_t;
@@ -51,7 +52,8 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
#define USB_RET_SUCCESS KERN_SUCCESS
#define USB_RET_NOT_RESPONDING kIOReturnNotResponding
#define USB_RET_IO kIOReturnNotResponding
#define USB_RET_IO kIOReturnNotReady
#define USB_RET_NO_DEVICE kIOReturnNoDevice
typedef IOReturn usb_ret_t;
typedef IOUSBInterfaceInterface245 **usb_device_handle_t;
@@ -98,6 +100,8 @@ struct mach_header_64
};
#endif
typedef void *(*pthread_start_t)(void *);
// Keep in sync with Pongo
#define PONGO_USB_VENDOR 0x05ac
#define PONGO_USB_PRODUCT 0x4141
@@ -147,7 +151,7 @@ typedef unsigned char niarelap_file_t[];
extern unsigned int verbose;
extern char* pongo_path;
#ifdef DEV_BUILD
#ifdef TUI
extern bool tui_started;
#endif
@@ -178,13 +182,13 @@ extern char* ext_checkra1n;
void thr_cleanup(void* ptr);
void* dfuhelper(void* ptr);
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char* __restrict format, ...);
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char* __restrict format, ...);
/* devhelper helpers */
void devinfo_free(devinfo_t *dev);
bool cpid_is_arm64(unsigned int cpid);
/* devhelper commands */
int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb);
int unsubscribe_cmd();
int unsubscribe_cmd(void);
int devinfo_cmd(devinfo_t *dev, const char *udid);
int enter_recovery_cmd(const char* udid);
int reboot_cmd(const char* udid);
@@ -193,35 +197,38 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
int autoboot_cmd(const uint64_t ecid);
int exitrecv_cmd(const uint64_t ecid);
int exec_checkra1n();
int exec_checkra1n(void);
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
void* pongo_helper(void* ptr);
const unsigned char *
boyermoore_horspool_memmem(const unsigned char* haystack, size_t hlen,
const unsigned char* needle, size_t nlen);
extern void* pongo_usb_callback(void* arg);
extern void* pongo_usb_callback(stuff_t* arg);
usb_ret_t USBControlTransfer(usb_device_handle_t handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t wLength, void *data, uint32_t *wLenDone);
const char *usb_strerror(usb_ret_t err);
int wait_for_pongo();
int issue_pongo_command();
int upload_pongo_file();
int tui();
int wait_for_pongo(void);
int upload_pongo_file(usb_device_handle_t, unsigned char*, unsigned int);
int issue_pongo_command(usb_device_handle_t, char*);
int tui(void);
int optparse(int argc, char* argv[]);
bool get_spin();
bool get_spin(void);
bool set_spin(bool val);
bool get_found_pongo();
bool get_found_pongo(void);
void* pongo_helper(void* _);
bool set_found_pongo(bool val);
uint64_t get_ecid_wait_for_dfu();
uint64_t get_ecid_wait_for_dfu(void);
uint64_t set_ecid_wait_for_dfu(uint64_t ecid);
void write_stdout(char *buf, uint32_t len);
void io_start(stuff_t *stuff);
void io_stop(stuff_t *stuff);
void print_credits();
void print_credits(void);
#ifdef DEV_BUILD
#ifdef TUI
#include <newt.h>
newtComponent get_tui_log();
newtComponent set_tui_log(newtComponent co);
+2 -1
View File
@@ -11,6 +11,7 @@
#include <locale.h>
#include <unistd.h>
#include <newt.h>
#include <kerninfo.h>
#define WIDTH 76
#define HEIGHT 19
@@ -19,7 +20,7 @@
#define PI_STEP_CURRENT NEWT_COLORSET_CUSTOM(1)
#define PI_STEP_OTHER NEWT_COLORSET_CUSTOM(2)
#define CHECKBOX_STATE(flags, opt) checkrain_option_enabled(flags, opt) ? '*' : ' '
#define CHECKBOX_STATE(flags, opt) checkrain_options_enabled(flags, opt) ? '*' : ' '
typedef enum tui_screens {
ERROR_SCREEN = -1,
+12
View File
@@ -1,6 +1,10 @@
#ifndef XXD_EMBEDDED_H
#define XXD_EMBEDDED_H
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
extern unsigned char checkra1n[];
extern unsigned int checkra1n_len;
@@ -13,4 +17,12 @@ extern unsigned int ramdisk_dmg_len;
extern unsigned char binpack_dmg[];
extern unsigned int binpack_dmg_len;
extern unsigned char Pongo_bin[];
extern unsigned int Pongo_bin_len;
#if defined(__APPLE__) && (TARGET_OS_IPHONE || defined(DEV_BUILD))
extern unsigned char libcheckra1nhelper_dylib[];
extern unsigned int libcheckra1nhelper_dylib_len;
#endif
#endif
+17
View File
@@ -0,0 +1,17 @@
Package: palera1n
Name: palera1n
Version: @DEB_VERSION@
Architecture: @DEB_ARCH@
Maintainer: palera1n team
Author: palera1n team
Depends: usbmuxd
Section: Utilities
Priority: optional
Homepage: https://palera.in
Description: iOS 15.0-16.5 semi-tethered checkm8 jailbreak
palera1n is an iOS/iPadOS 15.0-16.5 semi tethered jailbreak
based on the checkm8 exploit.
.
palera1n is able to jailbreak the device in fakefs-rootful mode,
where / is writable, as well as rootless mode, where / cannot be
written to.
+16
View File
@@ -0,0 +1,16 @@
Package: palera1n
Name: palera1n
Version: @DEB_VERSION@
Architecture: @DEB_ARCH@
Maintainer: palera1n team
Author: palera1n team
Section: Utilities
Priority: optional
Homepage: https://palera.in
Description: iOS 15.0-16.5 semi-tethered checkm8 jailbreak
palera1n is an iOS/iPadOS 15.0-16.5 semi tethered jailbreak
based on the checkm8 exploit.
.
palera1n is able to jailbreak the device in fakefs-rootful mode,
where / is writable, as well as rootless mode, where / cannot be
written to.
+27
View File
@@ -0,0 +1,27 @@
class Palera1n < Formula
desc "iOS 15.0-16.3.1 semi-tethered checkm8 jailbreak"
homepage "https://palera.in/"
url ""
version "2.0.0"
sha256 ""
license "MIT"
depends_on "cmake" => :build
depends_on "libimobiledevice" => :build
depends_on "libirecovery" => :build
depends_on "libusb" => :build
depends_on "libusbmuxd" => :build
depends_on "mbedtls" => :build
depends_on "pkg-config" => :build
depends_on "readline" => :build
def install
system "cmake", "."
system "make"
bin.install "output/palera1n" => "palera1n"
end
test do
system "false"
end
end
+6
View File
@@ -0,0 +1,6 @@
[Desktop Entry]
Name=palera1n
Exec=~/usr/local/bin
Icon=~/.palera1n/icon.ico
Terminal=false
Type=Application
@@ -1,6 +1,6 @@
From 632cdb6de3f1693fb90d60d81552b723e8dd5e84 Mon Sep 17 00:00:00 2001
From a2d012f3ba459f6debe636b576ad9aeab7b3c2aa Mon Sep 17 00:00:00 2001
From: Nick Chan <[email protected]>
Date: Wed, 25 Jan 2023 01:53:00 +0800
Date: Sat, 27 May 2023 23:50:23 +0800
Subject: [PATCH] Allow empty x509 cert issuer
---
@@ -8,25 +8,24 @@ Subject: [PATCH] Allow empty x509 cert issuer
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 0eee97cb6..46702f683 100644
index cf62532f2..ef25b3d77 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -1185,14 +1185,14 @@ static int x509_crt_parse_der_core( mbedtls_x509_crt *crt,
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
{
- mbedtls_x509_crt_free( crt );
- return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_X509_INVALID_FORMAT, ret ) );
+ // mbedtls_x509_crt_free( crt );
+ // return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_X509_INVALID_FORMAT, ret ) );
@@ -1061,13 +1061,13 @@ static int x509_crt_parse_der_core(mbedtls_x509_crt *crt,
if ((ret = mbedtls_asn1_get_tag(&p, end, &len,
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
- mbedtls_x509_crt_free(crt);
- return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);
+ /*mbedtls_x509_crt_free(crt);
+ return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);*/
}
if( ( ret = mbedtls_x509_get_name( &p, p + len, &crt->issuer ) ) != 0 )
{
- mbedtls_x509_crt_free( crt );
- return( ret );
+ // mbedtls_x509_crt_free( crt );
+ // return( ret );
if ((ret = mbedtls_x509_get_name(&p, p + len, &crt->issuer)) != 0) {
- mbedtls_x509_crt_free(crt);
- return ret;
+ /*mbedtls_x509_crt_free(crt);
+ return ret;*/
}
crt->issuer_raw.len = p - crt->issuer_raw.p;
-344
View File
@@ -1,344 +0,0 @@
#execute_process(COMMAND sh -c "cd ../dep_root && sh ../download_deps.sh")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
#set(SRC ${CMAKE_CURRENT_SOURCE_DIR})
#set(DEP ${SRC}/../dep_root)
cmake_parse_arguments(palera1n "" "" "-arch" ${ARGN})
set(CHECKRA1N_VERSION 0.1337.1)
if( ${LDID})
set(LDID ldid)
endif()
if( ${LIPO})
set(LIPO lipo)
endif()
if(APPLE)
set(CHECKRA1N_FILE_NAME checkra1n-macos)
else()
set(CHECKRA1N_FILE_NAME checkra1n-linux-${CMAKE_SYSTEM_PROCESSOR})
endif()
add_executable(palera1n
binpack.dmg.c
checkra1n-kpf-pongo.c
checkra1n.c
devhelper.c
dfuhelper.c
exec_checkra1n.c
lock_vars.c
lockdown_helper.c
log.c
main.c
optparse.c
override_file.c
pongo_helper.c
credits.c
ramdisk.dmg.c
../include/kerninfo.h
../include/palerain.h
../include/ANSI-color-codes.h
../include/tui.h
../include/xxd-embedded.h
)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -pedantic-errors -g)
# adds dev mode files
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES tui_main.c
tui_screen_enter_dfu.c
tui_screen_enter_recovery.c
tui_screen_jailbreak.c
tui_screen_main.c
tui_screen_options.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
elseif(CMAKE_BUILD_TYPE STREQUAL "ASAN")
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES tui_main.c
tui_screen_enter_dfu.c
tui_screen_enter_recovery.c
tui_screen_jailbreak.c
tui_screen_main.c
tui_screen_options.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
add_compile_options(-fsanitize=address,undefined -fsanitize-address-use-after-return=runtime)
elseif(CMAKE_BUILD_TYPE STREQUAL "TSAN")
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES tui_main.c
tui_screen_enter_dfu.c
tui_screen_enter_recovery.c
tui_screen_jailbreak.c
tui_screen_main.c
tui_screen_options.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
add_compile_options(-fsanitize=thread,undefined)
else()
set(CMAKE_BUILD_TYPE "Release")
endif()
#message("Testing for Clang/LLVM")
#string(TOLOWER CMAKE_C_COMPILER_ID COMPILER)
#if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# message("Using clang/llvm! Enabling -flto=full! Please make sure clang is up to date, or else compile will fail")
# add_compile_options(-flto=full)
#else()
# message("Not using clang/llvm! Using normal lto/no lto!")
# add_compile_options(-flto)
#endif()
#add_custom_command(TARGET palera1n
# COMMAND sh -c "curl -LO https://assets.checkra.in/downloads/preview/${CHECKRA1N_VERSION}/${CHECKRA1N_FILE_NAME} && chmod 755 ${CHECKRA1N_FILE_NAME}"
# )
#
#if(APPLE)
# add_custom_command(TARGET palera1n
# COMMAND sh -c "ldid -Scheckra1n.plist checkra1n"
# )
# add_custom_command(TARGET palera1n
# COMMAND lipo -thin ${CMAKE_SYSTEM_PROCESSOR} -output checkra1n checkra1n-macos
# )
# if(CFLAGS MATCHES "version-min=")
# add_custom_command(TARGET palera1n
# COMMAND sh -c "vtool -remove-build-version 1 -replace -output checkra1n checkra1n && vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n && install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n && install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n && ${LDID} -Susb.xml checkra1n"
# )
# endif()
#else()
# execute_process(
# COMMAND cp ${CHECKRA1N_FILE_NAME} ../src/checkra1n
# )
#endif()
#ifneq (,$(findstring arm64, $(CFLAGS)))
#$(LIPO) -thin arm64 -output checkra1n checkra1n-macos
#else ifneq (,$(findstring x86_64, $(CFLAGS)))
#$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
#else ifeq ($(shell arch),i386)
#$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
#else
#$(LIPO) -thin $(shell arch) -output checkra1n checkra1n-
if(APPLE)
if(${LIBUSB})
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES
usb_libusb.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
target_link_libraries(palera1n
${DEP}/lib/libusb-1.0.a
)
else()
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES
usb_iokit.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
endif()
if(IOS AND CMAKE_C_FLAGS MATCHES "arm64")
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND lipo -thin arm64 -output checkra1n checkra1n-macos
COMMAND sh -c "vtool -remove-build-version 1 -replace -output checkra1n checkra1n && vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n && install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n && install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n && ${LDID} -Susb.xml checkra1n"
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
elseif(CMAKE_C_FLAGS MATCHES "arm64")
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND lipo -thin arm64 -output checkra1n checkra1n-macos
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
else()
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND lipo -thin x86_64 -output checkra1n checkra1n-macos
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
endif()
else()
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES
usb_libusb.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
target_link_libraries(palera1n
${DEP}/lib/libusb-1.0.a
)
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
endif()
include_directories(
../include
${SRC}
)
target_compile_definitions(palera1n PRIVATE -DPALERAIN_VERSION=\"2.0.0\")
target_include_directories(palera1n PRIVATE
${SRC}/include
${SRC}
${DEP}/include
)
#if(${STATIC})
target_link_libraries(palera1n
${DEP}/lib/libimobiledevice-1.0.a
${DEP}/lib/libirecovery-1.0.a
${DEP}/lib/libusbmuxd-2.0.a
${DEP}/lib/libimobiledevice-glue-1.0.a
${DEP}/lib/libplist-2.0.a
${DEP}/lib/libmbedtls.a
${DEP}/lib/libmbedcrypto.a
${DEP}/lib/libmbedx509.a
${DEP}/lib/libreadline.a
)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
if(NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()
#else()
# find_library(LIBIMOBILEDEVICE libimobiledevice)
# if (NOT CORE_FOUNDATION)
# message(FATAL_ERROR "libimobiledevice not found")
# endif()
# target_link_libraries(palera1n ${LIBIMOBILEDEVICE})
#
# find_library(LIR libirecovery)
# if (NOT SYSCONF)
# message(FATAL_ERROR "libirecovery not found")
# endif()
# target_link_libraries(palera1n ${LIR})
#
# find_library(USBMUXD usbmuxd)
# if (NOT SEC)
# message(FATAL_ERROR "usbmuxd not found")
# endif()
# target_link_libraries(palera1n ${USBMUXD})
#
# find_library(GLUE libimobiledevice-glue)
# if (NOT IOKIT)
# message(FATAL_ERROR "libimobiledevice-glue not found")
# endif()
# target_link_libraries(palera1n ${GLUE})
#
## target_link_libraries(palera1n
## imobiledevice-1.0
## irecovery-1.0
## usbmuxd-2.0
## imobiledevice-glue-1.0
## plist-2.0
## mbedtls
## mbedcrypto
## mbedx509
## readline
## usb-1.0
## )
#endif()
#if(APPLE)
# add_compile_options(palera1n
# -framework CoreFoundation
# -framework SystemConfiguration
# -framework IOKit
# -framework Security
# )
#endif()
if(APPLE)
find_library(CORE_FOUNDATION CoreFoundation)
if (NOT CORE_FOUNDATION)
message(FATAL_ERROR "CoreFoundation not found")
endif()
target_link_libraries(palera1n ${CORE_FOUNDATION})
find_library(SYSCONF SystemConfiguration)
if (NOT SYSCONF)
message(FATAL_ERROR "SystemConfiguration not found")
endif()
target_link_libraries(palera1n ${SYSCONF})
find_library(SEC Security)
if (NOT SEC)
message(FATAL_ERROR "Security not found")
endif()
target_link_libraries(palera1n ${SEC})
find_library(IOKIT IOKit)
if (NOT IOKIT)
message(FATAL_ERROR "IOKit not found")
endif()
target_link_libraries(palera1n ${IOKIT})
endif()
add_compile_options(palera1n
-static -no-pie -Wl,--gc-sections
)
if(!BUILD_DATE)
execute_process(COMMAND date OUTPUT_VARIABLE BUILD_DATE)
endif()
if(!BUILD_TAG)
execute_process(COMMAND git describe --dirty --tags --abbrev=7 OUTPUT_VARIABLE BUILD_TAG)
endif()
if(!BUILD_WHOAMI)
execute_process(COMMAND whoami OUTPUT_VARIABLE BUILD_WHOAMI)
endif ()
set(INCLUDE_DIR /usr/local/include)
include_directories (${INCLUDE_DIR})
add_compile_definitions(
BUILD_DATE="${BUILD_DATE}"
BUILD_TAG="${BUILD_TAG}"
BUILD_WHOAMI="${BUILD_WHOAMI}"
BUILD_STYLE="${CMAKE_BUILD_TYPE}"
)
+66 -5
View File
@@ -3,32 +3,63 @@ all: palera1n
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o
OBJECTS += optparse.o override_file.o log.o lock_vars.o credits.o
OBJECTS += fake_embedded.o exec_checkra1n.o pongo_helper.o
OBJECTS += boyermoore_memmem.o
ifeq (,$(findstring macosx, $(CFLAGS)))
ifneq (,$(findstring version-min=, $(CFLAGS)))
OBJECTS += xxd-libcheckra1nhelper.dylib.o
endif
endif
ifeq ($(FORCE_HELPER),1)
OBJECTS += xxd-libcheckra1nhelper.dylib.o
CFLAGS += -DFORCE_HELPER
BUILD_OPTIONS += FORCE_HELPER
endif
ifneq ($(NO_RAMDISK),1)
OBJECTS += xxd-ramdisk.dmg.o
else
CFLAGS += -DNO_RAMDISK
BUILD_OPTIONS += NO_RAMDISK
endif
ifneq ($(NO_KPF),1)
OBJECTS += xxd-checkra1n-kpf-pongo.o
else
CFLAGS += -DNO_KPF
BUILD_OPTIONS += NO_KPF
endif
ifneq ($(NO_BINPACK),1)
ifneq ($(NO_OVERLAY),1)
OBJECTS += xxd-binpack.dmg.o
else
CFLAGS += -DNO_BINPACK
CFLAGS += -DNO_OVERLAY
BUILD_OPTIONS += NO_OVERLAY
endif
ifneq ($(NO_CHECKRAIN),1)
OBJECTS += xxd-checkra1n.o
else
CFLAGS += -DNO_CHECKRAIN
BUILD_OPTIONS += NO_CHECKRAIN
endif
ifeq ($(DEV_BUILD),1)
ifneq ($(NO_CUSTOM_PONGO),1)
OBJECTS += xxd-Pongo.bin.o
else
CFLAGS += -DNO_CUSTOM_PONGO
BUILD_OPTIONS += NO_CUSTOM_PONGO
endif
ifeq ($(TUI),1)
OBJECTS += tui_screen_enter_recovery.o tui_screen_enter_dfu.o tui_main.o
OBJECTS += tui_screen_jailbreak.o tui_screen_main.o tui_screen_options.o
BUILD_OPTIONS += TUI
CFLAGS += -DTUI
endif
ifeq ($(GUI),1)
CXXOBJECTS = gui_alerts.o gui_design.o gui_device.o gui_main.o
BUILD_OPTIONS += GUI
CFLAGS += -DGUI
endif
CHECKRA1N_VERSION ?= 0.1337.1
@@ -38,7 +69,13 @@ LDID = ldid
ifeq ($(TARGET_OS),Darwin)
ifneq ($(USE_LIBUSB),1)
OBJECTS += usb_iokit.o
else
LIBS += -framework SystemConfiguration -framework Security
BUILD_OPTIONS += USE_LIBUSB
endif
# add lto and debug symbols for lto
CFLAGS += -flto=full -g
LDFLAGS += -Wl,-object_path_lto,lto.o
else
USE_LIBUSB = 1
endif
@@ -49,6 +86,17 @@ CFLAGS += -DUSE_LIBUSB=1
LIBS += $(DEP)/lib/libusb-1.0.a
endif
ifneq ($(ROOTFUL),0)
CFLAGS += -DROOTFUL=1
BUILD_OPTIONS += ROOTFUL
endif
ifeq ($(BUILD_OPTIONS),)
BUILD_OPTIONS = (none)
endif
CFLAGS += -DBUILD_OPTIONS=\""$(BUILD_OPTIONS)"\"
checkra1n-%:
curl -LO https://assets.checkra.in/downloads/preview/$(CHECKRA1N_VERSION)/$@
chmod 755 $@
@@ -83,16 +131,26 @@ xxd-%.c: %
%.o: %.c $(wildcard ../include/*.h)
$(CC) -c $(CFLAGS) $<
%.o: %.cpp $(wildcard ../include/*.h)
$(CXX) -c $(CXXFLAGS) $<
palera1n: $(OBJECTS)
ifeq ($(GUI),1)
$(CXX) $(LDFLAGS) $(OBJECTS) $(CXXOBJECTS) $(LIBS) -o palera1n
else
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o palera1n
endif
ifeq (,$(findstring macosx, $(CFLAGS)))
ifneq (,$(findstring version-min=, $(CFLAGS)))
$(LDID) -Susb.xml palera1n
endif
endif
libcheckra1nhelper.dylib: chkstk.S
$(CC) $(CFLAGS) $(LDFLAGS) -shared chkstk.S -o libcheckra1nhelper.dylib
checkra1n-kpf-pongo:
curl -LO https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo
curl -LO https://cdn.nickchan.lol/palera1n/artifacts/kpf/checkra1n-kpf-pongo
ramdisk.dmg:
curl -LO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg
@@ -100,7 +158,10 @@ ramdisk.dmg:
binpack.dmg:
curl -LO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg
Pongo.bin:
curl -LO https://cdn.nickchan.lol/palera1n/artifacts/kpf/Pongo.bin
clean:
rm -rf *.o palera1n checkra1n checkra1n.c palera1n.dSYM
rm -rf *.o palera1n checkra1n checkra1n.c palera1n.dSYM libcheckra1nhelper.dylib
.PHONY: all clean
+59
View File
@@ -0,0 +1,59 @@
#include <limits.h>
#include <stdlib.h>
const unsigned char *
boyermoore_horspool_memmem(const unsigned char* haystack, size_t hlen,
const unsigned char* needle, size_t nlen)
{
size_t scan = 0;
size_t bad_char_skip[UCHAR_MAX + 1]; /* Officially called:
* bad character shift */
/* Sanity checks on the parameters */
if (nlen <= 0 || !haystack || !needle)
return NULL;
/* ---- Preprocess ---- */
/* Initialize the table to default value */
/* When a character is encountered that does not occur
* in the needle, we can safely skip ahead for the whole
* length of the needle.
*/
for (scan = 0; scan <= UCHAR_MAX; scan = scan + 1)
bad_char_skip[scan] = nlen;
/* C arrays have the first byte at [0], therefore:
* [nlen - 1] is the last byte of the array. */
size_t last = nlen - 1;
/* Then populate it with the analysis of the needle */
for (scan = 0; scan < last; scan = scan + 1)
bad_char_skip[needle[scan]] = last - scan;
/* ---- Do the matching ---- */
/* Search the haystack, while the needle can still be within it. */
while (hlen >= nlen)
{
/* scan from the end of the needle */
for (scan = last; haystack[scan] == needle[scan]; scan = scan - 1)
if (scan == 0) /* If the first byte matches, we've found it. */
{
return haystack;
}
/* otherwise, we need to skip some bytes and start again.
Note that here we are getting the skip value based on the last byte
of needle, no matter where we didn't match. So if needle is: "abcd"
then we are skipping based on 'd' and that value will be 4, and
for "abcdd" we again skip on 'd' but the value will be only 1.
The alternative of pretending that the mismatched character was
the last character is slower in the normal case (E.g. finding
"abcd" in "...azcd..." gives 4 by using 'd' but only
4-2==2 using 'z'. */
hlen -= bad_char_skip[haystack[last]];
haystack += bad_char_skip[haystack[last]];
}
return NULL;
}
+65
View File
@@ -0,0 +1,65 @@
#define _PTHREAD_STRUCT_DIRECT_STACKADDR_OFFSET -48
#define _PTHREAD_STRUCT_DIRECT_STACKBOTTOM_OFFSET -40
.align 4
_thread_chkstk_darwin:
.globl ___chkstk_darwin
___chkstk_darwin: // %w9/x9 == alloca size
stp x10, x11, [sp, #-16]
// validate that the frame pointer is on our stack (no alt stack)
mrs x10, TPIDRRO_EL0
// (%sp - pthread_self()->stackaddr) > 0 ?
#if defined(__ARM64_ARCH_8_32__)
ubfx x9, x9, #0, #32
ldur w11, [x10, _PTHREAD_STRUCT_DIRECT_STACKADDR_OFFSET]
#else
ldur x11, [x10, _PTHREAD_STRUCT_DIRECT_STACKADDR_OFFSET]
#endif
subs x11, sp, x11
b.hs Lprobe
// %sp <= pthread_self()->stackbottom ?
#if defined(__ARM64_ARCH_8_32__)
ldur w11, [x10, _PTHREAD_STRUCT_DIRECT_STACKBOTTOM_OFFSET]
#else
ldur x11, [x10, _PTHREAD_STRUCT_DIRECT_STACKBOTTOM_OFFSET]
#endif
mov x10, sp
cmp x10, x11
b.ls Lprobe
// %sp - (uintptr_t)%x9 < pthread_self()->stackbottom ?
subs x10, x10, x9
b.lo Lcrash
cmp x10, x11
b.lo Lcrash
Lexit:
ldp x10, x11, [sp, #-16]
ret
Lcrash:
// POSIX mandates that stack overflow crashes with SIGSEGV
// so load an address in the guard page and dereference it
//
// x11 contains pthread_self()->stackbottom already
ldr x11, [x11, #-8]
// if main_thread caused stack growth with setrlimit()
// fall into Lprobe and eventually cause SIGSEGV.
Lprobe:
mov x10, sp
cmp x9, #0x1000
b.lo Lend
Lloop:
sub x10, x10, #0x1000
ldr x11, [x10]
sub x9, x9, #0x1000
cmp x9, #0x1000
b.hi Lloop
Lend:
sub x10, x10, x9
ldr x11, [x10]
b Lexit
+20 -16
View File
@@ -1,19 +1,23 @@
#include <stdio.h>
#define EE fprintf
#define Q }
#define P print_credits() {
#define BAKERAIN_DEVELOPER "dora2ios"
#define O void
#define Y )
#define Z (
#define R stdout
#define S ,
#define T ;
#define A "# == palera1n-c == \n#\n"
#define B "# Made by: Nick Chan, Tom, Mineek, Nebula, llsc12\n#\n"
#define C "# Thanks to: " BAKERAIN_DEVELOPER ", pythonplayer, tihmstar, nikias\n"
#define D "# (libimobiledevice), checkra1n team (Siguza, axi0mx, littlelailo\n"
#define E "# et al.), Procursus Team (Hayden Seay, Cameron Katri, Keto et.al)\n\n"
#ifndef BAKERAIN_DEVELOPE_R
#define BAKERAIN_DEVELOPE_R "kok3shidoll"
#endif
#define THE_PLUSH "Ploosh"
O P EE Z R S A B C D E Y T Q
#define T void
#define R print_credits(void) {
#define O fprintf
#define U (
#define B stderr
#define L ,
#define E "# == palera1n-c == \n#\n"
#define M "# Made by: Nick Chan, " THE_PLUSH ", Samara, Nebula, staturnz, " BAKERAIN_DEVELOPE_R " \n#\n"
#define A "# Thanks to: pythonplayer123, llsc12, Mineek, tihmstar, nikias\n"
#define K "# (libimobiledevice), checkra1n team (Siguza, axi0mx, littlelailo\n"
#define I "# et al.), Procursus Team (Hayden Seay, Cameron Katri, Keto et.al)\n\n"
#define N )
#define G ;
#define S }
T R O U B L E M A K I N G S
+81 -76
View File
@@ -37,6 +37,7 @@
#include <palerain.h>
irecv_device_event_context_t irecvctx = NULL;
usbmuxd_subscription_context_t usbmuxdctx = NULL;
void devinfo_free(devinfo_t *dev) {
free(dev->buildVersion);
@@ -75,28 +76,29 @@ bool cpid_is_arm64(unsigned int cpid) {
* ========== 0x8960 ===========
* (ARM64) A7
*/
if (
cpid == 0x8960 || cpid == 0x7000 || cpid == 0x7001
|| cpid == 0x8000 || cpid == 0x8001 || cpid == 0x8003
|| cpid == 0x8010 || cpid == 0x8011 || cpid == 0x8012
|| cpid == 0x8015
) return true;
return false;
return (
cpid == 0x8960 || cpid == 0x7000 || cpid == 0x7001 ||
cpid == 0x8000 || cpid == 0x8001 || cpid == 0x8003 ||
cpid == 0x8010 || cpid == 0x8011 || cpid == 0x8012 ||
cpid == 0x8015
);
}
int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb)
{
usbmuxd_subscribe(device_event_cb, NULL);
irecv_device_event_subscribe(&irecvctx, irecv_event_cb, NULL);
int ret;
if ((ret = usbmuxd_events_subscribe(&usbmuxdctx, device_event_cb, NULL))) return ret;
if ((ret = irecv_device_event_subscribe(&irecvctx, irecv_event_cb, NULL))) return ret;
return 0;
}
int unsubscribe_cmd()
int unsubscribe_cmd(void)
{
usbmuxd_unsubscribe();
irecv_device_event_unsubscribe(irecvctx);
int ret;
if ((ret = usbmuxd_events_unsubscribe(usbmuxdctx))) return ret;
if ((ret = irecv_device_event_unsubscribe(irecvctx))) return ret;
irecvctx = NULL;
usbmuxdctx = NULL;
return 0;
}
@@ -117,15 +119,15 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
}
if (lockdownd_client_new(device, &lockdown, "palera1n") != LOCKDOWN_E_SUCCESS)
{
idevice_free(device);
(void)idevice_free(device);
LOG(LOG_ERROR, "Device is not in normal mode.");
return -1;
}
plist_t node = NULL;
if (lockdownd_get_value(lockdown, NULL, "UniqueChipID", &node) != LOCKDOWN_E_SUCCESS)
{
lockdownd_client_free(lockdown);
idevice_free(device);
(void)lockdownd_client_free(lockdown);
(void)idevice_free(device);
LOG(LOG_ERROR, "Error getting ECID");
return -1;
}
@@ -135,8 +137,8 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL;
if (lockdownd_get_value(lockdown, NULL, "ProductType", &node) != LOCKDOWN_E_SUCCESS)
{
lockdownd_client_free(lockdown);
idevice_free(device);
(void)lockdownd_client_free(lockdown);
(void)idevice_free(device);
LOG(LOG_ERROR, "Error getting product type");
return -1;
}
@@ -146,8 +148,8 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL;
if (lockdownd_get_value(lockdown, NULL, "CPUArchitecture", &node) != LOCKDOWN_E_SUCCESS)
{
lockdownd_client_free(lockdown);
idevice_free(device);
(void)lockdownd_client_free(lockdown);
(void)idevice_free(device);
LOG(LOG_ERROR, "Error getting CPU type");
return -1;
}
@@ -157,8 +159,8 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL;
if (lockdownd_get_value(lockdown, NULL, "ProductVersion", &node) != LOCKDOWN_E_SUCCESS)
{
lockdownd_client_free(lockdown);
idevice_free(device);
(void)lockdownd_client_free(lockdown);
(void)idevice_free(device);
LOG(LOG_ERROR, "Error getting product version");
return -1;
}
@@ -168,21 +170,21 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL;
if (lockdownd_get_value(lockdown, NULL, "BuildVersion", &node) != LOCKDOWN_E_SUCCESS)
{
lockdownd_client_free(lockdown);
idevice_free(device);
(void)lockdownd_client_free(lockdown);
(void)idevice_free(device);
LOG(LOG_ERROR, "Error getting build version");
return -1;
}
plist_get_string_val(node, &buildVersion);
plist_free(node);
lockdownd_client_free(lockdown);
idevice_free(device);
(void)lockdownd_client_free(lockdown);
(void)idevice_free(device);
irecv_device_t rcvydev;
if (irecv_devices_get_device_by_product_type(productType, &rcvydev) == IRECV_E_SUCCESS)
{
displayName = rcvydev->display_name;
}
else
} else
{
displayName = productType;
}
@@ -207,23 +209,22 @@ int enter_recovery_cmd(const char* udid) {
LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret));
return -1;
}
do {
ldret = lockdownd_enter_recovery(lockdown);
if (ldret == LOCKDOWN_E_SESSION_INACTIVE) {
lockdownd_client_free(lockdown);
lockdown = NULL;
if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, "palera1n"))) {
LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret));
return -1;
}
ldret = lockdownd_enter_recovery(lockdown);
}
ldret = lockdownd_enter_recovery(lockdown);
if (ldret == LOCKDOWN_E_SESSION_INACTIVE) {
lockdownd_client_free(lockdown);
lockdown = NULL;
ldret = lockdownd_client_new_with_handshake(device, &lockdown, "palera1n");
if (ldret != LOCKDOWN_E_SUCCESS) {
LOG(LOG_ERROR, "Could not trigger entering recovery mode: %s", lockdownd_strerror(ldret));
LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret));
return -1;
}
lockdownd_client_free(lockdown);
} while (0);
ldret = lockdownd_enter_recovery(lockdown);
}
if (ldret != LOCKDOWN_E_SUCCESS) {
LOG(LOG_ERROR, "Could not trigger entering recovery mode: %s", lockdownd_strerror(ldret));
return -1;
}
lockdownd_client_free(lockdown);
idevice_free(device);
return 0;
}
@@ -240,8 +241,8 @@ int reboot_cmd(const char* udid) {
if (diagnostics_relay_restart(diag, DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT) != DIAGNOSTICS_RELAY_E_SUCCESS) {
LOG(LOG_ERROR, "Could not reboot device.");
}
diagnostics_relay_goodbye(diag);
diagnostics_relay_client_free(diag);
(void)diagnostics_relay_goodbye(diag);
(void)diagnostics_relay_client_free(diag);
} else {
LOG(LOG_ERROR, "Could not connect to device.");
return -1;
@@ -300,9 +301,9 @@ int passstat_cmd(unsigned char* status, const char* udid) {
derr = diagnostics_relay_query_mobilegestalt(diagnostics_client, keys, &node);
plist_free(keys);
diagnostics_relay_client_free(diagnostics_client);
lockdownd_service_descriptor_free(service);
idevice_free(dev);
(void)diagnostics_relay_client_free(diagnostics_client);
(void)lockdownd_service_descriptor_free(service);
(void)idevice_free(dev);
if (derr != DIAGNOSTICS_RELAY_E_SUCCESS || !node)
{
@@ -320,7 +321,7 @@ int passstat_cmd(unsigned char* status, const char* udid) {
plist_get_string_val(status_node, &passstat_status);
if (!status || strncmp(passstat_status, "Succ", 4))
{
if (passstat_status)
if (passstat_status)
free(passstat_status);
passstat_status = NULL;
plist_free(node);
@@ -347,20 +348,16 @@ int passstat_cmd(unsigned char* status, const char* udid) {
int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
irecv_client_t client = NULL;
irecv_error_t err = irecv_open_with_ecid(&client, ecid);
if (err != IRECV_E_SUCCESS) {
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
if (err != IRECV_E_SUCCESS) goto err;
int mode = 0;
irecv_get_mode(client, &mode);
err = irecv_get_mode(client, &mode);
if (err != IRECV_E_SUCCESS) goto err;
char *ibootver = NULL;
irecv_getenv(client, "build-version", &ibootver);
err = irecv_getenv(client, "build-version", &ibootver);
if (err != IRECV_E_SUCCESS) goto err;
irecv_device_t device;
err = irecv_devices_get_device_by_client(client, &device);
if (err != IRECV_E_SUCCESS) {
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
if (err != IRECV_E_SUCCESS) goto err;
info->mode = mode;
info->cpid = device->chip_id;
snprintf(info->product_type, 0x20, "%s", device->product_type);
@@ -369,33 +366,41 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
free(ibootver);
irecv_close(client);
return 0;
err:
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
int autoboot_cmd(const uint64_t ecid) {
irecv_client_t client = NULL;
irecv_error_t err = irecv_open_with_ecid(&client, ecid);
if (err == IRECV_E_SUCCESS) {
irecv_setenv(client, "auto-boot", "true");
irecv_saveenv(client);
irecv_close(client);
return 0;
} else {
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_setenv(client, "auto-boot", "true");
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_saveenv(client);
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_close(client);
if (err != IRECV_E_SUCCESS) goto err;
return 0;
err:
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
}
int exitrecv_cmd(const uint64_t ecid) {
irecv_client_t client = NULL;
irecv_error_t err = irecv_open_with_ecid(&client, ecid);
if (err == IRECV_E_SUCCESS) {
irecv_setenv(client, "auto-boot", "true");
irecv_saveenv(client);
irecv_reboot(client);
irecv_close(client);
return 0;
} else {
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_setenv(client, "auto-boot", "true");
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_saveenv(client);
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_reboot(client);
if (err != IRECV_E_SUCCESS) goto err;
err = irecv_close(client);
if (err != IRECV_E_SUCCESS) goto err;
return 0;
err:
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
+123 -50
View File
@@ -36,12 +36,20 @@ int dfuhelper_thr_running = false;
void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
for (int i = time2; i < time; i++) {
printf(CYN "\r\033[K%s (%d)" CRESET, text, time - i + time2);
printf(
checkrain_options_enabled(host_flags, host_option_no_colors)
? "\r\033[K%s (%d)"
: BCYN "\r\033[K%s (%d)" CRESET, text, time - i + time2
);
fflush(stdout);
sleep(1);
if (cond != NULL && cond(cond_arg)) pthread_exit(NULL);
}
printf(CYN "\r%s (%d)" CRESET, text, time2);
printf(
checkrain_options_enabled(host_flags, host_option_no_colors)
? "\r%s (%d)"
: CYN "\r%s (%d)" CRESET, text, time2
);
if (time2 == 0) puts("");
}
@@ -53,13 +61,15 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
LOG(LOG_ERROR, "Unable to get device information");
return 0;
}
if (strcmp(dev.CPUArchitecture, "arm64")) {
if (strncmp(dev.CPUArchitecture, "arm64", strlen("arm64"))) {
devinfo_free(&dev);
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
LOG(LOG_WARNING, "palera1n doesn't and never will work on A12+ (arm64e)");
return -1;
}
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
if (!checkrain_options_enabled(host_flags, host_option_device_info))
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
unsigned char passcode_state = 0;
ret = passstat_cmd(&passcode_state, usbmuxd_device->udid);
if (ret != 0) {
@@ -69,15 +79,29 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
}
if (passcode_state) {
LOG(LOG_ERROR, "Passcode must be disabled on this device");
LOG(LOG_ERROR, "Additionally, passcode must never be set since restore on iOS 16+");
if (!checkrain_options_enabled(host_flags, host_option_device_info))
LOG(LOG_ERROR, "Additionally, passcode must never be set since a restore on iOS 16+");
devinfo_free(&dev);
return -1;
}
}
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
printf("Mode: normal\n");
printf("ProductType: %s\n", dev.productType);
printf("Architecture: %s\n", dev.CPUArchitecture);
printf("Version: %s\n", dev.productVersion);
printf("DisplayName: %s\n", dev.displayName);
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
return 0;
}
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
enter_recovery_cmd(usbmuxd_device->udid);
devinfo_free(&dev);
if (checkrain_option_enabled(host_flags, host_option_enter_recovery)) {
if (checkrain_options_enabled(host_flags, host_option_enter_recovery)) {
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
@@ -96,12 +120,13 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
cpid = info->cpid;
ecid = info->ecid;
bdid = info->bdid;
if (!cpid_is_arm64(info->cpid)) {
info = NULL;
if (!cpid_is_arm64(cpid)) {
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
return NULL;
}
sleep(1);
ret = autoboot_cmd(info->ecid);
ret = autoboot_cmd(ecid);
if (ret) {
LOG(LOG_ERROR, "Cannot set auto-boot back to true");
return NULL;
@@ -113,26 +138,22 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
step(4, 2, "Hold volume down + side button", NULL, 0);
else
step(4, 2, "Hold home + power button", NULL, 0);
set_ecid_wait_for_dfu(info->ecid);
ret = exitrecv_cmd(info->ecid);
info = NULL;
set_ecid_wait_for_dfu(ecid);
ret = exitrecv_cmd(ecid);
if (ret) {
LOG(LOG_ERROR, "Cannot exit recovery mode");
set_ecid_wait_for_dfu(0);
return NULL;
}
printf("\r\033[K");
bool nohome = NOHOME;
if (nohome)
if (NOHOME) {
step(2, 0, "Hold volume down + side button", NULL, 0);
else
step(2, 0, "Hold home + power Button", NULL, 0);
if (nohome)
step(10, 0, "Hold volume down button", conditional, ecid);
else
step(10, 0, "Hold home button", conditional, ecid);
if (get_ecid_wait_for_dfu() != ecid) {
} else {
step(2, 0, "Hold home + power button", NULL, 0);
step(10, 0, "Hold home button", conditional, ecid);
}
if (get_ecid_wait_for_dfu() == ecid) {
LOG(LOG_WARNING, "Whoops, device did not enter DFU mode");
LOG(LOG_INFO, "Waiting for device to reconnect...");
set_ecid_wait_for_dfu(0);
@@ -160,13 +181,15 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
switch (event->event) {
case UE_DEVICE_ADD:
LOG(LOG_VERBOSE, "Normal mode device connected");
if (checkrain_option_enabled(host_flags, host_option_exit_recovery)) {
if (checkrain_options_enabled(host_flags, host_option_exit_recovery)) {
break;
} else if (checkrain_option_enabled(host_flags, host_option_reboot_device)) {
reboot_cmd(event->device.udid);
LOG(LOG_INFO, "Restarted device");
set_spin(0);
unsubscribe_cmd();
} else if (checkrain_options_enabled(host_flags, host_option_reboot_device)) {
int ret = reboot_cmd(event->device.udid);
if (!ret) {
LOG(LOG_INFO, "Restarted device");
set_spin(0);
unsubscribe_cmd();
}
pthread_exit(NULL);
break;
}
@@ -180,35 +203,85 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
pthread_t recovery_thread, dfu_thread;
int ret;
switch(event->type) {
case IRECV_DEVICE_ADD:
if (event->mode == IRECV_K_RECOVERY_MODE_1 || event->mode == IRECV_K_RECOVERY_MODE_2 || event->mode == IRECV_K_RECOVERY_MODE_3 || event->mode == IRECV_K_RECOVERY_MODE_4) {
LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid);
if (checkrain_option_enabled(host_flags, host_option_exit_recovery)) {
exitrecv_cmd(event->device_info->ecid);
LOG(LOG_INFO, "Exited recovery mode");
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
checkrain_option_enabled(host_flags, host_option_reboot_device)) return;
pthread_create(&recovery_thread, NULL, (void* (*)(void*))connected_recovery_mode, event->device_info);
} else if (event->mode == IRECV_K_DFU_MODE) {
LOG(LOG_VERBOSE, "DFU mode device %ld connected", event->device_info->ecid);
if (
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
checkrain_option_enabled(host_flags, host_option_reboot_device)) {
if (event->mode == IRECV_K_RECOVERY_MODE_1 ||
event->mode == IRECV_K_RECOVERY_MODE_2 ||
event->mode == IRECV_K_RECOVERY_MODE_3 ||
event->mode == IRECV_K_RECOVERY_MODE_4) {
if (!checkrain_options_enabled(host_flags, host_option_device_info))
LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid);
if (checkrain_options_enabled(host_flags, host_option_exit_recovery)) {
ret = exitrecv_cmd(event->device_info->ecid);
if (!ret) {
LOG(LOG_INFO, "Exited recovery mode");
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
} else {
LOG(LOG_WARNING, "Could not exit recovery mode");
}
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
recvinfo_t info;
ret = recvinfo_cmd(&info, event->device_info->ecid);
if (ret) {
LOG(LOG_WARNING, "Could not get info from device");
} else {
printf("Mode: Recovery\n");
printf("ProductType: %s\n", info.product_type);
printf("DisplayName: %s\n", info.display_name);
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
}
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
checkrain_options_enabled(host_flags, host_option_reboot_device)) return;
pthread_create(&recovery_thread, NULL, (pthread_start_t)connected_recovery_mode, event->device_info);
} else if (event->mode == IRECV_K_DFU_MODE) {
if (!checkrain_options_enabled(host_flags, host_option_device_info))
LOG(LOG_VERBOSE, "DFU mode device %ld connected", event->device_info->ecid);
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
recvinfo_t info;
ret = recvinfo_cmd(&info, event->device_info->ecid);
if (ret) {
LOG(LOG_WARNING, "Could not get info from device");
} else {
printf("Mode: DFU\n");
printf("ProductType: %s\n", info.product_type);
printf("DisplayName: %s\n", info.display_name);
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
}
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (
checkrain_options_enabled(host_flags, host_option_exit_recovery) ||
checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
checkrain_options_enabled(host_flags, host_option_reboot_device)) {
break;
}
pthread_create(&dfu_thread, NULL, (pthread_start_t)connected_dfu_mode, event->device_info);
}
pthread_create(&dfu_thread, NULL, (void* (*)(void*))connected_dfu_mode, event->device_info);
}
break;
break;
case IRECV_DEVICE_REMOVE:
LOG(LOG_VERBOSE, "Recovery mode device disconnected");
break;
@@ -217,8 +290,8 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
void *dfuhelper(void* ptr) {
dfuhelper_thr_running = true;
subscribe_cmd(device_event_cb, irecv_device_event_cb);
set_spin(1);
subscribe_cmd(device_event_cb, irecv_device_event_cb);
while (get_spin()) {
sleep(1);
};
+121 -23
View File
@@ -11,63 +11,147 @@
#include <errno.h>
#include <limits.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
extern char **environ;
#include <palerain.h>
#include <xxd-embedded.h>
char* pongo_path = NULL;
bool external_pongo = false;
char* ext_checkra1n = NULL;
#define tmpdir getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")
int exec_checkra1n() {
int exec_checkra1n(void) {
LOG(LOG_INFO, "About to execute checkra1n");
int fd, ret;
int fd_checkra1n, fd_pongo, ret;
char* checkra1n_path = NULL;
if (ext_checkra1n != NULL) {
checkra1n_path = ext_checkra1n;
goto checkra1n_exec;
}
#ifndef NO_CUSTOM_PONGO
if (pongo_path == NULL) {
pongo_path = malloc(strlen(tmpdir) + 20);
snprintf(pongo_path, strlen(tmpdir) + 20, "%s/Pongo.bin.XXXXXX", tmpdir);
fd_pongo = mkstemp(pongo_path);
if (fd_pongo == -1) {
LOG(LOG_FATAL, "Cannot open temporary file %s: %d (%s)", pongo_path, errno, strerror(errno));
free(pongo_path);
return -1;
}
ssize_t didWrite_Pongo_bin = write(fd_pongo, Pongo_bin, Pongo_bin_len);
if (didWrite_Pongo_bin != (ssize_t)Pongo_bin_len) {
LOG(LOG_FATAL, "Size written to %s does not match expected: %lld != %d: %d (%s)", pongo_path, didWrite_Pongo_bin, Pongo_bin_len, errno, strerror(errno));
close(fd_pongo);
unlink(pongo_path);
free(pongo_path);
pongo_path = NULL;
return -1;
}
} else external_pongo = true;
#endif
checkra1n_path = malloc(strlen(tmpdir) + 20);
snprintf(checkra1n_path, strlen(tmpdir) + 20, "%s/checkra1n.XXXXXX", tmpdir);
fd = mkstemp(checkra1n_path);
if (fd == -1) {
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
fd_checkra1n = mkstemp(checkra1n_path);
if (fd_checkra1n == -1) {
LOG(LOG_FATAL, "Cannot open temporary file %s: %d (%s)", checkra1n_path, errno, strerror(errno));
free(checkra1n_path);
checkra1n_path = NULL;
return -1;
}
ssize_t didWrite = write(fd, checkra1n, checkra1n_len);
if (didWrite != (ssize_t)checkra1n_len) {
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite, checkra1n_len, errno, strerror(errno));
close(fd);
ssize_t didWrite_checkra1n = write(fd_checkra1n, checkra1n, checkra1n_len);
if (didWrite_checkra1n != (ssize_t)checkra1n_len) {
LOG(LOG_FATAL, "Size written to %s does not match expected: %lld != %d: %d (%s)", checkra1n_path, didWrite_checkra1n, checkra1n_len, errno, strerror(errno));
close(fd_checkra1n);
unlink(checkra1n_path);
free(checkra1n_path);
checkra1n_path = NULL;
return -1;
}
close(fd);
close(fd_checkra1n);
ret = chmod(checkra1n_path, 0700);
if (ret) {
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
unlink(checkra1n_path);
free(checkra1n_path);
checkra1n_path = NULL;
return -1;
}
#if defined(__APPLE__) && defined(__arm64__) && (TARGET_OS_IPHONE || defined(FORCE_HELPER))
char* libcheckra1nhelper_dylib_path = NULL;
{
struct utsname name;
uname(&name);
unsigned long darwinMajor = strtoul(name.release, NULL, 10);
assert(darwinMajor != 0);
#if !defined(FORCE_HELPER)
if (darwinMajor < 20) {
#endif
libcheckra1nhelper_dylib_path = malloc(strlen(tmpdir) + 40);
snprintf(libcheckra1nhelper_dylib_path, strlen(tmpdir) + 40, "%s/libcheckra1nhelper.dylib.XXXXXX", tmpdir);
int helper_fd = mkstemp(libcheckra1nhelper_dylib_path);
if (helper_fd == -1) {
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
return -1;
}
ssize_t didWrite_libcheckra1nhelper = write(helper_fd, libcheckra1nhelper_dylib, libcheckra1nhelper_dylib_len);
if ((unsigned int)didWrite_libcheckra1nhelper != libcheckra1nhelper_dylib_len) {
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite_libcheckra1nhelper, libcheckra1nhelper_dylib_len, errno, strerror(errno));
close(helper_fd);
unlink(libcheckra1nhelper_dylib_path);
return -1;
}
close(helper_fd);
ret = chmod(libcheckra1nhelper_dylib_path, 0700);
if (ret) {
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", libcheckra1nhelper_dylib_path, errno, strerror(errno));
unlink(libcheckra1nhelper_dylib_path);
return -1;
}
setenv("DYLD_INSERT_LIBRARIES", libcheckra1nhelper_dylib_path, 1);
#if !defined(FORCE_HELPER)
}
#endif
}
#endif
checkra1n_exec: {};
char args[0x10] = "-pE";
if (checkrain_option_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
if (pongo_path != NULL) strncat(args, "k", 0xf); // keep this at last
char args[0x10] = "-E";
if (checkrain_options_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
if (!checkrain_options_enabled(host_flags, palerain_option_checkrain_is_clone)) {
strncat(args, "p", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
if (checkrain_options_enabled(host_flags, host_option_no_colors)) strncat(args, "n", 0xf);
} else {
strncat(args, "R", 0xf);
}
LOG(LOG_VERBOSE5, args);
if (pongo_path != NULL) LOG(LOG_VERBOSE5, pongo_path);
pid_t pid;
char* checkra1n_argv[] = {
checkra1n_path,
args,
pongo_path,
NULL
};
ret = posix_spawn(&pid, checkra1n_path, NULL, NULL, checkra1n_argv, environ);
if (pongo_path != NULL) free(pongo_path);
pongo_path = NULL;
if (pongo_path != NULL) {
ret = posix_spawn(&pid, checkra1n_path, NULL, NULL, (char* []){
checkra1n_path,
args,
"-k",
pongo_path,
NULL
}, environ);
} else {
ret = posix_spawn(&pid, checkra1n_path, NULL, NULL, (char* []){
checkra1n_path,
args,
NULL
}, environ);
}
if (ret) {
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
if (ext_checkra1n != NULL) unlink(checkra1n_path);
@@ -81,5 +165,19 @@ checkra1n_exec: {};
checkra1n_path = NULL;
}
waitpid(pid, NULL, 0);
if (!external_pongo && pongo_path != NULL) {
unlink(pongo_path);
}
if (pongo_path != NULL) free(pongo_path);
pongo_path = NULL;
#if defined(__APPLE__) && defined(__arm64__) && (TARGET_OS_IPHONE || defined(FORCE_HELPER))
if (libcheckra1nhelper_dylib_path != NULL) {
unlink(libcheckra1nhelper_dylib_path);
unsetenv("DYLD_INSERT_LIBRARIES");
unsetenv("DYLD_FORCE_FLAT_NAMESPACE");
free(libcheckra1nhelper_dylib_path);
libcheckra1nhelper_dylib_path = NULL;
}
#endif
return 0;
}
+6 -1
View File
@@ -15,7 +15,12 @@ unsigned char* checkra1n = NULL;
unsigned int checkra1n_len = 0;
#endif
#ifdef NO_BINPACK
#ifdef NO_OVERLAY
unsigned char* binpack_dmg = NULL;
unsigned int binpack_dmg_len = 0;
#endif
#ifdef NO_CUSTOM_PONGO
unsigned char* Pongo_bin = NULL;
unsigned int Pongo_bin_len = 0;
#endif
+67
View File
@@ -0,0 +1,67 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <gui.h>
// 50/50 chance this will be removed for in-window alerts
#if __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#define IDOK 1
#define IDCANCEL 2
#define AL kCFUserNotificationNoteAlertLevel
#elif _WIN32
#include <windows.h>
#include <winuser.h>
#elif __linux__
// #include <gtk/gtk.h>
#elif BSD
#elif __ANDROID__
#else
#endif
void send_alert(const char *title, const char *msg) {
#if __APPLE__
CFStringRef header_ref = CFStringCreateWithCString(NULL, title, strlen(title));
CFStringRef message_ref = CFStringCreateWithCString(NULL, msg, strlen(msg));
// CFStringRef url_ref = CFStringCreateWithCString( NULL, "", strlen("") );
CFURLRef icon_ref = CFURLCreateWithString(kCFAllocatorDefault, NULL, NULL);
CFOptionFlags result;
CFUserNotificationDisplayAlert(0, AL, icon_ref, NULL, NULL, header_ref, message_ref, NULL, NULL, NULL, &result);
CFRelease(header_ref);
CFRelease(message_ref);
#elif _WIN32
MessageBox(0, msg, title, MB_OK);
#elif __linux__
char line[256];
FILE *fp;
fp=popen("zenity --version","r");
if (fp==NULL) {
perror("Pipe returned a error");
} else {
while (fgets(line,sizeof(line),fp)) printf("%s",line);
pclose(fp);
}
char *str_msg = (char*)malloc(40+strlen(title)+strlen(msg)+1);
sprintf(str_msg, "zenity --info --title '%s' --text '%s'", title, msg);
fp=popen(str_msg, "r");
if (fp==NULL) {
perror("Pipe returned a error");
} else {
printf("Exit code: %i\n",WEXITSTATUS(pclose(fp)));
}
#elif BSD
#elif __ANDROID__
#else
#endif
}
+372
View File
@@ -0,0 +1,372 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <hello_imgui/hello_imgui.h>
#include <imgui/imgui_internal.h>
#include <common.h>
#include <design.h>
/* ----------------- [ Animation Varibles ] ----------------- */
float btn_w = 0.0f;
float btn_h = 0.0f;
float btn_x = 0.0f;
float btn_y = 0.0f;
float box_w = 0.0f;
float box_h = 0.0f;
float box_x = 0.0f;
float box_y = 0.0f;
/* ----------------- [ UI Init/Reset ] ----------------- */
void init_colors() {
auto &colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_WindowBg] = ImVec4{0.21f, 0.23f, 0.31f, 1.0f};
colors[ImGuiCol_MenuBarBg] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
// Border
colors[ImGuiCol_Border] = ImVec4{0.44f, 0.37f, 0.61f, 0.0f};
colors[ImGuiCol_BorderShadow] = ImVec4{0.0f, 0.0f, 0.0f, 0.0f};
// Text
colors[ImGuiCol_Text] = ImVec4{1.0f, 1.0f, 1.0f, 1.0f};
colors[ImGuiCol_TextDisabled] = ImVec4{0.5f, 0.5f, 0.5f, 1.0f};
// Headers
colors[ImGuiCol_Header] = ImVec4{0.13f, 0.13f, 0.17, 1.0f};
colors[ImGuiCol_HeaderHovered] = ImVec4{0.19f, 0.2f, 0.25f, 1.0f};
colors[ImGuiCol_HeaderActive] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
// Buttons
colors[ImGuiCol_Button] = ImVec4{0.9f, 0.9f, 0.9f, 1.0f};
colors[ImGuiCol_ButtonHovered] = ImVec4{0.9f, 0.9f, 0.9f, 1.0f};
colors[ImGuiCol_ButtonActive] = ImVec4{0.9f, 0.9f, 0.9f, 1.0f};
colors[ImGuiCol_CheckMark] = ImVec4{0.9f, 0.9f, 0.9f, 1.0f};
// Popups
colors[ImGuiCol_PopupBg] = ImVec4{0.1f, 0.1f, 0.13f, 0.92f};
// Slider
colors[ImGuiCol_SliderGrab] = ImVec4{0.44f, 0.37f, 0.61f, 0.54f};
colors[ImGuiCol_SliderGrabActive] = ImVec4{0.74f, 0.58f, 0.98f, 0.54f};
// Frame BG
colors[ImGuiCol_FrameBg] = ImVec4{0.13f, 0.13f, 0.15f, 0.7f};
colors[ImGuiCol_FrameBgHovered] = ImVec4{0.13f, 0.13f, 0.15f, 0.7f};
colors[ImGuiCol_FrameBgActive] = ImVec4{0.13f, 0.13f, 0.15f, 0.7f};
// Tabs
colors[ImGuiCol_Tab] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
colors[ImGuiCol_TabHovered] = ImVec4{0.24, 0.24f, 0.32f, 1.0f};
colors[ImGuiCol_TabActive] = ImVec4{0.2f, 0.22f, 0.27f, 1.0f};
colors[ImGuiCol_TabUnfocused] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
colors[ImGuiCol_TabUnfocusedActive] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
// Title
colors[ImGuiCol_TitleBg] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
colors[ImGuiCol_TitleBgActive] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
colors[ImGuiCol_TitleBgCollapsed] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
// Scrollbar
colors[ImGuiCol_ScrollbarBg] = ImVec4{0.1f, 0.1f, 0.13f, 1.0f};
colors[ImGuiCol_ScrollbarGrab] = ImVec4{0.16f, 0.16f, 0.21f, 1.0f};
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4{0.19f, 0.2f, 0.25f, 1.0f};
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4{0.24f, 0.24f, 0.32f, 1.0f};
// Seperator
colors[ImGuiCol_Separator] = ImVec4{0.44f, 0.37f, 0.61f, 1.0f};
colors[ImGuiCol_SeparatorHovered] = ImVec4{0.74f, 0.58f, 0.98f, 1.0f};
colors[ImGuiCol_SeparatorActive] = ImVec4{0.84f, 0.58f, 1.0f, 1.0f};
// Resize Grip
colors[ImGuiCol_ResizeGrip] = ImVec4{0.44f, 0.37f, 0.61f, 0.29f};
colors[ImGuiCol_ResizeGripHovered] = ImVec4{0.74f, 0.58f, 0.98f, 0.29f};
colors[ImGuiCol_ResizeGripActive] = ImVec4{0.84f, 0.58f, 1.0f, 0.29f};
// Docking
colors[ImGuiCol_DockingPreview] = ImVec4{0.44f, 0.37f, 0.61f, 1.0f};
}
void init_style() {
auto &style = ImGui::GetStyle();
style.TabRounding = 0;
style.ScrollbarRounding = 0;
style.WindowRounding = 0;
style.GrabRounding = 0;
style.FrameRounding = 20;
style.PopupRounding = 0;
style.ChildRounding = 0;
}
void reset_design() {
ImGui::SetCursorPos(ImVec2(0, 0));
init_colors();
init_style();
}
void reset_views() {
waiting_for_device = false;
unsupported_device = false;
supported_device = false;
recovery_wait = false;
jailbreak = false;
enter_dfu = false;
dfu_helper = false;
}
/* ----------------- [ UI Element Styles ] ----------------- */
void image_btn_style() {
auto &colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Button] = ImVec4{1.0f, 1.0f, 1.0f, 1.0f};
colors[ImGuiCol_ButtonHovered] = ImVec4{0.95f, 0.95f, 0.95f, 1.0f};
colors[ImGuiCol_ButtonActive] = ImVec4{0.95f, 0.95f, 0.95f, 1.0f};
colors[ImGuiCol_CheckMark] = ImVec4{0.95f, 0.95f, 0.95f, 1.0f};
colors[ImGuiCol_Text] = ImVec4{0.1f, 0.1f, 0.1f, 1.0f};
}
void image_btn_style_alt() {
auto &colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Button] = ImVec4{0.0f, 0.0f, 0.0f, 0.0f};
colors[ImGuiCol_ButtonHovered] = ImVec4{0.0f, 0.0f, 0.0f, 0.0f};
colors[ImGuiCol_ButtonActive] = ImVec4{0.0f, 0.0f, 0.0f, 0.0f};
colors[ImGuiCol_CheckMark] = ImVec4{0.0f, 0.0f, 0.0f, 0.0f};
colors[ImGuiCol_Text] = ImVec4{0.0f, 0.0f, 0.0f, 0.0f};
}
/* ----------------- [ IDK Anymore ] ----------------- */
std::string addstr2(const char *str1, const char *str2) {
size_t str1_len = strlen(str1);
size_t str2_len = strlen(str2);
int buf_size = (int)str1_len + (int)str2_len + 1;
char buffer[buf_size];
sprintf(buffer, str1, str2);
return buffer;
}
std::string addstr3(const char *str1, const char *str2, const char *str3) {
size_t str1_len = strlen(str1);
size_t str2_len = strlen(str2);
size_t str3_len = strlen(str3);
int buf_size = (int)str1_len + (int)str2_len + (int)str3_len + 1;
char buffer[buf_size];
sprintf(buffer, str1, str2, str3);
return buffer;
}
std::string addstr4(const char *str1, const char *str2, const char *str3, const char *str4) {
size_t str1_len = strlen(str1);
size_t str2_len = strlen(str2);
size_t str3_len = strlen(str3);
size_t str4_len = strlen(str4);
int buf_size = (int)str1_len + (int)str2_len + (int)str3_len + (int)str4_len + 1;
char buffer[buf_size];
sprintf(buffer, str1, str2, str3, str4);
return buffer;
}
/* ----------------- [ UI Colors ] ----------------- */
ImVec4 hex_color(int hex, float alpha) {
float r = ((hex >> 16) & 0xFF) / 255.0f;
float g = ((hex >> 8) & 0xFF) / 255.0f;
float b = ((hex) & 0xFF) / 255.0f;
return ImVec4{r, g, b, alpha};
}
ImColor hex_imcolor(int hex, float alpha) {
float r = ((hex >> 16) & 0xFF) / 255.0f;
float g = ((hex >> 8) & 0xFF) / 255.0f;
float b = ((hex) & 0xFF) / 255.0f;
return ImColor{r, g, b, alpha};
}
/* ----------------- [ UI Element States ] ----------------- */
bool is_hovered(const char* id, int w, int h) {
ImGuiContext& g = *GImGui;
ImGuiWindow* window = ImGui::GetCurrentWindow();
ImGuiID btn_id = window->GetID(id);
const ImRect bb(window->DC.CursorPos, ImVec2(window->DC.CursorPos.x + w, window->DC.CursorPos.x + h));
bool hovered = false;
ImGui::ButtonBehavior(bb,btn_id,&hovered,NULL);
return hovered;
}
bool is_pressed(const char* id, int w, int h) {
ImGuiContext& g = *GImGui;
ImGuiWindow* window = ImGui::GetCurrentWindow();
ImGuiID btn_id = window->GetID(id);
const ImRect bb(window->DC.CursorPos, ImVec2(window->DC.CursorPos.x + w, window->DC.CursorPos.x + h));
bool pressed = false;
ImGui::ButtonBehavior(bb,btn_id,NULL,&pressed);
return pressed;
}
/* ----------------- [ Common UI Types ] ----------------- */
void label(const char *text, ImVec2 location, ImVec4 color, int font) {
auto &style = ImGui::GetStyle();
ImGuiIO &io = ImGui::GetIO();
ImGui::SetCursorPos(location);
ImGui::PushFont(io.Fonts->Fonts[font]);
auto &colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Text] = color;
ImGui::Text(text);
ImGui::PopFont();
reset_design();
}
void draw_box(ImVec2 location, ImVec2 size, ImVec4 color, float radius) {
auto &colors = ImGui::GetStyle().Colors;
auto &style = ImGui::GetStyle();
float temp_rounding = style.FrameRounding;
ImVec4 temp_color_idle = colors[ImGuiCol_FrameBg];
ImVec4 temp_color_hover = colors[ImGuiCol_FrameBgHovered];
ImVec4 temp_color_active = colors[ImGuiCol_FrameBgActive];
style.FrameRounding = radius;
colors[ImGuiCol_FrameBg] = color;
colors[ImGuiCol_FrameBgHovered] = color;
colors[ImGuiCol_FrameBgActive] = color;
ImGui::SetCursorPos(location);
ImGui::ProgressBar(0.0f, size, "");
style.FrameRounding = temp_rounding;
colors[ImGuiCol_FrameBg] = temp_color_idle;
colors[ImGuiCol_FrameBgHovered] = temp_color_hover;
colors[ImGuiCol_FrameBgActive] = temp_color_active;
}
/* ----------------- [ Animation Systems ] ----------------- */
void anim_btn(const char* id, ImVec2 size, ImVec2 size_to, ImVec2 pos, ImVec2 pos_to) {
ImGuiIO &io = ImGui::GetIO();
float global = 25.0f;
bool new_w_positive,new_h_positive,new_x_positive,new_y_positive = false;
float new_w,new_h,new_x,new_y = 0.0f;
float lrg_size,lrg_pos,lrg = 0.0f;
if (size.x > size_to.x) {new_w = size.x - size_to.x; new_w_positive = false;}
else {new_w = size_to.x - size.x; new_w_positive = true;}
if (size.y > size_to.y) {new_h = size.y - size_to.y; new_h_positive = false;}
else {new_h = size_to.y - size.y;new_h_positive = true;}
if (pos.x > pos_to.x) {new_x = pos.x - pos_to.x; new_x_positive = false;}
else {new_x = pos_to.x - pos.x;new_x_positive = true;}
if (pos.y > pos_to.y) {new_y = pos.y - pos_to.y; new_y_positive = false;}
else {new_y = pos_to.y - pos.y;new_y_positive = true;}
if (new_w > new_h) lrg_size = new_w;
else lrg_size = new_h;
if (new_x > new_y) lrg_pos = new_x;
else lrg_pos = new_y;
if (lrg_size > lrg_pos) lrg = lrg_size;
else lrg = lrg_pos;
if (new_w_positive) {if (btn_w < size_to.x) btn_w += (new_w / lrg) * global * io.DeltaTime;}
else {if (btn_w > size_to.x) btn_w -= (new_w / lrg) * global * io.DeltaTime;}
if (new_h_positive) {if (btn_h < size_to.y) btn_h += (new_h / lrg) * global * io.DeltaTime;}
else {if (btn_h > size_to.y) btn_h -= (new_h / lrg) * global * io.DeltaTime;}
if (new_x_positive) {if (btn_x < pos_to.x) btn_x += (new_x / lrg) * global * io.DeltaTime;}
else {if (btn_x > pos_to.x) btn_x -= (new_x / lrg) * global * io.DeltaTime;}
if (new_y_positive) {if (btn_y < pos_to.y) btn_y += (new_y / lrg) * global * io.DeltaTime;}
else {if (btn_y > pos_to.y) btn_y -= (new_y / lrg) * global * io.DeltaTime;}
}
void anim_box(const char* id, ImVec2 size, ImVec2 size_to, ImVec2 pos, ImVec2 pos_to) {
ImGuiIO &io = ImGui::GetIO();
float global = 500.0f;
bool new_w_positive,new_h_positive,new_x_positive,new_y_positive = false;
float new_w,new_h,new_x,new_y = 0.0f;
float lrg_size,lrg_pos,lrg = 0.0f;
if (size.x > size_to.x) {new_w = size.x - size_to.x; new_w_positive = false;}
else {new_w = size_to.x - size.x; new_w_positive = true;}
if (size.y > size_to.y) {new_h = size.y - size_to.y; new_h_positive = false;}
else {new_h = size_to.y - size.y;new_h_positive = true;}
if (pos.x > pos_to.x) {new_x = pos.x - pos_to.x; new_x_positive = false;}
else {new_x = pos_to.x - pos.x;new_x_positive = true;}
if (pos.y > pos_to.y) {new_y = pos.y - pos_to.y; new_y_positive = false;}
else {new_y = pos_to.y - pos.y;new_y_positive = true;}
if (new_w > new_h) lrg_size = new_w;
else lrg_size = new_h;
if (new_x > new_y) lrg_pos = new_x;
else lrg_pos = new_y;
if (lrg_size > lrg_pos) lrg = lrg_size;
else lrg = lrg_pos;
if (new_w_positive) {if (box_w < size_to.x) box_w += (new_w / lrg) * global * io.DeltaTime;}
else {if (box_w > size_to.x) box_w -= (new_w / lrg) * global * io.DeltaTime;}
if (new_h_positive) {if (box_h < size_to.y) box_h += (new_h / lrg) * global * io.DeltaTime;}
else {if (box_h > size_to.y) box_h -= (new_h / lrg) * global * io.DeltaTime;}
if (new_x_positive) {if (box_x < pos_to.x) box_x += (new_x / lrg) * global * io.DeltaTime;}
else {if (box_x > pos_to.x) box_x -= (new_x / lrg) * global * io.DeltaTime;}
if (new_y_positive) {if (box_y < pos_to.y) box_y += (new_y / lrg) * global * io.DeltaTime;}
else {if (box_y > pos_to.y) box_y -= (new_y / lrg) * global * io.DeltaTime;}
}
static inline ImVec2 operator+(const ImVec2 &lhs, const ImVec2 &rhs) {
return ImVec2(lhs.x + rhs.x, lhs.y + rhs.y);
}
void ImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle) {
ImDrawList *draw_list = ImGui::GetWindowDrawList();
float cos_a = cosf(angle);
float sin_a = sinf(angle);
ImVec2 pos[4] = {
center + ImRotate(ImVec2(-size.x * 0.5f, -size.y * 0.5f), cos_a, sin_a),
center + ImRotate(ImVec2(+size.x * 0.5f, -size.y * 0.5f), cos_a, sin_a),
center + ImRotate(ImVec2(+size.x * 0.5f, +size.y * 0.5f), cos_a, sin_a),
center + ImRotate(ImVec2(-size.x * 0.5f, +size.y * 0.5f), cos_a, sin_a)};
ImVec2 uvs[4] = {
ImVec2(0.0f, 0.0f),
ImVec2(1.0f, 0.0f),
ImVec2(1.0f, 1.0f),
ImVec2(0.0f, 1.0f)};
draw_list->AddImageQuad(tex_id, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], IM_COL32_WHITE);
}
void rotate_image(const char *image, ImVec2 pos, ImVec2 size, float angle, float speed) {
ImGuiIO &io = ImGui::GetIO();
ImTextureID image_texture = HelloImGui::ImTextureIdFromAsset(image);
static float image_angle = angle;
image_angle += io.DeltaTime * speed;
ImVec2 image_center = ImVec2(pos.x, pos.y);
ImGui::SetCursorPos(pos);
ImageRotated(image_texture, image_center, size, image_angle);
}
+133
View File
@@ -0,0 +1,133 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdbool.h>
#include <unistd.h>
#include <ctype.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/diagnostics_relay.h>
#include <plist/plist.h>
#include <libirecovery.h>
#include <usbmuxd.h>
#include <common.h>
extern "C" {
#include <palerain.h>
#include <gui.h>
}
/*
This will all be removed and merged
into devhelper.c and dfuhelper.c
later on, so for now it stays ig
*/
irecv_device_event_context_t irecvctx_gui = NULL;
usbmuxd_subscription_context_t usbmuxdctx_gui = NULL;
int device_status = DISCONNECTED;
devinfo_t dev;
char const *udid_gui;
int connected_normal_mode_gui(const usbmuxd_device_info_t *usbmuxd_device) {
int ret;
ret = devinfo_cmd(&dev, usbmuxd_device->udid);
if (ret != 0) {
LOG(LOG_ERROR, "Unable to get device information");
return 0;
}
udid_gui = usbmuxd_device->udid;
device_status = NORMAL;
if (strcmp(dev.CPUArchitecture, "arm64")) {
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
return -1;
}
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
if (!checkrain_option_enabled(host_flags, host_option_device_info))
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
unsigned char passcode_state = 0;
ret = passstat_cmd(&passcode_state, usbmuxd_device->udid);
if (ret != 0) {
LOG(LOG_ERROR, "Failed to get passcode state");
devinfo_free(&dev);
return -1;
}
if (passcode_state) {
LOG(LOG_ERROR, "Passcode must be disabled on this device");
if (!checkrain_option_enabled(host_flags, host_option_device_info))
LOG(LOG_ERROR, "Additionally, passcode must never be set since restore on iOS 16+");
devinfo_free(&dev);
return -1;
}
}
}
void device_event_cb_gui(const usbmuxd_event_t *event, void* userdata) {
if (event->device.conn_type != CONNECTION_TYPE_USB) return;
switch (event->event) {
case UE_DEVICE_ADD:
fprintf(stderr, "Normal mode device connected\n");
connected_normal_mode_gui(&event->device);
break;
case UE_DEVICE_REMOVE:
fprintf(stderr, "Normal mode device disconnected\n");
device_status = DISCONNECTED;
devinfo_free(&dev);
if (supported_device || unsupported_device) {
supported_device = false;
unsupported_device = false;
waiting_for_device = true;
}
break;
}
}
void irecv_device_event_cb_gui(const irecv_device_event_t *event, void* userdata) {
switch(event->type) {
case IRECV_DEVICE_ADD:
if (event->mode == IRECV_K_RECOVERY_MODE_1 || event->mode == IRECV_K_RECOVERY_MODE_2 || event->mode == IRECV_K_RECOVERY_MODE_3 || event->mode == IRECV_K_RECOVERY_MODE_4) {
fprintf(stderr, "Recovery mode device %llu connected\n", event->device_info->ecid);
recvinfo_t info;
recvinfo_cmd(&info, event->device_info->ecid);
printf("Mode: recovery\n");
printf("ProductType: %s\n", info.product_type);
printf("DisplayName: %s\n", info.display_name);
device_status = RECOVERY;
if (waiting_for_device) {
device_status = RECOVERY;
exitrecv_cmd(event->device_info->ecid);
send_alert("Device in Recovery", "Exiting recovery, device must start from normal mode.");
}
} else if (event->mode == IRECV_K_DFU_MODE) {
device_status == DFU;
fprintf(stderr, "DFU mode device %llu connected\n", event->device_info->ecid);
}
break;
case IRECV_DEVICE_REMOVE:
fprintf(stderr, "Recovery mode device disconnected\n");
device_status = DISCONNECTED;
if (enter_dfu) {
device_status = DISCONNECTED;
enter_dfu = false;
waiting_for_device = true;
}
break;
}
}
void dfuhelper() {
subscribe_cmd(device_event_cb_gui, irecv_device_event_cb_gui);
}
void guifree() {
devinfo_free(&dev);
unsubscribe_cmd();
}
+350
View File
@@ -0,0 +1,350 @@
#include <thread>
#include <iostream>
#include <math.h>
#include<unistd.h>
#include <imgui/imgui_internal.h>
#include <hello_imgui/hello_imgui.h>
#include <hello_imgui/app_window_params.h>
#include <design.h>
#include <common.h>
extern "C" {
#include <gui.h>
}
/* Bools for which view to show */
bool waiting_for_device = true;
bool unsupported_device = false;
bool supported_device = false;
bool recovery_wait = false;
bool jailbreak = false;
bool enter_dfu = false;
bool dfu_helper = false;
bool settings = false;
bool execjb = false;
uint64_t ms() {
using namespace std::chrono;
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}
/* ----------------- [ Main Function ] ----------------- */
int main(int argc, char *argv[]) {
if (argc >= 2) {
// temp for testing
return palera1n(argc, argv);
}
dfuhelper();
/* Vars for DFU Healper */
int dfu_step1 = 3;
int dfu_step2 = 5;
int dfu_step3 = 10;
bool dfu_done = false;
bool set_ms = true;
auto desired = ms() + 1000;
/* HelloImGui Stuff */
HelloImGui::RunnerParams params;
params.fpsIdling.fpsIdle = 60.f;
params.appWindowParams.borderless = false;
params.appWindowParams.resizable = false;
params.appWindowParams.windowGeometry.size = {550, 300};
params.appWindowParams.windowTitle = "palera1n";
params.appWindowParams.restorePreviousGeometry = false;
params.imGuiWindowParams.defaultImGuiWindowType = HelloImGui::DefaultImGuiWindowType::NoDefaultWindow;
/* Color & Size Stuff */
bool open = true;
ImColor grad_color_left = ImColor(255, 177, 35);
ImColor grad_color_right = ImColor(4, 121, 168);
int grad_color_left_r = 255;
float text_alpha = 0.0f;
bool reverse_gradient = false;
/* ImGui Loop */
params.callbacks.ShowGui = [&]() {
{
/* Init colors, style, and fonts */
auto &colors = ImGui::GetStyle().Colors;
auto &style = ImGui::GetStyle();
ImGuiIO &io = ImGui::GetIO();
init_colors();
init_style();
/* Init window size and start ImGui */
ImGui::SetNextWindowSize(ImVec2(560, 300));
ImGui::SetNextWindowPos(ImVec2(-5, 0));
ImGui::Begin("palera1n", &open, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar);
/* Set our background gradient */
ImGui::SetCursorPos(ImVec2(0, 0));
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (!reverse_gradient) grad_color_left_r -= FLOAT_TO_INT(io.DeltaTime * 100.f) /2;
else grad_color_left_r += FLOAT_TO_INT(io.DeltaTime * 100.f) /2;
if (grad_color_left_r <= 140) reverse_gradient = true;
if (grad_color_left_r >= 255) reverse_gradient = false;
grad_color_left = ImColor(135, 63, grad_color_left_r) ;
grad_color_right = ImColor(4, 160, grad_color_left_r) ;
auto dl(ImGui::GetWindowDrawList());
dl->AddRectFilledMultiColor(ImVec2(0, 0), // pos - x y
ImVec2(560, 300), // size - width height
grad_color_left, // color top left
hex_imcolor(0x2390b4, 1.0f), // color
hex_imcolor(0x04c2a8, 1.0f), // color
grad_color_right); // color
if (!recovery_wait && !dfu_helper && !jailbreak) {
ImTextureID settings_icon = HelloImGui::ImTextureIdFromAsset("s60.png"); // pngs will be embedded soon
ImTextureID about_icon = HelloImGui::ImTextureIdFromAsset("i60.png"); // pngs will be embedded soon
image_btn_style_alt();
ImGui::SetCursorPos(ImVec2(455, 245));
ImGui::ImageButton(about_icon, ImVec2(33.0f, 33.0f));
ImGui::SetCursorPos(ImVec2(500, 245));
ImGui::ImageButton(settings_icon, ImVec2(33.0f, 33.0f));
reset_design();
}
/* Waiting for device view */
if (waiting_for_device) {
if (device_status == NORMAL) {
const char *name = dev.displayName;
char *arch = dev.CPUArchitecture;
char *type = dev.productType;
char *version = dev.productVersion;
if (strcmp("arm64", arch) != 0) {
waiting_for_device = false;
unsupported_device = true;
btn_x = 213.0f;
btn_y = 190.0f;
btn_w = 125.0f;
btn_h = 35.0f;
} else if (strstr(version, "15") != 0 || strstr(version, "16") != 0) {
waiting_for_device = false;
supported_device = true;
btn_x = 213.0f;
btn_y = 190.0f;
btn_w = 125.0f;
btn_h = 35.0f;
}
}
box_x = 55.0f; box_y = 75.0f; box_w = 450.0f; box_h = 150.0f;
draw_box(pos(55, 75), size(450, 150), hex_color(0x000000, 0.25f), 20.0f); // box in center
rotate_image("spinner.png", pos(95, 150), size(40, 40), 0.0f, 4.0f); // loading anim in box
label("Waiting for connection...", pos(135,122), WHITE, SF_BoldLarge); // Large title
label("Connect your device in normal mode to get started!", pos(138, 157), WHITE, SF_Reg); // Sub title
/* Unsupported device view */
} else if (unsupported_device) {
anim_box("Jailbreak", ImVec2(450,150),ImVec2(300,200),ImVec2(54,75),ImVec2(129,50));
draw_box(ImVec2(box_x, box_y),ImVec2(box_w, box_h), hex_color(0x000000, 0.25f), 20.0f);
set_pos(167, 90); font(SF_Bold);
ImGui::Text("%s", dev.displayName);
ImGui::PopFont();
set_pos(167, 120); font(SF_RegMed);
ImGui::Text("%s running iOS %s (%s)", dev.productType, dev.productVersion, dev.CPUArchitecture);
colors[ImGuiCol_Text] = hex_color(0xEB5160, 1.0f);
set_pos(167, 147); ImGui::Text(ICON_FA_BAN);
colors[ImGuiCol_Text] = hex_color(0xFFFFFF, 1.0f);
ImGui::SameLine(); ImGui::Text("Unsupported device connected");
ImGui::PopFont();
set_pos(213, 190); font(SF_RoundBold); btn_text_on;
bool hovered = is_hovered("Exit", 125, 35);
bool pressed = is_pressed("Exit", 125, 35);
ImVec2 btn_size = ImVec2(120, 30);
if (hovered) {
anim_btn("Exit", ImVec2(125,35),ImVec2(127,37),ImVec2(213,190),ImVec2(212,189));
btn_size = ImVec2(btn_w, btn_h);
ImGui::SetCursorPos(ImVec2(btn_x,btn_y));
} else {
anim_btn("Exit", ImVec2(127,37),ImVec2(125,35),ImVec2(212,189),ImVec2(213,190));
btn_size = ImVec2(btn_w, btn_h);
ImGui::SetCursorPos(ImVec2(btn_x,btn_y));
}
ImGui::Button("Exit", btn_size);
if (pressed) {
exit(0);
}
/* Supported device view */
} else if (supported_device) {
anim_box("Jailbreak", ImVec2(450,150),ImVec2(300,200),ImVec2(54,75),ImVec2(129,50));
draw_box(ImVec2(box_x, box_y),ImVec2(box_w, box_h), hex_color(0x000000, 0.25f), 20.0f);
set_pos(167, 90); font(SF_Bold);
ImGui::Text("%s", dev.displayName);
ImGui::PopFont();
set_pos(167, 120); font(SF_RegMed);
ImGui::Text("%s running iOS %s (%s)", dev.productType, dev.productVersion, dev.CPUArchitecture);
colors[ImGuiCol_Text] = hex_color(0x3CFF55, 1.0f);
set_pos(167, 147); ImGui::Text(ICON_FA_CHECK_CIRCLE);
colors[ImGuiCol_Text] = hex_color(0xFFFFFF, 1.0f);
ImGui::SameLine(); ImGui::Text("Connected and ready.");
ImGui::PopFont();
set_pos(213, 190); font(SF_RoundBold); btn_text_on;
bool hovered = is_hovered("Jailbreak", 125, 35);
bool pressed = is_pressed("Jailbreak", 125, 35);
ImVec2 btn_size = ImVec2(120, 30);
if (hovered) {
anim_btn("Jailbreak", ImVec2(125,35),ImVec2(127,37),ImVec2(213,190),ImVec2(212,189));
btn_size = ImVec2(btn_w, btn_h);
ImGui::SetCursorPos(ImVec2(btn_x,btn_y));
} else {
anim_btn("Jailbreak", ImVec2(127,37),ImVec2(125,35),ImVec2(212,189),ImVec2(213,190));
btn_size = ImVec2(btn_w, btn_h);
ImGui::SetCursorPos(ImVec2(btn_x,btn_y));
}
ImGui::Button("Jailbreak", btn_size);
if (pressed) {
enter_recovery_cmd(0);
box_x = 140.0f; box_y = 55.0f; box_w = 320.0f; box_h = 240.0f;
supported_device = false;
recovery_wait = true;
btn_text_off;
ImGui::PopFont();
}
/* Waiting for recovery view */
} else if (recovery_wait) {
draw_box(ImVec2(125, 105),ImVec2(300, 90), hex_color(0x000000, 0.25f), 20.0f);
//ImageRotated(loader, ImVec2(160, 150), ImVec2(40.0f, 40.0f), angle);
set_pos(210, 138); font(SF_Bold);
ImGui::Text("Entering recovery...");
ImGui::PopFont();
if (device_status == RECOVERY) {
recovery_wait = false;
enter_dfu = true;
}
/* Ready for DFU view */
} else if (enter_dfu) {
draw_box(ImVec2(65, 105),ImVec2(450, 90), hex_color(0x000000, 0.25f), 20.0f);
set_pos(110, 128); font(SF_Bold);
ImGui::Text("Time to enter DFU mode!");
ImGui::PopFont();
set_pos(110, 153); font(SF_Reg);
ImGui::Text("Locate the power and volume down button before you proceed.");
set_pos(108, 210); font(SF_Sm_Bold); btn_text_on;
if (ImGui::Button("Start", ImVec2(125, 35))) {
enter_dfu = false;
dfu_helper = true;
btn_text_off;
ImGui::PopFont();
}
/* DFU helper view */
} else if (dfu_helper) {
draw_box(ImVec2(75, 65),ImVec2(450, 220), hex_color(0x000000, 0.5f), 20.0f);
if (dfu_step1 > 0) dfu_text_light;
else dfu_text_dark;
set_pos(110, 110); font(SF_Reg);
ImGui::Text("1. Get Ready! %d", dfu_step1);
if (dfu_step2 > 0 && dfu_step1 == 0) dfu_text_light;
else dfu_text_dark;
set_pos(110, 160); ImGui::Text("2. Hold volume down + side button %d", dfu_step2);
if (dfu_step3 > 0 && dfu_step2 == 0) dfu_text_light;
else dfu_text_dark;;
set_pos(110, 210);ImGui::Text("3. Release side button, but keep holding volume down %d", dfu_step3);
ImGui::PopFont();
if (!dfu_done) {
if (set_ms) {
desired = ms() + 1000;
set_ms = false;
}
if (ms() >= desired) {
set_ms = true;
if (dfu_step1 > 0) dfu_step1 -= 1;
else if (dfu_step2 > 0) dfu_step2 -= 1;
else if (dfu_step3 > 0) dfu_step3 -= 1;
else dfu_done = true;
}
}
if (dfu_step2 == 2) exitrecv_cmd(dev.ecid);
if (dfu_done) {
if (device_status == DFU) {
guifree();
dfu_helper = false;
jailbreak = true;
} else {
send_alert("Failed to enter DFU", "Device failed to enter DFU mode, please try again.");
dfu_step1 = 3; dfu_step2 = 5; dfu_step3 = 10;
dfu_done = false;
dfu_helper = false;
waiting_for_device = true;
}
}
/* Main Jailbreak view */
} else if (jailbreak) {
pthread_t jb;
draw_box(ImVec2(25, 70),ImVec2(500, 200), hex_color(0x000000, 0.25f), 20.0f);
set_pos(20, 15); font(SF_Bold);
ImGui::Text("Installing jailbreak...");
ImGui::PopFont();
set_pos(20, 40); font(SF_Reg);
ImGui::Text("This will take a moment to jailbreak, hang tight!");
set_pos(50, 100); font(Hack);
if (!execjb) {
execjb = true;
palera1n(1, NULL);
}
// redirect logs here...
ImGui::Text("[*] Running...");
set_pos(50, 125); ImGui::Text("[*] Some epic log stuff will go here :3");
set_pos(50, 150); ImGui::Text("[*] lorem ipsum :frcoal:");
ImGui::PopFont();
} else {
}
if (settings) {
draw_box(ImVec2(50.0f, 65.0f),ImVec2(230.0f, 230.0f), hex_color(0x000000, 0.5f), 20.0f);
draw_box(ImVec2(320.0f, 65.0f),ImVec2(230.0f, 230.0f), hex_color(0x000000, 0.5f), 20.0f);
}
ImGui::End();
}
};
HelloImGui::Run(params);
return 0;
}
+25 -29
View File
@@ -30,7 +30,7 @@
#include <kerninfo.h>
pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
#ifdef DEV_BUILD
#ifdef TUI
#include <newt.h>
pthread_mutex_t tui_log_mutex;
newtComponent tui_log_output = NULL;
@@ -39,43 +39,39 @@ newtComponent tui_log_output = NULL;
bool spin, found_pongo = 0;
uint64_t ecid_wait_for_dfu = 0;
bool get_spin() {
LOG(LOG_VERBOSE5, "locking spin mutex for get");
pthread_mutex_lock(&spin_mutex);
bool ret = spin;
LOG(LOG_VERBOSE5, "UN-locking spin mutex, spin value is %d", spin);
pthread_mutex_unlock(&spin_mutex);
static bool get_locked_bool(bool* val, pthread_mutex_t* mutex) {
// fprintf(stderr, "%s: val = %p mutex = %p\n", __func__, (void*)val, (void*)mutex);
pthread_mutex_lock(mutex);
bool ret = *val;
pthread_mutex_unlock(mutex);
return ret;
}
bool set_spin(bool val) {
LOG(LOG_VERBOSE5, "locking spin mutex for set spin = %d", val);
pthread_mutex_lock(&spin_mutex);
spin = val;
LOG(LOG_VERBOSE5, "UN-locking spin mutex after setting spin\n");
pthread_mutex_unlock(&spin_mutex);
return val;
static bool set_locked_bool(bool* val, bool newval, pthread_mutex_t* mutex) {
// fprintf(stderr, "%s: val = %p mutex = %p, newval = %d\n", __func__, (void*)val, (void*)mutex, newval);
pthread_mutex_lock(mutex);
*val = newval;
pthread_mutex_unlock(mutex);
return newval;
}
bool get_found_pongo() {
LOG(LOG_VERBOSE5, "locking found pongo mutex for get");
pthread_mutex_lock(&found_pongo_mutex);
bool ret = found_pongo;
LOG(LOG_VERBOSE5, "UN-locking pongo mutex, found_pongo value is %d", found_pongo);
pthread_mutex_unlock(&found_pongo_mutex);
return ret;
bool get_spin(void) {
return get_locked_bool(&spin, &spin_mutex);
}
bool set_spin(bool newval) {
return set_locked_bool(&spin, newval, &spin_mutex);
}
bool get_found_pongo(void) {
return get_locked_bool(&found_pongo, &found_pongo_mutex);
}
bool set_found_pongo(bool val) {
LOG(LOG_VERBOSE5, "locking found pongo mutex for set found_pongo = %d", val);
pthread_mutex_lock(&found_pongo_mutex);
found_pongo = val;
LOG(LOG_VERBOSE5, "UN-locking pongo mutex after setting found_pongo");
pthread_mutex_unlock(&found_pongo_mutex);
return val;
return set_locked_bool(&found_pongo, val, &found_pongo_mutex);
}
uint64_t get_ecid_wait_for_dfu() {
uint64_t get_ecid_wait_for_dfu(void) {
LOG(LOG_VERBOSE5, "locking ecid wait for dfu mutex for get");
pthread_mutex_lock(&ecid_dfu_wait_mutex);
uint64_t ret = ecid_wait_for_dfu;
@@ -93,7 +89,7 @@ uint64_t set_ecid_wait_for_dfu(uint64_t ecid) {
return ecid;
}
#ifdef DEV_BUILD
#ifdef TUI
newtComponent get_tui_log() {
pthread_mutex_lock(&tui_log_mutex);
newtComponent ret = tui_log_output;
+10 -20
View File
@@ -11,22 +11,19 @@
#ifdef DEBUG
#define log_debug(...) fprintf(stderr, __VA_ARGS__); fputc('\n', stderr)
#else
#define log_debug(...)
#define log_debug(...) do {} while (0)
#endif
#define log_error(...) fprintf(stderr, __VA_ARGS__); fputc('\n', stderr)
int lockdown_connect_handle(uint32_t handle)
{
int lockdown_connect_handle(uint32_t handle) {
int fd = usbmuxd_connect(handle, 62078);
if (fd < 0) {
log_debug("Can't connect to lockownd on device #%u", handle);
return fd;
}
return fd;
}
int lockdown_connect_udid(const char* udid)
{
int lockdown_connect_udid(const char* udid) {
usbmuxd_device_info_t device;
if (usbmuxd_get_device_by_udid(udid, &device) < 0) {
log_debug("Can't find device %s", udid);
@@ -35,8 +32,7 @@ int lockdown_connect_udid(const char* udid)
return lockdown_connect_handle(device.handle);
}
void lockdown_disconnect(int fd)
{
void lockdown_disconnect(int fd) {
usbmuxd_disconnect(fd);
}
@@ -56,8 +52,7 @@ static const int INTEGER_NODE_SIZE = sizeof(INTEGER_NODE)-1;
static const int STRING_NODE_SIZE = sizeof(STRING_NODE)-1;
static const int ERROR_KEY_NODE_SIZE = sizeof(ERROR_KEY_NODE)-1;
static void skip_ws(char** cur, char* end)
{
static void skip_ws(char** cur, char* end) {
char* p = *cur;
while (p < end && ((*p == ' ') || (*p == '\t') || (*p == '\r') || (*p == '\n'))) {
p++;
@@ -65,8 +60,7 @@ static void skip_ws(char** cur, char* end)
*cur = p;
}
static char* _send_request_and_get_reply(int fd, const char* request, uint32_t len, uint32_t* received)
{
static char* _send_request_and_get_reply(int fd, const char* request, uint32_t len, uint32_t* received) {
uint32_t sent_bytes = 0;
usbmuxd_send(fd, request, len, &sent_bytes);
if (sent_bytes != len) {
@@ -100,8 +94,7 @@ static char* _send_request_and_get_reply(int fd, const char* request, uint32_t l
return resp;
}
int lockdown_check_type(int fd, const char* type_match)
{
int lockdown_check_type(int fd, const char* type_match) {
unsigned char tmp[512];
uint32_t len = (uint32_t)snprintf((char*)tmp, 512, QUERY_TYPE_REQUEST);
uint32_t belen = htonl(len-4);
@@ -119,8 +112,7 @@ int lockdown_check_type(int fd, const char* type_match)
return result;
}
int lockdown_get_uint_value(int fd, const char* domain, const char* key, uint64_t* value)
{
int lockdown_get_uint_value(int fd, const char* domain, const char* key, uint64_t* value) {
char tmp[1024];
uint32_t len;
if (domain) {
@@ -159,8 +151,7 @@ int lockdown_get_uint_value(int fd, const char* domain, const char* key, uint64_
return 0;
}
int lockdown_get_string_value(int fd, const char* domain, const char* key, char** value)
{
int lockdown_get_string_value(int fd, const char* domain, const char* key, char** value) {
char tmp[1024];
uint32_t len;
if (domain) {
@@ -212,8 +203,7 @@ int lockdown_get_string_value(int fd, const char* domain, const char* key, char*
return 0;
}
int lockdown_enter_recovery(int fd)
{
int lockdown_enter_recovery(int fd) {
char tmp[512];
uint32_t len = (uint32_t)snprintf(tmp, 512, ENTER_RECOVERY_REQUEST);
*(uint32_t*)&tmp = htonl(len-4);
+26 -11
View File
@@ -8,11 +8,11 @@
#include <ANSI-color-codes.h>
#include <palerain.h>
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...)
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char *__restrict format, ...)
{
if (verbose >= 5
#ifdef DEV_BUILD
&& !checkrain_option_enabled(host_flags, host_option_tui)
#ifdef TUI
&& !checkrain_options_enabled(host_flags, host_option_tui)
#endif
) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
int ret = 0;
@@ -23,7 +23,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
va_start(args, format);
if (verbose < (loglevel - 3) && loglevel > LOG_INFO) {
if (verbose >= 5
#ifdef DEV_BUILD
#ifdef TUI
&& !tui_started
#endif
) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
@@ -57,8 +57,12 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
snprintf(colour_bold, 0x10, "%s", BWHT);
break;
}
#ifdef DEV_BUILD
if (checkrain_option_enabled(host_flags, host_option_tui) && tui_started) {
if (checkrain_options_enabled(host_flags, host_option_no_colors)) {
colour[0] = '\0';
colour_bold[0] = '\0';
}
#ifdef TUI
if (checkrain_options_enabled(host_flags, host_option_tui) && tui_started) {
newtComponent co = get_tui_log();
if (co == NULL) {
return 0; /* 0 bytes printed */
@@ -75,20 +79,31 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
time_t curtime;
time(&curtime);
struct tm* timeinfo = localtime(&curtime);
snprintf(timestring, 0x80, "%s[%s%02d/%02d/%d %02d:%02d:%02d%s]", CRESET, HBLK, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, CRESET);
if (verbose >= 2) {
if (!checkrain_options_enabled(host_flags, host_option_no_colors))
snprintf(timestring, 0x80, "%s[%s%02d/%02d/%d %02d:%02d:%02d%s]", CRESET, HBLK, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, CRESET);
else
snprintf(timestring, 0x80, "[%02d/%02d/%d %02d:%02d:%02d]", timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
if (verbose >= 2 && !checkrain_options_enabled(host_flags, host_option_no_colors)) {
printf("%s| - %s%s <%s> " CRESET "%s" HBLU "%s" CRESET ":" BLU "%d" CRESET ":" BMAG "%s()" CRESET ": \n%s| ----> ", colour_bold, timestring, colour_bold, type, WHT, fname, lineno, fxname, colour_bold);
} else {
} else if (!checkrain_options_enabled(host_flags, host_option_no_colors)) {
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
} else if (verbose >= 2 && checkrain_options_enabled(host_flags, host_option_no_colors)) {
printf("%s| - %s%s <%s> %s:%d:%s(): \n%s| ----> ", colour_bold, timestring, colour_bold, type, fname, lineno, fxname, colour_bold);
} else if (checkrain_options_enabled(host_flags, host_option_no_colors)) {
printf(" - %s %s<%s>: ", timestring, colour_bold, type);
}
printf("%s", colour);
ret = vprintf(format, args);
va_end(args);
if (verbose < 2)
if (verbose < 2 && !checkrain_options_enabled(host_flags, host_option_no_colors))
printf(CRESET "\n");
else
else if (!checkrain_options_enabled(host_flags, host_option_no_colors))
printf("\n%s-%s\n", colour, CRESET);
else if (verbose < 2)
printf("\n");
else
printf("\n%s-\n", colour);
fflush(stdout);
}
pthread_mutex_unlock(&log_mutex);
+51 -38
View File
@@ -7,6 +7,7 @@
#include <unistd.h>
#include <stdarg.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>
#include <sys/select.h>
@@ -16,7 +17,6 @@
#include <signal.h>
#include <pthread.h>
#include <inttypes.h>
#include <getopt.h>
#include <errno.h>
#include <spawn.h>
#include <sys/mman.h>
@@ -28,6 +28,7 @@
#include <palerain.h>
#include <xxd-embedded.h>
#include <kerninfo.h>
#include <gui.h>
#define CMD_LEN_MAX 512
#define OVERRIDE_MAGIC 0xd803b376
@@ -56,9 +57,9 @@ void thr_cleanup(void* ptr) {
*(int*)ptr = 0;
}
int build_checks() {
#if defined(__APPLE__)
int build_checks(void) {
#ifndef NO_CHECKRAIN
#if defined(__APPLE__)
struct mach_header_64* c1_header = (struct mach_header_64*)&checkra1n[0];
if (c1_header->magic != MH_MAGIC_64 && c1_header->magic != MH_CIGAM_64) {
LOG(LOG_FATAL, "Broken build: checkra1n is not a thin Mach-O");
@@ -69,14 +70,19 @@ int build_checks() {
return -1;
}
#endif
if (checkra1n_len <= (UCHAR_MAX + 1)) {
LOG(LOG_FATAL, "checkra1n too small");
}
if (boyermoore_horspool_memmem(&checkra1n[0], checkra1n_len, (const unsigned char *)"[ra1npoc15-part] thanks to", strlen("[ra1npoc15-part] thanks to")) != NULL) {
host_flags |= palerain_option_checkrain_is_clone;
}
#endif
#ifndef NO_KPF
struct mach_header_64 *kpf_hdr = (struct mach_header_64 *)checkra1n_kpf_pongo;
if (kpf_hdr->magic != MH_MAGIC_64 && kpf_hdr->magic != MH_CIGAM_64) {
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not thin 64-bit Mach-O");
return -1;
} else
if (kpf_hdr->filetype != MH_KEXT_BUNDLE) {
} else if (kpf_hdr->filetype != MH_KEXT_BUNDLE) {
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not a kext bundle");
return -1;
} else if (kpf_hdr->cputype != CPU_TYPE_ARM64) {
@@ -87,41 +93,67 @@ int build_checks() {
return 0;
}
#ifdef DEV_BUILD
#ifdef TUI
bool tui_started = false;
#endif
#ifdef USE_LIBUSB
void log_cb(libusb_context *ctx, enum libusb_log_level level, const char *str) {
LOG(level + 0, str);
}
#endif
int palera1n(int argc, char *argv[]) {
print_credits();
int ret = 0;
pthread_mutex_init(&log_mutex, NULL);
pthread_mutex_init(&spin_mutex, NULL);
pthread_mutex_init(&found_pongo_mutex, NULL);
pthread_mutex_init(&ecid_dfu_wait_mutex, NULL);
if ((ret = build_checks())) return ret;
print_credits();
if ((ret = optparse(argc, argv))) goto cleanup;
if (checkrain_option_enabled(host_flags, host_option_palerain_version)) goto normal_exit;
#ifdef DEV_BUILD
if (checkrain_option_enabled(host_flags, host_option_tui)) {
if (!checkrain_options_enabled(host_flags, host_option_device_info) && checkrain_options_enabled(host_flags, host_option_palerain_version)) goto normal_exit;
#ifdef TUI
if (checkrain_options_enabled(host_flags, host_option_tui)) {
ret = tui();
if (ret) goto cleanup;
else goto normal_exit;
}
#endif
LOG(LOG_INFO, "Waiting for devices");
#ifdef USE_LIBUSB
{
libusb_set_log_cb(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
libusb_context* ctx = NULL;
int test_libusb = libusb_init(&ctx);
if (test_libusb) {
LOG(LOG_ERROR, "cannot initialize libusb: %d (%s)\n", test_libusb, libusb_strerror(test_libusb));
libusb_exit(ctx);
goto cleanup;
}
libusb_exit(ctx);
}
#endif
if (!checkrain_options_enabled(host_flags, host_option_device_info))
LOG(LOG_INFO, "Waiting for devices");
if (access("/var/run/usbmuxd", F_OK) != 0)
LOG(LOG_WARNING, "/var/run/usbmuxd not found, normal mode device detection will not work.");
pthread_create(&pongo_thread, NULL, pongo_helper, NULL);
pthread_create(&dfuhelper_thread, NULL, dfuhelper, NULL);
pthread_join(dfuhelper_thread, NULL);
set_spin(0);
if (checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
checkrain_option_enabled(host_flags, host_option_reboot_device) ||
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
device_has_booted)
if (checkrain_options_enabled(host_flags, host_option_dfuhelper_only |
host_option_reboot_device |
host_option_exit_recovery |
host_option_enter_recovery |
host_option_device_info
) || device_has_booted)
goto normal_exit;
if (exec_checkra1n()) goto cleanup;
if (checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_demote))
if (checkrain_options_enabled(host_flags, host_option_pongo_exit | host_option_demote))
goto normal_exit;
set_spin(1);
sleep(2);
@@ -132,27 +164,6 @@ int palera1n(int argc, char *argv[]) {
sleep(1);
}
normal_exit:
if (access("/usr/bin/curl", F_OK) == 0 && !checkrain_option_enabled(host_flags, host_option_no_ohio)) {
LOG(LOG_VERBOSE4, "Ohio");
char* ohio_argv[] = {
"/usr/bin/curl",
"-sX",
"POST",
"-d",
"{\"app_name\": \"palera1n_c-rewrite\"}",
"-H",
"Content-Type: application/json",
"-H",
"User-Agent: python-requests/99 palera1n-c-rewrite/0",
"-o",
"/dev/null",
"https://ohio.itsnebula.net/hit",
NULL
};
pid_t pid;
posix_spawn(&pid, ohio_argv[0], NULL, NULL, ohio_argv, environ);
}
cleanup:
if (override_kpf.magic == OVERRIDE_MAGIC) {
munmap(override_kpf.ptr, (size_t)override_kpf.len);
@@ -175,6 +186,8 @@ cleanup:
}
#ifndef GUI
int main (int argc, char* argv[]) {
return palera1n(argc, argv);
}
#endif
+107 -35
View File
@@ -9,15 +9,19 @@
#include <ctype.h>
#include <assert.h>
#include <getopt.h>
#include <limits.h>
#include <errno.h>
#include <palerain.h>
#include <sys/mman.h>
checkrain_option_t host_flags = 0;
checkrain_option_p host_flags_p = &host_flags;
static bool force_use_verbose_boot = false;
static struct option longopts[] = {
{"setup-partial-fakefs", no_argument, NULL, 'B'},
{"setup-fakefs", no_argument, NULL, 'c'},
{"setup-fakefs-forced", no_argument, NULL, 'C'},
{"clean-fakefs", no_argument, NULL, 'c'},
{"dfuhelper", no_argument, NULL, 'D'},
{"help", no_argument, NULL, 'h'},
{"pongo-shell", no_argument, NULL, 'p'},
@@ -30,20 +34,23 @@ static struct option longopts[] = {
{"jbinit-log-to-file", no_argument, NULL, 'L'},
{"demote", no_argument, NULL, 'd'},
{"force-revert", no_argument, NULL, palerain_option_case_force_revert},
{"no-colors", no_argument, NULL, 'S'},
{"safe-mode", no_argument, NULL, 's'},
{"version", no_argument, NULL, palerain_option_case_version},
{"override-pongo", required_argument, NULL, 'k'},
{"override-overlay", required_argument, NULL, 'o'},
{"override-ramdisk", required_argument, NULL, 'r'},
{"override-kpf", required_argument, NULL, 'K'},
{"disable-ohio", no_argument, NULL, 'O'},
{"override-checkra1n", required_argument, NULL, 'i'},
{"reboot-device", no_argument, NULL, 'R'},
{"exit-recovery", no_argument, NULL, 'n'},
{"enter-recovery", no_argument, NULL, 'E'},
{"device-info", no_argument, NULL, 'I'},
#ifdef DEV_BUILD
{"test1", no_argument, NULL, '1'},
{"test2", no_argument, NULL, '2'},
#endif
#ifdef TUI
{"tui", no_argument, NULL, 't'},
#endif
{NULL, 0, NULL, 0}
@@ -52,27 +59,38 @@ static struct option longopts[] = {
static int usage(int e, char* prog_name)
{
fprintf(stderr,
"Usage: %s [-"
"DEhpvVldsSLRnPI"
#ifdef DEV_BUILD
"Usage: %s [-12cCdDEfhlLnOpRstvV]"
#else
"Usage: %s [-cCdDEfhlLnOpRsvV]"
"12"
#endif
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n"
#ifdef ROOTFUL
"cCfB"
#endif
#ifdef TUI
"t"
#endif
"] [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n"
"Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n"
"iOS/iPadOS 15+ arm64 jailbreaking tool\n\n"
"iOS/iPadOS 15.0-16.5 arm64 jailbreaking tool\n\n"
"\t--version\t\t\t\tPrint version\n"
"\t--force-revert\t\t\t\tRemove jailbreak\n"
#ifdef DEV_BUILD
"\t-1, --test1\t\t\t\tSet palerain_option_test1\n"
"\t-2, --test2\t\t\t\tSet palerain_option_test2\n"
#endif
#ifdef ROOTFUL
"\t-B, --setup-partial-fakefs\t\tSetup partial fakefs\n"
"\t-c, --setup-fakefs\t\t\tSetup fakefs\n"
"\t-C, --setup-fakefs-forced\t\tSetup fakefs and overwrite any existing ones\n"
"\t-C, --clean-fakefs\t\t\tClean fakefs\n"
#endif
"\t-d, --demote\t\t\t\tDemote\n"
"\t-D, --dfuhelper-only\t\t\tExit after entering DFU\n"
"\t-D, --dfuhelper\t\t\t\tExit after entering DFU\n"
"\t-e, --boot-args <boot arguments>\tXNU boot arguments\n"
"\t-E, --enter-recovery\t\t\tEnter recovery mode\n"
#ifdef ROOTFUL
"\t-f, --fakefs \t\t\t\tBoots fakefs\n"
#endif
"\t-h, --help\t\t\t\tShow this help\n"
"\t-i, --override-checkra1n <file>\t\tOverride checkra1n\n"
"\t-k, --override-pongo <file>\t\tOverride Pongo image\n"
@@ -80,18 +98,19 @@ static int usage(int e, char* prog_name)
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\n"
"\t-n, --exit-recovery\t\t\tExit recovery mode\n"
"\t-I, --device-info\t\t\tPrint info about the connected device\n"
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
"\t-p, --pongo-shell\t\t\tBoots to PongoOS shell\n"
"\t-P, --pongo-full\t\t\tBoots to a PongoOS shell with default images already uploaded\n"
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
"\t-R, --reboot-device\t\t\tReboot connected device in normal mode\n"
"\t-s, --safe-mode\t\t\t\tEnter safe mode\n"
"\t-S, --no-colors\t\t\t\tDisable colors on the command line\n"
"\t-v, --debug-logging\t\t\tEnable debug logging\n"
"\t\tThis option can be repeated for extra verbosity.\n"
"\t-V, --verbose-boot\t\t\tVerbose boot\n"
#ifdef DEV_BUILD
#ifdef TUI
"\t-t, --tui\t\t\t\tTerminal user interface\n"
#endif
"\nEnvironmental variables:\n"
@@ -104,23 +123,26 @@ static int usage(int e, char* prog_name)
int optparse(int argc, char* argv[]) {
int opt;
int index;
while ((opt = getopt_long(argc, argv,
while ((opt = getopt_long(argc, argv,
"DEhpvVldsSLtRnPIe:o:r:K:k:i:"
#ifdef DEV_BUILD
"12cCDEhpvVldsOLftRnPe:o:r:K:k:i:",
#else
"cCDEhpvVldsOLfRnPe:o:r:K:k:i:",
"12"
#endif
longopts, NULL)) != -1)
"fCcB"
,longopts, NULL)) != -1)
{
switch (opt) {
case 'B':
palerain_flags |= palerain_option_setup_partial_root;
palerain_flags |= palerain_option_setup_rootful;
kpf_flags |= checkrain_option_verbose_boot;
break;
case 'c':
palerain_flags |= palerain_option_setup_rootful;
kpf_flags |= checkrain_option_verbose_boot;
break;
case 'C':
palerain_flags |= palerain_option_setup_rootful;
palerain_flags |= palerain_option_setup_rootful_forced;
kpf_flags |= checkrain_option_verbose_boot;
palerain_flags |= palerain_option_clean_fakefs;
break;
case 'p':
host_flags |= host_option_pongo_exit;
@@ -139,6 +161,7 @@ int optparse(int argc, char* argv[]) {
break;
case 'V':
kpf_flags |= checkrain_option_verbose_boot;
force_use_verbose_boot = true;
break;
case 'e':
if (strstr(optarg, "rootdev=") != NULL) {
@@ -209,7 +232,36 @@ int optparse(int argc, char* argv[]) {
} else if (!(st.st_mode & S_IXUSR) && !(st.st_mode & S_IXGRP) && !(st.st_mode & S_IXOTH)) {
LOG(LOG_FATAL, "%s is not executable", optarg);
return -1;
};
} else if (!S_ISREG(st.st_mode)) {
LOG(LOG_FATAL, "%s is not a regular file", optarg);
return -1;
}
if (st.st_size < (UCHAR_MAX+1)) {
LOG(LOG_FATAL, "%s too small", optarg);
return -1;
}
int checkra1n_fd = open(optarg, O_RDONLY);
if (checkra1n_fd == -1) {
LOG(LOG_FATAL, "Cannot open %s: %d (%s)", optarg, errno, strerror(errno));
return -1;
}
void* addr = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, checkra1n_fd, 0);
if (addr == MAP_FAILED) {
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", optarg, errno, strerror(errno));
return -1;
}
if (boyermoore_horspool_memmem(addr, st.st_size, (const unsigned char*)"[ra1npoc15-part] thanks to", strlen("[ra1npoc15-part] thanks to")) != NULL)
{
host_flags |= palerain_option_checkrain_is_clone;
LOG(LOG_VERBOSE3, "%s is checkra1n clone", optarg);
}
else
{
host_flags &= ~palerain_option_checkrain_is_clone;
LOG(LOG_VERBOSE3, "%s is checkra1n", optarg);
}
munmap(addr, st.st_size);
close(checkra1n_fd);
ext_checkra1n = calloc(1, strlen(optarg) + 1);
snprintf(ext_checkra1n, strlen(optarg) + 1, "%s", optarg);
break;
@@ -219,13 +271,18 @@ int optparse(int argc, char* argv[]) {
case 'n':
host_flags |= host_option_exit_recovery;
break;
case 'O':
host_flags |= host_option_no_ohio;
case 'I':
host_flags |= host_option_device_info;
break;
#ifdef DEV_BUILD
case 'S':
host_flags |= host_option_no_colors;
break;
#ifdef TUI
case 't':
host_flags |= host_option_tui;
break;
#endif
#ifdef DEV_BUILD
case '1':
palerain_flags |= palerain_option_test1;
break;
@@ -244,15 +301,28 @@ int optparse(int argc, char* argv[]) {
break;
}
}
if (checkrain_option_enabled(host_flags, host_option_palerain_version)) {
printf("palera1n version " PALERAIN_VERSION ": " BUILD_DATE "; " BUILD_WHOAMI ":" BUILD_TAG "/" BUILD_STYLE "\n");
if (checkrain_options_enabled(host_flags, host_option_palerain_version)) {
printf(
"palera1n " PALERAIN_VERSION "\n"
BUILD_COMMIT " " BUILD_NUMBER " (" BUILD_BRANCH ")\n\n"
"Build date: " BUILD_DATE "\n"
"Build style: " BUILD_STYLE "\n"
"Build tag: " BUILD_TAG "\n"
"Built by: " BUILD_WHOAMI "\n"
#ifdef USE_LIBUSB
"USB backend: libusb\n"
#else
"USB backend: IOKit\n"
#endif
"Build options: " BUILD_OPTIONS "\n"
);
return 0;
}
if (checkrain_option_enabled(checkrain_flags, checkrain_option_force_revert) && checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
LOG(LOG_WARNING, "force revert and setup rootful requested at the same time, behaviour here is undefined");
if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) {
kpf_flags &= ~checkrain_option_verbose_boot;
}
snprintf(checkrain_flags_cmd, 0x20, "checkra1n_flags 0x%x", checkrain_flags);
snprintf(palerain_flags_cmd, 0x20, "palera1n_flags 0x%x", palerain_flags);
snprintf(kpf_flags_cmd, 0x20, "kpf_flags 0x%x", kpf_flags);
@@ -273,17 +343,17 @@ int optparse(int argc, char* argv[]) {
LOG(LOG_VERBOSE4, "overlay override ptr %p -> %p", override_overlay.orig_ptr, **overlay_to_upload);
}
if (!checkrain_option_enabled(palerain_flags, palerain_option_rootful)) {
if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful) || checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful_forced)) {
if (!checkrain_options_enabled(palerain_flags, palerain_option_rootful)) {
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful) || checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful_forced)) {
LOG(LOG_FATAL, "Cannot setup rootful when rootless is requested. Use -f to enable rootful mode.");
return -1;
}
}
if (!(
checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
checkrain_option_enabled(host_flags, host_option_reboot_device)))
checkrain_options_enabled(host_flags, host_option_dfuhelper_only) ||
checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
checkrain_options_enabled(host_flags, host_option_exit_recovery) ||
checkrain_options_enabled(host_flags, host_option_reboot_device)))
{
#ifdef NO_CHECKRAIN
if (checkra1n_len == 0 && ext_checkra1n == NULL)
@@ -291,7 +361,7 @@ int optparse(int argc, char* argv[]) {
LOG(LOG_FATAL, "checkra1n omitted in build but no override specified");
return -1;
}
if (!(checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_pongo_exit)))
if (!(checkrain_options_enabled(host_flags, host_option_pongo_exit) || checkrain_options_enabled(host_flags, host_option_pongo_exit)))
{
#ifdef NO_KPF
if (checkra1n_kpf_pongo_len == 0)
@@ -320,8 +390,10 @@ int optparse(int argc, char* argv[]) {
}
}
if (verbose >= 2) setenv("LIBUSB_DEBUG", "1", 1);
if (verbose >= 3)
{
libusbmuxd_set_debug_level(verbose - 2);
irecv_set_debug_level(1);
setenv("LIBUSB_DEBUG", "2", 1);
}
+40 -15
View File
@@ -11,6 +11,7 @@
#include <sys/stat.h> // fstst
#include <palerain.h>
#include <ANSI-color-codes.h>
bool device_has_booted = 0;
int pongo_thr_running = 0;
@@ -28,15 +29,15 @@ void* pongo_helper(void* ptr) {
return NULL;
}
void *pongo_usb_callback(void *arg) {
void *pongo_usb_callback(stuff_t *arg) {
if (get_found_pongo())
return NULL;
set_found_pongo(1);
if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) {
strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1);
}
LOG(LOG_INFO, "Found PongoOS USB Device");
usb_device_handle_t handle = *(usb_device_handle_t *)arg;
usb_device_handle_t handle = arg->handle;
issue_pongo_command(handle, NULL);
issue_pongo_command(handle, "fuse lock");
issue_pongo_command(handle, "sep auto");
@@ -45,7 +46,7 @@ void *pongo_usb_callback(void *arg) {
issue_pongo_command(handle, kpf_flags_cmd);
issue_pongo_command(handle, checkrain_flags_cmd);
issue_pongo_command(handle, palerain_flags_cmd);
if (checkrain_option_enabled(palerain_flags, palerain_option_rootful))
if (checkrain_options_enabled(palerain_flags, palerain_option_rootful))
{
issue_pongo_command(handle, "rootfs");
}
@@ -57,7 +58,7 @@ void *pongo_usb_callback(void *arg) {
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len);
issue_pongo_command(handle, "ramdisk");
}
#ifdef NO_BINPACK
#ifdef NO_OVERLAY
if (binpack_dmg_len != 0)
#endif
{
@@ -65,15 +66,25 @@ void *pongo_usb_callback(void *arg) {
issue_pongo_command(handle, "overlay");
}
issue_pongo_command(handle, xargs_cmd);
if (checkrain_option_enabled(host_flags, host_option_pongo_full)) goto done;
if (checkrain_options_enabled(host_flags, host_option_pongo_full)) goto done;
issue_pongo_command(handle, "bootx");
LOG(LOG_INFO, "Booting Kernel...");
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_partial_root)) {
LOG(LOG_INFO, "Please wait up to 5 minutes for the bindfs to be created.");
LOG(LOG_INFO, "Once the device boots up to iOS, run again without the -B (Create BindFS) option to jailbreak.");
} else if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) {
LOG(LOG_INFO, "Please wait up to 10 minutes for the fakefs to be created.");
LOG(LOG_INFO, "Once the device boots up to iOS, run again without the -c (Create FakeFS) option to jailbreak.");
}
if (dfuhelper_thr_running) {
pthread_cancel(dfuhelper_thread);
dfuhelper_thr_running = false;
}
done:
device_has_booted = true;
#ifdef USE_LIBUSB
libusb_unref_device(arg->dev);
#endif
set_spin(0);
return NULL;
}
@@ -129,10 +140,10 @@ fetch_output:
bad:
if (ret != USB_RET_SUCCESS)
{
if (ret == USB_RET_NOT_RESPONDING)
return 0;
if (command != NULL && (!strncmp("boot", command, 4) && ret == USB_RET_IO))
return 0;
if (command != NULL && (!strncmp("boot", command, 4))) {
if (ret == USB_RET_IO || ret == USB_RET_NO_DEVICE || ret == USB_RET_NOT_RESPONDING)
return 0;
}
LOG(LOG_ERROR, "USB error: %s", usb_strerror(ret));
return ret;
}
@@ -149,19 +160,28 @@ int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned i
ret = USBBulkUpload(handle, buf, buf_len);
if (ret == USB_RET_SUCCESS)
{
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
if (verbose < 3 || verbose > 4) {
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
} else {
if (checkrain_options_enabled(host_flags, host_option_no_colors))
printf("/send mem:%p:%p\nUploaded %llu bytes]\n", (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
else
printf("/send mem:%p:%p\n" BCYN "[Uploaded %llu bytes]\n" CRESET, (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
}
}
}
if (verbose >= 3) printf("pongoOS> ");
return ret;
}
void io_start(stuff_t *stuff)
{
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, &stuff->handle);
int r = pthread_create(&stuff->th, NULL, (pthread_start_t)pongo_usb_callback, stuff);
if(r != 0)
{
ERR("pthread_create: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
set_spin(0);
return;
}
pthread_join(stuff->th, NULL);
}
@@ -172,14 +192,19 @@ void io_stop(stuff_t *stuff)
if(r != 0)
{
ERR("pthread_cancel: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
set_spin(0);
return;
}
r = pthread_join(stuff->th, NULL);
if(r != 0)
{
ERR("pthread_join: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
set_spin(0);
return;
}
#ifdef USE_LIBUSB
libusb_unref_device(stuff->dev);
#endif
}
void write_stdout(char *buf, uint32_t len)
+59 -58
View File
@@ -38,7 +38,7 @@
#include <sys/stat.h> // fstst
#include <palerain.h>
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
#define ERR(...) LOG(LOG_ERROR, __VA_ARGS__)
void io_start(stuff_t *stuff);
void io_stop(stuff_t *stuff);
@@ -114,12 +114,12 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len)
static int FoundDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *arg)
{
LOG(LOG_VERBOSE, "PongoOS USB Device connected");
stuff_t *stuff = arg;
if(stuff->handle)
{
return LIBUSB_SUCCESS;
}
LOG(LOG_VERBOSE, "PongoOS USB Device connected");
libusb_device_handle *handle;
int r = libusb_open(dev, &handle);
@@ -162,15 +162,16 @@ static int FoundDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_e
static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *arg)
{
LOG(LOG_VERBOSE, "PongoOS USB Device disconnected");
stuff_t *stuff = arg;
if(stuff->dev != dev)
{
return LIBUSB_SUCCESS;
}
LOG(LOG_VERBOSE, "PongoOS USB Device disconnected");
io_stop(stuff);
libusb_close(stuff->handle);
libusb_unref_device(dev);
stuff->handle = NULL;
stuff->dev = NULL;
@@ -180,9 +181,11 @@ static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_ev
int wait_for_pongo(void)
{
stuff_t stuff;
stuff.handle = NULL;
libusb_hotplug_callback_handle hp[2];
libusb_context* ctx = NULL;
int r = libusb_init(NULL);
int r = libusb_init(&ctx);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_init: %s", libusb_error_name(r));
@@ -192,75 +195,73 @@ int wait_for_pongo(void)
if(!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG))
{
ERR("libusb: no hotplug capability");
libusb_exit(NULL);
libusb_exit(ctx);
return -1;
}
r = libusb_hotplug_register_callback(NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, 0, PONGO_USB_VENDOR, PONGO_USB_PRODUCT, LIBUSB_HOTPLUG_MATCH_ANY, FoundDevice, &stuff, &hp[0]);
r = libusb_hotplug_register_callback(ctx, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, 0, PONGO_USB_VENDOR, PONGO_USB_PRODUCT, LIBUSB_HOTPLUG_MATCH_ANY, LostDevice, &stuff, &hp[1]);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_hotplug: %s", libusb_error_name(r));
libusb_exit(NULL);
libusb_exit(ctx);
return -1;
}
r = libusb_hotplug_register_callback(NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, 0, PONGO_USB_VENDOR, PONGO_USB_PRODUCT, LIBUSB_HOTPLUG_MATCH_ANY, LostDevice, &stuff, &hp[1]);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_hotplug: %s", libusb_error_name(r));
libusb_exit(NULL);
return -1;
}
libusb_device **list;
ssize_t sz = libusb_get_device_list(NULL, &list);
if(sz < 0)
{
ERR("libusb_get_device_list: %s", libusb_error_name((int)sz));
libusb_exit(NULL);
return -1;
}
for(ssize_t i = 0; i < sz; ++i)
{
struct libusb_device_descriptor desc;
r = libusb_get_device_descriptor(list[i], &desc);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_get_device_descriptor: %s", libusb_error_name(r));
// continue anyway
}
if(desc.idVendor != PONGO_USB_VENDOR || desc.idProduct != PONGO_USB_PRODUCT)
{
libusb_unref_device(list[i]);
continue;
}
r = FoundDevice(NULL, list[i], LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, &stuff);
for(ssize_t j = i + 1; j < sz; ++j)
{
libusb_unref_device(list[j]);
}
if(r != LIBUSB_SUCCESS)
{
libusb_free_device_list(list, 0);
libusb_exit(NULL);
return -1;
}
break;
}
libusb_free_device_list(list, 0);
while(get_spin())
{
r = libusb_handle_events(NULL);
while (1) {
r = libusb_handle_events(ctx);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_handle_events: %s", libusb_error_name(r));
break;
}
libusb_device **list;
ssize_t sz = libusb_get_device_list(ctx, &list);
bool done = false;
if(sz < 0)
{
ERR("libusb_get_device_list: %s", libusb_error_name((int)sz));
libusb_exit(ctx);
return -1;
}
for(ssize_t i = 0; i < sz; ++i)
{
struct libusb_device_descriptor desc;
r = libusb_get_device_descriptor(list[i], &desc);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_get_device_descriptor: %s", libusb_error_name(r));
// continue anyway
}
if(desc.idVendor != PONGO_USB_VENDOR || desc.idProduct != PONGO_USB_PRODUCT)
{
libusb_unref_device(list[i]);
continue;
}
r = FoundDevice(ctx, list[i], LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, &stuff);
for (ssize_t j = i; j < sz; ++j) {
libusb_unref_device(list[j]);
}
if(r != LIBUSB_SUCCESS)
{
libusb_free_device_list(list, 0);
libusb_exit(ctx);
return -1;
} else {
done = true;
}
break;
}
libusb_free_device_list(list, 0);
if (done) goto end;
}
libusb_exit(NULL);
return 0;
end:
libusb_exit(ctx);
return 0;
}
#endif