Compare commits

..
79 Commits
Author SHA1 Message Date
Nick Chan e61ae40291 2023-03-15 15:56:16 +08:00
Nick Chan 48bd5dccc2 2023-03-15 09:23:29 +08:00
Nick Chan 310e0313d3 2023-03-15 09:08:19 +08:00
Nick Chan 0b95d8ad44 fix build jbinit 2023-03-15 09:04:54 +08:00
Tom E 91d17c2422 this SUCKS 2023-03-14 11:03:48 -04:00
Tom E aad7a4bc05 directory issue 2023-03-14 10:26:22 -04:00
Tom E 2e483568b0 the fix 2023-03-14 09:28:14 -04:00
Tom E a74c5a1236 fix: dumb mistake 2023-03-14 08:14:32 -04:00
Tom E 131bba04b6 need libssl headers too 2023-03-14 07:51:43 -04:00
Tom E 20f5c3c987 fix: install llvm 2023-03-14 07:38:13 -04:00
Nick Chan 07578558a2 2023-03-14 19:30:55 +08:00
Nick Chan e811c9c0f9 update submodules 2023-03-14 19:11:07 +08:00
Nick Chan 98a9310d25 Update build.yml 2023-03-14 18:05:24 +08:00
Nick Chan 7439d7f9eb Update build.yml 2023-03-14 18:01:22 +08:00
Nick Chan fc77488b6d Update build.yml 2023-03-14 17:53:49 +08:00
Nick Chan 8590c9a054 Update build.yml 2023-03-14 17:47:33 +08:00
Nick Chan fcc34b920d Update build.yml 2023-03-14 17:44:32 +08:00
Nick Chan 2133f2f94f Update build.yml 2023-03-14 17:42:15 +08:00
Nick Chan aace97112f fix checkra1n-kpf-pongo uplaod 2023-03-14 17:32:42 +08:00
Nick Chan df68b2910e kpf action changes 2023-03-14 17:29:39 +08:00
Nick Chan 8a912898c9 build things in one action (WILL fail) 2023-03-14 17:21:59 +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
43 changed files with 906 additions and 647 deletions

No files matched your search

