Compare commits

...
Author SHA1 Message Date
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
Nick Chan 3388b36c22 cmake fixes 2023-02-11 19:30:55 +08:00
Nick Chan 1bf0ff5574 add credits printing 2023-02-11 19:23:57 +08:00
Nick Chan 6e324f1b54 allow proceed with no ramdisk or binpack 2023-02-11 01:25:08 +08:00
Nick Chan 96cadc4105 allow not embedding resources 2023-02-10 22:34:29 +08:00
junepark678 c2c3f527c6 fix the cmakelists 2023-02-10 18:49:00 +08:00
Nick Chan 70d71f20e8 flower requested changes 2023-02-10 18:08:29 +08:00
b2f8c26282 Change from Makefile to CMake (#4)
* add "build" into .gitignore for future out-of-source compilation

* help me this is a break point not to be committed

* help me this is a break point not to be committed again

* Fix many major problems
1. Fix deps so that a script can download the deps instead of some special
 actions build.yml runner step
2. Fix CMakeLists.txt so that it (partially) works
   It is still **NOT** recommended to use cmake for the build as it is currently not functional
3. Add to gitignore so that git doesn't track a bunch of generated files

* fix deps

* change the dep_root population into git submodules. I succeeded in finding git repos for all.

* fix all issues and fix ftp settings

* change all to cmake

* fix CMakeLists.txt so that it doesn't suck as much

* switch from ftp to artifacts

* fix more issues in src/CMakeLists.txt

* fix more issues in src/CMakeLists.txt again

* fix more issues in src/CMakeLists.txt again again

* add passcode info for A11

* better description formatting

* add the 3s wait

* dfuhelper: lowercase steps except for first letter

* i cant spell

* made C99 compliant

* turn into valid c99

* fix more issues in src/CMakeLists.txt again again again

* Use xcode instead of makefiles

* fix deps again

* fix deps again again

* fix deps again again again

* add "build" into .gitignore for future out-of-source compilation

* help me this is a break point not to be committed

* help me this is a break point not to be committed again

* Fix many major problems
1. Fix deps so that a script can download the deps instead of some special
 actions build.yml runner step
2. Fix CMakeLists.txt so that it (partially) works
   It is still **NOT** recommended to use cmake for the build as it is currently not functional
3. Add to gitignore so that git doesn't track a bunch of generated files

* change the dep_root population into git submodules. I succeeded in finding git repos for all.

* fix all issues and fix ftp settings

* change all to cmake

* fix CMakeLists.txt so that it doesn't suck as much

* switch from ftp to artifacts

* fix more issues in src/CMakeLists.txt

* fix more issues in src/CMakeLists.txt again

* fix more issues in src/CMakeLists.txt again again

* made C99 compliant

* turn into valid c99

* fix more issues in src/CMakeLists.txt again again again

* Use xcode instead of makefiles

* fix deps again again again

* make more fixes

* help me

* Revert "help me"

This reverts commit 866d3669d8aa90bcd7eda0412aea8cb05f42389c.

* fix most issues with compiling hopefully

* make more fixes again

* make more fixes again

* make more fixes again

* make more fixes again

* add gpm

* fix gpm patches

* go back to automake popt

* help me

* make popt hopefully listen

* make popt hopefully listen

* FUCK NEWT

* idk

* add CMAKE_BUILD_TYPE work

* fix checkra1n xxd issues

* fix binary locations

* fix binary locations again

* fix binary locations again

* try ftp again

* try to fix ftp bugs

* try to fix ftp bugs again

* Update build.yml

* try to fix ftp bugs again

* try to find where final executable is

* fix all the issues (hopefully)

* fix all the issues (hopefully) again

* fix all the issues (hopefully) again again

* finalize build.yml

* finalize build.yml v2

* finalize build.yml v2

* finalize build.yml v4

* finalize build.yml v5

* finalize build.yml v6

* finalize build.yml v7

* finalize build.yml v8

* finalize build.yml v9

* finalize build.yml v10

* finalize build.yml v10

* finalize build.yml v12

* finalize build.yml v13
fuck off amfi

* finalize build.yml v14
fuck off amfi

* finalize build.yml v15
fuck you macos build times

* finalize build.yml v16
fuck you macos build times

* finalize build.yml v17
fuck you macos build times

* finalize build.yml v17
fuck you macos build times

* finalize build.yml v19
fuck you macos build times

* finalize build.yml v20
fuck you macos build times
FUCK AMFI

* finalize build.yml v21
fuck you macos build times
FUCK AMFI

fix so that it downloads build time not configure time

* finalize build.yml v23
fuck you macos build times
FUCK AMFI

fix so that libs aren't broken

* finalize build.yml v23
fuck you macos build times
FUCK AMFI

fix so that libs aren't broken

* finalize build.yml v25
fuck you macos build times
FUCK AMFI

fix so that libs aren't broken

* finalize build.yml v25
well pagure just fucked up everything

* finalize build.yml v26
find pls work

* finalize build.yml v26
now, remove submodules because of pagure

* finalize build.yml v27

HELPPPPPPPPP

* finalize build.yml v27

fix linux

* finalize build.yml v27

fix linux again

* finalize build.yml v27

fix linux again again

* finalize build.yml v27

fix mac again

* finalize build.yml v27

fix mac again again

* finalize build.yml v30

fix mac again again again

* finalize build.yml v32

fix mac again again again again

* finalize build.yml v32

fix mac again again again again again

* finalize build.yml v32

fix mac again again again again again again

* finalize build.yml v32

fix mac again again again again again again again

* add lto

* fix some library issues

* fix more issues

* fix more issues

* add lto to deps

* try dynamic code finding with cmake and find_library.

* fix more issues ( make static build )

* fix more issues ( make static build )

* fix more issues ( make static build )

* fix more issues ( make static build )

* fuck libusb

* fuck cmake add_executable only once

* fuck version change

* fuck version change

* fuck version change

* fuck version change

* fix more stuff

* rename usbmuxd to libusbmuxd

* fix linking issues

* remove static on MacOS

* add binary artifacts on MacOS

* Revert "add binary artifacts on MacOS"

This reverts commit 43799af8134609cbce7bdd231db6c4e16fe019ee.

* remove -D lines

* move to C99

* remove submodules

* various changes
1. remove submodules
2. fix build.yml
3. add trailing spaces
4. add TSAN

---------

Co-authored-by: Nick Chan <[email protected]>
Co-authored-by: Tom E <[email protected]>
Co-authored-by: Nebula <[email protected]>
2023-02-10 15:56:58 +08:00
Nick Chan f0478ffb43 fixes 2023-02-10 01:28:47 +08:00
Nick Chan 17f3517c01 need to be return huh 2023-02-10 01:18:33 +08:00
Nick Chan 8b7b199384 add test1 and test2 flag support 2023-02-09 09:21:37 +08:00
Nick Chan 93302942c5 also run when modifying yml itself 2023-02-08 18:15:16 +08:00
Nick Chan 7b0821367a dont run on absolutely every change 2023-02-08 18:11:55 +08:00
Nick Chan 3082392397 skip some steps on pull request 2023-02-08 18:07:59 +08:00
Nick Chan 3d5441fba2 remove LTO 2023-02-08 17:44:36 +08:00
Nick Chan 5c15ad4ac4 workaround invalid system headers 2023-02-08 17:31:25 +08:00
junepark678 9d9f030e30 Add lto to dependency libraries 2023-02-08 17:15:18 +08:00
Nick Chan bee42e422f return 0 2023-02-08 17:14:43 +08:00
Nick Chan 550ce0bd1c condition libusb include 2023-02-08 17:14:00 +08:00
Nick Chan 01531fabda fix libirecovery ios 2023-02-08 17:04:45 +08:00
Nick Chan 3f6aa81fb4 iokit usb backend 2023-02-08 16:50:12 +08:00
Mineek 53399b11d4 huh 2023-02-07 15:38:47 +01:00
Mineek 84287eba8e I have a mbp 2012 2023-02-07 15:37:52 +01:00
Nick Chan 90759eb293 dumb stdlib headers 2023-02-07 17:17:16 +08:00
Nick Chan 50f8dc37b9 test 3 2023-02-07 17:02:03 +08:00
Nick Chan c219f96c1d more fixes 2023-02-07 16:53:44 +08:00
Nick Chan 2415d7d4ee fixes 2023-02-07 16:43:33 +08:00
Nick Chan 8138d582ab define _GNU_SOURCE 2023-02-07 16:25:33 +08:00
Nick Chan 907ac98c9c turn into valid c99 2023-02-07 16:19:06 +08:00
Nick Chan a6f8181211 made C99 compliant 2023-02-07 16:07:55 +08:00
Nick Chan 47a5a9443d i cant spell 2023-02-07 09:18:44 +08:00
Nebula 21e205dea6 dfuhelper: lowercase steps except for first letter 2023-02-06 17:34:48 -05:00
Tom E 3785a77232 add the 3s wait 2023-02-06 17:33:08 -05:00
Nick Chan 09f63da485 better description formatting 2023-02-07 00:05:22 +08:00
Nick Chan a35be8497e add passcode info for A11 2023-02-07 00:00:10 +08:00
Tom E b7bbcf5bb7 🥺 2023-02-06 08:04:05 -05:00
Tom E c25644e70d i think nick's cat keeps accidentally pressing keys 2023-02-06 08:01:51 -05:00
Tom E 08a0838518 more typo 2023-02-06 07:58:45 -05:00
Tom E 20c3be4446 fix typos 2023-02-06 07:55:43 -05:00
Nick Chan 7e8b616708 s/qbut/but/g 2023-02-06 20:50:28 +08:00
Nick Chan a809a91af2 add bugs section 2023-02-06 18:55:37 +08:00
Nick Chan 84a2654f24 fix even more manpage typos 2023-02-06 17:30:20 +08:00
Nick Chan 020ebdb41c organize documentation 2023-02-06 16:33:59 +08:00
Nick Chan 4158d6a0aa Documents arguments properly 2023-02-06 16:28:09 +08:00
Nick Chan bd15cadb6c omg it is -o not --o 2023-02-06 16:13:51 +08:00
Nick Chan 74d161cdd8 imagine having an iBridgeq 2023-02-06 16:12:18 +08:00
Nick Chan fc94b29d5f add css 2023-02-06 16:08:14 +08:00
Nick Chan bbdfa9b7a2 run apt-get update 2023-02-06 15:58:11 +08:00
Nick Chan 7c7f08f422 build documentation 2023-02-06 15:53:02 +08:00
Nick Chan c647520062 get rid of .q 2023-02-06 15:34:18 +08:00
Nick Chan 4a14826629 jailbreak is not jailbrak fr 2023-02-06 15:22:18 +08:00
Nick Chan 349cb81752 add palera1n.1 2023-02-06 15:20:50 +08:00
Nick Chan e3aad1a249 fix dumb unlink issue 2023-02-06 11:27:26 +08:00
Nick Chan 6127bdb3d6 palerain.h 2023-02-06 01:03:29 +08:00
Nick Chan 6f88b0cd26 fix f12 when not on button in options 2023-02-05 17:41:05 +08:00
Nick Chan 89ed9e7565 require 80x24 2023-02-05 17:27:58 +08:00
Nick Chan dc9065dd76 unset tui_started after finishing 2023-02-05 16:19:54 +08:00
Nick Chan b518a88354 fixes 2023-02-05 16:16:19 +08:00
Nick Chan 020fdd4939 fix kernel command line 2023-02-05 16:04:16 +08:00
Nick Chan 1524ed9440 tui log 2023-02-05 15:04:42 +08:00
Nick Chan 597280c3c6 custom colors 2023-02-05 14:37:01 +08:00
Nick Chan d3edd09550 fix iphoneos 2023-02-05 13:20:31 +08:00
Nick Chan cc62982233 more fixes 2023-02-05 03:25:12 +08:00
Nick Chan 3f60d435ee color scheme fixes 2023-02-05 03:13:20 +08:00
Nick Chan c112de8d23 fix flower chain 2023-02-05 03:00:29 +08:00
Nick Chan 5f5210b08d make tui bigger but within 80x24 2023-02-05 02:42:12 +08:00
Nick Chan c2a452d3b1 fixes 2 2023-02-04 21:47:53 +08:00
Nick Chan 42a47d656c fixes 2023-02-04 21:42:25 +08:00
Nick Chan f22bee6870 newt ui 2023-02-04 21:29:49 +08:00
Nick Chan ad2cb43392 fix newt 2023-02-04 20:13:13 +08:00
Nick Chan 1ae665cf41 real 2023-02-04 20:00:09 +08:00
Nick Chan 2519850712 fixes 2023-02-04 19:54:47 +08:00
Nick Chan 82eece415e fixes 2023-02-04 19:40:57 +08:00
Nick Chan 92ff35ae13 PATCH gpm 2023-02-04 19:09:54 +08:00
Nick Chan 78b5f7d75e gpm doesnt exist on mac 2023-02-04 18:59:31 +08:00
Nick Chan 32d5f6a4df k ill autogen 2023-02-04 18:58:53 +08:00
Nick Chan d48988ef83 forgot autoreconf 2023-02-04 18:55:12 +08:00
Nick Chan 686a753ff5 more O to curl 2023-02-04 18:50:44 +08:00
Nick Chan d006f1a2ae try build newt 2023-02-04 18:47:16 +08:00
Nick Chan f69f964d04 just in case 2023-02-03 14:44:26 +08:00
Nick Chan 4692a33dc0 galaxy requested changes 2023-02-03 13:22:07 +08:00
48 changed files with 3143 additions and 936 deletions

No files matched your search

+320 -163
View File
@@ -2,10 +2,48 @@ name: Build palera1n
on:
push:
paths:
- 'src/**'
- 'docs/**'
- 'patches/**'
- 'include/**'
- 'Makefile'
- 'CMakeLists.txt'
- '.github/workflows/build.yml'
pull_request:
workflow_dispatch:
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies (packages)
run: |
sudo apt-get -y update
sudo apt-get -y install mandoc make
- name: Build Documentation
run: |
make -j$(nproc) docs
mkdir ready
cp docs/*.html docs/mandoc.css docs/palera1n.1 ready
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
build-darwin:
strategy:
matrix:
@@ -21,13 +59,14 @@ 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
LIBUSB_VERSION: 1.0.26
READLINE_VERSION: 8.2
NCURSES_VERSION: 6.4
SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23
POPT_VERSION: 1.19
steps:
- name: Checkout
@@ -38,33 +77,39 @@ jobs:
- name: Install dependencies (packages)
run: |
sudo /usr/local/bin/pip3 install jsonschema jinja2
brew install make autoconf automake pkg-config gnu-sed ncurses
brew install make autoconf automake pkg-config gnu-sed gettext
sudo rm -rf /usr/local/Frameworks/Python*
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64
sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid
- name: Download dependencies (embedded binaries)
run: |
make -j5 download-deps
echo "SDK=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)" >> $GITHUB_ENV
- name: Download dependencies (source code)
run: |
curl -LOOOO \
curl -LOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
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
- name: Select correct Xcode
run: |
sudo xcode-select -s /Applications/Xcode_14.2.app
- name: Setup environment
run: |
mkdir sysroot
@@ -75,18 +120,24 @@ 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" >> $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" >> $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" >> $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 "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
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration" >> $GITHUB_ENV
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV
echo $(echo $(brew --cellar)/ncurses/*/bin/tic | sed 's|/tic||') >> $GITHUB_PATH
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: |
@@ -119,50 +170,13 @@ jobs:
gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h
- name: Build ncurses
run: |
cd ncurses-${{ env.NCURSES_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-build-cc="${{ env.CC }}" \
--with-build-cflags="${{ env.CFLAGS_FOR_NUILD }}" \
--with-build-cpp="${{ env.CC }} -E" \
--with-build-cppflags="${{ env.CPPFLAGS_FOR_BUILD }}" \
--with-build-ldflags="${{ env.LDFLAGS_FOR_BUILD }}" \
--with-pthread \
--enable-const \
--enable-ext-colors \
--enable-ext-mouse \
--enable-ext-putwin \
--enable-wattr-macros \
--disable-overwrite \
--without-debug \
--without-tests \
--enable-sigwinch \
--enable-const \
--enable-symlinks \
--enable-termcap \
--enable-pc-files \
--without-x11-rgb \
--with-tic-path=$(echo $(brew --cellar)/ncurses/*/bin/tic) \
--includedir="${{ env.PREFIX }}/include" \
--with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \
--enable-widec \
--with-default-terminfo-dir="/opt/procursus/share/terminfo" \
--with-terminfo-dirs="/var/jb/usr/share/terminfo:/opt/procursus/share/terminfo:/opt/local/share/terminfo:/opt/homebrew/share/terminfo:/usr/local/share/terminfo:/opt/sw/share/terminfo:/sw/share/terminfo:/usr/share/terminfo" \
LDFLAGS="${{ env.LDFLAGS }}" \
PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig" || (cat config.log && exit 1)
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build Mbed TLS
run: |
cd mbedtls-${{ env.MBEDTLS_VERSION }}
cat ../patches/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
mkdir build
cd build
cmake .. \
SDKROOT="${{ env.SDK }}" cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_SYSTEM_NAME=Darwin \
@@ -175,19 +189,8 @@ jobs:
-DENABLE_PROGRAMS=OFF \
-DMBEDTLS_FATAL_WARNINGS=OFF \
-DCMAKE_INSTALL_SYSCONFDIR="/etc"
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libusb
run: |
cd libusb-${{ env.LIBUSB_VERSION }}
if [ "${{ matrix.os }}" != "macosx" ]; then
curl -Lo libusb.patch https://github.com/ProcursusTeam/Procursus/raw/5f4f302f6cb81ce10c7d92ffefd75c004b5da18f/build_patch/libusb/0001-Get-rid-of-some-macro-checks.patch
cat libusb.patch | patch -sN -d . -p1
fi
./configure ${{ env.CONFIGURE_ARGS }} --disable-udev --enable-log
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) \
SDKROOT="${{ env.SDK }}"
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
@@ -199,6 +202,51 @@ jobs:
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build S-Lang
run: |
cd slang-${{ env.SLANG_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-x \
--without-pcre \
--without-onig \
--without-z \
--without-png \
--without-iconv
gmake -j$(sysctl -n hw.ncpu) static
gmake -j$(sysctl -n hw.ncpu) install-static DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build popt
run: |
cd popt-popt-${{ env.POPT_VERSION }}-release
autoreconf -fiv
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-libiconv-prefix \
--without-libintl-prefix \
--disable-nls \
--disable-werror
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build newt
run: |
cd newt-${{ env.NEWT_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-readline=gnu \
--without-python \
--without-tcl \
--disable-nls
gmake -j$(sysctl -n hw.ncpu) libnewt.a
mkdir -p ${{ env.DESTDIR }}/usr/local/{lib/pkgconfig,include}
install -m644 libnewt.pc ${{ env.DESTDIR }}/usr/local/lib/pkgconfig
install -m644 libnewt.a ${{ env.DESTDIR }}/usr/local/lib
install -m644 newt.h ${{ env.DESTDIR }}/usr/local/include
cd ..
- name: Build libplist
run: |
cd libplist
@@ -223,10 +271,9 @@ jobs:
cd libirecovery
autoreconf -fiv
if [ "${{ matrix.os }}" != "macosx" ]; then
./configure ${{ env.CONFIGURE_ARGS }} --with-iokit=no
else
./configure ${{ env.CONFIGURE_ARGS }}
gsed -i '/case kIOUSBTransactionTimeout/d' src/libirecovery.c
fi
./configure ${{ env.CONFIGURE_ARGS }}
echo -e 'all:\ninstall:' > tools/Makefile
make -j$(sysctl -n hw.ncpu) LIBS="-lncurses"
make -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
@@ -255,19 +302,23 @@ jobs:
- name: Build palera1n
run: |
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
if [ "${{ matrix.os }}" = "macosx" ]; then
gmake -j$(sysctl -n hw.ncpu)
elif [ "${{ matrix.os }}" = "iphoneos" ]; then
gmake -j$(sysctl -n hw.ncpu) FAKE_PLATFORM=2 FAKE_SDK=14.0 FAKE_MINOS=14.0
fi
find dep_root -name '*.dylib' -delete
find dep_root -name '*.la' -delete
gmake -j$(sysctl -n hw.ncpu)
mkdir -p ready
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: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
@@ -279,19 +330,8 @@ jobs:
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
- name: Upload artifact
uses: wangyucode/[email protected]
with:
host: ${{ secrets.MINEEK_FTP_HOST }}
port: 22
username: mineekfiles
password: ${{ secrets.MINEEK_FTP_PASS }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/uploads/palera1n/artifacts/palera1n-c'
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} build
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}
@@ -299,6 +339,7 @@ jobs:
retention-days: 1
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} debug symbols
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
@@ -306,9 +347,22 @@ jobs:
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
@@ -327,7 +381,81 @@ 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||')
# 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_${version}_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_${version}_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_${version}_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_${version}_iphoneos-arm64.deb
mv palera1n*.deb ready/
rm -rf stage
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
@@ -339,18 +467,6 @@ jobs:
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
- name: Upload artifact
uses: wangyucode/[email protected]
with:
host: ${{ secrets.MINEEK_FTP_HOST }}
port: 22
username: mineekfiles
password: ${{ secrets.MINEEK_FTP_PASS }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/uploads/palera1n/artifacts/palera1n-c'
build-Linux:
strategy:
matrix:
@@ -364,7 +480,10 @@ jobs:
MBEDTLS_VERSION: 3.3.0
LIBUSB_VERSION: 1.0.26
READLINE_VERSION: 8.2
NCURSES_VERSION: 6.4
SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23
GPM_VERSION: 1.20.7
POPT_VERSION: 1.19
steps:
- name: Checkout
@@ -374,8 +493,8 @@ jobs:
- name: Install build dependencies (packages)
run: |
sudo apt remove -y libssl-dev libreadline-dev
sudo apt install -y pkg-config autoconf automake
sudo apt-get remove -y libssl-dev libreadline-dev
sudo apt-get install -y pkg-config autoconf automake autopoint mandoc
sudo pip3 install jsonschema jinja2
- name: Download toolchain checksum
@@ -403,15 +522,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
@@ -426,67 +549,34 @@ jobs:
mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
- name: Download dependencies (embedded binaries)
run: |
make -j5 download-deps
- name: Download dependencies (source code)
run: |
curl -LOOOO \
curl -LOOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
https://github.com/telmich/gpm/archive/refs/tags/${{ env.GPM_VERSION }}.tar.gz \
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
tar -xf ${{ env.GPM_VERSION }}.tar.gz
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
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
- name: Build ncurses
run: |
cd ncurses-${{ env.NCURSES_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-build-cc="cc" \
--with-build-cflags=" " \
--with-build-cpp="cc -E" \
--with-build-cppflags=" " \
--with-build-ldflags=" " \
--enable-const \
--enable-ext-colors \
--enable-ext-mouse \
--enable-ext-putwin \
--enable-wattr-macros \
--with-pthread \
--disable-overwrite \
--without-debug \
--without-tests \
--enable-sigwinch \
--enable-const \
--enable-symlinks \
--enable-termcap \
--enable-pc-files \
--without-x11-rgb \
--with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \
--includedir="${{ env.PREFIX }}/include" \
--enable-widec \
--with-default-terminfo-dir="/usr/share/terminfo" \
--with-terminfo-dirs="/usr/share/terminfo:/lib/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo:/data/data/com.termux/files/usr/share/terminfo" \
LDFLAGS="${{ env.LDFLAGS }}" \
PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig"
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build Mbed TLS
run: |
cd mbedtls-${{ env.MBEDTLS_VERSION }}
cat ../patches/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
mkdir build
cd build
cmake .. \
@@ -522,6 +612,63 @@ jobs:
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build S-Lang
run: |
cd slang-${{ env.SLANG_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-x \
--without-pcre \
--without-onig \
--without-z \
--without-png \
--without-iconv
gmake -j$(sysctl -n hw.ncpu) static
gmake -j$(sysctl -n hw.ncpu) install-static DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build GPM
run: |
cd gpm-${{ env.GPM_VERSION }}
cat ../patches/gpm/*.patch | patch -sN -d . -p1
./autogen.sh
./configure \
${{ env.CONFIGURE_ARGS }}
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build popt
run: |
cd popt-popt-${{ env.POPT_VERSION }}-release
autoreconf -fiv
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-libiconv-prefix \
--without-libintl-prefix \
--disable-nls \
--disable-werror
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build newt
run: |
cd newt-${{ env.NEWT_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-readline=gnu \
--without-python \
--without-tcl \
--disable-nls \
--with-gpm-support
gmake -j$(sysctl -n hw.ncpu) libnewt.a
mkdir -p ${{ env.DESTDIR }}/usr/local/{lib/pkgconfig,include}
install -m644 libnewt.pc ${{ env.DESTDIR }}/usr/local/lib/pkgconfig
install -m644 libnewt.a ${{ env.DESTDIR }}/usr/local/lib
install -m644 newt.h ${{ env.DESTDIR }}/usr/local/include
cd ..
- name: Build libplist
run: |
cd libplist
@@ -579,7 +726,7 @@ jobs:
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.so' -delete
find dep_root -name '*.la' -delete
make -j$(nproc) CC="${{ matrix.triple }}-gcc" palera1n
CC="${{ matrix.triple }}-gcc" make -j$(nproc)
- name: Seperate debug symbols
run: |
@@ -595,7 +742,29 @@ jobs:
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||')
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_${version}_${{ env.ARCH_NAME }}.deb
mv palera1n*.deb ready/
rm -rf stage
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
@@ -606,15 +775,3 @@ jobs:
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
- name: Upload artifact
uses: wangyucode/[email protected]
with:
host: ${{ secrets.MINEEK_FTP_HOST }}
port: 22
username: mineekfiles
password: ${{ secrets.MINEEK_FTP_PASS }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/uploads/palera1n/artifacts/palera1n-c'
+10 -2
View File
@@ -1,5 +1,5 @@
dep_root/**
contrib/**
dep_root/**
!dep_root/.keep
!contrib/.keep
contrib/
@@ -8,9 +8,17 @@ contrib/
checkra1n*
payload.c
src/palera1n
palera1n*
!xxd-embedded.h
src/binpack.dmg
src/ramdisk.dmg
src/xxd-*.c
.DS_Store
!palera1n.1
palera1n.1.html
Payload
docs/*.html
build
src/*.dmg.c
.idea
src/stage2/
src/libcheckra1nhelper.dylib*
+32 -8
View File
@@ -1,34 +1,42 @@
NAME = Tumbleweed
SRC = $(shell pwd)
DEP = $(SRC)/dep_root
STRIP = strip
CC ?= cc
CFLAGS += -I$(DEP)/include -I$(DEP)/include/ncursestw -I$(SRC)/include -I$(SRC)
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
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE
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
ifeq ($(TARGET_OS),)
TARGET_OS = $(shell uname -s)
endif
ifeq ($(TARGET_OS),Darwin)
CFLAGS += -Wno-nullability-extension
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
LIBS += $(DEP)/lib/libusb-1.0.a
ifeq ($(DEV_BUILD),1)
LIBS += $(DEP)/lib/libmenutw.a $(DEP)/lib/libncursestw.a
LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
ifeq ($(TARGET_OS),Linux)
LIBS += $(DEP)/lib/libgpm.a
endif
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
@@ -36,13 +44,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 CFLAGS LDFLAGS LIBS TARGET_OS DEV_BUILD BUILD_DATE BUILD_TAG BUILD_WHOAMI BUILD_STYLE BUILD_NUMBER BUILD_BRANCH
all: palera1n
@@ -51,12 +71,16 @@ palera1n: download-deps
clean:
$(MAKE) -C src 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
docs:
$(MAKE) -C docs
distclean: clean
rm -rf palera1n-* palera1n*.dSYM src/checkra1n-* src/checkra1n-kpf-pongo src/ramdisk.dmg src/binpack.dmg
.PHONY: all palera1n clean
.PHONY: all palera1n clean docs distclean
+65 -77
View File
@@ -1,97 +1,85 @@
<h1 align="center">
palera1n
</h1>
<img align="left" height="120" src="https://cdn.discordapp.com/attachments/1017854329887129611/1073858292159352862/thing.png" alt="palera1n logo" style="float: left;"/>
<h3 align="right">An iOS 15.0-16.3.1 work-in-progress, <br>semi-tethered checkm8 jailbreak</h3>
<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 align="right" >
<strong><a href="https://cdn.nickchan.lol/palera1n/c-rewrite/releases/v2.0.0-beta.4/palera1n.1.html">Usage</a></strong>
•
<strong><a href="https://github.com/palera1n/palera1n/graphs/contributors">Contributors</a></strong>
•
<strong><a href="https://dsc.gg/palera1n">Discord</a></strong>
•
<strong><a href="https://twitter.com/palera1n">Twitter</a></strong>
</p>
<div class="clear"></div>
<p align="center">
iOS 15.0-16.3 work in progress, semi-tethered checkm8 jailbreak
</p>
### You can obtain v2.0.0 beta [here](https://github.com/palera1n/palera1n/releases).
If you need an older v2.0.0 beta, please get it [here](https://github.com/palera1n/palera1n-c/releases/tag/v2.0.0-beta.4).
# BEFORE YOU USE
# Warnings
- This palera1n rewrite has noticeably different arguments compared to the shell version of palera1n.
- Highly recommended that you take a look at how to use palera1n-c [here](https://cdn.nickchan.lol/palera1n/c-rewrite/releases/v2.0.0-beta.1/palera1n.1.html).
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.
- This does **NOT** support tethered creation or booting. You must use the older [shell version of palera1n](https://github.com/palera1n/palera1n/tree/legacy) (clone with `-b legacy`).
This version of palera1n supports booting fakefs setups with the `-f` option. No arguments required.
- 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 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.
- palera1n will never work in VirtualBox, VMware or any virtual machine that doesn't support PCI passthrough.
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).
# 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).
If the device is previously jailbroken, the jailbreak environment is automatically prepared.
You can use the `-s` option to skip this behaviour.
- **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>
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)
- 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
You can obtain the latest build of palera1n-c [here](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/).
# Need help?
# This is a work in progress.
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.
Read this throughly, feel free to ask questions, know the risks. If you want to ask questions, either:
Using `-V` and `-v` would help with debugging.
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).-->
Join the [Support Discord](https://dsc.gg/palera1n), and find the palera1n-c thread under #jailbreak [here](https://discord.com/channels/1028398973452570725/1074251283143344180).
# Credits
<details><summary>palera1n-c Contributors and Credits</summary>
<p>
- [Nebula](https://github.com/itsnebulalol), palera1n owner and Python rewrite lead developer
- [Nathan](https://github.com/verygenericname)
- [Nick Chan](https://github.com/asdfugil) for the rewrite
- [Nebula](https://github.com/itsnebulalol) - palera1n owner and manager
- [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
- [Tom](https://github.com/plooshi) for updated ploosh kpf and universal loader
- [Lakhan Lothiyi](https://github.com/llsc12) for 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>
</p>
+9
View File
@@ -0,0 +1,9 @@
PAGES = palera1n.1.html
all: $(PAGES)
%.1.html: %.1
mandoc -T html -O style=mandoc.css palera1n.1 > palera1n.1.html
clean:
rm -f $(PAGES)
+269
View File
@@ -0,0 +1,269 @@
/* $OpenBSD: mandoc.css,v 1.35 2021/03/30 19:23:50 schwarze Exp $ */
/*
* Standard style sheet for mandoc(1) -Thtml and man.cgi(8).
*
* Written by Ingo Schwarze <[email protected]>.
* I place this file into the public domain.
* Permission to use, copy, modify, and distribute it for any purpose
* with or without fee is hereby granted, without any conditions.
*/
/* Global defaults. */
html {
--bg: #FFFFFF;
--fg: #000000; }
body { background: var(--bg);
color: var(--fg);
font-family: monospace,Helvetica,Arial,sans-serif;
max-width: 80ch;
margin: 1em auto;
padding: 0 1ch;
}
h1 { font-size: 110%; }
table { margin-top: 0em;
margin-bottom: 0em;
border-collapse: collapse; }
/* Some browsers set border-color in a browser style for tbody,
* but not for table, resulting in inconsistent border styling. */
tbody { border-color: inherit; }
tr { border-color: inherit; }
td { vertical-align: top;
padding-left: 0.2em;
padding-right: 0.2em;
border-color: inherit; }
ul, ol, dl { margin-top: 0em;
margin-bottom: 0em; }
li, dt { margin-top: 1em; }
pre { font-family: inherit; }
.permalink { border-bottom: thin dotted;
color: inherit;
font: inherit;
text-decoration: inherit; }
* { clear: both }
/* Search form and search results. */
form {
position: sticky;
top: 0px;
background-color: var(--bg);
z-index: 1;
}
fieldset { border: thin solid silver;
border-radius: 0.3em;
text-align: center; }
input[name=expr] {
width: 25%; }
table.results { margin-top: 1em;
margin-left: 2em;
font-size: smaller; }
/* Header and footer lines. */
table.head { width: 100%;
border-bottom: 1px dotted #808080;
margin-bottom: 1em;
font-size: smaller;
overflow-wrap: anywhere; }
td.head-vol { text-align: center; }
td.head-rtitle {
text-align: right; }
table.foot { width: 100%;
border-top: 1px dotted #808080;
margin-top: 1em;
font-size: smaller;
overflow-wrap: anywhere; }
td.foot-os { text-align: right; }
table.Nm {
overflow-wrap:anywhere;
}
/* Sections and paragraphs. */
.manual-text {
margin-left: 3.8em; }
h1.Sh { margin-top: 1.2em;
margin-bottom: 0.6em;
margin-left: -3.2em; }
h2.Ss { margin-top: 1.2em;
margin-bottom: 0.6em;
margin-left: -1.2em;
font-size: 105%; }
.Pp { margin: 0.6em 0em; }
/* Displays and lists. */
.Bd-indent { margin-left: 3.8em; }
.Bl-bullet { list-style-type: disc;
padding-left: 1em; }
.Bl-dash { list-style-type: none;
padding-left: 0em; }
.Bl-dash > li:before {
content: "\2014 "; }
.Bl-item { list-style-type: none;
padding-left: 0em; }
.Bl-compact > li {
margin-top: 0em; }
.Bl-enum { padding-left: 2em; }
.Bl-compact > li {
margin-top: 0em; }
.Bl-diag > dt {
font-style: normal;
font-weight: bold; }
.Bl-diag > dd {
margin-left: 0em; }
.Bl-hang > dd {
margin-left: 5.5em; }
.Bl-inset > dd {
margin-left: 0em; }
.Bl-ohang > dd {
margin-left: 0em; }
.Bl-tag { margin-top: 0.6em;
margin-left: 5.5em; }
.Bl-tag > dt {
float: left;
margin-top: 0em;
margin-left: -5.5em;
padding-right: 0.5em;
vertical-align: top; }
.Bl-tag > dd {
clear: right;
column-count: 1; /* Force block formatting context. */
width: 100%;
margin-top: 0em;
margin-left: 0em;
margin-bottom: 0.6em;
vertical-align: top; }
.Bl-compact { margin-top: 0em; }
.Bl-compact > dd {
margin-bottom: 0em; }
.Bl-compact > dt {
margin-top: 0em; }
.Bl-column > tbody > tr > td {
margin-top: 1em; }
.Bl-compact > tbody > tr > td {
margin-top: 0em; }
.Rs { font-style: normal;
font-weight: normal; }
.RsB { font-style: italic;
font-weight: normal; }
.RsI { font-style: italic;
font-weight: normal; }
.RsJ { font-style: italic;
font-weight: normal; }
.RsT { text-decoration: underline; }
.tbl td { vertical-align: middle; }
.HP { margin-left: 3.8em;
text-indent: -3.8em; }
/* Semantic markup for command line utilities. */
code.Nm { font-style: normal;
font-weight: bold;
font-family: inherit;
overflow-wrap: normal; }
.Fl { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Cm { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ar { font-style: italic;
font-weight: normal; }
.Op { display: inline; }
.Ic { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ev { font-style: normal;
font-weight: normal;
font-family: monospace; }
.Pa { font-style: italic;
font-weight: normal; }
/* Semantic markup for function libraries. */
code.In { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Fd { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ft { font-style: italic;
font-weight: normal; }
.Fn { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Fa { font-style: italic;
font-weight: normal; }
.Vt { font-style: italic;
font-weight: normal; }
.Va { font-style: italic;
font-weight: normal; }
.Dv { font-style: normal;
font-weight: normal;
font-family: monospace; }
.Er { font-style: normal;
font-weight: normal;
font-family: monospace; }
/* Various semantic markup. */
.Cd { font-style: normal;
font-weight: bold;
font-family: inherit; }
.Ad { font-style: italic;
font-weight: normal; }
.Ms { font-style: normal;
font-weight: bold; }
/* Physical markup. */
.Bf { display: inline; }
.No { font-style: normal;
font-weight: normal; }
.Em { font-style: italic;
font-weight: normal; }
.Sy { font-style: normal;
font-weight: bold; }
.Li { font-style: normal;
font-weight: normal;
font-family: monospace; }
/* Overrides to avoid excessive margins on small devices. */
@media (max-width: 37.5em) {
.manual-text {
margin-left: 0.5em; }
h1.Sh, h2.Ss { margin-left: 0em; }
.Bd-indent { margin-left: 2em; }
.Bl-hang > dd {
margin-left: 2em; }
.Bl-tag { margin-left: 2em; }
.Bl-tag > dt {
margin-left: -2em; }
.HP { margin-left: 2em;
text-indent: -2em; }
}
/* Overrides for a dark color scheme for accessibility. */
@media (prefers-color-scheme: dark) {
html { --bg: #000000;
--fg: #FFFFFF; }
:link { color: #BAD7FF; }
:visited { color: #BAD7FF; }
}
+343
View File
@@ -0,0 +1,343 @@
.\"-
.\" Copyright (c) 2023 Nick Chan
.\" SPDX-License-Identifier: MIT
.\"
.Dd "20 March 2023"
.Dt palera1n 1
.Sh NAME
.Nm palera1n
.Nd iOS 15.0-16.3.1 arm64 iOS/iPadOS jailbreaking tool
.Sh SYNOPSIS
.Nm
.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
.Sh DESCRIPTION
.Nm
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.3.1,
utilizing the
.Em checkm8
bootROM exploit.
.Pp
.Nm
is able to jailbreak the device in fakefs-rootful mode, where /
is writable, as well as rootless mode, where / cannot be written to.
.Pp
Due to the nature of the
.Em checkm8
exploit,
.Nm
is semi-tethered. That is, you must run the
.Nm
tool after the device reboot in order to enter the jailbroken state.
However, it is not required for the device to boot.
.Pp
On A11 devices, that is, iPhone 8, iPhone 8 Plus and iPhone X, the passcode cannot
be used.
.Pp
On iOS 15, the passcode must be off while jailbroken.
.Pp
On iOS 16, the passcode must be off since restore, and
.Sy Reset All Contents and Settings
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 15.0-16.3.1 devices are supported, here is an explicit
list of supported devicecs:
.Bl -tag -compact
.It iPhone 6s
.It iPhone 6s Plus
.It iPhone SE (2016)
.It iPhone 7
.It iPhone 7 Plus
.It iPhone 8
.It iPhone 8 Plus
.It iPhone X
.El
.Bl -tag -compact
.It iPad mini 4
.It iPad Air 2
.It iPad (5th generation)
.It iPad (6th generation)
.It iPad (7th generation)
.It iPad Pro (9.7")
.It iPad Pro (12.9") (1st generation)
.It iPad Pro (10.5")
.It iPad Pro (12.9") (2nd generation)
.El
.Bl -tag -compact
.It iPod Touch (7th generation)
.El
Support for other arm64 Darwin devices, including Apple TV, HomePod and iBridge
on Darwin 21 and above could be added, but they are currently unsupported.
arm64e devices will NEVER be supported.
.Sh OPTIONS
.Bl -tag -width -indent
.It Fl -version
Prints the program version and exit.
.It Fl -force-revert
Remove the jailbreak while keeping user data. Some jailbreak files may remain
after running this command. Additionally, jailbreak apps will remain on the
home screen on for a while even when the files are deleted as the icon cache
still has their icons. When used with
.Fl f , -fakefs ,
this will actually boot the device in rootless mode then delete the jailbreak
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 ,
creates the new APFS volume required for rootful. Will fail if one already exists.
.It Fl d , -demote
Set the effective production fuse to 0, so as to enable hardware debugging features.
.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
Specify custom XNU kernel command line. The
.Em rootdev=md0
argument is used by
.Nm
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.
.It Fl f , -fakefs
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
Specify the path to a custom checkra1n file.
.It Fl k , -override-pongo Ar pongo file
Override PongoOS image. The raw image, named
.Em Pongo.bin
when built, should be used. PongoOS 2.6.0 or later is required.
.It Fl K , -override-kpf Ar KPF file
Override the kernel patchfinder PongoOS module. The module is required to support setting
root filesystem in paleinfo with
.Em rootfs
command. If in doubt, use
.Sy https://github.com/guacaplushy/PongoOS
iOS15 branch or your own fork of it.
.It Fl l , -rootless
Proceed in rootless mode, this is the default when neither
.Fl l , -rootless
and
.Fl f , -fakefs
is specified.
.Fl L , -jbinit-log-to-file
Makes jbinit log to
.Em /cores/jbinit.log
This file may be viewed from sandboxed applications while jailbroken.
.It Fl n , -exit-recovery
Exit recovery mode and exit.
.It Fl o , -override-overlay Ar overlay file
Specify the path to a custom overlay file, which is then mounted onto /cores/binpack
during boot, if the default ramdisk is used. The default ramdisk expects the overlay
to contain a folder named
.Em Applications
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 p , -pongo-shell
Exit after booting into a clean PongoOS shell
.It Fl P , -pongo-full
Like
.Fl p , -pongo-shell
but default images and options have been uploaded and applied respectively.
.It Fl r , -override-ramdisk Ar ramdisk file
Override the ramdisk. At a very minimum, it should contain a
.Em /sbin/launchd
as well as a fake dyld
.Em /usr/lib/dyld
where the logic is expected to be in.
.It Fl R , -reboot-device
Reboot device in normal mode and exit.
.It Fl s , -safe-mode
Enter safe mode. An alert will be displayed. Jailbreak daemons nor early boot executable files
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 Ev TMPDIR
This environmental variable should contain the a directory for temporary
files. Without the
.Fl i , -override-checkra1n
option, files must be executable from it as the built-in checkra1n file
is extracted and executed here. When not set, /tmp is used.
.El
.Sh EXAMPLES
To (re-)jailbreak in rootless mode:
.Pp
.Dl "palera1n"
.Pp
To setup fakefs for rootful mode:
.Pp
.Dl "palera1n -fc"
.Pp
After the device has rebooted, follow the following example.
.Pp
To re-jailbreak in rootful mode:
.Pp
.Dl "palera1n -f"
.Pp
To remove the jailbreak in rootful mode:
.Pp
.Dl "palera1n --force-revert -f"
.Pp
To remove the jailbreak in rootless mode:
.Pp
.Dl "palera1n --force-revert"
.Pp
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"
.Pp
.Sh CAVEATS
.Pp
.Em -v
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
option when jailbreaking.
.Pp
Fakefs takes up around 5-10 GB of storage, and take up to 10 minutes to setup.
.Pp
iOS 15.0 requires DER entitlements, and iOS 15.1 requires hash agility in code signatures.
As a result, binaries with the old code signature format need to be resigned with a recent
version of the Procursus fork of
.Xr ldid 1
before they can be ran on a device jailbroken with
.Nm
\[char46]
.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
.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
.Em Sileo
package manager.
You can install other package managers from settings of the loader app.
.Sh FILES
During the jailbreak process, a temporary filesystem is mounted on /cores as a place
to stash jailbreak files needed during the boot process. No files are ever written
onto the actual disk if you do not use the SSH server to write files or using the
loader app to install additional jailbreak files.
.Bl -tag -width "/var/jb/Library/LaunchDaemons"
.It Pa /cores
The location of the temporary filesystem where jailbreak files are stash during boot.
.It Pa /cores/jbinit.log
When
.Fl L
is used, the log file of jbinit.
.It Pa /Library/LaunchDaemons
The directory where jailbreak-specific
.Xr launchd.plist 5
property list files should be placed on rootful.
.It Pa /var/jb/Library/LaunchDaemons
The directory where jailbreak-specific
.Xr launchd.plist 5
property list files should be placed on rootless.
.It Pa /etc/rc.d
The directory where executable filse that needs to be executed during boot, before
daemons are launched, are placed rootful. They are executed after all filesystems
has been mounted.
.It Pa /var/jb/etc/rc.d
The directory where executable files that needs to be executed during boot, before
daemons are launched, are placed on rootless. They are executed after all filesystems
has been mounted.
.El
.Sh BUGS
.Nm
may crash if the machine it is running on:
.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
.Fl B , -setup-fakefs-partial
does not work on iOS 16.
.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
.Xr ldid 1
.Sh HISTORY
The
.Nm
jailbreak was first written by Nebula and Mineek on September 26, 2022, as a shell
script. Tweak support with DEVELOPMENT kernels are added on October 2, 2022. RELEASE
kernel support is added on November 14, 2022. iOS 16 Support is added on
December 13, 2022. Later, the first attempt to rewrite palera1n into C begins on January
01 2023. The
.Nm
utility described here is the second attempt, which first started on January 16, 2023,
using checkra1n 1337 and the plush KPF.
+20
View File
@@ -0,0 +1,20 @@
curl -LOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.3.0.tar.gz \
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 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
tar xf newt-0.52.23.tar.gz
tar xf master-release.tar.gz
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
+59 -59
View File
@@ -8,78 +8,78 @@
#define ANSI_COLOR_CODES_H
//Regular text
#define BLK "\e[0;30m"
#define RED "\e[0;31m"
#define GRN "\e[0;32m"
#define YEL "\e[0;33m"
#define BLU "\e[0;34m"
#define MAG "\e[0;35m"
#define CYN "\e[0;36m"
#define WHT "\e[0;37m"
#define BLK "\033[0;30m"
#define RED "\033[0;31m"
#define GRN "\033[0;32m"
#define YEL "\033[0;33m"
#define BLU "\033[0;34m"
#define MAG "\033[0;35m"
#define CYN "\033[0;36m"
#define WHT "\033[0;37m"
//Regular bold text
#define BBLK "\e[1;30m"
#define BRED "\e[1;31m"
#define BGRN "\e[1;32m"
#define BYEL "\e[1;33m"
#define BBLU "\e[1;34m"
#define BMAG "\e[1;35m"
#define BCYN "\e[1;36m"
#define BWHT "\e[1;37m"
#define BBLK "\033[1;30m"
#define BRED "\033[1;31m"
#define BGRN "\033[1;32m"
#define BYEL "\033[1;33m"
#define BBLU "\033[1;34m"
#define BMAG "\033[1;35m"
#define BCYN "\033[1;36m"
#define BWHT "\033[1;37m"
//Regular underline text
#define UBLK "\e[4;30m"
#define URED "\e[4;31m"
#define UGRN "\e[4;32m"
#define UYEL "\e[4;33m"
#define UBLU "\e[4;34m"
#define UMAG "\e[4;35m"
#define UCYN "\e[4;36m"
#define UWHT "\e[4;37m"
#define UBLK "\033[4;30m"
#define URED "\033[4;31m"
#define UGRN "\033[4;32m"
#define UYEL "\033[4;33m"
#define UBLU "\033[4;34m"
#define UMAG "\033[4;35m"
#define UCYN "\033[4;36m"
#define UWHT "\033[4;37m"
//Regular background
#define BLKB "\e[40m"
#define REDB "\e[41m"
#define GRNB "\e[42m"
#define YELB "\e[43m"
#define BLUB "\e[44m"
#define MAGB "\e[45m"
#define CYNB "\e[46m"
#define WHTB "\e[47m"
#define BLKB "\033[40m"
#define REDB "\033[41m"
#define GRNB "\033[42m"
#define YELB "\033[43m"
#define BLUB "\033[44m"
#define MAGB "\033[45m"
#define CYNB "\033[46m"
#define WHTB "\033[47m"
//High intensty background
#define BLKHB "\e[0;100m"
#define REDHB "\e[0;101m"
#define GRNHB "\e[0;102m"
#define YELHB "\e[0;103m"
#define BLUHB "\e[0;104m"
#define MAGHB "\e[0;105m"
#define CYNHB "\e[0;106m"
#define WHTHB "\e[0;107m"
#define BLKHB "\033[0;100m"
#define REDHB "\033[0;101m"
#define GRNHB "\033[0;102m"
#define YELHB "\033[0;103m"
#define BLUHB "\033[0;104m"
#define MAGHB "\033[0;105m"
#define CYNHB "\033[0;106m"
#define WHTHB "\033[0;107m"
//High intensty text
#define HBLK "\e[0;90m"
#define HRED "\e[0;91m"
#define HGRN "\e[0;92m"
#define HYEL "\e[0;93m"
#define HBLU "\e[0;94m"
#define HMAG "\e[0;95m"
#define HCYN "\e[0;96m"
#define HWHT "\e[0;97m"
#define HBLK "\033[0;90m"
#define HRED "\033[0;91m"
#define HGRN "\033[0;92m"
#define HYEL "\033[0;93m"
#define HBLU "\033[0;94m"
#define HMAG "\033[0;95m"
#define HCYN "\033[0;96m"
#define HWHT "\033[0;97m"
//Bold high intensity text
#define BHBLK "\e[1;90m"
#define BHRED "\e[1;91m"
#define BHGRN "\e[1;92m"
#define BHYEL "\e[1;93m"
#define BHBLU "\e[1;94m"
#define BHMAG "\e[1;95m"
#define BHCYN "\e[1;96m"
#define BHWHT "\e[1;97m"
#define BHBLK "\033[1;90m"
#define BHRED "\033[1;91m"
#define BHGRN "\033[1;92m"
#define BHYEL "\033[1;93m"
#define BHBLU "\033[1;94m"
#define BHMAG "\033[1;95m"
#define BHCYN "\033[1;96m"
#define BHWHT "\033[1;97m"
//Reset
#define reset "\e[0m"
#define CRESET "\e[0m"
#define COLOR_RESET "\e[0m"
#define reset "\033[0m"
#define CRESET "\033[0m"
#define COLOR_RESET "\033[0m"
#endif
+26 -1
View File
@@ -58,6 +58,31 @@
#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 */
#ifdef DEV_BUILD
#define palerain_option_test1 (1 << 29)
#define palerain_option_test2 (1 << 30)
#endif
// 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
#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 */
// (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'
@@ -111,4 +136,4 @@ static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_
return (flags & opt) != 0;
}
#endif
#endif
+88 -25
View File
@@ -1,5 +1,9 @@
#ifndef COMMON_H
#define COMMON_H
#ifndef PALERAIN_H
#define PALERAIN_H
#if defined(__APPLE__)
#define _DARWIN_C_SOURCE 1
#endif
#include "xxd-embedded.h"
#include "kerninfo.h"
@@ -10,16 +14,59 @@
#include <usbmuxd.h>
#include <libirecovery.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libusb-1.0/libusb.h>
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define CLEAR() printf("\33[2K\r");
#define palerain_option_case(x) (512 + x)
#define palerain_option_version 129
#define CMD_LEN_MAX 512
#define OVERRIDE_MAGIC 0xd803b376
#define palerain_option_case_version palerain_option_case(0)
#define palerain_option_case_force_revert palerain_option_case(1)
#ifdef USE_LIBUSB
#include <libusb-1.0/libusb.h>
#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;
typedef struct stuff
{
pthread_t th;
libusb_device *dev;
usb_device_handle_t handle;
} stuff_t;
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#include <IOKit/IOKitLib.h>
#include <IOKit/usb/IOUSBLib.h>
#include <IOKit/IOCFPlugIn.h>
#pragma clang diagnostic pop
#define USB_RET_SUCCESS KERN_SUCCESS
#define USB_RET_NOT_RESPONDING kIOReturnNotResponding
#define USB_RET_IO kIOReturnNotReady
#define USB_RET_NO_DEVICE kIOReturnNoDevice
typedef IOReturn usb_ret_t;
typedef IOUSBInterfaceInterface245 **usb_device_handle_t;
typedef struct
{
pthread_t th;
volatile uint64_t regID;
IOUSBDeviceInterface245 **dev;
usb_device_handle_t handle;
} stuff_t;
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, uint32_t len);
#endif
#ifndef PALERAIN_VERSION
#define PALERAIN_VERSION "2.0.0"
@@ -53,6 +100,12 @@ struct mach_header_64
};
#endif
// Keep in sync with Pongo
#define PONGO_USB_VENDOR 0x05ac
#define PONGO_USB_PRODUCT 0x4141
#define CMD_LEN_MAX 512
#define UPLOADSZ_MAX (1024 * 1024 * 128)
typedef enum {
LOG_FATAL = 0,
LOG_ERROR = 1,
@@ -92,19 +145,17 @@ typedef struct {
} override_file_t;
typedef unsigned char niarelap_file_t[];
typedef int usb_ret_t;
typedef libusb_device_handle *usb_device_handle_t;
extern unsigned int verbose;
extern int demote;
extern char* pongo_path;
extern bool dfuhelper_only, pongo_exit;
#ifdef DEV_BUILD
extern bool use_tui;
extern bool tui_started;
#endif
extern checkrain_option_t host_flags;
extern checkrain_option_p host_flags_p;
extern pthread_t dfuhelper_thread, pongo_thread;
extern int pongo_thr_running, dfuhelper_thr_running;
@@ -117,27 +168,25 @@ extern pthread_mutex_t log_mutex;
extern pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
extern int enable_rootful, demote;
extern int pongo_thr_running, dfuhelper_thr_running;
extern bool ohio, pongo_full, device_has_booted;
extern bool device_has_booted;
extern char xargs_cmd[0x270];
extern char checkrain_flags_cmd[0x20];
extern char palerain_flags_cmd[0x20];
extern char kpf_flags_cmd[0x20];
extern char dtpatch_cmd[0x20];
extern char rootfs_cmd[512];
extern bool palerain_version;
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);
@@ -146,26 +195,40 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
int autoboot_cmd(const uint64_t ecid);
int exitrecv_cmd(const uint64_t ecid);
void 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);
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);
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
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);
#endif
void write_stdout(char *buf, uint32_t len);
void io_start(stuff_t *stuff);
void io_stop(stuff_t *stuff);
void print_credits(void);
#ifdef DEV_BUILD
#include <newt.h>
newtComponent get_tui_log();
newtComponent set_tui_log(newtComponent co);
#endif
#endif
+13 -9
View File
@@ -1,8 +1,5 @@
#ifndef TUI_H
#define TUI_H
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -13,14 +10,16 @@
#include <string.h>
#include <locale.h>
#include <unistd.h>
#include <newt.h>
#define MAIN_OPTIONS "Options"
#define MAIN_START "Start"
#define MAIN_EXIT "Exit"
#define BACK_BUTTON "Back"
#define WIDTH 76
#define HEIGHT 19
#define MSG_COLOR 1
#define ICON_COLOR 2
#define PI_LOG_COLOR NEWT_COLORSET_CUSTOM(0)
#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) ? '*' : ' '
typedef enum tui_screens {
ERROR_SCREEN = -1,
@@ -32,6 +31,11 @@ typedef enum tui_screens {
ENTER_RECOVERY_SCREEN = 5
} tui_screen_t;
typedef struct bitfield_checkbox_info {
checkrain_option_p flags_p;
checkrain_option_t opt;
} tui_bit_info_t;
tui_screen_t tui_screen_main();
tui_screen_t tui_screen_options();
tui_screen_t tui_screen_enter_recovery();
+10 -1
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,9 @@ extern unsigned int ramdisk_dmg_len;
extern unsigned char binpack_dmg[];
extern unsigned int binpack_dmg_len;
#endif
#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.3.1 semi-tethered checkm8 jailbreak
palera1n is an iOS/iPadOS 15.0-15.3.1 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.3.1 semi-tethered checkm8 jailbreak
palera1n is an iOS/iPadOS 15.0-15.3.1 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.
+23
View File
@@ -0,0 +1,23 @@
Description: Add no-op option -V for compatibility
Index: b/src/daemon/cmdline.c
===================================================================
--- a/src/daemon/cmdline.c 2008-05-29 02:26:08.000000000 +0300
+++ b/src/daemon/cmdline.c 2008-06-11 05:46:23.000000000 +0300
@@ -32,7 +32,7 @@
void cmdline(int argc, char **argv)
{
extern struct options option;
- char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:Tuv23";
+ char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV23";
int opt;
/* initialize for the dual mouse */
@@ -81,6 +81,7 @@ void cmdline(int argc, char **argv)
case 'u': option.autodetect = 1; break;
case 'T': opt_test++; break;
case 'v': printf(GPM_MESS_VERSION "\n"); exit(0);
+ case 'V': /* Compat code */ break;
case '2': (which_mouse->opt_three) = -1; break;
case '3': (which_mouse->opt_three) = 1; break;
default: exit(usage("commandline"));
+39
View File
@@ -0,0 +1,39 @@
Description: source code of gpm_has_mouse_control helper
Index: b/contrib/control/gpm_has_mouse_control.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ b/contrib/control/gpm_has_mouse_control.c 2007-12-10 08:25:45.000000000 +0200
@@ -0,0 +1,20 @@
+#include <sys/fcntl.h>
+#include <sys/kd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+
+int main (int argc, char **argv)
+{
+ int fd;
+ int mode;
+ fd = open ("/dev/tty0", O_RDONLY);
+ if (fd == -1)
+ fd = open ("/dev/vc/0", O_RDONLY);
+ if (fd == -1)
+ perror ("open");
+ if (ioctl (fd, KDGETMODE, &mode) != 0)
+ perror ("ioctl");
+ exit(mode);
+}
+
Index: b/contrib/control/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ b/contrib/control/Makefile 2007-12-10 08:25:45.000000000 +0200
@@ -0,0 +1,7 @@
+CC := gcc
+
+all: gpm_has_mouse_control.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpm_has_mouse_control -Wall gpm_has_mouse_control.c
+
+clean:
+ -rm -f gpm_has_mouse_control
+107
View File
@@ -0,0 +1,107 @@
Description: Use MAX_NR_CONSOLES instead of MAX_VC
--- a/src/daemon/gpm.c
+++ b/src/daemon/gpm.c
@@ -93,7 +93,7 @@
int fifofd=-1;
int eventFlag=0;
-Gpm_Cinfo *cinfo[MAX_VC+1];
+Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1];
time_t last_selection_time;
time_t opt_age_limit = 0;
--- a/src/daemon/old_main.c
+++ b/src/daemon/old_main.c
@@ -141,7 +141,7 @@
signal(SIGWINCH,gpm_killed); /* reinstall handler */
/* and notify clients */
- for(i=0; i<MAX_VC+1; i++) {
+ for(i=0; i<=MAX_NR_CONSOLES; i++) {
Gpm_Cinfo *ci;
for (ci = cinfo[i]; ci; ci = ci->next) kill(ci->data.pid,SIGWINCH);
}
@@ -214,7 +214,7 @@
/*........................ got request */
/* itz 10-22-96 check _all_ clients, not just those on top! */
- for (i=0; pending && (i<=MAX_VC); i++) {
+ for (i=0; pending && (i<=MAX_NR_CONSOLES); i++) {
Gpm_Cinfo* ci;
for (ci = cinfo[i]; pending && ci; ci = ci->next) {
if (FD_ISSET(ci->fd,&selSet)) {
--- a/src/daemon/processconn.c
+++ b/src/daemon/processconn.c
@@ -67,8 +67,8 @@
return -1;
}
- if((vc = request->vc) > MAX_VC) {
- gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_VC);
+ if((vc = request->vc) > MAX_NR_CONSOLES) {
+ gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_NR_CONSOLES);
free(info);
close(newfd);
return -1;
--- a/src/daemon/processrequest.c
+++ b/src/daemon/processrequest.c
@@ -41,7 +41,7 @@
gpm_report(GPM_PR_INFO, GPM_MESS_CON_REQUEST, ci->fd, vc);
- if (vc>MAX_VC) return -1;
+ if (vc>MAX_NR_CONSOLES) return -1;
/* itz 10-22-96 this shouldn't happen now */
if (vc==-1) gpm_report(GPM_PR_OOPS, GPM_MESS_UNKNOWN_FD);
--- a/src/headers/daemon.h
+++ b/src/headers/daemon.h
@@ -26,6 +26,7 @@
*/
#include "gpm.h" /* Gpm_Event */
#include <sys/select.h> /* fd_set */
+#include <linux/vt.h> /* for cinfo -- to be moved to os/linux in 2.x! */
/*************************************************************************
* Types / structures
@@ -104,13 +105,6 @@
* Macros
*/
-/* How many virtual consoles are managed? */
-#ifndef MAX_NR_CONSOLES
-# define MAX_NR_CONSOLES 64 /* this is always sure */
-#endif
-
-#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */
-
/* for adding a mouse; add_mouse */
#define GPM_ADD_DEVICE 0
#define GPM_ADD_TYPE 1
@@ -174,7 +168,7 @@
extern int eventFlag;
extern struct winsize win;
-extern Gpm_Cinfo *cinfo[MAX_VC+1];
+extern Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1];
extern struct mouse_features mouse_table[3],
*which_mouse; /*the current one*/
--- a/src/headers/gpmCfg.h
+++ b/src/headers/gpmCfg.h
@@ -32,14 +32,6 @@
#include <linux/tty.h>
#endif
-/* FIXME: still needed ?? */
-/* How many virtual consoles are managed? */
-#ifndef MAX_NR_CONSOLES
-# define MAX_NR_CONSOLES 64 /* this is always sure */
-#endif
-
-#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */
-
/* How many buttons may the mouse have? */
/* #define MAX_BUTTONS 3 ===> not used, it is hardwired :-( */
+13
View File
@@ -0,0 +1,13 @@
Description: Add AC_CANONICAL_HOST
--- a/configure.ac.footer
+++ b/configure.ac.footer
@@ -35,6 +35,8 @@
# Find programs
#
+AC_CANONICAL_HOST
+
AC_PROG_CC
AC_PROG_LIBTOOL
AC_PROG_INSTALL
@@ -0,0 +1,16 @@
Description: Fix FTBFS with -Wformat-security
Author: Axel Beckert <[email protected]>
Bug-Debian: https://bugs.debian.org/888792
Bug-Debian: https://bugs.debian.org/888797
--- a/src/lib/report-lib.c
+++ b/src/lib/report-lib.c
@@ -47,7 +47,7 @@
log_level = LOG_CRIT; break;
}
#ifdef HAVE_VSYSLOG
- syslog(log_level, string);
+ syslog(log_level, "%s", string);
vsyslog(log_level, text, ap);
#else
fprintf(stderr,"%s[%s(%d)]:\n",string,file,line);
+133
View File
@@ -0,0 +1,133 @@
Description: Fix spelling errors found by lintian
Author: Axel Beckert <[email protected]>
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -132,7 +132,7 @@
to keep hold of processor time for at least 1 second).
- no pnp vendor will be able to support three buttons any more (no
more mouse protocols, all mice must behave the same).
- - similary, only 1200 baud devices (any serial device) are supported,
+ - similarly, only 1200 baud devices (any serial device) are supported,
because the initialization string of pnp devices only tells
the vendor and release, with no information about required
port configuration.
--- a/doc/doc.gpm.in
+++ b/doc/doc.gpm.in
@@ -394,7 +394,7 @@
automatically forces the @emph{repeater} (@samp{\-R}) option on.
@item \-o @var{list-of-extra-options}
- The option works similary to the ``\-o'' option of mount; it is
+ The option works similarly to the ``\-o'' option of mount; it is
used to specify a list of ``extra options'' that are specific
to each mouse type. The list is comma-separated. The options
@samp{dtr}, @samp{rts} or @samp{both} are used by the serial
--- a/src/daemon/old_main.c
+++ b/src/daemon/old_main.c
@@ -190,7 +190,7 @@
/*....................................... got mouse, process event */
/*
* Well, actually, run a loop to maintain inlining of functions without
- * lenghtening the file. This is not too clean a code, but it works....
+ * lengthening the file. This is not too clean a code, but it works....
*/
for (i=1; i <= 1+opt_double; i++) {
--- a/src/mice.c
+++ b/src/mice.c
@@ -122,7 +122,7 @@
break;
}
if (p->type == ARGV_END) { /* not found */
- fprintf(stderr, "%s: Uknown option \"%s\" for pointer \"%s\"\n",
+ fprintf(stderr, "%s: Unknown option \"%s\" for pointer \"%s\"\n",
option.progname, argv[i], argv[0]);
errors++;
continue;
--- a/src/prog/mouse-test.c
+++ b/src/prog/mouse-test.c
@@ -524,7 +524,7 @@
Gpm_Event event;
if (packetsize!=cur->this->packetlen) {
- REMOVETYPE(cur,"different packet lenght");
+ REMOVETYPE(cur,"different packet length");
continue;
}
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2471,7 +2471,7 @@
#define PS2_SCALE_11 0xE6 /* Set scale to 1:1 */
-/* Normal ps2 responce */
+/* Normal ps2 response */
#define PS2_ERROR 0xFC /* Error, after a reset,resend or disconnect*/
#define PS2_ACK 0xFA /* Command acknowledge */
#define PS2_READY 0xAA /* Send after a calibration or ERROR */
@@ -2538,7 +2538,7 @@
}
# ifdef DEBUG_PUTBYTE_ACK
- gpm_report(GPM_PR_DEBUG,"Responce %X to byte %X",ack,b);
+ gpm_report(GPM_PR_DEBUG,"Response %X to byte %X",ack,b);
# endif
return ack;
@@ -2565,11 +2565,11 @@
/* Do some sanity checking */
if((response[0] & 0xFC) != 0x84) {
- gpm_report (GPM_PR_ERR,"Byte 0 of stick device responce is not valid");
+ gpm_report (GPM_PR_ERR,"Byte 0 of stick device response is not valid");
return -1;
}
if((response[3] & 0xCC) != 0xC4) {
- gpm_report (GPM_PR_ERR,"Byte 3 of stick device responce is not valid");
+ gpm_report (GPM_PR_ERR,"Byte 3 of stick device response is not valid");
return -1;
}
}
@@ -2844,7 +2844,7 @@
byte status,id_code = PS2_MOUSE_IDCODE;
byte reset_cmd = PS2_RESET;
- gpm_report(GPM_PR_DEBUG,"Reseting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad"));
+ gpm_report(GPM_PR_DEBUG,"Resetting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad"));
/* Send reset command without eating the ack. */
if(!stick) {
@@ -2871,11 +2871,11 @@
usleep(750000);
if ( (status = syn_ps2_getbyte(fd,stick)) != PS2_READY ){
- gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: No READY, got %02X.\n"
+ gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: No READY, got %02X.\n"
"Check pc_keyb.c for reconnect smartness.\n",status);
}
if ( (id_code = syn_ps2_getbyte(fd,stick)) != PS2_MOUSE_IDCODE){
- gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: Wrong ID, got %02X.\n",id_code);
+ gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: Wrong ID, got %02X.\n",id_code);
}
}
@@ -3155,7 +3155,7 @@
void syn_serial_reset(int fd)
{
- gpm_report (GPM_PR_INFO,"Reseting Synaptic Serial Touchpad.");
+ gpm_report (GPM_PR_INFO,"Resetting Synaptic Serial Touchpad.");
syn_serial_set_mode (fd, (RELATIVE_MODE |
HIGH_REPORT_RATE |
@@ -3247,7 +3247,7 @@
void syn_ps2_reset (int fd)
{
- gpm_report (GPM_PR_INFO,"Reseting Synaptic PS/2 Touchpad.");
+ gpm_report (GPM_PR_INFO,"Resetting Synaptic PS/2 Touchpad.");
/* Stop incoming motion data (of whatever kind absolute/relative). */
tp_ps2_disable_data(fd);
@@ -0,0 +1,63 @@
Origin: http://download.nutyx.org/x86_64/rolling/cli/gpm/gpm-1.20.7-consolidated-1.patch
Bug: https://github.com/telmich/gpm/issues/21
Bug-Debian: https://bugs.debian.org/886903
Bug-LFS: https://wiki.linuxfromscratch.org/blfs/ticket/9616#ticket
Author: tnut from nutyx.org, https://github.com/tnut
Description: Fix FTBFS with glibc 2.26
--- a/src/daemon/open_console.c
+++ b/src/daemon/open_console.c
@@ -24,6 +24,10 @@
#include <sys/ioctl.h> /* ioctl */
#include <sys/types.h> /* major() */
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h> /* major() w/newer glibc */
+#endif
+
/* Linux specific (to be outsourced in gpm2 */
#include <linux/serial.h> /* for serial console check */
#include <asm/ioctls.h> /* for serial console check */
--- a/src/prog/gpm-root.y
+++ b/src/prog/gpm-root.y
@@ -443,6 +443,7 @@
}
/*---------------------------------------------------------------------*/
+#if 0
static int f_debug_one(FILE *f, Draw *draw)
{
DrawItem *ip;
@@ -465,6 +466,7 @@
#undef LINE
return 0;
}
+#endif
int f_debug(int mode, DrawItem *self, int uid)
{
@@ -960,10 +962,8 @@
/*------------*/
static inline void scr_restore(int fd, FILE *f, unsigned char *buffer, int vc)
{
- int x,y, dumpfd;
+ int dumpfd;
char dumpname[20];
-
- x=buffer[2]; y=buffer[3];
/* WILL NOT WORK WITH DEVFS! FIXME! */
sprintf(dumpname,"/dev/vcsa%i",vc);
@@ -1196,11 +1196,7 @@
LOG_DAEMON : LOG_USER);
/* reap your zombies */
childaction.sa_handler=reap_children;
-#if defined(__GLIBC__)
- __sigemptyset(&childaction.sa_mask);
-#else /* __GLIBC__ */
- childaction.sa_mask=0;
-#endif /* __GLIBC__ */
+ sigemptyset(&childaction.sa_mask);
childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */
sigaction(SIGCHLD,&childaction,NULL);
@@ -0,0 +1,20 @@
Description: FTBFS with gcc-10 due to -fno-commons
Author: Sergei Trofimovich <[email protected]>
Reviewed-By: Helmut Grohne <[email protected]>
Origin: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f7e2ac82fc5a1847c132057fb7de1a996d66c76
Forwarded: https://github.com/telmich/gpm/pull/37
Bug: https://github.com/telmich/gpm/pull/37
Bug-Gentoo: https://bugs.gentoo.org/705878
Bug-Debian: https://bugs.debian.org/953266
--- a/src/headers/daemon.h
+++ b/src/headers/daemon.h
@@ -176,7 +176,7 @@
extern Gpm_Type mice[];
extern Gpm_Type *repeated_type;
-time_t last_selection_time;
+extern time_t last_selection_time;
@@ -0,0 +1,69 @@
Description: Add musl support
* Use SA_NODEFER instead of its non-standard alias SA_NOMASK.
* Add missing sys/select.h and fcntl.h includes.
* Use standard sigemptyset unconditionally.
* Define SA_INTERRUPT if it's not defined (historical no-op).
* With these changes gpm builds against musl libc.
Author: Szabolcs Nagy <[email protected]>
Bug-Debian: https://bugs.debian.org/813751
--- a/src/lib/liblow.c
+++ b/src/lib/liblow.c
@@ -179,7 +179,7 @@
/* Reincarnation. Prepare for another death early. */
sigemptyset(&sa.sa_mask);
sa.sa_handler = gpm_suspend_hook;
- sa.sa_flags = SA_NOMASK;
+ sa.sa_flags = SA_NODEFER;
sigaction (SIGTSTP, &sa, 0);
/* Pop the gpm stack by closing the useless connection */
@@ -386,7 +386,7 @@
/* if signal was originally ignored, job control is not supported */
if (gpm_saved_suspend_hook.sa_handler != SIG_IGN) {
- sa.sa_flags = SA_NOMASK;
+ sa.sa_flags = SA_NODEFER;
sa.sa_handler = gpm_suspend_hook;
sigaction(SIGTSTP, &sa, 0);
}
--- a/src/prog/display-buttons.c
+++ b/src/prog/display-buttons.c
@@ -36,6 +36,7 @@
#include <stdio.h> /* printf() */
#include <time.h> /* time() */
#include <errno.h> /* errno */
+#include <sys/select.h> /* fd_set, FD_ZERO */
#include <gpm.h> /* gpm information */
/* display resulting data */
--- a/src/prog/display-coords.c
+++ b/src/prog/display-coords.c
@@ -37,6 +37,7 @@
#include <stdio.h> /* printf() */
#include <time.h> /* time() */
#include <errno.h> /* errno */
+#include <sys/select.h> /* fd_set, FD_ZERO */
#include <gpm.h> /* gpm information */
/* display resulting data */
--- a/src/prog/gpm-root.y
+++ b/src/prog/gpm-root.y
@@ -1197,6 +1197,9 @@
/* reap your zombies */
childaction.sa_handler=reap_children;
sigemptyset(&childaction.sa_mask);
+#ifndef SA_INTERRUPT
+#define SA_INTERRUPT 0
+#endif
childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */
sigaction(SIGCHLD,&childaction,NULL);
--- a/contrib/control/gpm_has_mouse_control.c
+++ b/contrib/control/gpm_has_mouse_control.c
@@ -1,4 +1,4 @@
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <sys/kd.h>
#include <stdio.h>
#include <stdlib.h>
+62 -8
View File
@@ -1,9 +1,42 @@
all: palera1n
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o exec_checkra1n.o
OBJECTS += pongo_usb.o optparse.o override_file.o pongo_helper.o log.o
OBJECTS += xxd-checkra1n.o xxd-checkra1n-kpf-pongo.o xxd-ramdisk.dmg.o
OBJECTS += xxd-binpack.dmg.o lock_vars.o
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
endif
ifneq ($(NO_RAMDISK),1)
OBJECTS += xxd-ramdisk.dmg.o
else
CFLAGS += -DNO_RAMDISK
endif
ifneq ($(NO_KPF),1)
OBJECTS += xxd-checkra1n-kpf-pongo.o
else
CFLAGS += -DNO_KPF
endif
ifneq ($(NO_BINPACK),1)
OBJECTS += xxd-binpack.dmg.o
else
CFLAGS += -DNO_BINPACK
endif
ifneq ($(NO_CHECKRAIN),1)
OBJECTS += xxd-checkra1n.o
else
CFLAGS += -DNO_CHECKRAIN
endif
ifeq ($(DEV_BUILD),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
@@ -13,6 +46,22 @@ CHECKRA1N_VERSION ?= 0.1337.1
LIPO = lipo
LDID = ldid
ifeq ($(TARGET_OS),Darwin)
ifneq ($(USE_LIBUSB),1)
OBJECTS += usb_iokit.o
else
LIBS += -framework SystemConfiguration -framework Security
endif
else
USE_LIBUSB = 1
endif
ifeq ($(USE_LIBUSB),1)
OBJECTS += usb_libusb.o
CFLAGS += -DUSE_LIBUSB=1
LIBS += $(DEP)/lib/libusb-1.0.a
endif
checkra1n-%:
curl -LO https://assets.checkra.in/downloads/preview/$(CHECKRA1N_VERSION)/$@
chmod 755 $@
@@ -23,6 +72,8 @@ 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-macos
endif
@@ -42,7 +93,7 @@ endif
xxd-%.c: %
xxd -iC $< > $@
%.o: %.c
%.o: %.c $(wildcard ../include/*.h)
$(CC) -c $(CFLAGS) $<
palera1n: $(OBJECTS)
@@ -53,16 +104,19 @@ ifneq (,$(findstring version-min=, $(CFLAGS)))
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
curl -LO https://cdn.nickchan.lol/palera1n/artifacts/jbinit_rootless/ramdisk.dmg
binpack.dmg:
curl -LO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg
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
+23
View File
@@ -0,0 +1,23 @@
#include <stdio.h>
#ifndef BAKERAIN_DEVELOPE_R
#define BAKERAIN_DEVELOPE_R "dora2ios"
#endif
#define THE_PLUSH "Ploosh"
#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 ", Mineek, Nebula, llsc12\n#\n"
#define A "# Thanks to: " BAKERAIN_DEVELOPE_R ", pythonplayer, 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
+10 -8
View File
@@ -34,9 +34,10 @@
#include <libtvcontrol.h>
#endif
#include <common.h>
#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);
@@ -87,16 +88,17 @@ bool cpid_is_arm64(unsigned int cpid) {
int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb)
{
usbmuxd_subscribe(device_event_cb, NULL);
usbmuxd_events_subscribe(&usbmuxdctx, device_event_cb, NULL);
irecv_device_event_subscribe(&irecvctx, irecv_event_cb, NULL);
return 0;
}
int unsubscribe_cmd()
int unsubscribe_cmd(void)
{
usbmuxd_unsubscribe();
usbmuxd_events_unsubscribe(usbmuxdctx);
irecv_device_event_unsubscribe(irecvctx);
irecvctx = NULL;
usbmuxdctx = NULL;
return 0;
}
@@ -322,7 +324,7 @@ int passstat_cmd(unsigned char* status, const char* udid) {
{
if (passstat_status)
free(passstat_status);
passstat_status = NULL;
plist_free(node);
LOG(LOG_ERROR, "Error getting passcode state (invalid status)");
return -1;
@@ -363,9 +365,9 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
}
info->mode = mode;
info->cpid = device->chip_id;
strncpy(info->product_type, device->product_type, 0x20);
strncpy(info->display_name, device->display_name, 0x20);
strncpy(info->iboot_ver, (ibootver) ? ibootver : "", 0x20);
snprintf(info->product_type, 0x20, "%s", device->product_type);
snprintf(info->display_name, 0x20, "%s", device->display_name);
snprintf(info->iboot_ver, 0x20, "%s", (ibootver) ? ibootver : "");
free(ibootver);
irecv_close(client);
return 0;
+105 -31
View File
@@ -25,7 +25,7 @@
#include <usbmuxd.h>
#include <ANSI-color-codes.h>
#include <common.h>
#include <palerain.h>
#define FORMAT_KEY_VALUE 1
#define FORMAT_XML 2
@@ -36,12 +36,12 @@ 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\e[K%s (%d)" CRESET, text, time - i + time2);
printf(checkrain_option_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_option_enabled(host_flags, host_option_no_colors) ? "\r%s (%d)" : CYN "\r%s (%d)" CRESET, text, time2);
if (time2 == 0) puts("");
}
@@ -59,7 +59,8 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
return -1;
}
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
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) {
@@ -69,14 +70,33 @@ 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_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;
}
}
if (checkrain_option_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)) {
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
}
return 0;
}
@@ -91,43 +111,41 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
cpid = info->cpid;
ecid = info->ecid;
bdid = info->bdid;
#if defined(__APPLE__) || defined(__linux__)
pthread_setname_np("in.palera.recovery-mode-handler");
#endif
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;
}
LOG(LOG_INFO, "Press any key when ready for DFU mode");
LOG(LOG_INFO, "Press Enter when ready for DFU mode");
getchar();
step(3, 0, "Get ready", NULL, 0);
if (NOHOME)
step(4, 2, "Hold Volume Down + Side button", NULL, 0);
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;
step(4, 2, "Hold home + power button", NULL, 0);
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\e[K");
printf("\r\033[K");
bool nohome = NOHOME;
if (nohome)
step(2, 0, "Hold Volume Down + Side button", NULL, 0);
step(2, 0, "Hold volume down + side button", NULL, 0);
else
step(2, 0, "Hold Home + Power Button", NULL, 0);
step(2, 0, "Hold home + power button", NULL, 0);
if (nohome)
step(10, 0, "Hold Volume Down button", conditional, ecid);
step(10, 0, "Hold volume down button", conditional, ecid);
else
step(10, 0, "Hold Home button", conditional, ecid);
step(10, 0, "Hold home button", conditional, ecid);
if (get_ecid_wait_for_dfu() != ecid) {
} else {
LOG(LOG_WARNING, "Whoops, device did not enter DFU mode");
@@ -141,16 +159,13 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
}
void* connected_dfu_mode(struct irecv_device_info* info) {
#if defined(__APPLE__) || defined(__linux__)
pthread_setname_np("in.palera.dfu-mode-handler");
#endif
if (get_ecid_wait_for_dfu() == info->ecid) {
set_ecid_wait_for_dfu(0);
puts("");
LOG(LOG_INFO, "Device entered DFU mode successfully");
}
unsubscribe_cmd();
set_spin(0);
unsubscribe_cmd();
pthread_exit(NULL);
return NULL;
}
@@ -160,6 +175,16 @@ 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)) {
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();
pthread_exit(NULL);
break;
}
connected_normal_mode(&event->device);
break;
case UE_DEVICE_REMOVE:
@@ -174,10 +199,62 @@ void irecv_device_event_cb(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) {
LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid);
if (!checkrain_option_enabled(host_flags, host_option_device_info))
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_device_info)) {
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_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_device_info))
LOG(LOG_VERBOSE, "DFU mode device %ld connected", event->device_info->ecid);
if (checkrain_option_enabled(host_flags, host_option_device_info)) {
recvinfo_t info;
recvinfo_cmd(&info, event->device_info->ecid);
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_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)) {
break;
}
pthread_create(&dfu_thread, NULL, (void* (*)(void*))connected_dfu_mode, event->device_info);
}
break;
@@ -189,11 +266,8 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
void *dfuhelper(void* ptr) {
dfuhelper_thr_running = true;
#if defined(__APPLE__) || defined(__linux__)
pthread_setname_np("in.palera.dfu-helper");
#endif
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);
};
+85 -12
View File
@@ -11,41 +11,101 @@
#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 <common.h>
#include <palerain.h>
#include <xxd-embedded.h>
char* pongo_path = NULL;
char* ext_checkra1n = NULL;
void exec_checkra1n() {
#define tmpdir getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")
int exec_checkra1n(void) {
LOG(LOG_INFO, "About to execute checkra1n");
int fd, ret;
char checkra1n_path[] = "/tmp/checkra1n.XXXXXX";
char* checkra1n_path = NULL;
if (ext_checkra1n != NULL) {
checkra1n_path = ext_checkra1n;
goto checkra1n_exec;
}
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));
return;
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);
unlink(checkra1n_path);
return;
return -1;
}
close(fd);
ret = chmod(checkra1n_path, 0700);
if (ret) {
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
unlink(checkra1n_path);
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 = write(helper_fd, libcheckra1nhelper_dylib, libcheckra1nhelper_dylib_len);
if ((unsigned int)didWrite != libcheckra1nhelper_dylib_len) {
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite, 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] = "-E";
if (checkrain_option_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
if (!checkrain_option_enabled(host_flags, palerain_option_checkrain_is_clone)) {
strncat(args, "p", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
if (checkrain_option_enabled(host_flags, host_option_no_colors)) strncat(args, "n", 0xf);
} else {
strncat(args, "R", 0xf);
}
char args[0x10] = "-pE";
if (demote) strncat(args, "d", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
if (pongo_path != NULL) strncat(args, "k", 0xf); // keep this at last
pid_t pid;
char* checkra1n_argv[] = {
@@ -59,12 +119,25 @@ void exec_checkra1n() {
pongo_path = NULL;
if (ret) {
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
unlink(checkra1n_path);
return;
if (ext_checkra1n != NULL) unlink(checkra1n_path);
return -1;
}
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
sleep(2);
unlink(checkra1n_path);
if (ext_checkra1n == NULL) {
unlink(checkra1n_path);
free(checkra1n_path);
checkra1n_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
waitpid(pid, NULL, 0);
return;
return 0;
}
+21
View File
@@ -0,0 +1,21 @@
#include <stdlib.h>
#ifdef NO_KPF
unsigned char* checkra1n_kpf_pongo = NULL;
unsigned int checkra1n_kpf_pongo_len = 0;
#endif
#ifdef NO_RAMDISK
unsigned char* ramdisk_dmg = NULL;
unsigned int ramdisk_dmg_len = 0;
#endif
#ifdef NO_CHECKRAIN
unsigned char* checkra1n = NULL;
unsigned int checkra1n_len = 0;
#endif
#ifdef NO_BINPACK
unsigned char* binpack_dmg = NULL;
unsigned int binpack_dmg_len = 0;
#endif
+46 -29
View File
@@ -25,52 +25,53 @@
#include <libimobiledevice/libimobiledevice.h>
#include <ANSI-color-codes.h>
#include <common.h>
#include <palerain.h>
#include <xxd-embedded.h>
#include <kerninfo.h>
pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
#ifdef DEV_BUILD
#include <newt.h>
pthread_mutex_t tui_log_mutex;
newtComponent tui_log_output = NULL;
#endif
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;
@@ -80,10 +81,26 @@ uint64_t get_ecid_wait_for_dfu() {
}
uint64_t set_ecid_wait_for_dfu(uint64_t ecid) {
LOG(LOG_VERBOSE5, "locking ecid wait for dfu value for set ecid_wait_for_dfu = %llu", ecid);
LOG(LOG_VERBOSE5, "locking ecid wait for dfu mutex for set ecid_wait_for_dfu = %llu", ecid);
pthread_mutex_lock(&ecid_dfu_wait_mutex);
ecid_wait_for_dfu = ecid;
LOG(LOG_VERBOSE5, "UN-locking ecid wait for dfu mutex afrer setting ecid_wait_for_dfu");
pthread_mutex_unlock(&ecid_dfu_wait_mutex);
return ecid;
}
#ifdef DEV_BUILD
newtComponent get_tui_log() {
pthread_mutex_lock(&tui_log_mutex);
newtComponent ret = tui_log_output;
pthread_mutex_unlock(&tui_log_mutex);
return ret;
}
newtComponent set_tui_log(newtComponent co) {
pthread_mutex_lock(&tui_log_mutex);
tui_log_output = co;
pthread_mutex_unlock(&tui_log_mutex);
return co;
}
#endif
+1 -1
View File
@@ -205,7 +205,7 @@ int lockdown_get_string_value(int fd, const char* domain, const char* key, char*
}
size_t str_len = p - str_start;
*value = (char*)malloc(str_len + 1);
strncpy(*value, str_start, str_len);
snprintf(*value, str_len, "%s", str_start);
(*value)[str_len] = '\0';
free(resp);
+60 -25
View File
@@ -6,11 +6,15 @@
#include <assert.h>
#include <ANSI-color-codes.h>
#include <common.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) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
if (verbose >= 5
#ifdef DEV_BUILD
&& !checkrain_option_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;
char type[0x10];
char colour[0x10];
@@ -18,7 +22,11 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
va_list args;
va_start(args, format);
if (verbose < (loglevel - 3) && loglevel > LOG_INFO) {
if (verbose >= 5) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
if (verbose >= 5
#ifdef DEV_BUILD
&& !tui_started
#endif
) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
return 0;
}
switch (loglevel) {
@@ -49,28 +57,55 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
snprintf(colour_bold, 0x10, "%s", BWHT);
break;
}
pthread_mutex_lock(&log_mutex);
char timestring[0x80];
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) {
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 {
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
if (checkrain_option_enabled(host_flags, host_option_no_colors)) {
colour[0] = '\0';
colour_bold[0] = '\0';
}
printf("%s", colour);
ret = vprintf(format, args);
va_end(args);
#ifdef DEV_BUILD
if (checkrain_option_enabled(host_flags, host_option_tui) && tui_started) {
newtComponent co = get_tui_log();
if (co == NULL) {
return 0; /* 0 bytes printed */
}
char printbuf[0x200];
ret = vsnprintf(printbuf, 0x200, format, args);
pthread_mutex_lock(&log_mutex);
newtTextboxSetText(co, printbuf);
} else
#endif
{
pthread_mutex_lock(&log_mutex);
char timestring[0x80];
time_t curtime;
time(&curtime);
struct tm* timeinfo = localtime(&curtime);
if (!checkrain_option_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_option_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 if (!checkrain_option_enabled(host_flags, host_option_no_colors)) {
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
} else if (verbose >= 2 && checkrain_option_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_option_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)
printf(CRESET "\n");
else {
printf("\n%s-%s\n", colour, CRESET);
if (verbose < 2 && !checkrain_option_enabled(host_flags, host_option_no_colors))
printf(CRESET "\n");
else if (!checkrain_option_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);
}
fflush(stdout);
pthread_mutex_unlock(&log_mutex);
pthread_mutex_unlock(&log_mutex);
return ret;
}
}
+59 -41
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>
@@ -25,7 +25,7 @@
#include <libimobiledevice/libimobiledevice.h>
#include <ANSI-color-codes.h>
#include <common.h>
#include <palerain.h>
#include <xxd-embedded.h>
#include <kerninfo.h>
@@ -33,12 +33,9 @@
#define OVERRIDE_MAGIC 0xd803b376
unsigned int verbose = 0;
int enable_rootful = 0, demote = 0;
bool ohio = true;
char xargs_cmd[0x270] = "xargs", checkrain_flags_cmd[0x20] = "deadbeef", palerain_flags_cmd[0x20] = "deadbeef";
char xargs_cmd[0x270] = "xargs ", checkrain_flags_cmd[0x20] = "deadbeef", palerain_flags_cmd[0x20] = "deadbeef";
char kpf_flags_cmd[0x20] = "deadbeef", dtpatch_cmd[0x20] = "deadbeef", rootfs_cmd[512] = "deadbeef";
extern char** environ;
typedef unsigned char niarelap_file_t[];
niarelap_file_t* kpf_to_upload_1 = &checkra1n_kpf_pongo;
niarelap_file_t* ramdisk_to_upload_1 = &ramdisk_dmg;
@@ -59,7 +56,8 @@ void thr_cleanup(void* ptr) {
*(int*)ptr = 0;
}
int build_checks() {
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) {
@@ -67,57 +65,97 @@ int build_checks() {
return -1;
}
if (c1_header->cputype != _mh_execute_header.cputype) {
LOG(LOG_FATAL, "Broken build: checkra1n CPU type is not the same as %s CPU type", getprogname());
LOG(LOG_FATAL, "Broken build: checkra1n CPU type does not match palera1n CPU type");
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;
LOG(LOG_WARNING, "Do not distribute!");
}
#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) {
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: CPU type is not arm64");
return -1;
}
#endif
return 0;
}
bool dfuhelper_only = false, pongo_exit = false, palerain_version = false;
#ifdef DEV_BUILD
bool use_tui = false;
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;
#if defined(__APPLE__) || defined(__linux__)
pthread_setname_np("in.palera.main-thread");
#endif
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;
if ((ret = optparse(argc, argv))) goto cleanup;
if (palerain_version) goto normal_exit;
if (!checkrain_option_enabled(host_flags, host_option_device_info))
if (checkrain_option_enabled(host_flags, host_option_palerain_version)) goto normal_exit;
#ifdef DEV_BUILD
if (use_tui) {
if (checkrain_option_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_option_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 (dfuhelper_only || device_has_booted)
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) ||
checkrain_option_enabled(host_flags, host_option_device_info) ||
device_has_booted)
goto normal_exit;
exec_checkra1n();
if (pongo_exit || demote)
if (exec_checkra1n()) goto cleanup;
if (checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_demote))
goto normal_exit;
set_spin(1);
sleep(2);
@@ -128,27 +166,6 @@ int palera1n(int argc, char *argv[]) {
sleep(1);
}
normal_exit:
if (access("/usr/bin/curl", F_OK) == 0 && 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);
@@ -162,6 +179,7 @@ cleanup:
munmap(override_overlay.ptr, (size_t)override_overlay.len);
close(override_overlay.fd);
}
if (ext_checkra1n != NULL) free(ext_checkra1n);
pthread_mutex_destroy(&log_mutex);
pthread_mutex_destroy(&spin_mutex);
pthread_mutex_destroy(&found_pongo_mutex);
+166 -55
View File
@@ -9,13 +9,17 @@
#include <ctype.h>
#include <assert.h>
#include <getopt.h>
#include <limits.h>
#include <errno.h>
#include <common.h>
#include <palerain.h>
#include <sys/mman.h>
checkrain_option_t host_flags = 0;
checkrain_option_p host_flags_p = &host_flags;
static struct option longopts[] = {
{"setup-partial-fakefs", no_argument, NULL, 'B'},
{"setup-fakefs", no_argument, NULL, 'c'},
{"setup-fakefs-forced", no_argument, NULL, 'C'},
{"dfuhelper", no_argument, NULL, 'D'},
{"help", no_argument, NULL, 'h'},
{"pongo-shell", no_argument, NULL, 'p'},
@@ -27,15 +31,22 @@ static struct option longopts[] = {
{"rootless", no_argument, NULL, 'l'},
{"jbinit-log-to-file", no_argument, NULL, 'L'},
{"demote", no_argument, NULL, 'd'},
{"force-revert", no_argument, NULL, checkrain_option_force_revert},
{"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_version},
{"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'},
{"tui", no_argument, NULL, 't'},
#endif
{NULL, 0, NULL, 0}
@@ -45,38 +56,50 @@ static int usage(int e, char* prog_name)
{
fprintf(stderr,
#ifdef DEV_BUILD
"Usage: %s [-cCDhpvVldsOLtf]"
"Usage: %s [-12cCdDEfhIlLnOpRsStvV]"
#else
"Usage: %s [-cCDhpvVldsOLf]"
"Usage: %s [-cCdDEfhIlLnOpRsSvV]"
#endif
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file]\n"
" [-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.3.1 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
"\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-D, --dfuhelper-only\t\t\tExit after entering DFU\n"
"\t-d, --demote\t\t\t\tDemote\n"
"\t-D, --dfuhelper\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"
"\t-f, --fakefs \t\t\t\tBoots fakefs\n"
"\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"
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
"\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-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\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"
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\n"
"\t-e, --boot-args <boot arguments>\tXNU boot arguments\n"
"\t-f, --fakefs \t\t\t\tBoots fakefs\n"
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
"\t-s, --safe-mode\t\t\t\tEnter safe mode\n"
"\t-d, --demote\t\t\t\tDemote\n"
"\t-k, --override-pongo <file>\t\tOverride Pongo image\n"
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
#ifdef DEV_BUILD
"\t-t, --tui\t\t\t\tTerminal user interface\n"
#endif
"\nEnvironmental variables:\n"
"\tTMPDIR\t\ttemporary diretory (path the built-in checkra1n will be extracted to)\n"
,
prog_name);
exit(e);
@@ -87,30 +110,30 @@ int optparse(int argc, char* argv[]) {
int index;
while ((opt = getopt_long(argc, argv,
#ifdef DEV_BUILD
"cCDhpvVldsOLtfPe:o:r:K:k:",
"12BcDEhpvVldsSLftRnPIe:o:r:K:k:i:",
#else
"cCDhpvVldsOLfPe:o:r:K:k:",
"BcDEhpvVldsSLfRnPIe:o:r:K:k:i:",
#endif
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;
break;
case 'p':
pongo_exit = true;
host_flags |= host_option_pongo_exit;
break;
case 'P':
pongo_full = 1;
host_flags |= host_option_pongo_full;
break;
case 'D':
dfuhelper_only = true;
host_flags |= host_option_dfuhelper_only;
break;
case 'h':
usage(0, argv[0]);
@@ -134,16 +157,19 @@ int optparse(int argc, char* argv[]) {
case 'f':
snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg);
snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg);
enable_rootful = 1;
palerain_flags |= palerain_option_rootful;
break;
case 'l':
enable_rootful = 0;
palerain_flags &= ~palerain_option_rootful;
break;
case 'L':
palerain_flags |= palerain_option_jbinit_log_to_file;
break;
case 'd':
demote = 1;
host_flags |= host_option_demote;
break;
case 'E':
host_flags |= host_option_enter_recovery;
break;
case 's':
checkrain_flags |= checkrain_option_safemode;
@@ -179,44 +205,105 @@ int optparse(int argc, char* argv[]) {
return -1;
}
break;
case 'O':
ohio = false;
case 'i': {};
struct stat st;
if (stat(optarg, &st) != 0) {
LOG(LOG_FATAL, "cannot stat external checkra1n file: %d (%s)", errno, strerror(errno));
return -1;
} 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 (!(st.st_mode & S_IFREG)) {
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;
case 'R':
host_flags |= host_option_reboot_device;
break;
case 'n':
host_flags |= host_option_exit_recovery;
break;
case 'I':
host_flags |= host_option_device_info;
break;
case 'S':
host_flags |= host_option_no_colors;
break;
#ifdef DEV_BUILD
case 't':
use_tui = true;
host_flags |= host_option_tui;
break;
case '1':
palerain_flags |= palerain_option_test1;
break;
case '2':
palerain_flags |= palerain_option_test2;
break;
#endif
case checkrain_option_force_revert:
case palerain_option_case_force_revert:
checkrain_flags |= checkrain_option_force_revert;
break;
case palerain_option_version:
palerain_version = true;
case palerain_option_case_version:
host_flags |= host_option_palerain_version;
break;
default:
usage(1, argv[0]);
break;
}
}
if (palerain_version) {
printf("palera1n version " PALERAIN_VERSION ": " BUILD_DATE "; " BUILD_WHOAMI ":" BUILD_TAG "/" BUILD_STYLE "\n");
if (checkrain_option_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
);
return 0;
}
if (enable_rootful) {
palerain_flags |= palerain_option_rootful;
}
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");
}
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);
LOG(LOG_VERBOSE3, "checkrain_flags: %s", checkrain_flags_cmd);
LOG(LOG_VERBOSE3, "palerain_flags: %s", palerain_flags_cmd);
LOG(LOG_VERBOSE3, "kpf_flags: %s", kpf_flags_cmd);
LOG(LOG_VERBOSE3, "host_flags: 0x%x", host_flags);
if (override_kpf.magic == OVERRIDE_MAGIC) {
LOG(LOG_VERBOSE4, "kpf override length %u -> %u", override_kpf.orig_len, checkra1n_kpf_pongo_len);
LOG(LOG_VERBOSE4, "kpf override ptr %p -> %p", override_kpf.orig_ptr, **kpf_to_upload);
@@ -236,6 +323,30 @@ int optparse(int argc, char* argv[]) {
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)))
{
#ifdef NO_CHECKRAIN
if (checkra1n_len == 0 && ext_checkra1n == NULL)
{
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)))
{
#ifdef NO_KPF
if (checkra1n_kpf_pongo_len == 0)
{
LOG(LOG_FATAL, "kernel patchfinder omitted in build but no override specified");
return -1;
}
#endif
}
#endif
}
for (index = optind; index < argc; index++)
{
@@ -252,17 +363,17 @@ int optparse(int argc, char* argv[]) {
usage(1, argv[0]);
}
}
if (verbose >= 2) putenv("LIBUSB_DEBUG=1");
if (verbose >= 2) setenv("LIBUSB_DEBUG", "1", 1);
if (verbose >= 3)
{
irecv_set_debug_level(1);
putenv("LIBUSB_DEBUG=2");
setenv("LIBUSB_DEBUG", "2", 1);
}
if (verbose >= 4) {
idevice_set_debug_level(1);
putenv("LIBUSB_DEBUG=3");
setenv("LIBUSB_DEBUG", "3", 1);
}
if (verbose >= 5)
putenv("LIBUSB_DEBUG=4");
setenv("LIBUSB_DEBUG", "4", 1);
return 0;
}
+4 -3
View File
@@ -1,3 +1,5 @@
#include <palerain.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -12,7 +14,6 @@
#include <sys/mman.h>
#include <errno.h>
#include <common.h>
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename) {
int ret = 0;
@@ -30,7 +31,7 @@ int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *
return errno;
}
LOG(LOG_VERBOSE5, "override_file: fstat fd %d succeeded!", fd);
void *addr = mmap(NULL, st.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
void *addr = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (addr == MAP_FAILED) {
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", filename, errno, strerror(errno));
return errno;
@@ -46,4 +47,4 @@ int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *
*orig_len = (unsigned int)st.st_size;
LOG(LOG_VERBOSE5, "override_file() finished!");
return 0;
};
}
+167 -17
View File
@@ -10,17 +10,17 @@
#include <sys/mman.h> // mmap, munmap
#include <sys/stat.h> // fstst
#include <common.h>
#include <palerain.h>
#include <ANSI-color-codes.h>
bool pongo_full, device_has_booted = 0;
bool device_has_booted = 0;
int pongo_thr_running = 0;
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
void* pongo_helper(void* ptr) {
pongo_thr_running = 1;
pthread_cleanup_push(thr_cleanup, &pongo_thr_running);
#if defined(__APPLE__) || defined(__linux__)
pthread_setname_np("in.palera.pongo-helper");
#endif
wait_for_pongo();
while (get_spin()) {
sleep(1);
@@ -33,15 +33,11 @@ void *pongo_usb_callback(void *arg) {
if (get_found_pongo())
return NULL;
set_found_pongo(1);
#if defined(__APPLE__) || defined(__linux__)
pthread_setname_np("in.palera.pongo-handler");
#endif
strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1);
if (checkrain_option_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 = (((stuff_t *)arg)->handle);
issue_pongo_command(handle, NULL);
issue_pongo_command(handle, "fuse lock");
issue_pongo_command(handle, "sep auto");
@@ -50,24 +46,178 @@ 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 (enable_rootful)
if (checkrain_option_enabled(palerain_flags, palerain_option_rootful))
{
issue_pongo_command(handle, "rootfs");
}
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len);
issue_pongo_command(handle, "ramdisk");
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
issue_pongo_command(handle, "overlay");
#ifdef NO_RAMDISK
if (ramdisk_dmg_len != 0)
#endif
{
strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1);
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len);
issue_pongo_command(handle, "ramdisk");
}
#ifdef NO_BINPACK
if (binpack_dmg_len != 0)
#endif
{
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
issue_pongo_command(handle, "overlay");
}
issue_pongo_command(handle, xargs_cmd);
if (pongo_full) goto done;
if (checkrain_option_enabled(host_flags, host_option_pongo_full)) goto done;
issue_pongo_command(handle, "bootx");
LOG(LOG_INFO, "Booting Kernel...");
if (checkrain_option_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_option_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(((stuff_t *)arg)->dev);
#endif
set_spin(0);
return NULL;
}
}
int issue_pongo_command(usb_device_handle_t handle, char *command)
{
uint32_t outpos = 0;
uint32_t outlen = 0;
int ret = USB_RET_SUCCESS;
uint8_t in_progress = 1;
if (command == NULL) goto fetch_output;
size_t len = strlen(command);
char command_buf[512];
char stdout_buf[0x2000];
if (len > (CMD_LEN_MAX - 2))
{
LOG(LOG_ERROR, "Pongo command %s too long (max %d)", command, CMD_LEN_MAX - 2);
return EINVAL;
}
if (verbose < 3 || verbose > 4) {
LOG(LOG_VERBOSE, "Executing PongoOS command: '%s'", command);
} else {
printf("%s\n", command);
}
snprintf(command_buf, 512, "%s\n", command);
len = strlen(command_buf);
ret = USBControlTransfer(handle, 0x21, 4, 1, 0, 0, NULL, NULL);
if (ret)
goto bad;
ret = USBControlTransfer(handle, 0x21, 3, 0, 0, (uint32_t)len, command_buf, NULL);
fetch_output:
while (in_progress) {
ret = USBControlTransfer(handle, 0xa1, 2, 0, 0, (uint32_t)sizeof(in_progress), &in_progress, NULL);
if (ret == USB_RET_SUCCESS)
{
ret = USBControlTransfer(handle, 0xa1, 1, 0, 0, 0x1000, stdout_buf + outpos, &outlen);
if (ret == USB_RET_SUCCESS)
{
write_stdout(stdout_buf + outpos, outlen);
outpos += outlen;
if (outpos > 0x1000)
{
memmove(stdout_buf, stdout_buf + outpos - 0x1000, 0x1000);
outpos = 0x1000;
}
}
}
if (ret != USB_RET_SUCCESS)
{
goto bad;
}
}
bad:
if (ret != USB_RET_SUCCESS)
{
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;
}
else
return ret;
}
int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned int buf_len)
{
int ret = 0;
ret = USBControlTransfer(handle, 0x21, 1, 0, 0, 4, &buf_len, NULL);
if (ret == USB_RET_SUCCESS)
{
ret = USBBulkUpload(handle, buf, buf_len);
if (ret == USB_RET_SUCCESS)
{
if (verbose < 3 || verbose > 4) {
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
} else {
if (checkrain_option_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);
if(r != 0)
{
ERR("pthread_create: %s", strerror(r));
set_spin(0);
return;
}
pthread_join(stuff->th, NULL);
}
void io_stop(stuff_t *stuff)
{
int r = pthread_cancel(stuff->th);
if(r != 0)
{
ERR("pthread_cancel: %s", strerror(r));
set_spin(0);
return;
}
r = pthread_join(stuff->th, NULL);
if(r != 0)
{
ERR("pthread_join: %s", strerror(r));
set_spin(0);
return;
}
#ifdef USE_LIBUSB
libusb_unref_device(stuff->dev);
#endif
}
void write_stdout(char *buf, uint32_t len)
{
while(len > 0) {
if (verbose >= 3) {
ssize_t s = write(1, buf, len);
if(s < 0) {
LOG(LOG_ERROR, "write: %s", strerror(errno));
pthread_exit(NULL);
}
buf += s;
len -= s;
} else break;
}
}
+66 -56
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -14,78 +9,93 @@
#include <unistd.h>
#include <assert.h>
#include <common.h>
#include <palerain.h>
#include <tui.h>
int redraw_screen() {
erase();
resizeterm(24, 80);
box(stdscr, 0, 0);
mvaddstr(0, 80 - strlen("[palera1n version " PALERAIN_VERSION "]") - 2 , "[palera1n version " PALERAIN_VERSION "]");
return 0;
}
int destroy_window() {
endwin();
return 0;
}
int init_window() {
setlocale(LC_ALL, NULL);
initscr();
if (has_colors() == TRUE) {
start_color();
init_pair(MSG_COLOR, COLOR_YELLOW, COLOR_BLACK);
init_pair(ICON_COLOR, COLOR_WHITE, COLOR_BLACK);
}
int height, width;
getmaxyx(stdscr, height, width);
if (width < 80 || height < 24) {
LOG(LOG_ERROR, "Terminal size must be at least 80x24");
setenv(
"NEWT_COLORS",
"root=,black\n"
"border=lightgray,black\n"
"title=lightgray,black\n"
"roottext=red,black\n"
"label=lightgray,black\n"
"entry=lightgray,black\n"
"window=red,black\n"
"textbox=lightgray,black\n"
"button=black,lightgray\n"
"compactbutton=lightgray,black\n"
"listbox=lightgray,black\n"
"actlistbox=black,lightgray\n"
"actsellistbox=black,lightgray\n"
"checkbox=lightgray,black\n"
"actcheckbox=black,lightgray\n",
0);
tui_started = true;
newtInit();
int cols, rows;
newtGetScreenSize(&cols, &rows);
if (cols < 80 || rows < 24) {
newtFinished();
tui_started = false;
LOG(LOG_FATAL, "Terminal size must be at least 80x24");
return -1;
}
if (has_colors() == FALSE) {
LOG(LOG_VERBOSE2, "Terminal without color support detected");
}
cbreak();
noecho();
keypad(stdscr, TRUE);
LOG(LOG_VERBOSE3, "cols: %d, rows: %d\n", cols, rows);
newtCls();
newtSetColor(PI_LOG_COLOR, "yellow", "black");
newtSetColor(PI_STEP_CURRENT, "lightgray", "black");
newtSetColor(PI_STEP_OTHER, "gray", "black");
newtDrawRootText(0, 0, "palera1n version 2.0.0");
newtPushHelpLine(NULL);
return 0;
}
int tui() {
int ret = MAIN_SCREEN;
init_window();
int ret = 0;
if ((ret = init_window())) return ret;
ret = MAIN_SCREEN;
while (1) {
redraw_screen();
switch (ret) {
case ERROR_SCREEN:
goto out;
break;
case EXIT_SCREEN:
goto out;
break;
case MAIN_SCREEN:
ret = tui_screen_main();
break;
case OPTIONS_SCREEN:
ret = tui_screen_options();
break;
case ENTER_RECOVERY_SCREEN:
ret = tui_screen_enter_recovery();
break;
case ENTER_DFU_SCREEN:
ret = tui_screen_enter_dfu();
break;
case JAILBREAKING_SCREEN:
ret = tui_screen_jailbreak();
break;
default:
assert(0);
goto out;
case ERROR_SCREEN:
goto out;
break;
case EXIT_SCREEN:
goto out;
break;
case MAIN_SCREEN:
ret = tui_screen_main();
break;
case OPTIONS_SCREEN:
ret = tui_screen_options();
break;
case ENTER_RECOVERY_SCREEN:
ret = tui_screen_enter_recovery();
break;
case ENTER_DFU_SCREEN:
ret = tui_screen_enter_dfu();
break;
case JAILBREAKING_SCREEN:
ret = tui_screen_jailbreak();
break;
default:
assert(0);
goto out;
}
newtPopWindow();
}
out:
destroy_window();
return ret;
newtFinished();
tui_started = false;
return 0;
}
+1 -6
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -14,7 +9,7 @@
#include <unistd.h>
#include <assert.h>
#include <common.h>
#include <palerain.h>
#include <tui.h>
tui_screen_t tui_screen_enter_dfu() { return JAILBREAKING_SCREEN; }
+1 -6
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -14,7 +9,7 @@
#include <unistd.h>
#include <assert.h>
#include <common.h>
#include <palerain.h>
#include <tui.h>
tui_screen_t tui_screen_enter_recovery() { return ENTER_DFU_SCREEN; }
+1 -6
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -14,7 +9,7 @@
#include <unistd.h>
#include <assert.h>
#include <common.h>
#include <palerain.h>
#include <tui.h>
tui_screen_t tui_screen_jailbreak() { return EXIT_SCREEN; }
+30 -93
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -14,97 +9,39 @@
#include <unistd.h>
#include <assert.h>
#include <common.h>
#include <palerain.h>
#include <tui.h>
tui_screen_t tui_screen_main() {
int ret = -1;
mvaddstr(1, 2, "Welcome to palera1n!");
move(2,1);
whline(stdscr, ACS_HLINE, 80 - 2);
move(5,2);
attron(COLOR_PAIR(MSG_COLOR));
mvaddstr(4,2, "Connect your iPhone, iPad, or iPod Touch");
mvaddstr(5,2, "to begin.");
attroff(COLOR_PAIR(MSG_COLOR));
attron(COLOR_PAIR(ICON_COLOR));
mvaddwstr(2, 43, L" MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ");
mvaddwstr(3, 44, L"MMMMMMMMMMMMMWNOddONWMMMMMMMMMMMMM");
mvaddwstr(4, 44, L"MMMMMMMMMMMMWNx. .xNWMMMMMMMMMMMM");
mvaddwstr(5, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM");
mvaddwstr(6, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM");
mvaddwstr(7, 44, L"MMMMMMMMMMMWXo'.....lKWMMMMMMMMMMM");
mvaddwstr(8, 44, L"MMMMMMMMMMWNkc;'....'dNWMMMMMMMMMM");
mvaddwstr(9, 44, L"MMMMMMMMMMN0dc:,''''.:ONWMMMMMMMMM");
mvaddwstr(10, 44, L"MMMMMMMMMWKxllc;,'''',lKWMMMMMMMMM");
mvaddwstr(11, 44, L"MMMMMMMMWNkoolc;,,,,;;:xXWMMMMMMMM");
mvaddwstr(12, 44, L"MMMMMMMMW0olllc;,,,,,,,:OWMMMMMMMM");
mvaddwstr(13, 44, L"MMMMMMMMNOollc:,'....'';xNMMMMMMMM");
mvaddwstr(14, 44, L"MMMMMMMMW0dllc:,''''''':OWMMMMMMMM");
mvaddwstr(15, 44, L"MMMMMMMMWN0dc::;;,,,,,cONWMMMMMMMM");
mvaddwstr(16, 44, L"MMMMMMMMMMWXOxoc::cldkXWMMMMMMMMMM");
mvaddwstr(17, 44, L"MMMMMMMMMMMMWWNNXXNNWWMMMMMMMMMMMM");
mvaddwstr(18, 44, L"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
mvaddstr(7, 2, "Made by: Nick Chan, Mineek, Tom, Nebula,");
mvaddstr(8, 2, "llsc12, Nathan");
move(9, 2);
whline(stdscr, ACS_HLINE, 40);
mvaddstr(10, 2, "Thanks to: nyuszika7h, Procursus Team");
mvaddstr(11, 2, "dora2ios, m1sta, Serena, xerub, tihmstar");
mvaddstr(12, 2, "sbingner, checkra1n team (Siguza, Axi0mx");
mvaddstr(13, 2, "argp et al.)");
move(14, 2);
whline(stdscr, ACS_HLINE, 40);
mvaddstr(19, 2, "palera1n is NOT affinated with checkra1n");
mvaddstr(20, 2, "Note: Backup your stuff. Use at your own risk.");
mvaddstr(19, 78 - strlen("@palera1n"), "@palera1n");
mvaddstr(20, 78 - strlen("https://palera.in"), "https://palera.in");
attroff(COLOR_PAIR(ICON_COLOR));
move(21,1);
whline(stdscr, ACS_HLINE, 80 - 2);
move(22, 40);
ITEM* main_buttons[4];
MENU* main_menu;
main_buttons[0] = new_item(MAIN_OPTIONS, "");
main_buttons[1] = new_item(MAIN_START, "");
main_buttons[2] = new_item(MAIN_EXIT, "");
main_buttons[3] = NULL;
main_menu = new_menu(main_buttons);
item_opts_off(main_buttons[1], O_SELECTABLE);
set_menu_format(main_menu, 1, 40);
set_menu_sub(main_menu, derwin(stdscr, 0, 0, 22, 50));
post_menu(main_menu);
raw();
refresh();
while (1) {
int ch = getch();
if (ch == KEY_LEFT) {
menu_driver(main_menu, REQ_LEFT_ITEM);
} else if (ch == KEY_RIGHT) {
menu_driver(main_menu, REQ_RIGHT_ITEM);
} else if (ch == 10) {
if (!(item_opts(current_item(main_menu)) & O_SELECTABLE)) continue;
// fprintf(stderr, "Button %s pressed\n", current_item(main_menu)->name.str);
if (!strcmp(current_item(main_menu)->name.str, MAIN_EXIT)) {
ret = EXIT_SCREEN;
} else if (!strcmp(current_item(main_menu)->name.str, MAIN_START)) {
ret = ENTER_RECOVERY_SCREEN;
} else if (!strcmp(current_item(main_menu)->name.str, MAIN_OPTIONS)) {
ret = OPTIONS_SCREEN;
}
goto end;
}
refresh();
int ret = MAIN_SCREEN;
bool can_start = false;
newtCenteredWindow(WIDTH, HEIGHT, NULL);
newtComponent optionsButton = newtCompactButton(46, 18, "Options");
newtComponent startButton = newtCompactButton(57, 18, "Start");
newtComponent exitButton = newtCompactButton(66, 18, "Exit");
newtComponent welcome = newtLabel(1, 0, "Welcome to palera1n!");
newtComponent deviceMsg = newtTextbox(1, 2, 40, 3, NEWT_FLAG_WRAP);
set_tui_log(deviceMsg);
LOG(LOG_INFO, "Connect your iPhone, iPad or iPod Touch to begin.");
newtTextboxSetColors(deviceMsg, PI_LOG_COLOR, PI_LOG_COLOR);
set_tui_log(deviceMsg);
newtComponent form = newtForm(NULL, NULL, 0);
newtFormAddComponents(form, optionsButton, startButton, exitButton, welcome,
deviceMsg, NULL);
newtRunForm(form);
newtRefresh();
newtComponent buttonPressed = newtFormGetCurrent(form);
if (buttonPressed == optionsButton) {
ret = OPTIONS_SCREEN;
} else if (buttonPressed == startButton) {
if (can_start)
ret = ENTER_RECOVERY_SCREEN;
else
ret = MAIN_SCREEN;
} else if (buttonPressed == exitButton) {
ret = EXIT_SCREEN;
}
end:
noraw();
unpost_menu(main_menu);
free_menu(main_menu);
free_item(main_buttons[0]);
free_item(main_buttons[1]);
free_item(main_buttons[2]);
set_tui_log(NULL);
newtFormDestroy(form);
return ret;
}
+57 -37
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -14,44 +9,69 @@
#include <unistd.h>
#include <assert.h>
#include <common.h>
#include <palerain.h>
#include <tui.h>
void bitfield_check_cb(newtComponent box, void* data) {
if (newtCheckboxGetValue(box) == ' ') {
*((tui_bit_info_t*)data)->flags_p = *((tui_bit_info_t*)data)->flags_p &~ ((tui_bit_info_t*)data)->opt;
} else if (newtCheckboxGetValue(box) == '*') {
*((tui_bit_info_t*)data)->flags_p |= ((tui_bit_info_t*)data)->opt;
} else assert(0);
}
tui_screen_t tui_screen_options() {
tui_screen_t ret = EXIT_SCREEN;
ITEM* back_button[2];
MENU* back_menu;
back_button[0] = new_item("Back", "");
back_button[1] = NULL;
back_menu = new_menu(back_button);
tui_bit_info_t verbose_info = { &kpf_flags, checkrain_option_verbose_boot };
tui_bit_info_t rootful_info = { &palerain_flags, palerain_option_rootful };
tui_bit_info_t setup_rootful_info = { &palerain_flags, palerain_option_setup_rootful };
tui_bit_info_t force_revert_info = { &checkrain_flags, checkrain_option_force_revert };
tui_bit_info_t safemode_info = { &checkrain_flags, checkrain_option_safemode };
move(21, 1);
hline(ACS_HLINE, 80 - 2);
set_menu_format(back_menu, 1, 10);
set_menu_sub(back_menu, derwin(stdscr, 0, 0, 22, 68));
post_menu(back_menu);
FORM* options_form;
FIELD* options[3];
static checkrain_option_t flower_flags = 0, flower_option_flower_chain = (1 << 0);
tui_bit_info_t flower_chain_info = { &flower_flags, flower_option_flower_chain };
const char* bootargs_entered = NULL;
int ret = MAIN_SCREEN;
refresh();
newtCenteredWindow(WIDTH, HEIGHT, NULL);
newtComponent backButton = newtCompactButton(66, 18, "Back");
while(1) {
int ch = getch();
if (ch == 10) {
if (!(item_opts(current_item(back_menu)) & O_SELECTABLE)) continue;
if (!strcmp(current_item(back_menu)->name.str, BACK_BUTTON)) {
ret = MAIN_SCREEN;
}
goto end;
}
refresh();
}
end:
unpost_menu(back_menu);
free_item(back_button[0]);
free_menu(back_menu);
newtComponent optionsNotice = newtTextbox(1, 0, WIDTH - 2, 3, NEWT_FLAG_WRAP);
newtTextboxSetText(optionsNotice, "You may set the following options. If you don't know what they mean you'll probably have no reason to set them.");
// newtTextboxSetColors(optionsNotice, NEWT_COLORSET_LABEL, NEWT_COLORSET_LABEL);
newtComponent verboseBootBox = newtCheckbox(1, 3, "Verbose boot", CHECKBOX_STATE(kpf_flags, checkrain_option_verbose_boot), NULL, NULL);
newtComponent rootfulBox = newtCheckbox(1, 4, "Rootful", CHECKBOX_STATE(palerain_flags, palerain_option_rootful), NULL, NULL);
newtComponent rootfulSetupBox = newtCheckbox(1, 5, "Setup fakefs", CHECKBOX_STATE(palerain_flags, palerain_option_setup_rootful), NULL, NULL);
newtComponent forceRevertBox = newtCheckbox(1, 6, "Restore system", CHECKBOX_STATE(checkrain_flags, checkrain_option_force_revert), NULL, NULL);
newtComponent safeModeBox = newtCheckbox(1, 7, "Safe mode", CHECKBOX_STATE(checkrain_flags, checkrain_option_safemode), NULL, NULL);
newtComponentAddCallback(verboseBootBox, bitfield_check_cb, &verbose_info);
newtComponentAddCallback(rootfulBox, bitfield_check_cb, &rootful_info);
newtComponentAddCallback(rootfulSetupBox, bitfield_check_cb, &setup_rootful_info);
newtComponentAddCallback(forceRevertBox, bitfield_check_cb, &force_revert_info);
newtComponentAddCallback(safeModeBox, bitfield_check_cb, &safemode_info);
newtComponent bootCmdlineLabel = newtLabel(1, 8, "Kernel command line:");
newtComponent bootCmdlineEntry = newtEntry(1, 9, &xargs_cmd[6], WIDTH - 2, &bootargs_entered, NEWT_ENTRY_SCROLL);
newtComponent flowerChainBox = newtCheckbox(1, 10, "Flower chain", CHECKBOX_STATE(flower_flags, flower_option_flower_chain), NULL, NULL);
newtComponentAddCallback(flowerChainBox, bitfield_check_cb, &flower_chain_info);
newtComponent form = newtForm(NULL, NULL, 0);
newtFormAddComponents(form, backButton, verboseBootBox, rootfulBox,
rootfulSetupBox, forceRevertBox, safeModeBox, bootCmdlineLabel,
bootCmdlineEntry, flowerChainBox, optionsNotice,
NULL);
newtRunForm(form);
newtRefresh();
snprintf(xargs_cmd, 0x270, "xargs %s", bootargs_entered);
newtComponent buttonPressed = newtFormGetCurrent(form);
if (buttonPressed == backButton) {
ret = MAIN_SCREEN;
} else ret = MAIN_SCREEN;
newtFormDestroy(form);
return ret;
}
+252
View File
@@ -0,0 +1,252 @@
/*
* pongoOS - https://checkra.in
*
* Copyright (C) 2019-2022 checkra1n team
*
* This file is part of pongoOS.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include <errno.h>
#include <fcntl.h> // open
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h> // exit, strtoull
#include <string.h> // strlen, strerror, memcpy, memmove
#include <unistd.h> // close
#include <wordexp.h>
#include <sys/mman.h> // mmap, munmap
#include <sys/stat.h> // fstst
#include <mach/mach.h>
#include <palerain.h>
#include <CoreFoundation/CoreFoundation.h>
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
const char *usb_strerror(usb_ret_t err)
{
return mach_error_string(err);
}
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)
{
IOUSBDevRequest request =
{
.bmRequestType = bmRequestType,
.bRequest = bRequest,
.wValue = wValue,
.wIndex = wIndex,
.wLength = wLength,
.pData = data,
};
usb_ret_t ret = (*handle)->ControlRequest(handle, 0, &request);
if(wLenDone) *wLenDone = request.wLenDone;
return ret;
}
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, uint32_t len)
{
return (*handle)->WritePipe(handle, 2, data, len);
}
static void FoundDevice(void *refCon, io_iterator_t it)
{
stuff_t *stuff = refCon;
if(stuff->regID)
{
return;
}
io_service_t usbDev = MACH_PORT_NULL;
while((usbDev = IOIteratorNext(it)))
{
uint64_t regID;
kern_return_t ret = IORegistryEntryGetRegistryEntryID(usbDev, &regID);
if(ret != KERN_SUCCESS)
{
ERR("IORegistryEntryGetRegistryEntryID: %s", mach_error_string(ret));
goto next;
}
SInt32 score = 0;
IOCFPlugInInterface **plugin = NULL;
ret = IOCreatePlugInInterfaceForService(usbDev, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin, &score);
if(ret != KERN_SUCCESS)
{
ERR("IOCreatePlugInInterfaceForService(usbDev): %s", mach_error_string(ret));
goto next;
}
HRESULT result = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*)&stuff->dev);
(*plugin)->Release(plugin);
if(result != 0)
{
ERR("QueryInterface(dev): 0x%x", result);
goto next;
}
ret = (*stuff->dev)->USBDeviceOpenSeize(stuff->dev);
if(ret != KERN_SUCCESS)
{
ERR("USBDeviceOpenSeize: %s", mach_error_string(ret));
}
else
{
ret = (*stuff->dev)->SetConfiguration(stuff->dev, 1);
if(ret != KERN_SUCCESS)
{
ERR("SetConfiguration: %s", mach_error_string(ret));
}
else
{
IOUSBFindInterfaceRequest request =
{
.bInterfaceClass = kIOUSBFindInterfaceDontCare,
.bInterfaceSubClass = kIOUSBFindInterfaceDontCare,
.bInterfaceProtocol = kIOUSBFindInterfaceDontCare,
.bAlternateSetting = kIOUSBFindInterfaceDontCare,
};
io_iterator_t iter = MACH_PORT_NULL;
ret = (*stuff->dev)->CreateInterfaceIterator(stuff->dev, &request, &iter);
if(ret != KERN_SUCCESS)
{
ERR("CreateInterfaceIterator: %s", mach_error_string(ret));
}
else
{
io_service_t usbIntf = MACH_PORT_NULL;
while((usbIntf = IOIteratorNext(iter)))
{
ret = IOCreatePlugInInterfaceForService(usbIntf, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin, &score);
IOObjectRelease(usbIntf);
if(ret != KERN_SUCCESS)
{
ERR("IOCreatePlugInInterfaceForService(usbIntf): %s", mach_error_string(ret));
continue;
}
result = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID), (LPVOID*)&stuff->handle);
(*plugin)->Release(plugin);
if(result != 0)
{
ERR("QueryInterface(intf): 0x%x", result);
continue;
}
ret = (*stuff->handle)->USBInterfaceOpen(stuff->handle);
if(ret != KERN_SUCCESS)
{
ERR("USBInterfaceOpen: %s", mach_error_string(ret));
}
else
{
io_start(stuff);
stuff->regID = regID;
while((usbIntf = IOIteratorNext(iter))) IOObjectRelease(usbIntf);
IOObjectRelease(iter);
while((usbDev = IOIteratorNext(it))) IOObjectRelease(usbDev);
IOObjectRelease(usbDev);
return;
}
(*stuff->handle)->Release(stuff->handle);
stuff->handle = NULL;
}
IOObjectRelease(iter);
}
}
}
next:;
if(stuff->dev)
{
(*stuff->dev)->USBDeviceClose(stuff->dev);
(*stuff->dev)->Release(stuff->dev);
stuff->dev = NULL;
}
IOObjectRelease(usbDev);
}
}
static void LostDevice(void *refCon, io_iterator_t it)
{
stuff_t *stuff = refCon;
io_service_t usbDev = MACH_PORT_NULL;
while((usbDev = IOIteratorNext(it)))
{
uint64_t regID;
kern_return_t ret = IORegistryEntryGetRegistryEntryID(usbDev, &regID);
IOObjectRelease(usbDev);
if(ret == KERN_SUCCESS && stuff->regID == regID)
{
io_stop(stuff);
stuff->regID = 0;
(*stuff->handle)->USBInterfaceClose(stuff->handle);
(*stuff->handle)->Release(stuff->handle);
(*stuff->dev)->USBDeviceClose(stuff->dev);
(*stuff->dev)->Release(stuff->dev);
}
}
}
static const int pongo_usb_vendor = PONGO_USB_VENDOR;
static const int pongo_usb_product = PONGO_USB_PRODUCT;
int wait_for_pongo(void) {
kern_return_t ret;
stuff_t stuff;
io_iterator_t found, lost;
void* cfdict_keys[3];
void* cfdict_values[3];
cfdict_keys[0] = (void*)CFSTR("IOProviderClass");
cfdict_keys[1] = (void*)CFSTR("idVendor");
cfdict_keys[2] = (void*)CFSTR("idProduct");
cfdict_values[0] = (void*)CFSTR("IOUSBDevice");
cfdict_values[1] = (void*)CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pongo_usb_vendor);
cfdict_values[2] = (void*)CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pongo_usb_product);
CFDictionaryRef cfdict = CFDictionaryCreate(kCFAllocatorDefault, (const void**)cfdict_keys, (const void**)cfdict_values, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
IONotificationPortRef notifyPort = IONotificationPortCreate(kIOMasterPortDefault);
CFRetain(cfdict);
// CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPort), kCFRunLoopDefaultMode);
ret = IOServiceAddMatchingNotification(notifyPort, kIOFirstMatchNotification, cfdict, &FoundDevice, &stuff, &found);
if(ret != KERN_SUCCESS)
{
ERR("IOServiceAddMatchingNotification: %s", mach_error_string(ret));
return -1;
}
FoundDevice(&stuff, found);
CFRetain(cfdict);
ret = IOServiceAddMatchingNotification(notifyPort, kIOTerminatedNotification, cfdict, &LostDevice, &stuff, &lost);
if(ret != KERN_SUCCESS)
{
ERR("IOServiceAddMatchingNotification: %s", mach_error_string(ret));
return -1;
}
LostDevice(&stuff, lost);
// CFRunLoopRun();
while (get_spin()) {
sleep(1);
}
CFRelease(cfdict);
return 0;
}
+22 -157
View File
@@ -24,8 +24,7 @@
* SOFTWARE.
*
*/
#ifdef USE_LIBUSB
#include <errno.h>
#include <fcntl.h> // open
#include <pthread.h>
@@ -38,20 +37,11 @@
#include <sys/mman.h> // mmap, munmap
#include <sys/stat.h> // fstst
#include <common.h>
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
// Keep in sync with Pongo
#define PONGO_USB_VENDOR 0x05ac
#define PONGO_USB_PRODUCT 0x4141
#define CMD_LEN_MAX 512
#define UPLOADSZ_MAX (1024 * 1024 * 128)
typedef struct stuff stuff_t;
static void io_start(stuff_t *stuff);
static void io_stop(stuff_t *stuff);
#include <palerain.h>
#define ERR(...) LOG(LOG_ERROR, __VA_ARGS__)
void io_start(stuff_t *stuff);
void io_stop(stuff_t *stuff);
const char *usb_strerror(usb_ret_t err)
{
@@ -122,13 +112,6 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len)
return LIBUSB_SUCCESS;
}
struct stuff
{
pthread_t th;
libusb_device *dev;
usb_device_handle_t handle;
};
static int FoundDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *arg)
{
LOG(LOG_VERBOSE, "PongoOS USB Device connected");
@@ -188,6 +171,7 @@ static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_ev
io_stop(stuff);
libusb_close(stuff->handle);
libusb_unref_device(dev);
stuff->handle = NULL;
stuff->dev = NULL;
@@ -196,10 +180,11 @@ static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_ev
int wait_for_pongo(void)
{
stuff_t stuff = {};
stuff_t stuff;
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));
@@ -209,38 +194,38 @@ 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_ARRIVED, 0, PONGO_USB_VENDOR, PONGO_USB_PRODUCT, LIBUSB_HOTPLUG_MATCH_ANY, FoundDevice, &stuff, &hp[0]);
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]);
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;
}
libusb_device **list;
ssize_t sz = libusb_get_device_list(NULL, &list);
ssize_t sz = libusb_get_device_list(ctx, &list);
if(sz < 0)
{
ERR("libusb_get_device_list: %s", libusb_error_name((int)sz));
libusb_exit(NULL);
libusb_exit(ctx);
return -1;
}
for(ssize_t i = 0; i < sz; ++i)
{
struct libusb_device_descriptor desc = {};
struct libusb_device_descriptor desc;
r = libusb_get_device_descriptor(list[i], &desc);
if(r != LIBUSB_SUCCESS)
{
@@ -252,7 +237,7 @@ int wait_for_pongo(void)
libusb_unref_device(list[i]);
continue;
}
r = FoundDevice(NULL, list[i], LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, &stuff);
r = FoundDevice(ctx, list[i], LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, &stuff);
for(ssize_t j = i + 1; j < sz; ++j)
{
libusb_unref_device(list[j]);
@@ -260,7 +245,7 @@ int wait_for_pongo(void)
if(r != LIBUSB_SUCCESS)
{
libusb_free_device_list(list, 0);
libusb_exit(NULL);
libusb_exit(ctx);
return -1;
}
break;
@@ -269,7 +254,7 @@ int wait_for_pongo(void)
while(get_spin())
{
r = libusb_handle_events(NULL);
r = libusb_handle_events(ctx);
if(r != LIBUSB_SUCCESS)
{
ERR("libusb_handle_events: %s", libusb_error_name(r));
@@ -277,127 +262,7 @@ int wait_for_pongo(void)
}
}
libusb_exit(NULL);
libusb_exit(ctx);
return 0;
}
static void io_start(stuff_t *stuff)
{
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, &stuff->handle);
if(r != 0)
{
ERR("pthread_create: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
}
pthread_join(stuff->th, NULL);
}
static void io_stop(stuff_t *stuff)
{
int r = pthread_cancel(stuff->th);
if(r != 0)
{
ERR("pthread_cancel: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
}
r = pthread_join(stuff->th, NULL);
if(r != 0)
{
ERR("pthread_join: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
}
}
static void write_stdout(char *buf, uint32_t len)
{
while(len > 0) {
if (verbose >= 3) {
ssize_t s = write(1, buf, len);
if(s < 0) {
LOG(LOG_ERROR, "write: %s", strerror(errno));
pthread_exit(NULL);
}
buf += s;
len -= s;
} else break;
}
}
int issue_pongo_command(usb_device_handle_t handle, char *command)
{
uint32_t outpos = 0;
uint32_t outlen = 0;
int ret = USB_RET_SUCCESS;
uint8_t in_progress = 1;
if (command == NULL) goto fetch_output;
size_t len = strlen(command);
char command_buf[512];
char stdout_buf[0x2000];
if (len > (CMD_LEN_MAX - 2))
{
LOG(LOG_ERROR, "Pongo command %s too long (max %d)", command, CMD_LEN_MAX - 2);
return EINVAL;
}
if (verbose < 3 || verbose > 4) {
LOG(LOG_VERBOSE, "Executing PongoOS command: '%s'", command);
} else {
printf("%s\n", command);
}
snprintf(command_buf, 512, "%s\n", command);
len = strlen(command_buf);
ret = USBControlTransfer(handle, 0x21, 4, 1, 0, 0, NULL, NULL);
if (ret)
goto bad;
ret = USBControlTransfer(handle, 0x21, 3, 0, 0, (uint32_t)len, command_buf, NULL);
fetch_output:
while (in_progress) {
ret = USBControlTransfer(handle, 0xa1, 2, 0, 0, (uint32_t)sizeof(in_progress), &in_progress, NULL);
if (ret == USB_RET_SUCCESS)
{
ret = USBControlTransfer(handle, 0xa1, 1, 0, 0, 0x1000, stdout_buf + outpos, &outlen);
if (ret == USB_RET_SUCCESS)
{
write_stdout(stdout_buf + outpos, outlen);
outpos += outlen;
if (outpos > 0x1000)
{
memmove(stdout_buf, stdout_buf + outpos - 0x1000, 0x1000);
outpos = 0x1000;
}
}
}
if (ret != USB_RET_SUCCESS)
{
goto bad;
}
}
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;
LOG(LOG_ERROR, "USB error: %s", usb_strerror(ret));
return ret;
}
else
return ret;
}
int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned int buf_len)
{
int ret = 0;
ret = USBControlTransfer(handle, 0x21, 1, 0, 0, 4, &buf_len, NULL);
if (ret == USB_RET_SUCCESS)
{
ret = USBBulkUpload(handle, buf, buf_len);
if (ret == USB_RET_SUCCESS)
{
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
}
}
return ret;
}
#endif