+304 -31
View File
@@ -29,7 +29,7 @@ jobs:
run: |
make -j$(nproc) docs
mkdir ready
cp docs/*.html docs/mandoc.css ready
cp docs/*.html docs/mandoc.css docs/palera1n.1 ready
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
@@ -44,6 +44,236 @@ jobs:
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
build-loader:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get loader commit
run: echo "LOADER_COMMIT=$(git -C src/loader rev-parse HEAD)" >> $GITHUB_ENV
- name: Cache compile
id: loader_cache
uses: actions/cache@v3
with:
path: src/loader/packages
key: loader-${{ env.LOADER_COMMIT }}
- name: Install dependencies (packages)
if: steps.loader_cache.outputs.cache-hit != 'true'
run: |
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: Compile
if: steps.loader_cache.outputs.cache-hit != 'true'
run: make -C src/loader
- name: Upload loader
uses: actions/upload-artifact@v3
with:
name: palera1n.ipa
path: src/loader/packages/palera1n.ipa
retention-days: 1
build-binpack:
needs: build-loader
runs-on: macos-12
steps:
- name: Cache Procursus
uses: actions/cache@v3
id: procache
with:
path: |
~/__cache
key: ${{ runner.os }}-procursus
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get binpack commit
run: echo "BINPACK_COMMIT=$(git -C src/binpack rev-parse HEAD)" >> $GITHUB_ENV
- name: Cache binpack.tgz
uses: actions/cache@v3
id: binpack_cache
with:
path: src/jbinit/binpack.tgz
key: binpack-${{ env.BINPACK_COMMIT }}
- name: Download loader
uses: actions/download-artifact@v3
with:
name: palera1n.ipa
path: src/jbinit/palera1n.ipa
- name: Checkout Procursus
if: steps.binpack_cache.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: ProcursusTeam/Procursus
path: src/Procursus
- name: Setup Procursus Bootstrap (install)
if: steps.procache.outputs.cache-hit != 'true' && steps.binpack_cache.outputs.cache-hit != 'true'
run: |
wget https://apt.procurs.us/bootstraps/big_sur/bootstrap-darwin-amd64.tar.zst
sudo gtar --preserve-permissions -xkf ./bootstrap-darwin-amd64.tar.zst -C /
echo '/opt/procursus/sbin:/opt/procursus/bin' >> $GITHUB_PATH
PATH=/opt/procursus/sbin:/opt/procursus/bin:$PATH sudo /opt/procursus/bin/apt update
sudo /opt/procursus/bin/apt -V full-upgrade -y || :
sudo /opt/procursus/bin/apt install asciidoc autoconf autoconf-archive automake autopoint bash bison cmake docbook-xml docbook-xsl fakeroot findutils flex file gawk git gnupg gpgrt-tools groff gzip ldid libtool libltdl-dev llvm make ncurses-bin openssl patch pkg-config po4a python3 sed tar triehash wget xz-utils zstd -y
- name: Add Procursus to PATH
if: steps.binpack_cache.outputs.cache-hit != 'true'
run: |
echo '/opt/procursus/sbin:/opt/procursus/bin' >> $GITHUB_PATH
- name: Setup Procursus Bootstrap (cache)
if: steps.procache.outputs.cache-hit == 'true' && steps.binpack_cache.outputs.cache-hit != 'true'
run: |
sudo mkdir -p ~/__cache/procursus/var/cache/apt/archives/partial ~/__cache/procursus/var/lib/apt/lists/partial
sudo rsync -aP ~/__cache/procursus /opt
sudo /opt/procursus/bin/apt update
sudo /opt/procursus/bin/apt --allow-downgrades -V dist-upgrade -y
sudo /opt/procursus/bin/apt --allow-downgrades -V dist-upgrade -y
- name: Build binpack
if: steps.binpack_cache.outputs.cache-hit != 'true'
run: |
cd src/binpack
gmake MEMO_CFVER=1800 MEMO_PREFIX=/cores/binpack MEMO_TARGET=iphoneos-arm64 binpack
cd ../..
- name: Process binpack.tar into binpack.tgz
if: steps.binpack_cache.outputs.cache-hit != 'true'
run: |
cd src/jbinit
cp ../binpack/build_strap/iphoneos-arm64/1800/binpack.tar .
sudo tar --preserve-permissions -xf binpack.tar
sudo cp -R cores/binpack .
sudo chown $UID:$GID .
sudo mkdir -p binpack/Library/LaunchDaemons
sudo sed 's|/binpack|/cores/binpack|' binpack/usr/share/dropbear.plist.example | sudo tee binpack/Library/LaunchDaemons/dropbear.plist
sudo rm -rf binpack/usr/share/dropbear.plist.example
sudo plutil -convert binary1 binpack/Library/LaunchDaemons/dropbear.plist
sudo chown 0:0 binpack/Library/LaunchDaemons/dropbear.plist
sudo gchmod 755 -R binpack/Library
sudo gchmod 644 binpack/Library/LaunchDaemons/dropbear.plist
tar -zcf binpack.tgz binpack
cd ../..
- name: Generate binpack.dmg
run: |
cd src/jbinit
sudo gmake binpack.dmg
cd ../..
- name: Upload binpack
uses: actions/upload-artifact@v3
with:
name: binpack.dmg
path: src/jbinit/binpack.dmg
retention-days: 1
- name: Copy Procursus to Cache Location
run: |
sudo mkdir -p ~/__cache
sudo rsync -aP /opt/procursus ~/__cache
sudo rm -rf ~/__cache/procursus/var/cache/apt/archives/partial ~/__cache/procursus/var/lib/apt/lists/partial ~/__cache/procursus/Library/dpkg/triggers/Lock
build-jbinit:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get jbinit commit
run: echo "JBINIT_COMMIT=$(git -C src/jbinit rev-parse HEAD)" >> $GITHUB_ENV
- name: Cache jbinit
uses: actions/cache@v3
id: jbinit_cache
with:
path: src/jbinit/ramdisk.dmg
key: jbinit-${{ env.JBINIT_COMMIT }}
- name: Download dependencies
if: steps.jbinit_cache.cache_hit != 'true'
run: |
brew install make coreutils
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: Build jbinit
if: steps.jbinit_cache.cache_hit != 'true'
run: |
cd src/jbinit
git submodule update --init --recursive
sudo cp -a $(xcrun -sdk macosx --show-sdk-path)/usr/include/{xpc,{launch,bootstrap}.h} $(xcrun -sdk iphoneos --show-sdk-path)/usr/include
sudo sed -i.bak -Ee 's/API_UNAVAILABLE\(.*\)//g' $(xcrun -sdk iphoneos --show-sdk-path)//System/Library/Frameworks/CoreFoundation.framework/Headers/CFUserNotification.h
sudo sed -i.bak -e 's/;}/;/g' $(xcrun -sdk iphoneos --show-sdk-path)//System/Library/Frameworks/CoreFoundation.framework/Headers/CFUserNotification.h
sudo sed -i.bak -e 's/__UNAVAILABLE_PUBLIC_IOS;/;/g' $(xcrun -sdk iphoneos --show-sdk-path)/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h
ruby -e "File.write(ARGV[0], File.read(ARGV[0]).gsub(ARGV[1]) { ARGV[2] })" $(xcrun -sdk iphoneos --show-sdk-path)/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h '__API_DEPRECATED_WITH_REPLACEMENT("kIOMainPortDefault", macos(10.0, 12.0)) __API_UNAVAILABLE(ios, watchos, tvos);' '__API_DEPRECATED_WITH_REPLACEMENT("kIOMainPortDefault", macos(10.0, 12.0)) /*__API_UNAVAILABLE(ios, watchos, tvos)*/;'
sudo chown $UID:$GID .
sudo gmake -j$(sysctl -n hw.ncpu) ramdisk.dmg
- name: Upload ramdisk
uses: actions/upload-artifact@v3
with:
name: ramdisk.dmg
path: src/jbinit/ramdisk.dmg
retention-days: 1
build-kpf:
runs-on: ubuntu-20.04
steps:
- name: Install toolchain
run: |
echo 'deb https://assets.checkra.in/debian /' | sudo tee /etc/apt/sources.list.d/checkra1n.list
sudo apt-key adv --fetch-keys https://assets.checkra.in/debian/archive.key
sudo apt-get update
sudo apt-get install -y ld64 cctools-strip
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Get Pongo commit
run: echo "PONGO_COMMIT=$(git -C src/PongoOS rev-parse HEAD)" >> $GITHUB_ENV
- name: Voodoo magic
id: voodoo
uses: actions/cache@v2
with:
key: ${{ github.event_name }}-${{ env.PONGO_COMMIT }}-${{ github.run_id }}
restore-keys: |
pongo-${{ env.PONGO_COMMIT }}-
pongo-
path: |
src/PongoOS/**
- name: Compile
run: |
cd src/PongoOS
EMBEDDED_CC='clang-10' EMBEDDED_AR='llvm-ar-10' EMBEDDED_RANLIB='llvm-ranlib-10' DEV_BUILD=1 make build/checkra1n-kpf-pongo
- name: Upload checkra1n-kpf-pongo
uses: actions/upload-artifact@v3
with:
name: checkra1n-kpf-pongo
path: src/PongoOS/build/checkra1n-kpf-pongo
retention-days: 1
build-darwin:
strategy:
matrix:
@@ -59,8 +289,9 @@ jobs:
- arch: arm64
gnu_triple: aarch64-apple-darwin
os: iphoneos
minos: 14.0
runs-on: macos-latest
minos: 7.0
runs-on: macos-12
needs: [build-loader, build-jbinit, build-binpack, build-kpf]
env:
MBEDTLS_VERSION: 3.3.0
READLINE_VERSION: 8.2
@@ -85,6 +316,24 @@ jobs:
- name: Download dependencies (embedded binaries)
run: |
echo "SDK=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)" >> $GITHUB_ENV
- name: Download binpack.dmg
uses: actions/download-artifact@v3
with:
name: binpack.dmg
path: src/palera1n/binpack.dmg
- name: Download ramdisk.dmg
uses: actions/download-artifact@v3
with:
name: ramdisk.dmg
path: src/palera1n/ramdisk.dmg
- name: Download checkra1n-kpf-pongo
uses: actions/download-artifact@v3
with:
name: checkra1n-kpf-pongo
path: src/palera1n/checkra1n-kpf-pongo
- name: Download dependencies (source code)
run: |
@@ -106,6 +355,10 @@ jobs:
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
- name: Select correct Xcode
run: |
sudo xcode-select -s /Applications/Xcode_14.2.app
- name: Setup environment
run: |
mkdir sysroot
@@ -127,6 +380,13 @@ jobs:
mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
- name: Prepare iPhoneOS environment
if: matrix.os == 'iphoneos'
run: |
echo "FAKE_PLATFORM=2" >> $GITHUB_ENV
echo "FAKE_SDK=7.0" >> $GITHUB_ENV
echo "FAKE_MINOS=7.0" >> $GITHUB_ENV
- name: Prepare headers
if: matrix.os != 'macosx'
run: |
@@ -293,23 +553,16 @@ jobs:
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.dylib' -delete
find dep_root -name '*.la' -delete
mkdir build
cd build
cmake .. -DSTATIC=1 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_C_COMPILER="${{ env.CC }}" \
-DCMAKE_C_FLAGS='${{ env.CFLAGS }}' \
-DCMAKE_FIND_ROOT_PATH="${{ env.DESTDIR }}" \
-DCMAKE_INSTALL_PREFIX="${{ env.PREFIX }}" \
-DSTATIC=1
make -j$(sysctl -n hw.ncpu)
cd ..
gmake -j$(sysctl -n hw.ncpu)
mkdir -p ready
mv build/src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
mv src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
dsymutil palera1n-${{ matrix.os }}-${{ matrix.arch }}
strip palera1n-${{ matrix.os }}-${{ matrix.arch }}
ldid -s palera1n-${{ matrix.os }}-${{ matrix.arch }}
if [ "${{ matrix.os }}" == "macosx" ]; then
ldid -S palera1n-${{ matrix.os }}-${{ matrix.arch }}
else
ldid -Ssrc/usb.xml palera1n-${{ matrix.os }}-${{ matrix.arch }}
fi
mkdir -p ready
tar -zcf ready/dep_root-${{ matrix.os }}-${{ matrix.arch }}.tgz dep_root
@@ -387,6 +640,7 @@ jobs:
- armel-linux-musleabi
- aarch64-linux-musl
runs-on: ubuntu-latest
needs: [build-loader, build-jbinit, build-binpack, build-kpf]
env:
MBEDTLS_VERSION: 3.3.0
LIBUSB_VERSION: 1.0.26
@@ -425,6 +679,24 @@ jobs:
run: |
curl -LO https://musl.cc/${{ matrix.triple }}-cross.tgz
- name: Download binpack.dmg
uses: actions/download-artifact@v3
with:
name: binpack.dmg
path: src/palera1n/binpack.dmg
- name: Download ramdisk.dmg
uses: actions/download-artifact@v3
with:
name: ramdisk.dmg
path: src/palera1n/ramdisk.dmg
- name: Download checkra1n-kpf-pongo
uses: actions/download-artifact@v3
with:
name: checkra1n-kpf-pongo
path: src/palera1n/checkra1n-kpf-pongo
- name: Setup environment
run: |
tar -xf ${{ matrix.triple }}-cross.tgz
@@ -632,29 +904,20 @@ jobs:
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.so' -delete
find dep_root -name '*.la' -delete
mkdir build
cd build
CC="${{ matrix.triple }}-gcc" cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \
-DCMAKE_FIND_ROOT_PATH=${{ env.DESTDIR }}${{ env.PREFIX }} \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_C_FLAGS="-I${{ env.DESTDIR }}${{ env.PREFIX }}/include \
-L${{ env.DESTDIR }}${{ env.PREFIX }}/lib -Wl,-rpath,${{ env.PREFIX }}/lib" -DSTATIC=1
make -j$(nproc) CC="${{ matrix.triple }}-gcc"
CC="${{ matrix.triple }}-gcc" make -j$(nproc)
- name: Seperate debug symbols
run: |
${{ matrix.triple }}-objcopy --only-keep-debug build/src/palera1n palera1n.debug
${{ matrix.triple }}-strip --strip-debug --strip-unneeded build/src/palera1n
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug build/src/palera1n
${{ matrix.triple }}-objcopy --only-keep-debug src/palera1n palera1n.debug
${{ matrix.triple }}-strip --strip-debug --strip-unneeded src/palera1n
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug src/palera1n
chmod -x palera1n.debug
- name: Prepare artifact
run: |
mkdir ready
mv palera1n.debug ready/palera1n-${{ env.CHECKRA1N_NAME }}.debug
mv build/src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
mv src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
tar -zcf ready/dep_root_${{ matrix.triple }}.tgz dep_root
- name: Upload artifact
@@ -669,3 +932,13 @@ jobs:
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
delete-artifacts:
runs-on: ubuntu-latest
needs: [darwin-dist, build-Linux]
steps:
- name: Delete all artifacts on GitHub
uses: geekyeggo/delete-artifact@v2
with:
name: '*'
failOnError: false
+6 -5
View File
@@ -7,16 +7,17 @@ contrib/
.vscode
checkra1n*
payload.c
src/palera1n
src/palera1n/palera1n
!xxd-embedded.h
src/binpack.dmg
src/ramdisk.dmg
src/xxd-*.c
src/palera1n/binpack.dmg
src/palera1n/ramdisk.dmg
src/palera1n/xxd-*.c
.DS_Store
!palera1n.1
palera1n.1.html
Payload
docs/*.html
build
src/*.dmg.c
src/palera1n/*.dmg.c
.idea
src/palera1n/libcheckra1nhelper.dylib*
+12
View File
@@ -0,0 +1,12 @@
[submodule "src/PongoOS"]
path = src/PongoOS
url = [email protected]:plooshi/PongoOS.git
[submodule "src/jbinit"]
path = src/jbinit
url = [email protected]:palera1n/jbinit.git
[submodule "src/loader"]
path = src/loader
url = [email protected]:palera1n/loader.git
[submodule "src/binpack"]
path = src/binpack
url = [email protected]:palera1n/binpack.git
-22
View File
@@ -1,22 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(palera1n)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_CXX_STANDARD 99)
set(SRC ${CMAKE_CURRENT_SOURCE_DIR})
set(DEP ${SRC}/dep_root)
set(CMAKE_C_STANDARD 99)
set(STATIC 0)
set(CMAKE_SUPPRESS_REGENERATION ON)
set(CMAKE_BUILD_TYPE BUILD_TYPE)
add_custom_target(distclean
COMMAND sh -c "find src -name '*.o' -type f -delete"
COMMAND sh -c "find src -perm -u+x -type f -delete"
)
#add_custom_target(distclean
# COMMAND sh -c "rm -rf *"
# )
add_subdirectory(src)
add_subdirectory(docs)
+17 -6
View File
@@ -1,10 +1,12 @@
NAME = The Beginning of the End
SRC = $(shell pwd)
DEP = $(SRC)/dep_root
STRIP = strip
CC ?= cc
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC)
CFLAGS += -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=199506L -D_DARWIN_C_SOURCE
CFLAGS += -Wno-unused-variable -I$(SRC)/src/palera1n -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),)
@@ -16,7 +18,7 @@ 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
@@ -32,6 +34,9 @@ CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
ifeq ($(ASAN),1)
BUILD_STYLE=ASAN
CFLAGS += -fsanitize=address,undefined -fsanitize-address-use-after-return=runtime
else ifeq ($(TSAN),1)
BUILD_STYLE=TSAN
CFLAGS += -fsanitize=thread,undefined
else
BUILD_STYLE = DEVELOPMENT
endif
@@ -39,25 +44,31 @@ 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_TAG := $(shell git describe --dirty --tags --abbrev=7)
BUILD_WHOAMI := $(shell whoami)
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)\"" -DBUILD_WHOAMI=\"$(BUILD_WHOAMI)\" -DBUILD_TAG=\"$(BUILD_TAG)\"
export SRC DEP CC CFLAGS LDFLAGS LIBS TARGET_OS DEV_BUILD BUILD_DATE BUILD_TAG BUILD_WHOAMI BUILD_STYLE
all: palera1n
palera1n: download-deps
$(MAKE) -C src
$(MAKE) -C src/palera1n
clean:
$(MAKE) -C src clean
$(MAKE) -C src/palera1n clean
$(MAKE) -C docs clean
download-deps:
$(MAKE) -C src checkra1n-macos checkra1n-linux-arm64 checkra1n-linux-armel checkra1n-linux-x86 checkra1n-linux-x86_64 checkra1n-kpf-pongo ramdisk.dmg binpack.dmg
$(MAKE) -C src/palera1n 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
+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>
-4
View File
@@ -1,4 +0,0 @@
add_custom_target(
docs
COMMAND sh -c "mandoc -T html -O style=mandoc.css palera1n.1 > palera1n.1.html"
)
+20 -15
View File
@@ -8,10 +8,10 @@
.Os
.Sh NAME
.Nm palera1n
.Nd iOS 15+ arm64 iOS/iPadOS jailbreaking tool
.Nd iOS 15.0-16.3.1 arm64 iOS/iPadOS jailbreaking tool
.Sh SYNOPSIS
.Nm
.Op Fl cCdDEfhlnLOpRsvV
.Op Fl BcdDEfhlnLOpRsvVI
.Op Fl e Ar Boot arguments
.Op Fl k Ar Pongo image
.Op Fl o Ar overlay file
@@ -20,7 +20,7 @@
.Op Fl i Ar checkra1n file
.Sh DESCRIPTION
.Nm
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15+,
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.3.1,
utilizing the
.Em checkm8
bootROM exploit.
@@ -49,7 +49,7 @@ from settings app counts as a restore.
A backup may be used in this case.
.Pp
.Sh SUPPORTED DEVICES
As described above, arm64 iOS/iPadOS 15+ devices are supported, here is an explicit
As described above, arm64 iOS/iPadOS 15.0-16.3.1 devices are supported, here is an explicit
list of supported devicecs:
.Bl -tag -compact
@@ -99,19 +99,18 @@ 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. (good for 16 GB devices)
.It Fl c , -setup-fakefs
When used with
.Fl f , -fakefs ,
Create the new APFS volume required for rootful. Will fail if one already exists.
.It Fl C , -setup-fakefs-forced
When used with
.Fl f , -fakefs ,
behaves like
.Fl c , -setup-fakefs ,
but existing fakefs, if exists, will be overwritten instead.
.It Fl d , -demote
Set the effective production fuse to 0, so as to enable hardware debugging features.
.It Fl D , -dfuhelper-only
.It Fl D , -dfuhelper
Execute the DFU helper to guide the user into putting the device into DFU mode
then exit.
.It Fl e , -boot-args Ar boot arguments
@@ -123,7 +122,7 @@ and cannot be overriden. Additionally, the
.Em wdt=-1
argument is used during fakefs setup.
.It Fl E , -enter-recovery
Exit after entering recovery mode.q
Exit after entering recovery mode.
.It Fl f , -fakefs
Jailbreak in rootful mode.
.It Fl h , -help
@@ -188,6 +187,8 @@ as well as any jailbreak-specific apps you have installed.
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
@@ -206,7 +207,7 @@ To (re-)jailbreak in rootless mode:
To setup fakefs for rootful mode:
.Pp
.Dl "palera1n -fc"
.Ppq
.Pp
After the device has rebooted, follow the following example.
.Pp
To re-jailbreak in rootful mode:
@@ -225,6 +226,10 @@ To verbose boot in rootful mode:
.Pp
.Dl "palera1n -Vf"
.Pp
To create a partial fakefs with bind mounts:
.Pp
.Dl "palera1n -Bf"
.Pp
To exit recovery mode:
.Pp
.Dl "palera1n -n"
@@ -292,9 +297,9 @@ has been mounted.
.Nm
may crash if the machine it is running on:
.Pp
.Dl "- Has no USB ports"
.Pp
.Dl "- Has non-compliant USB devices plugged in"
.Pp
The exploit may also work less reliably on some hosts, like AMD desktops, or some MediaTek devices.
.Sh NOTES
.Nm
injects a dylib into launchd to allow the
-20
View File
@@ -1,20 +0,0 @@
curl -LOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.3.0.tar.gz \
https://github.com/libusb/libusb/releases/download/1.0.26/libusb-1.0.26.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-8.2.tar.gz \
https://www.jedsoft.org/releases/slang/slang-2.3.3.tar.bz2 \
https://releases.pagure.org/newt/newt-0.52.23.tar.gz \
https://github.com/rpm-software-management/popt/archive/master-release.tar.gz
tar xf master.tar.gz
tar xf 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
+3
View File
@@ -58,6 +58,8 @@
#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)
@@ -79,6 +81,7 @@
#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 PALEINFO_MAGIC 'PLSH'
#define PALEINFO_CIGAM 'HSLP'
+17 -12
View File
@@ -31,6 +31,7 @@
#define USB_RET_SUCCESS LIBUSB_SUCCESS
#define USB_RET_NOT_RESPONDING LIBUSB_ERROR_OTHER
#define USB_RET_IO LIBUSB_ERROR_IO
#define USB_RET_NO_DEVICE LIBUSB_ERROR_NO_DEVICE
typedef int usb_ret_t;
typedef libusb_device_handle *usb_device_handle_t;
@@ -51,7 +52,8 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
#define USB_RET_SUCCESS KERN_SUCCESS
#define USB_RET_NOT_RESPONDING kIOReturnNotResponding
#define USB_RET_IO kIOReturnNotResponding
#define USB_RET_IO kIOReturnNotReady
#define USB_RET_NO_DEVICE kIOReturnNoDevice
typedef IOReturn usb_ret_t;
typedef IOUSBInterfaceInterface245 **usb_device_handle_t;
@@ -178,13 +180,13 @@ extern char* ext_checkra1n;
void thr_cleanup(void* ptr);
void* dfuhelper(void* ptr);
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char* __restrict format, ...);
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char* __restrict format, ...);
/* devhelper helpers */
void devinfo_free(devinfo_t *dev);
bool cpid_is_arm64(unsigned int cpid);
/* devhelper commands */
int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb);
int unsubscribe_cmd();
int unsubscribe_cmd(void);
int devinfo_cmd(devinfo_t *dev, const char *udid);
int enter_recovery_cmd(const char* udid);
int reboot_cmd(const char* udid);
@@ -193,33 +195,36 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
int autoboot_cmd(const uint64_t ecid);
int exitrecv_cmd(const uint64_t ecid);
int exec_checkra1n();
int exec_checkra1n(void);
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
void* pongo_helper(void* ptr);
const unsigned char *
boyermoore_horspool_memmem(const unsigned char* haystack, size_t hlen,
const unsigned char* needle, size_t nlen);
extern void* pongo_usb_callback(void* arg);
usb_ret_t USBControlTransfer(usb_device_handle_t handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t wLength, void *data, uint32_t *wLenDone);
const char *usb_strerror(usb_ret_t err);
int wait_for_pongo();
int issue_pongo_command();
int upload_pongo_file();
int tui();
int wait_for_pongo(void);
int upload_pongo_file(usb_device_handle_t, unsigned char*, unsigned int);
int issue_pongo_command(usb_device_handle_t, char*);
int tui(void);
int optparse(int argc, char* argv[]);
bool get_spin();
bool get_spin(void);
bool set_spin(bool val);
bool get_found_pongo();
bool get_found_pongo(void);
void* pongo_helper(void* _);
bool set_found_pongo(bool val);
uint64_t get_ecid_wait_for_dfu();
uint64_t get_ecid_wait_for_dfu(void);
uint64_t set_ecid_wait_for_dfu(uint64_t ecid);
void write_stdout(char *buf, uint32_t len);
void io_start(stuff_t *stuff);
void io_stop(stuff_t *stuff);
void print_credits();
void print_credits(void);
#ifdef DEV_BUILD
#include <newt.h>
+9
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;
#if defined(__APPLE__) && (TARGET_OS_IPHONE || defined(DEV_BUILD))
extern unsigned char libcheckra1nhelper_dylib[];
extern unsigned int libcheckra1nhelper_dylib_len;
#endif
#endif
-344
View File
@@ -1,344 +0,0 @@
#execute_process(COMMAND sh -c "cd ../dep_root && sh ../download_deps.sh")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
#set(SRC ${CMAKE_CURRENT_SOURCE_DIR})
#set(DEP ${SRC}/../dep_root)
cmake_parse_arguments(palera1n "" "" "-arch" ${ARGN})
set(CHECKRA1N_VERSION 0.1337.1)
if( ${LDID})
set(LDID ldid)
endif()
if( ${LIPO})
set(LIPO lipo)
endif()
if(APPLE)
set(CHECKRA1N_FILE_NAME checkra1n-macos)
else()
set(CHECKRA1N_FILE_NAME checkra1n-linux-${CMAKE_SYSTEM_PROCESSOR})
endif()
add_executable(palera1n
binpack.dmg.c
checkra1n-kpf-pongo.c
checkra1n.c
devhelper.c
dfuhelper.c
exec_checkra1n.c
lock_vars.c
lockdown_helper.c
log.c
main.c
optparse.c
override_file.c
pongo_helper.c
credits.c
ramdisk.dmg.c
../include/kerninfo.h
../include/palerain.h
../include/ANSI-color-codes.h
../include/tui.h
../include/xxd-embedded.h
)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -pedantic-errors -g)
# adds dev mode files
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES tui_main.c
tui_screen_enter_dfu.c
tui_screen_enter_recovery.c
tui_screen_jailbreak.c
tui_screen_main.c
tui_screen_options.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
elseif(CMAKE_BUILD_TYPE STREQUAL "ASAN")
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES tui_main.c
tui_screen_enter_dfu.c
tui_screen_enter_recovery.c
tui_screen_jailbreak.c
tui_screen_main.c
tui_screen_options.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
add_compile_options(-fsanitize=address,undefined -fsanitize-address-use-after-return=runtime)
elseif(CMAKE_BUILD_TYPE STREQUAL "TSAN")
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES tui_main.c
tui_screen_enter_dfu.c
tui_screen_enter_recovery.c
tui_screen_jailbreak.c
tui_screen_main.c
tui_screen_options.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
add_compile_options(-fsanitize=thread,undefined)
else()
set(CMAKE_BUILD_TYPE "Release")
endif()
#message("Testing for Clang/LLVM")
#string(TOLOWER CMAKE_C_COMPILER_ID COMPILER)
#if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# message("Using clang/llvm! Enabling -flto=full! Please make sure clang is up to date, or else compile will fail")
# add_compile_options(-flto=full)
#else()
# message("Not using clang/llvm! Using normal lto/no lto!")
# add_compile_options(-flto)
#endif()
#add_custom_command(TARGET palera1n
# COMMAND sh -c "curl -LO https://assets.checkra.in/downloads/preview/${CHECKRA1N_VERSION}/${CHECKRA1N_FILE_NAME} && chmod 755 ${CHECKRA1N_FILE_NAME}"
# )
#
#if(APPLE)
# add_custom_command(TARGET palera1n
# COMMAND sh -c "ldid -Scheckra1n.plist checkra1n"
# )
# add_custom_command(TARGET palera1n
# COMMAND lipo -thin ${CMAKE_SYSTEM_PROCESSOR} -output checkra1n checkra1n-macos
# )
# if(CFLAGS MATCHES "version-min=")
# add_custom_command(TARGET palera1n
# COMMAND sh -c "vtool -remove-build-version 1 -replace -output checkra1n checkra1n && vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n && install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n && install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n && ${LDID} -Susb.xml checkra1n"
# )
# endif()
#else()
# execute_process(
# COMMAND cp ${CHECKRA1N_FILE_NAME} ../src/checkra1n
# )
#endif()
#ifneq (,$(findstring arm64, $(CFLAGS)))
#$(LIPO) -thin arm64 -output checkra1n checkra1n-macos
#else ifneq (,$(findstring x86_64, $(CFLAGS)))
#$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
#else ifeq ($(shell arch),i386)
#$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
#else
#$(LIPO) -thin $(shell arch) -output checkra1n checkra1n-
if(APPLE)
if(${LIBUSB})
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES
usb_libusb.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
target_link_libraries(palera1n
${DEP}/lib/libusb-1.0.a
)
else()
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES
usb_iokit.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
endif()
if(IOS AND CMAKE_C_FLAGS MATCHES "arm64")
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND lipo -thin arm64 -output checkra1n checkra1n-macos
COMMAND sh -c "vtool -remove-build-version 1 -replace -output checkra1n checkra1n && vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n && install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n && install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n && ${LDID} -Susb.xml checkra1n"
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
elseif(CMAKE_C_FLAGS MATCHES "arm64")
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND lipo -thin arm64 -output checkra1n checkra1n-macos
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
else()
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND lipo -thin x86_64 -output checkra1n checkra1n-macos
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
endif()
else()
add_custom_command(
COMMAND sh -c "curl -Lo checkra1n https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
COMMAND pwd
COMMAND xxd -iC checkra1n checkra1n.c
COMMAND xxd -iC binpack.dmg binpack.dmg.c
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
)
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
list(APPEND MY_TARGET_SOURCES
usb_libusb.c)
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
target_link_libraries(palera1n
${DEP}/lib/libusb-1.0.a
)
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
endif()
include_directories(
../include
${SRC}
)
target_compile_definitions(palera1n PRIVATE -DPALERAIN_VERSION=\"2.0.0\")
target_include_directories(palera1n PRIVATE
${SRC}/include
${SRC}
${DEP}/include
)
#if(${STATIC})
target_link_libraries(palera1n
${DEP}/lib/libimobiledevice-1.0.a
${DEP}/lib/libirecovery-1.0.a
${DEP}/lib/libusbmuxd-2.0.a
${DEP}/lib/libimobiledevice-glue-1.0.a
${DEP}/lib/libplist-2.0.a
${DEP}/lib/libmbedtls.a
${DEP}/lib/libmbedcrypto.a
${DEP}/lib/libmbedx509.a
${DEP}/lib/libreadline.a
)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
if(NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()
#else()
# find_library(LIBIMOBILEDEVICE libimobiledevice)
# if (NOT CORE_FOUNDATION)
# message(FATAL_ERROR "libimobiledevice not found")
# endif()
# target_link_libraries(palera1n ${LIBIMOBILEDEVICE})
#
# find_library(LIR libirecovery)
# if (NOT SYSCONF)
# message(FATAL_ERROR "libirecovery not found")
# endif()
# target_link_libraries(palera1n ${LIR})
#
# find_library(USBMUXD usbmuxd)
# if (NOT SEC)
# message(FATAL_ERROR "usbmuxd not found")
# endif()
# target_link_libraries(palera1n ${USBMUXD})
#
# find_library(GLUE libimobiledevice-glue)
# if (NOT IOKIT)
# message(FATAL_ERROR "libimobiledevice-glue not found")
# endif()
# target_link_libraries(palera1n ${GLUE})
#
## target_link_libraries(palera1n
## imobiledevice-1.0
## irecovery-1.0
## usbmuxd-2.0
## imobiledevice-glue-1.0
## plist-2.0
## mbedtls
## mbedcrypto
## mbedx509
## readline
## usb-1.0
## )
#endif()
#if(APPLE)
# add_compile_options(palera1n
# -framework CoreFoundation
# -framework SystemConfiguration
# -framework IOKit
# -framework Security
# )
#endif()
if(APPLE)
find_library(CORE_FOUNDATION CoreFoundation)
if (NOT CORE_FOUNDATION)
message(FATAL_ERROR "CoreFoundation not found")
endif()
target_link_libraries(palera1n ${CORE_FOUNDATION})
find_library(SYSCONF SystemConfiguration)
if (NOT SYSCONF)
message(FATAL_ERROR "SystemConfiguration not found")
endif()
target_link_libraries(palera1n ${SYSCONF})
find_library(SEC Security)
if (NOT SEC)
message(FATAL_ERROR "Security not found")
endif()
target_link_libraries(palera1n ${SEC})
find_library(IOKIT IOKit)
if (NOT IOKIT)
message(FATAL_ERROR "IOKit not found")
endif()
target_link_libraries(palera1n ${IOKIT})
endif()
add_compile_options(palera1n
-static -no-pie -Wl,--gc-sections
)
if(!BUILD_DATE)
execute_process(COMMAND date OUTPUT_VARIABLE BUILD_DATE)
endif()
if(!BUILD_TAG)
execute_process(COMMAND git describe --dirty --tags --abbrev=7 OUTPUT_VARIABLE BUILD_TAG)
endif()
if(!BUILD_WHOAMI)
execute_process(COMMAND whoami OUTPUT_VARIABLE BUILD_WHOAMI)
endif ()
set(INCLUDE_DIR /usr/local/include)
include_directories (${INCLUDE_DIR})
add_compile_definitions(
BUILD_DATE="${BUILD_DATE}"
BUILD_TAG="${BUILD_TAG}"
BUILD_WHOAMI="${BUILD_WHOAMI}"
BUILD_STYLE="${CMAKE_BUILD_TYPE}"
)
Submodule
+1
Submodule src/PongoOS added at f3e1294f42.
Submodule
+1
Submodule src/binpack added at dc0ef6423c.
-19
View File
@@ -1,19 +0,0 @@
#include <stdio.h>
#define EE fprintf
#define Q }
#define P print_credits() {
#define BAKERAIN_DEVELOPER "dora2ios"
#define O void
#define Y )
#define Z (
#define R stdout
#define S ,
#define T ;
#define A "# == palera1n-c == \n#\n"
#define B "# Made by: Nick Chan, Tom, Mineek, Nebula, llsc12\n#\n"
#define C "# Thanks to: " BAKERAIN_DEVELOPER ", pythonplayer, tihmstar, nikias\n"
#define D "# (libimobiledevice), checkra1n team (Siguza, axi0mx, littlelailo\n"
#define E "# et al.), Procursus Team (Hayden Seay, Cameron Katri, Keto et.al)\n\n"
O P EE Z R S A B C D E Y T Q
Submodule
+1
Submodule src/jbinit added at 68dfd57cd5.
Submodule
+1
Submodule src/loader added at d73b4ac49f.
+19 -3
View File
@@ -3,7 +3,18 @@ all: palera1n
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o
OBJECTS += optparse.o override_file.o log.o lock_vars.o credits.o
OBJECTS += fake_embedded.o exec_checkra1n.o pongo_helper.o
OBJECTS += boyermoore_memmem.o
ifeq (,$(findstring macosx, $(CFLAGS)))
ifneq (,$(findstring version-min=, $(CFLAGS)))
OBJECTS += xxd-libcheckra1nhelper.dylib.o
endif
endif
ifeq ($(FORCE_HELPER),1)
OBJECTS += xxd-libcheckra1nhelper.dylib.o
CFLAGS += -DFORCE_HELPER
endif
ifneq ($(NO_RAMDISK),1)
OBJECTS += xxd-ramdisk.dmg.o
@@ -38,6 +49,8 @@ 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
@@ -91,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 stdout
#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
+5 -3
View File
@@ -37,6 +37,7 @@
#include <palerain.h>
irecv_device_event_context_t irecvctx = NULL;
usbmuxd_subscription_context_t usbmuxdctx = NULL;
void devinfo_free(devinfo_t *dev) {
free(dev->buildVersion);
@@ -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;
}
+61 -12
View File
@@ -36,7 +36,7 @@ int dfuhelper_thr_running = false;
void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
for (int i = time2; i < time; i++) {
printf(CYN "\r\033[K%s (%d)" CRESET, text, time - i + time2);
printf(BCYN "\r\033[K%s (%d)" CRESET, text, time - i + time2);
fflush(stdout);
sleep(1);
if (cond != NULL && cond(cond_arg)) pthread_exit(NULL);
@@ -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,11 +70,25 @@ 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);
@@ -96,12 +111,13 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
cpid = info->cpid;
ecid = info->ecid;
bdid = info->bdid;
if (!cpid_is_arm64(info->cpid)) {
info = NULL;
if (!cpid_is_arm64(cpid)) {
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
return NULL;
}
sleep(1);
ret = autoboot_cmd(info->ecid);
ret = autoboot_cmd(ecid);
if (ret) {
LOG(LOG_ERROR, "Cannot set auto-boot back to true");
return NULL;
@@ -113,9 +129,8 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
step(4, 2, "Hold volume down + side button", NULL, 0);
else
step(4, 2, "Hold home + power button", NULL, 0);
set_ecid_wait_for_dfu(info->ecid);
ret = exitrecv_cmd(info->ecid);
info = NULL;
set_ecid_wait_for_dfu(ecid);
ret = exitrecv_cmd(ecid);
if (ret) {
LOG(LOG_ERROR, "Cannot exit recovery mode");
set_ecid_wait_for_dfu(0);
@@ -126,7 +141,7 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
if (nohome)
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);
else
@@ -184,7 +199,8 @@ 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");
@@ -195,11 +211,44 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
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) ||
@@ -217,8 +266,8 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
void *dfuhelper(void* ptr) {
dfuhelper_thr_running = true;
subscribe_cmd(device_event_cb, irecv_device_event_cb);
set_spin(1);
subscribe_cmd(device_event_cb, irecv_device_event_cb);
while (get_spin()) {
sleep(1);
};
@@ -11,9 +11,15 @@
#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;
@@ -24,7 +30,7 @@ char* ext_checkra1n = NULL;
#define tmpdir getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")
int exec_checkra1n() {
int exec_checkra1n(void) {
LOG(LOG_INFO, "About to execute checkra1n");
int fd, ret;
char* checkra1n_path = NULL;
@@ -53,10 +59,52 @@ int exec_checkra1n() {
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] = "-pE";
char args[0x10] = "-E";
if (checkrain_option_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
if (!checkrain_option_enabled(host_flags, palerain_option_checkrain_is_clone)) {
strncat(args, "p", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
} else {
strncat(args, "R", 0xf);
}
if (pongo_path != NULL) strncat(args, "k", 0xf); // keep this at last
pid_t pid;
char* checkra1n_argv[] = {
@@ -80,6 +128,15 @@ checkra1n_exec: {};
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 0;
}
File renamed without changes.
+23 -27
View File
@@ -39,43 +39,39 @@ newtComponent tui_log_output = NULL;
bool spin, found_pongo = 0;
uint64_t ecid_wait_for_dfu = 0;
bool get_spin() {
LOG(LOG_VERBOSE5, "locking spin mutex for get");
pthread_mutex_lock(&spin_mutex);
bool ret = spin;
LOG(LOG_VERBOSE5, "UN-locking spin mutex, spin value is %d", spin);
pthread_mutex_unlock(&spin_mutex);
static bool get_locked_bool(bool* val, pthread_mutex_t* mutex) {
// fprintf(stderr, "%s: val = %p mutex = %p\n", __func__, (void*)val, (void*)mutex);
pthread_mutex_lock(mutex);
bool ret = *val;
pthread_mutex_unlock(mutex);
return ret;
}
bool set_spin(bool val) {
LOG(LOG_VERBOSE5, "locking spin mutex for set spin = %d", val);
pthread_mutex_lock(&spin_mutex);
spin = val;
LOG(LOG_VERBOSE5, "UN-locking spin mutex after setting spin\n");
pthread_mutex_unlock(&spin_mutex);
return val;
static bool set_locked_bool(bool* val, bool newval, pthread_mutex_t* mutex) {
// fprintf(stderr, "%s: val = %p mutex = %p, newval = %d\n", __func__, (void*)val, (void*)mutex, newval);
pthread_mutex_lock(mutex);
*val = newval;
pthread_mutex_unlock(mutex);
return newval;
}
bool get_found_pongo() {
LOG(LOG_VERBOSE5, "locking found pongo mutex for get");
pthread_mutex_lock(&found_pongo_mutex);
bool ret = found_pongo;
LOG(LOG_VERBOSE5, "UN-locking pongo mutex, found_pongo value is %d", found_pongo);
pthread_mutex_unlock(&found_pongo_mutex);
return ret;
bool get_spin(void) {
return get_locked_bool(&spin, &spin_mutex);
}
bool set_spin(bool newval) {
return set_locked_bool(&spin, newval, &spin_mutex);
}
bool get_found_pongo(void) {
return get_locked_bool(&found_pongo, &found_pongo_mutex);
}
bool set_found_pongo(bool val) {
LOG(LOG_VERBOSE5, "locking found pongo mutex for set found_pongo = %d", val);
pthread_mutex_lock(&found_pongo_mutex);
found_pongo = val;
LOG(LOG_VERBOSE5, "UN-locking pongo mutex after setting found_pongo");
pthread_mutex_unlock(&found_pongo_mutex);
return val;
return set_locked_bool(&found_pongo, val, &found_pongo_mutex);
}
uint64_t get_ecid_wait_for_dfu() {
uint64_t get_ecid_wait_for_dfu(void) {
LOG(LOG_VERBOSE5, "locking ecid wait for dfu mutex for get");
pthread_mutex_lock(&ecid_dfu_wait_mutex);
uint64_t ret = ecid_wait_for_dfu;
File renamed without changes.
File renamed without changes.
+1 -1
View File
@@ -8,7 +8,7 @@
#include <ANSI-color-codes.h>
#include <palerain.h>
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...)
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char *__restrict format, ...)
{
if (verbose >= 5
#ifdef DEV_BUILD
+39 -5
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>
@@ -56,9 +56,9 @@ void thr_cleanup(void* ptr) {
*(int*)ptr = 0;
}
int build_checks() {
#if defined(__APPLE__)
int build_checks(void) {
#ifndef NO_CHECKRAIN
#if defined(__APPLE__)
struct mach_header_64* c1_header = (struct mach_header_64*)&checkra1n[0];
if (c1_header->magic != MH_MAGIC_64 && c1_header->magic != MH_CIGAM_64) {
LOG(LOG_FATAL, "Broken build: checkra1n is not a thin Mach-O");
@@ -69,6 +69,13 @@ int build_checks() {
return -1;
}
#endif
if (checkra1n_len <= (UCHAR_MAX + 1)) {
LOG(LOG_FATAL, "checkra1n too small");
}
if (boyermoore_horspool_memmem(&checkra1n[0], checkra1n_len, (const unsigned char*)"[ra1npoc15-part] thanks to", strlen("[ra1npoc15-part] thanks to")) != NULL) {
host_flags |= palerain_option_checkrain_is_clone;
LOG(LOG_WARNING, "Do not distribute!");
}
#endif
#ifndef NO_KPF
struct mach_header_64 *kpf_hdr = (struct mach_header_64 *)checkra1n_kpf_pongo;
@@ -91,6 +98,12 @@ int build_checks() {
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[]) {
int ret = 0;
pthread_mutex_init(&log_mutex, NULL);
@@ -98,8 +111,9 @@ int palera1n(int argc, char *argv[]) {
pthread_mutex_init(&found_pongo_mutex, NULL);
pthread_mutex_init(&ecid_dfu_wait_mutex, NULL);
if ((ret = build_checks())) return ret;
print_credits();
if ((ret = optparse(argc, argv))) goto cleanup;
if (!checkrain_option_enabled(host_flags, host_option_device_info))
print_credits();
if (checkrain_option_enabled(host_flags, host_option_palerain_version)) goto normal_exit;
#ifdef DEV_BUILD
if (checkrain_option_enabled(host_flags, host_option_tui)) {
@@ -108,7 +122,26 @@ int palera1n(int argc, char *argv[]) {
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);
@@ -117,6 +150,7 @@ int palera1n(int argc, char *argv[]) {
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;
if (exec_checkra1n()) goto cleanup;
+47 -15
View File
@@ -9,15 +9,17 @@
#include <ctype.h>
#include <assert.h>
#include <getopt.h>
#include <limits.h>
#include <errno.h>
#include <palerain.h>
#include <sys/mman.h>
checkrain_option_t host_flags = 0;
checkrain_option_p host_flags_p = &host_flags;
static 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'},
@@ -41,6 +43,7 @@ static struct option longopts[] = {
{"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'},
@@ -59,17 +62,17 @@ static int usage(int e, char* prog_name)
#endif
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n"
"Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n"
"iOS/iPadOS 15+ arm64 jailbreaking tool\n\n"
"iOS/iPadOS 15.0-16.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, --demote\t\t\t\tDemote\n"
"\t-D, --dfuhelper-only\t\t\tExit after entering DFU\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"
@@ -80,6 +83,7 @@ static int usage(int e, char* prog_name)
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\n"
"\t-n, --exit-recovery\t\t\tExit recovery mode\n"
"\t-I, --device-info\t\t\tPrint info about the connected device\n"
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
"\t-p, --pongo-shell\t\t\tBoots to PongoOS shell\n"
@@ -106,20 +110,20 @@ int optparse(int argc, char* argv[]) {
int index;
while ((opt = getopt_long(argc, argv,
#ifdef DEV_BUILD
"12cCDEhpvVldsOLftRnPe:o:r:K:k:i:",
"12BcDEhpvVldsOLftRnPIe:o:r:K:k:i:",
#else
"cCDEhpvVldsOLfRnPe:o:r:K:k:i:",
"BcDEhpvVldsOLfRnPIe:o:r:K:k:i:",
#endif
longopts, NULL)) != -1)
{
switch (opt) {
case 'c':
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;
palerain_flags |= palerain_option_setup_rootful_forced;
case 'c':
palerain_flags |= palerain_option_setup_rootful;
kpf_flags |= checkrain_option_verbose_boot;
break;
case 'p':
@@ -209,7 +213,36 @@ int optparse(int argc, char* argv[]) {
} else if (!(st.st_mode & S_IXUSR) && !(st.st_mode & S_IXGRP) && !(st.st_mode & S_IXOTH)) {
LOG(LOG_FATAL, "%s is not executable", optarg);
return -1;
};
} else if (!(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;
@@ -222,6 +255,9 @@ int optparse(int argc, char* argv[]) {
case 'O':
host_flags |= host_option_no_ohio;
break;
case 'I':
host_flags |= host_option_device_info;
break;
#ifdef DEV_BUILD
case 't':
host_flags |= host_option_tui;
@@ -249,10 +285,6 @@ int optparse(int argc, char* argv[]) {
return 0;
}
if (checkrain_option_enabled(checkrain_flags, checkrain_option_force_revert) && checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
LOG(LOG_WARNING, "force revert and setup rootful requested at the same time, behaviour here is undefined");
}
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);
File renamed without changes.
@@ -11,6 +11,7 @@
#include <sys/stat.h> // fstst
#include <palerain.h>
#include <ANSI-color-codes.h>
bool device_has_booted = 0;
int pongo_thr_running = 0;
@@ -36,7 +37,7 @@ void *pongo_usb_callback(void *arg) {
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");
@@ -68,12 +69,22 @@ void *pongo_usb_callback(void *arg) {
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;
}
@@ -129,10 +140,10 @@ fetch_output:
bad:
if (ret != USB_RET_SUCCESS)
{
if (ret == USB_RET_NOT_RESPONDING)
return 0;
if (command != NULL && (!strncmp("boot", command, 4) && ret == USB_RET_IO))
return 0;
if (command != NULL && (!strncmp("boot", command, 4))) {
if (ret == USB_RET_IO || ret == USB_RET_NO_DEVICE || ret == USB_RET_NOT_RESPONDING)
return 0;
}
LOG(LOG_ERROR, "USB error: %s", usb_strerror(ret));
return ret;
}
@@ -149,19 +160,25 @@ int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned i
ret = USBBulkUpload(handle, buf, buf_len);
if (ret == USB_RET_SUCCESS)
{
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
if (verbose < 3 || verbose > 4) {
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
} else {
printf("/send mem:%p:%p\n" BCYN "[Uploaded %llu bytes]\n" CRESET, (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
}
}
}
if (verbose >= 3) printf("pongoOS> ");
return ret;
}
void io_start(stuff_t *stuff)
{
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, &stuff->handle);
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, stuff);
if(r != 0)
{
ERR("pthread_create: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
set_spin(0);
return;
}
pthread_join(stuff->th, NULL);
}
@@ -172,14 +189,19 @@ void io_stop(stuff_t *stuff)
if(r != 0)
{
ERR("pthread_cancel: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
set_spin(0);
return;
}
r = pthread_join(stuff->th, NULL);
if(r != 0)
{
ERR("pthread_join: %s", strerror(r));
exit(-1); // TODO: ok with libusb?
set_spin(0);
return;
}
#ifdef USE_LIBUSB
libusb_unref_device(stuff->dev);
#endif
}
void write_stdout(char *buf, uint32_t len)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+15 -13
View File
@@ -38,7 +38,7 @@
#include <sys/stat.h> // fstst
#include <palerain.h>
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
#define ERR(...) LOG(LOG_ERROR, __VA_ARGS__)
void io_start(stuff_t *stuff);
void io_stop(stuff_t *stuff);
@@ -171,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;
@@ -181,8 +182,9 @@ int wait_for_pongo(void)
{
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));
@@ -192,32 +194,32 @@ 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;
}
@@ -235,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]);
@@ -243,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;
@@ -252,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));
@@ -260,7 +262,7 @@ int wait_for_pongo(void)
}
}
libusb_exit(NULL);
libusb_exit(ctx);
return 0;
}
#endif