Compare commits

..
Author SHA1 Message Date
Nick Chan f92cc2c04d rootful real part 1 2023-04-15 22:15:08 +08:00
17 changed files with 305 additions and 265 deletions

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ DEP = $(SRC)/dep_root
STRIP = strip STRIP = strip
CC ?= cc CC ?= cc
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC)
CFLAGS += -Wall -Wextra -Wno-unused-parameter -DPALERAIN_VERSION=\"2.0.0\" 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=200112L CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=200112L
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread
+1 -1
View File
@@ -2,7 +2,7 @@
<source media="(prefers-color-scheme: light)" srcset="https://cdn.discordapp.com/attachments/1028398976640229380/1088049124441604136/IMG_0033.png"> <source media="(prefers-color-scheme: light)" srcset="https://cdn.discordapp.com/attachments/1028398976640229380/1088049124441604136/IMG_0033.png">
<img align="left" height="120" src="https://cdn.discordapp.com/attachments/1017854329887129611/1073858292159352862/thing.png" alt="palera1n logo" style="float: left;"/> <img align="left" height="120" src="https://cdn.discordapp.com/attachments/1017854329887129611/1073858292159352862/thing.png" alt="palera1n logo" style="float: left;"/>
</picture> </picture>
<h3 align="right">An iOS 15.0-16.4.1 work-in-progress, <br>semi-tethered checkm8 jailbreak</h3> <h3 align="right">An iOS 15.0-16.4 work-in-progress, <br>semi-tethered checkm8 jailbreak</h3>
<p align="right" > <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://cdn.nickchan.lol/palera1n/c-rewrite/releases/v2.0.0-beta.4/palera1n.1.html">Usage</a></strong>
+11 -11
View File
@@ -6,7 +6,7 @@
.Dt palera1n 1 .Dt palera1n 1
.Sh NAME .Sh NAME
.Nm palera1n .Nm palera1n
.Nd iOS 15.0-16.4.1 arm64 iOS/iPadOS jailbreaking tool .Nd iOS 15.0-16.4 arm64 iOS/iPadOS jailbreaking tool
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl cCdDEfhIlLnpRsSvV .Op Fl cCdDEfhIlLnpRsSvV
@@ -20,7 +20,7 @@
.Op Fl -force-revert .Op Fl -force-revert
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.4.1, jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.4,
utilizing the utilizing the
.Em checkm8 .Em checkm8
bootROM exploit. bootROM exploit.
@@ -52,7 +52,7 @@ In the remainder of this document, the term "iOS" and "iPadOS" will be used inte
as the difference is negligible as far as the jailbreak is concerened. as the difference is negligible as far as the jailbreak is concerened.
.Pp .Pp
.Sh SUPPORTED DEVICES .Sh SUPPORTED DEVICES
As described above, arm64 iOS 15.0-16.4.1 devices are supported, here is an explicit As described above, arm64 iOS 15.0-16.4 devices are supported, here is an explicit
list of supported devicecs: list of supported devicecs:
.Bl -tag -compact .Bl -tag -compact
@@ -96,11 +96,11 @@ Remove the jailbreak while keeping user data. Some jailbreak files may remain
after running this command. Additionally, jailbreak apps will remain on the 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 home screen on for a while even when the files are deleted as the icon cache
still has their icons. When used with still has their icons. When used with
.Fl f , -fakefs , .Fl f , -rootful ,
this will actually boot the device in rootless mode then delete the jailbreak 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 files. As a result, using the loader app to install the jailbreak environment
is not supported when this option is used together with is not supported when this option is used together with
.Fl f , -fakefs .Fl f , -rootful
\[char46] \[char46]
.It Fl B , -setup-fakefs-partial .It Fl B , -setup-fakefs-partial
Like Like
@@ -111,8 +111,8 @@ when setting up fakefs for rootful, as they do not have enough storage for full
This option currently does not work on iOS 16. This option currently does not work on iOS 16.
.It Fl c , -setup-fakefs .It Fl c , -setup-fakefs
When used with When used with
.Fl f , -fakefs , .Fl f , -rootful ,
creates the new APFS volume required for rootful. Will fail if one already exists. creates the new APFS volume required for rootful on iOS/iPadOS. Will fail if one already exists.
.It Fl d , -demote .It Fl d , -demote
Set the effective production fuse to 0, so as to enable hardware debugging features. Set the effective production fuse to 0, so as to enable hardware debugging features.
.It Fl D , -dfuhelper .It Fl D , -dfuhelper
@@ -128,7 +128,7 @@ and cannot be overriden. Additionally, the
argument is used during fakefs setup. argument is used during fakefs setup.
.It Fl E , -enter-recovery .It Fl E , -enter-recovery
Exit after entering recovery mode. Exit after entering recovery mode.
.It Fl f , -fakefs .It Fl f , -rootful
Proceed in rootful mode. This applies to both full fakefs and partial fakefs. Proceed in rootful mode. This applies to both full fakefs and partial fakefs.
.It Fl h , -help .It Fl h , -help
Prints help text. Prints help text.
@@ -149,7 +149,7 @@ iOS15 branch or your own fork of it.
Proceed in rootless mode, this is the default when neither Proceed in rootless mode, this is the default when neither
.Fl l , -rootless .Fl l , -rootless
and and
.Fl f , -fakefs .Fl f , -rootful
is specified. is specified.
.Fl L , -jbinit-log-to-file .Fl L , -jbinit-log-to-file
Makes jbinit log to Makes jbinit log to
@@ -259,7 +259,7 @@ before they can be ran on a device jailbroken with
\[char46] \[char46]
.Pp .Pp
When using rootful mode, the When using rootful mode, the
.Fl f , -fakefs .Fl f , -rootful
flag must be specified at all times. It does not matter whether you want to create 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. create partial fakefs, rejailbreak or remove jailbreak.
.Sh POST INSTALLATION .Sh POST INSTALLATION
@@ -311,7 +311,7 @@ may crash if the machine it is running on:
.Pp .Pp
The exploit may also work less reliably on some hosts, like AMD desktops, or some MediaTek devices. The exploit may also work less reliably on some hosts, like AMD desktops, or some MediaTek devices.
.Pp .Pp
The device may randomly crash and reboot due to launchd exiting with code 7. The device may randomly crash and reboot due to launchd receiving signal 7 (SIGEMT).
.Sh NOTES .Sh NOTES
.Nm .Nm
injects a dylib into launchd to allow the injects a dylib into launchd to allow the
+14 -1
View File
@@ -61,6 +61,9 @@
#define palerain_option_setup_partial_root (1 << 4) /* fakefs creating should be partial */ #define palerain_option_setup_partial_root (1 << 4) /* fakefs creating should be partial */
#define palerain_option_checkrain_is_clone (1 << 5) /* supplied checkra1n is checkra1n clone */ #define palerain_option_checkrain_is_clone (1 << 5) /* supplied checkra1n is checkra1n clone */
#define palerain_option_rootless_livefs (1 << 6) /* mount root livefs on rootless */ #define palerain_option_rootless_livefs (1 << 6) /* mount root livefs on rootless */
#define palerain_option_no_ssv (1 << 7) /* no signed system volume */
#define palerain_option_force_fakefs (1 << 8) /* force fakefs, even without SSV */
#define palerain_option_rootless (1 << 9) /* rootless jailbreak */
#ifdef DEV_BUILD #ifdef DEV_BUILD
#define palerain_option_test1 (1 << 29) #define palerain_option_test1 (1 << 29)
@@ -122,8 +125,18 @@ struct kpfinfo {
options = (checkrain_option_t)(options & ~option); \ options = (checkrain_option_t)(options & ~option); \
} while (0); } while (0);
static inline bool checkrain_options_enabled(checkrain_option_t flags, checkrain_option_t opt) static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_option_t opt)
{ {
if(flags == checkrain_option_failure)
{
switch(opt)
{
case checkrain_option_safemode:
return true;
default:
return false;
}
}
return (flags & opt) != 0; return (flags & opt) != 0;
} }
+9 -5
View File
@@ -22,8 +22,14 @@
#define CMD_LEN_MAX 512 #define CMD_LEN_MAX 512
#define OVERRIDE_MAGIC 0xd803b376 #define OVERRIDE_MAGIC 0xd803b376
#define palerain_option_case_version palerain_option_case(0) #define palerain_option_case_version palerain_option_case(0)
#define palerain_option_case_force_revert palerain_option_case(1) #define palerain_option_case_force_revert palerain_option_case(1)
#ifdef DEV_BUILD
#define palerain_option_case_ignore_ssv palerain_option_case(2)
#define palerain_option_case_force_fakefs palerain_option_case(3)
#define palerain_option_case_rootless_livefs palerain_option_case(4)
#endif
#ifdef USE_LIBUSB #ifdef USE_LIBUSB
#include <libusb-1.0/libusb.h> #include <libusb-1.0/libusb.h>
@@ -100,8 +106,6 @@ struct mach_header_64
}; };
#endif #endif
typedef void *(*pthread_start_t)(void *);
// Keep in sync with Pongo // Keep in sync with Pongo
#define PONGO_USB_VENDOR 0x05ac #define PONGO_USB_VENDOR 0x05ac
#define PONGO_USB_PRODUCT 0x4141 #define PONGO_USB_PRODUCT 0x4141
@@ -205,7 +209,7 @@ boyermoore_horspool_memmem(const unsigned char* haystack, size_t hlen,
const unsigned char* needle, size_t nlen); const unsigned char* needle, size_t nlen);
extern void* pongo_usb_callback(stuff_t* arg); 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 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); const char *usb_strerror(usb_ret_t err);
int wait_for_pongo(void); int wait_for_pongo(void);
+1 -1
View File
@@ -20,7 +20,7 @@
#define PI_STEP_CURRENT NEWT_COLORSET_CUSTOM(1) #define PI_STEP_CURRENT NEWT_COLORSET_CUSTOM(1)
#define PI_STEP_OTHER NEWT_COLORSET_CUSTOM(2) #define PI_STEP_OTHER NEWT_COLORSET_CUSTOM(2)
#define CHECKBOX_STATE(flags, opt) checkrain_options_enabled(flags, opt) ? '*' : ' ' #define CHECKBOX_STATE(flags, opt) checkrain_option_enabled(flags, opt) ? '*' : ' '
typedef enum tui_screens { typedef enum tui_screens {
ERROR_SCREEN = -1, ERROR_SCREEN = -1,
+1 -1
View File
@@ -8,7 +8,7 @@ Depends: usbmuxd
Section: Utilities Section: Utilities
Priority: optional Priority: optional
Homepage: https://palera.in Homepage: https://palera.in
Description: iOS 15.0-16.4.1 semi-tethered checkm8 jailbreak Description: iOS 15.0-16.4 semi-tethered checkm8 jailbreak
palera1n is an iOS/iPadOS 15.0-15.3.1 semi tethered jailbreak palera1n is an iOS/iPadOS 15.0-15.3.1 semi tethered jailbreak
based on the checkm8 exploit. based on the checkm8 exploit.
. .
+1 -1
View File
@@ -7,7 +7,7 @@ Author: palera1n team
Section: Utilities Section: Utilities
Priority: optional Priority: optional
Homepage: https://palera.in Homepage: https://palera.in
Description: iOS 15.0-16.4.1 semi-tethered checkm8 jailbreak Description: iOS 15.0-16.4 semi-tethered checkm8 jailbreak
palera1n is an iOS/iPadOS 15.0-15.3.1 semi tethered jailbreak palera1n is an iOS/iPadOS 15.0-15.3.1 semi tethered jailbreak
based on the checkm8 exploit. based on the checkm8 exploit.
. .
+3 -3
View File
@@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#ifndef BAKERAIN_DEVELOPE_R #ifndef BAKERAIN_DEVELOPE_R
#define BAKERAIN_DEVELOPE_R "kok3shidoll" #define BAKERAIN_DEVELOPE_R "dora2ios"
#endif #endif
#define THE_PLUSH "Ploosh" #define THE_PLUSH "Ploosh"
@@ -12,8 +12,8 @@
#define B stderr #define B stderr
#define L , #define L ,
#define E "# == palera1n-c == \n#\n" #define E "# == palera1n-c == \n#\n"
#define M "# Made by: Nick Chan, " THE_PLUSH ", Samara, Nebula, staturnz, " BAKERAIN_DEVELOPE_R " \n#\n" #define M "# Made by: Nick Chan, " THE_PLUSH ", Mineek, Nebula, llsc12\n#\n"
#define A "# Thanks to: pythonplayer123, llsc12, Mineek, tihmstar, nikias\n" #define A "# Thanks to: " BAKERAIN_DEVELOPE_R ", pythonplayer, tihmstar, nikias\n"
#define K "# (libimobiledevice), checkra1n team (Siguza, axi0mx, littlelailo\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 I "# et al.), Procursus Team (Hayden Seay, Cameron Katri, Keto et.al)\n\n"
#define N ) #define N )
+75 -78
View File
@@ -76,27 +76,27 @@ bool cpid_is_arm64(unsigned int cpid) {
* ========== 0x8960 =========== * ========== 0x8960 ===========
* (ARM64) A7 * (ARM64) A7
*/ */
return ( if (
cpid == 0x8960 || cpid == 0x7000 || cpid == 0x7001 || cpid == 0x8960 || cpid == 0x7000 || cpid == 0x7001
cpid == 0x8000 || cpid == 0x8001 || cpid == 0x8003 || || cpid == 0x8000 || cpid == 0x8001 || cpid == 0x8003
cpid == 0x8010 || cpid == 0x8011 || cpid == 0x8012 || || cpid == 0x8010 || cpid == 0x8011 || cpid == 0x8012
cpid == 0x8015 || cpid == 0x8015
);
) return true;
return false;
} }
int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb) int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb)
{ {
int ret; usbmuxd_events_subscribe(&usbmuxdctx, device_event_cb, NULL);
if ((ret = usbmuxd_events_subscribe(&usbmuxdctx, device_event_cb, NULL))) return ret; irecv_device_event_subscribe(&irecvctx, irecv_event_cb, NULL);
if ((ret = irecv_device_event_subscribe(&irecvctx, irecv_event_cb, NULL))) return ret;
return 0; return 0;
} }
int unsubscribe_cmd(void) int unsubscribe_cmd(void)
{ {
int ret; usbmuxd_events_unsubscribe(usbmuxdctx);
if ((ret = usbmuxd_events_unsubscribe(usbmuxdctx))) return ret; irecv_device_event_unsubscribe(irecvctx);
if ((ret = irecv_device_event_unsubscribe(irecvctx))) return ret;
irecvctx = NULL; irecvctx = NULL;
usbmuxdctx = NULL; usbmuxdctx = NULL;
return 0; return 0;
@@ -119,15 +119,15 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
} }
if (lockdownd_client_new(device, &lockdown, "palera1n") != LOCKDOWN_E_SUCCESS) if (lockdownd_client_new(device, &lockdown, "palera1n") != LOCKDOWN_E_SUCCESS)
{ {
(void)idevice_free(device); idevice_free(device);
LOG(LOG_ERROR, "Device is not in normal mode."); LOG(LOG_ERROR, "Device is not in normal mode.");
return -1; return -1;
} }
plist_t node = NULL; plist_t node = NULL;
if (lockdownd_get_value(lockdown, NULL, "UniqueChipID", &node) != LOCKDOWN_E_SUCCESS) if (lockdownd_get_value(lockdown, NULL, "UniqueChipID", &node) != LOCKDOWN_E_SUCCESS)
{ {
(void)lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
(void)idevice_free(device); idevice_free(device);
LOG(LOG_ERROR, "Error getting ECID"); LOG(LOG_ERROR, "Error getting ECID");
return -1; return -1;
} }
@@ -137,8 +137,8 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL; node = NULL;
if (lockdownd_get_value(lockdown, NULL, "ProductType", &node) != LOCKDOWN_E_SUCCESS) if (lockdownd_get_value(lockdown, NULL, "ProductType", &node) != LOCKDOWN_E_SUCCESS)
{ {
(void)lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
(void)idevice_free(device); idevice_free(device);
LOG(LOG_ERROR, "Error getting product type"); LOG(LOG_ERROR, "Error getting product type");
return -1; return -1;
} }
@@ -148,8 +148,8 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL; node = NULL;
if (lockdownd_get_value(lockdown, NULL, "CPUArchitecture", &node) != LOCKDOWN_E_SUCCESS) if (lockdownd_get_value(lockdown, NULL, "CPUArchitecture", &node) != LOCKDOWN_E_SUCCESS)
{ {
(void)lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
(void)idevice_free(device); idevice_free(device);
LOG(LOG_ERROR, "Error getting CPU type"); LOG(LOG_ERROR, "Error getting CPU type");
return -1; return -1;
} }
@@ -159,8 +159,8 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL; node = NULL;
if (lockdownd_get_value(lockdown, NULL, "ProductVersion", &node) != LOCKDOWN_E_SUCCESS) if (lockdownd_get_value(lockdown, NULL, "ProductVersion", &node) != LOCKDOWN_E_SUCCESS)
{ {
(void)lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
(void)idevice_free(device); idevice_free(device);
LOG(LOG_ERROR, "Error getting product version"); LOG(LOG_ERROR, "Error getting product version");
return -1; return -1;
} }
@@ -170,21 +170,21 @@ int devinfo_cmd(devinfo_t *dev, const char *udid)
node = NULL; node = NULL;
if (lockdownd_get_value(lockdown, NULL, "BuildVersion", &node) != LOCKDOWN_E_SUCCESS) if (lockdownd_get_value(lockdown, NULL, "BuildVersion", &node) != LOCKDOWN_E_SUCCESS)
{ {
(void)lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
(void)idevice_free(device); idevice_free(device);
LOG(LOG_ERROR, "Error getting build version"); LOG(LOG_ERROR, "Error getting build version");
return -1; return -1;
} }
plist_get_string_val(node, &buildVersion); plist_get_string_val(node, &buildVersion);
plist_free(node); plist_free(node);
(void)lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
(void)idevice_free(device); idevice_free(device);
irecv_device_t rcvydev; irecv_device_t rcvydev;
if (irecv_devices_get_device_by_product_type(productType, &rcvydev) == IRECV_E_SUCCESS) if (irecv_devices_get_device_by_product_type(productType, &rcvydev) == IRECV_E_SUCCESS)
{ {
displayName = rcvydev->display_name; displayName = rcvydev->display_name;
} else }
else
{ {
displayName = productType; displayName = productType;
} }
@@ -209,22 +209,23 @@ int enter_recovery_cmd(const char* udid) {
LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret)); LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret));
return -1; return -1;
} }
ldret = lockdownd_enter_recovery(lockdown); do {
if (ldret == LOCKDOWN_E_SESSION_INACTIVE) { ldret = lockdownd_enter_recovery(lockdown);
lockdownd_client_free(lockdown); if (ldret == LOCKDOWN_E_SESSION_INACTIVE) {
lockdown = NULL; lockdownd_client_free(lockdown);
ldret = lockdownd_client_new_with_handshake(device, &lockdown, "palera1n"); lockdown = NULL;
if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, "palera1n"))) {
LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret));
return -1;
}
ldret = lockdownd_enter_recovery(lockdown);
}
if (ldret != LOCKDOWN_E_SUCCESS) { if (ldret != LOCKDOWN_E_SUCCESS) {
LOG(LOG_ERROR, "Could not connect to lockdownd: %s", lockdownd_strerror(ldret)); LOG(LOG_ERROR, "Could not trigger entering recovery mode: %s", lockdownd_strerror(ldret));
return -1; return -1;
} }
ldret = lockdownd_enter_recovery(lockdown); lockdownd_client_free(lockdown);
} } while (0);
if (ldret != LOCKDOWN_E_SUCCESS) {
LOG(LOG_ERROR, "Could not trigger entering recovery mode: %s", lockdownd_strerror(ldret));
return -1;
}
lockdownd_client_free(lockdown);
idevice_free(device); idevice_free(device);
return 0; return 0;
} }
@@ -241,8 +242,8 @@ int reboot_cmd(const char* udid) {
if (diagnostics_relay_restart(diag, DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT) != DIAGNOSTICS_RELAY_E_SUCCESS) { if (diagnostics_relay_restart(diag, DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT) != DIAGNOSTICS_RELAY_E_SUCCESS) {
LOG(LOG_ERROR, "Could not reboot device."); LOG(LOG_ERROR, "Could not reboot device.");
} }
(void)diagnostics_relay_goodbye(diag); diagnostics_relay_goodbye(diag);
(void)diagnostics_relay_client_free(diag); diagnostics_relay_client_free(diag);
} else { } else {
LOG(LOG_ERROR, "Could not connect to device."); LOG(LOG_ERROR, "Could not connect to device.");
return -1; return -1;
@@ -301,9 +302,9 @@ int passstat_cmd(unsigned char* status, const char* udid) {
derr = diagnostics_relay_query_mobilegestalt(diagnostics_client, keys, &node); derr = diagnostics_relay_query_mobilegestalt(diagnostics_client, keys, &node);
plist_free(keys); plist_free(keys);
(void)diagnostics_relay_client_free(diagnostics_client); diagnostics_relay_client_free(diagnostics_client);
(void)lockdownd_service_descriptor_free(service); lockdownd_service_descriptor_free(service);
(void)idevice_free(dev); idevice_free(dev);
if (derr != DIAGNOSTICS_RELAY_E_SUCCESS || !node) if (derr != DIAGNOSTICS_RELAY_E_SUCCESS || !node)
{ {
@@ -321,7 +322,7 @@ int passstat_cmd(unsigned char* status, const char* udid) {
plist_get_string_val(status_node, &passstat_status); plist_get_string_val(status_node, &passstat_status);
if (!status || strncmp(passstat_status, "Succ", 4)) if (!status || strncmp(passstat_status, "Succ", 4))
{ {
if (passstat_status) if (passstat_status)
free(passstat_status); free(passstat_status);
passstat_status = NULL; passstat_status = NULL;
plist_free(node); plist_free(node);
@@ -348,16 +349,20 @@ int passstat_cmd(unsigned char* status, const char* udid) {
int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) { int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
irecv_client_t client = NULL; irecv_client_t client = NULL;
irecv_error_t err = irecv_open_with_ecid(&client, ecid); irecv_error_t err = irecv_open_with_ecid(&client, ecid);
if (err != IRECV_E_SUCCESS) goto err; if (err != IRECV_E_SUCCESS) {
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
int mode = 0; int mode = 0;
err = irecv_get_mode(client, &mode); irecv_get_mode(client, &mode);
if (err != IRECV_E_SUCCESS) goto err;
char *ibootver = NULL; char *ibootver = NULL;
err = irecv_getenv(client, "build-version", &ibootver); irecv_getenv(client, "build-version", &ibootver);
if (err != IRECV_E_SUCCESS) goto err;
irecv_device_t device; irecv_device_t device;
err = irecv_devices_get_device_by_client(client, &device); err = irecv_devices_get_device_by_client(client, &device);
if (err != IRECV_E_SUCCESS) goto err; if (err != IRECV_E_SUCCESS) {
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
}
info->mode = mode; info->mode = mode;
info->cpid = device->chip_id; info->cpid = device->chip_id;
snprintf(info->product_type, 0x20, "%s", device->product_type); snprintf(info->product_type, 0x20, "%s", device->product_type);
@@ -366,41 +371,33 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
free(ibootver); free(ibootver);
irecv_close(client); irecv_close(client);
return 0; return 0;
err:
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
} }
int autoboot_cmd(const uint64_t ecid) { int autoboot_cmd(const uint64_t ecid) {
irecv_client_t client = NULL; irecv_client_t client = NULL;
irecv_error_t err = irecv_open_with_ecid(&client, ecid); irecv_error_t err = irecv_open_with_ecid(&client, ecid);
if (err != IRECV_E_SUCCESS) goto err; if (err == IRECV_E_SUCCESS) {
err = irecv_setenv(client, "auto-boot", "true"); irecv_setenv(client, "auto-boot", "true");
if (err != IRECV_E_SUCCESS) goto err; irecv_saveenv(client);
err = irecv_saveenv(client); irecv_close(client);
if (err != IRECV_E_SUCCESS) goto err; return 0;
err = irecv_close(client); } else {
if (err != IRECV_E_SUCCESS) goto err; LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return 0;
err:
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1; return -1;
}
} }
int exitrecv_cmd(const uint64_t ecid) { int exitrecv_cmd(const uint64_t ecid) {
irecv_client_t client = NULL; irecv_client_t client = NULL;
irecv_error_t err = irecv_open_with_ecid(&client, ecid); irecv_error_t err = irecv_open_with_ecid(&client, ecid);
if (err != IRECV_E_SUCCESS) goto err; if (err == IRECV_E_SUCCESS) {
err = irecv_setenv(client, "auto-boot", "true"); irecv_setenv(client, "auto-boot", "true");
if (err != IRECV_E_SUCCESS) goto err; irecv_saveenv(client);
err = irecv_saveenv(client); irecv_reboot(client);
if (err != IRECV_E_SUCCESS) goto err; irecv_close(client);
err = irecv_reboot(client); return 0;
if (err != IRECV_E_SUCCESS) goto err; } else {
err = irecv_close(client); LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
if (err != IRECV_E_SUCCESS) goto err; return -1;
return 0; }
err:
LOG(LOG_ERROR, "libirecovery error: %d (%s)", err, irecv_strerror(err));
return -1;
} }
+80 -104
View File
@@ -36,20 +36,12 @@ int dfuhelper_thr_running = false;
void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) { void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
for (int i = time2; i < time; i++) { for (int i = time2; i < time; i++) {
printf( 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);
checkrain_options_enabled(host_flags, host_option_no_colors)
? "\r\033[K%s (%d)"
: BCYN "\r\033[K%s (%d)" CRESET, text, time - i + time2
);
fflush(stdout); fflush(stdout);
sleep(1); sleep(1);
if (cond != NULL && cond(cond_arg)) pthread_exit(NULL); if (cond != NULL && cond(cond_arg)) pthread_exit(NULL);
} }
printf( printf(checkrain_option_enabled(host_flags, host_option_no_colors) ? "\r%s (%d)" : CYN "\r%s (%d)" CRESET, text, time2);
checkrain_options_enabled(host_flags, host_option_no_colors)
? "\r%s (%d)"
: CYN "\r%s (%d)" CRESET, text, time2
);
if (time2 == 0) puts(""); if (time2 == 0) puts("");
} }
@@ -61,14 +53,13 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
LOG(LOG_ERROR, "Unable to get device information"); LOG(LOG_ERROR, "Unable to get device information");
return 0; return 0;
} }
if (strncmp(dev.CPUArchitecture, "arm64", strlen("arm64"))) { if (strcmp(dev.CPUArchitecture, "arm64")) {
devinfo_free(&dev); devinfo_free(&dev);
LOG(LOG_WARNING, "Ignoring non-arm64 device..."); LOG(LOG_WARNING, "Ignoring non-arm64 device...");
LOG(LOG_WARNING, "palera1n doesn't and never will work on A12+ (arm64e)");
return -1; return -1;
} }
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) { if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
if (!checkrain_options_enabled(host_flags, host_option_device_info)) if (!checkrain_option_enabled(host_flags, host_option_device_info))
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType); LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
unsigned char passcode_state = 0; unsigned char passcode_state = 0;
ret = passstat_cmd(&passcode_state, usbmuxd_device->udid); ret = passstat_cmd(&passcode_state, usbmuxd_device->udid);
@@ -79,14 +70,14 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
} }
if (passcode_state) { if (passcode_state) {
LOG(LOG_ERROR, "Passcode must be disabled on this device"); LOG(LOG_ERROR, "Passcode must be disabled on this device");
if (!checkrain_options_enabled(host_flags, host_option_device_info)) if (!checkrain_option_enabled(host_flags, host_option_device_info))
LOG(LOG_ERROR, "Additionally, passcode must never be set since a restore on iOS 16+"); LOG(LOG_ERROR, "Additionally, passcode must never be set since a restore on iOS 16+");
devinfo_free(&dev); devinfo_free(&dev);
return -1; return -1;
} }
} }
if (checkrain_options_enabled(host_flags, host_option_device_info)) { if (checkrain_option_enabled(host_flags, host_option_device_info)) {
printf("Mode: normal\n"); printf("Mode: normal\n");
printf("ProductType: %s\n", dev.productType); printf("ProductType: %s\n", dev.productType);
printf("Architecture: %s\n", dev.CPUArchitecture); printf("Architecture: %s\n", dev.CPUArchitecture);
@@ -101,7 +92,7 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid); LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
enter_recovery_cmd(usbmuxd_device->udid); enter_recovery_cmd(usbmuxd_device->udid);
devinfo_free(&dev); devinfo_free(&dev);
if (checkrain_options_enabled(host_flags, host_option_enter_recovery)) { if (checkrain_option_enabled(host_flags, host_option_enter_recovery)) {
device_has_booted = true; device_has_booted = true;
set_spin(0); set_spin(0);
unsubscribe_cmd(); unsubscribe_cmd();
@@ -146,14 +137,17 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
return NULL; return NULL;
} }
printf("\r\033[K"); printf("\r\033[K");
if (NOHOME) { 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);
step(10, 0, "Hold volume down button", conditional, ecid); else
} 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
step(10, 0, "Hold home button", conditional, ecid); step(10, 0, "Hold home button", conditional, ecid);
} if (get_ecid_wait_for_dfu() != ecid) {
if (get_ecid_wait_for_dfu() == ecid) { } else {
LOG(LOG_WARNING, "Whoops, device did not enter DFU mode"); LOG(LOG_WARNING, "Whoops, device did not enter DFU mode");
LOG(LOG_INFO, "Waiting for device to reconnect..."); LOG(LOG_INFO, "Waiting for device to reconnect...");
set_ecid_wait_for_dfu(0); set_ecid_wait_for_dfu(0);
@@ -181,15 +175,13 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
switch (event->event) { switch (event->event) {
case UE_DEVICE_ADD: case UE_DEVICE_ADD:
LOG(LOG_VERBOSE, "Normal mode device connected"); LOG(LOG_VERBOSE, "Normal mode device connected");
if (checkrain_options_enabled(host_flags, host_option_exit_recovery)) { if (checkrain_option_enabled(host_flags, host_option_exit_recovery)) {
break; break;
} else if (checkrain_options_enabled(host_flags, host_option_reboot_device)) { } else if (checkrain_option_enabled(host_flags, host_option_reboot_device)) {
int ret = reboot_cmd(event->device.udid); reboot_cmd(event->device.udid);
if (!ret) { LOG(LOG_INFO, "Restarted device");
LOG(LOG_INFO, "Restarted device"); set_spin(0);
set_spin(0); unsubscribe_cmd();
unsubscribe_cmd();
}
pthread_exit(NULL); pthread_exit(NULL);
break; break;
} }
@@ -203,85 +195,69 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) { void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
pthread_t recovery_thread, dfu_thread; pthread_t recovery_thread, dfu_thread;
int ret;
switch(event->type) { switch(event->type) {
case IRECV_DEVICE_ADD: case IRECV_DEVICE_ADD:
if (event->mode == IRECV_K_RECOVERY_MODE_1 || 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) {
event->mode == IRECV_K_RECOVERY_MODE_2 || if (!checkrain_option_enabled(host_flags, host_option_device_info))
event->mode == IRECV_K_RECOVERY_MODE_3 || LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid);
event->mode == IRECV_K_RECOVERY_MODE_4) { if (checkrain_option_enabled(host_flags, host_option_exit_recovery)) {
if (!checkrain_options_enabled(host_flags, host_option_device_info)) exitrecv_cmd(event->device_info->ecid);
LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid); LOG(LOG_INFO, "Exited recovery mode");
if (checkrain_options_enabled(host_flags, host_option_exit_recovery)) { device_has_booted = true;
ret = exitrecv_cmd(event->device_info->ecid); set_spin(0);
if (!ret) { unsubscribe_cmd();
LOG(LOG_INFO, "Exited recovery mode"); if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
device_has_booted = true; pthread_exit(NULL);
set_spin(0); break;
unsubscribe_cmd();
} else {
LOG(LOG_WARNING, "Could not exit recovery mode");
}
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
recvinfo_t info;
ret = recvinfo_cmd(&info, event->device_info->ecid);
if (ret) {
LOG(LOG_WARNING, "Could not get info from device");
} else {
printf("Mode: Recovery\n");
printf("ProductType: %s\n", info.product_type);
printf("DisplayName: %s\n", info.display_name);
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
}
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
checkrain_options_enabled(host_flags, host_option_reboot_device)) return;
pthread_create(&recovery_thread, NULL, (pthread_start_t)connected_recovery_mode, event->device_info);
} else if (event->mode == IRECV_K_DFU_MODE) {
if (!checkrain_options_enabled(host_flags, host_option_device_info))
LOG(LOG_VERBOSE, "DFU mode device %ld connected", event->device_info->ecid);
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
recvinfo_t info;
ret = recvinfo_cmd(&info, event->device_info->ecid);
if (ret) {
LOG(LOG_WARNING, "Could not get info from device");
} else {
printf("Mode: DFU\n");
printf("ProductType: %s\n", info.product_type);
printf("DisplayName: %s\n", info.display_name);
device_has_booted = true;
set_spin(0);
unsubscribe_cmd();
}
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
pthread_exit(NULL);
break;
}
if (
checkrain_options_enabled(host_flags, host_option_exit_recovery) ||
checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
checkrain_options_enabled(host_flags, host_option_reboot_device)) {
break;
}
pthread_create(&dfu_thread, NULL, (pthread_start_t)connected_dfu_mode, event->device_info);
} }
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) {
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;
case IRECV_DEVICE_REMOVE: case IRECV_DEVICE_REMOVE:
LOG(LOG_VERBOSE, "Recovery mode device disconnected"); LOG(LOG_VERBOSE, "Recovery mode device disconnected");
break; break;
+3 -3
View File
@@ -126,11 +126,11 @@ int exec_checkra1n(void) {
#endif #endif
checkra1n_exec: {}; checkra1n_exec: {};
char args[0x10] = "-E"; char args[0x10] = "-E";
if (checkrain_options_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf); if (checkrain_option_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
if (!checkrain_options_enabled(host_flags, palerain_option_checkrain_is_clone)) { if (!checkrain_option_enabled(host_flags, palerain_option_checkrain_is_clone)) {
strncat(args, "p", 0xf); strncat(args, "p", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf); if (verbose >= 2) strncat(args, "v", 0xf);
if (checkrain_options_enabled(host_flags, host_option_no_colors)) strncat(args, "n", 0xf); if (checkrain_option_enabled(host_flags, host_option_no_colors)) strncat(args, "n", 0xf);
} else { } else {
strncat(args, "R", 0xf); strncat(args, "R", 0xf);
} }
+20 -10
View File
@@ -11,19 +11,22 @@
#ifdef DEBUG #ifdef DEBUG
#define log_debug(...) fprintf(stderr, __VA_ARGS__); fputc('\n', stderr) #define log_debug(...) fprintf(stderr, __VA_ARGS__); fputc('\n', stderr)
#else #else
#define log_debug(...) do {} while (0) #define log_debug(...)
#endif #endif
#define log_error(...) fprintf(stderr, __VA_ARGS__); fputc('\n', stderr) #define log_error(...) fprintf(stderr, __VA_ARGS__); fputc('\n', stderr)
int lockdown_connect_handle(uint32_t handle) { int lockdown_connect_handle(uint32_t handle)
{
int fd = usbmuxd_connect(handle, 62078); int fd = usbmuxd_connect(handle, 62078);
if (fd < 0) { if (fd < 0) {
log_debug("Can't connect to lockownd on device #%u", handle); log_debug("Can't connect to lockownd on device #%u", handle);
return fd;
} }
return fd; return fd;
} }
int lockdown_connect_udid(const char* udid) { int lockdown_connect_udid(const char* udid)
{
usbmuxd_device_info_t device; usbmuxd_device_info_t device;
if (usbmuxd_get_device_by_udid(udid, &device) < 0) { if (usbmuxd_get_device_by_udid(udid, &device) < 0) {
log_debug("Can't find device %s", udid); log_debug("Can't find device %s", udid);
@@ -32,7 +35,8 @@ int lockdown_connect_udid(const char* udid) {
return lockdown_connect_handle(device.handle); return lockdown_connect_handle(device.handle);
} }
void lockdown_disconnect(int fd) { void lockdown_disconnect(int fd)
{
usbmuxd_disconnect(fd); usbmuxd_disconnect(fd);
} }
@@ -52,7 +56,8 @@ static const int INTEGER_NODE_SIZE = sizeof(INTEGER_NODE)-1;
static const int STRING_NODE_SIZE = sizeof(STRING_NODE)-1; static const int STRING_NODE_SIZE = sizeof(STRING_NODE)-1;
static const int ERROR_KEY_NODE_SIZE = sizeof(ERROR_KEY_NODE)-1; static const int ERROR_KEY_NODE_SIZE = sizeof(ERROR_KEY_NODE)-1;
static void skip_ws(char** cur, char* end) { static void skip_ws(char** cur, char* end)
{
char* p = *cur; char* p = *cur;
while (p < end && ((*p == ' ') || (*p == '\t') || (*p == '\r') || (*p == '\n'))) { while (p < end && ((*p == ' ') || (*p == '\t') || (*p == '\r') || (*p == '\n'))) {
p++; p++;
@@ -60,7 +65,8 @@ static void skip_ws(char** cur, char* end) {
*cur = p; *cur = p;
} }
static char* _send_request_and_get_reply(int fd, const char* request, uint32_t len, uint32_t* received) { static char* _send_request_and_get_reply(int fd, const char* request, uint32_t len, uint32_t* received)
{
uint32_t sent_bytes = 0; uint32_t sent_bytes = 0;
usbmuxd_send(fd, request, len, &sent_bytes); usbmuxd_send(fd, request, len, &sent_bytes);
if (sent_bytes != len) { if (sent_bytes != len) {
@@ -94,7 +100,8 @@ static char* _send_request_and_get_reply(int fd, const char* request, uint32_t l
return resp; return resp;
} }
int lockdown_check_type(int fd, const char* type_match) { int lockdown_check_type(int fd, const char* type_match)
{
unsigned char tmp[512]; unsigned char tmp[512];
uint32_t len = (uint32_t)snprintf((char*)tmp, 512, QUERY_TYPE_REQUEST); uint32_t len = (uint32_t)snprintf((char*)tmp, 512, QUERY_TYPE_REQUEST);
uint32_t belen = htonl(len-4); uint32_t belen = htonl(len-4);
@@ -112,7 +119,8 @@ int lockdown_check_type(int fd, const char* type_match) {
return result; return result;
} }
int lockdown_get_uint_value(int fd, const char* domain, const char* key, uint64_t* value) { int lockdown_get_uint_value(int fd, const char* domain, const char* key, uint64_t* value)
{
char tmp[1024]; char tmp[1024];
uint32_t len; uint32_t len;
if (domain) { if (domain) {
@@ -151,7 +159,8 @@ int lockdown_get_uint_value(int fd, const char* domain, const char* key, uint64_
return 0; return 0;
} }
int lockdown_get_string_value(int fd, const char* domain, const char* key, char** value) { int lockdown_get_string_value(int fd, const char* domain, const char* key, char** value)
{
char tmp[1024]; char tmp[1024];
uint32_t len; uint32_t len;
if (domain) { if (domain) {
@@ -203,7 +212,8 @@ int lockdown_get_string_value(int fd, const char* domain, const char* key, char*
return 0; return 0;
} }
int lockdown_enter_recovery(int fd) { int lockdown_enter_recovery(int fd)
{
char tmp[512]; char tmp[512];
uint32_t len = (uint32_t)snprintf(tmp, 512, ENTER_RECOVERY_REQUEST); uint32_t len = (uint32_t)snprintf(tmp, 512, ENTER_RECOVERY_REQUEST);
*(uint32_t*)&tmp = htonl(len-4); *(uint32_t*)&tmp = htonl(len-4);
+10 -10
View File
@@ -12,7 +12,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
{ {
if (verbose >= 5 if (verbose >= 5
#ifdef TUI #ifdef TUI
&& !checkrain_options_enabled(host_flags, host_option_tui) && !checkrain_option_enabled(host_flags, host_option_tui)
#endif #endif
) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname); ) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
int ret = 0; int ret = 0;
@@ -57,12 +57,12 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
snprintf(colour_bold, 0x10, "%s", BWHT); snprintf(colour_bold, 0x10, "%s", BWHT);
break; break;
} }
if (checkrain_options_enabled(host_flags, host_option_no_colors)) { if (checkrain_option_enabled(host_flags, host_option_no_colors)) {
colour[0] = '\0'; colour[0] = '\0';
colour_bold[0] = '\0'; colour_bold[0] = '\0';
} }
#ifdef TUI #ifdef TUI
if (checkrain_options_enabled(host_flags, host_option_tui) && tui_started) { if (checkrain_option_enabled(host_flags, host_option_tui) && tui_started) {
newtComponent co = get_tui_log(); newtComponent co = get_tui_log();
if (co == NULL) { if (co == NULL) {
return 0; /* 0 bytes printed */ return 0; /* 0 bytes printed */
@@ -79,26 +79,26 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
time_t curtime; time_t curtime;
time(&curtime); time(&curtime);
struct tm* timeinfo = localtime(&curtime); struct tm* timeinfo = localtime(&curtime);
if (!checkrain_options_enabled(host_flags, host_option_no_colors)) 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); 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 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); snprintf(timestring, 0x80, "[%02d/%02d/%d %02d:%02d:%02d]", timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
if (verbose >= 2 && !checkrain_options_enabled(host_flags, host_option_no_colors)) { 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); 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_options_enabled(host_flags, host_option_no_colors)) { } else if (!checkrain_option_enabled(host_flags, host_option_no_colors)) {
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET); printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
} else if (verbose >= 2 && checkrain_options_enabled(host_flags, host_option_no_colors)) { } 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); printf("%s| - %s%s <%s> %s:%d:%s(): \n%s| ----> ", colour_bold, timestring, colour_bold, type, fname, lineno, fxname, colour_bold);
} else if (checkrain_options_enabled(host_flags, host_option_no_colors)) { } else if (checkrain_option_enabled(host_flags, host_option_no_colors)) {
printf(" - %s %s<%s>: ", timestring, colour_bold, type); printf(" - %s %s<%s>: ", timestring, colour_bold, type);
} }
printf("%s", colour); printf("%s", colour);
ret = vprintf(format, args); ret = vprintf(format, args);
va_end(args); va_end(args);
if (verbose < 2 && !checkrain_options_enabled(host_flags, host_option_no_colors)) if (verbose < 2 && !checkrain_option_enabled(host_flags, host_option_no_colors))
printf(CRESET "\n"); printf(CRESET "\n");
else if (!checkrain_options_enabled(host_flags, host_option_no_colors)) else if (!checkrain_option_enabled(host_flags, host_option_no_colors))
printf("\n%s-%s\n", colour, CRESET); printf("\n%s-%s\n", colour, CRESET);
else if (verbose < 2) else if (verbose < 2)
printf("\n"); printf("\n");
+14 -12
View File
@@ -72,7 +72,7 @@ int build_checks(void) {
if (checkra1n_len <= (UCHAR_MAX + 1)) { if (checkra1n_len <= (UCHAR_MAX + 1)) {
LOG(LOG_FATAL, "checkra1n too small"); 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) { 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; host_flags |= palerain_option_checkrain_is_clone;
} }
#endif #endif
@@ -81,7 +81,8 @@ int build_checks(void) {
if (kpf_hdr->magic != MH_MAGIC_64 && kpf_hdr->magic != MH_CIGAM_64) { 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"); LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not thin 64-bit Mach-O");
return -1; 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"); LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not a kext bundle");
return -1; return -1;
} else if (kpf_hdr->cputype != CPU_TYPE_ARM64) { } else if (kpf_hdr->cputype != CPU_TYPE_ARM64) {
@@ -111,9 +112,10 @@ int palera1n(int argc, char *argv[]) {
pthread_mutex_init(&ecid_dfu_wait_mutex, NULL); pthread_mutex_init(&ecid_dfu_wait_mutex, NULL);
if ((ret = build_checks())) return ret; if ((ret = build_checks())) return ret;
if ((ret = optparse(argc, argv))) goto cleanup; if ((ret = optparse(argc, argv))) goto cleanup;
if (!checkrain_options_enabled(host_flags, host_option_device_info) && checkrain_options_enabled(host_flags, host_option_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 TUI #ifdef TUI
if (checkrain_options_enabled(host_flags, host_option_tui)) { if (checkrain_option_enabled(host_flags, host_option_tui)) {
ret = tui(); ret = tui();
if (ret) goto cleanup; if (ret) goto cleanup;
else goto normal_exit; else goto normal_exit;
@@ -133,7 +135,7 @@ int palera1n(int argc, char *argv[]) {
} }
#endif #endif
if (!checkrain_options_enabled(host_flags, host_option_device_info)) if (!checkrain_option_enabled(host_flags, host_option_device_info))
LOG(LOG_INFO, "Waiting for devices"); LOG(LOG_INFO, "Waiting for devices");
if (access("/var/run/usbmuxd", F_OK) != 0) if (access("/var/run/usbmuxd", F_OK) != 0)
@@ -143,16 +145,16 @@ int palera1n(int argc, char *argv[]) {
pthread_create(&dfuhelper_thread, NULL, dfuhelper, NULL); pthread_create(&dfuhelper_thread, NULL, dfuhelper, NULL);
pthread_join(dfuhelper_thread, NULL); pthread_join(dfuhelper_thread, NULL);
set_spin(0); set_spin(0);
if (checkrain_options_enabled(host_flags, host_option_dfuhelper_only | if (checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
host_option_reboot_device | checkrain_option_enabled(host_flags, host_option_reboot_device) ||
host_option_exit_recovery | checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
host_option_enter_recovery | checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
host_option_device_info checkrain_option_enabled(host_flags, host_option_device_info) ||
) || device_has_booted) device_has_booted)
goto normal_exit; goto normal_exit;
if (exec_checkra1n()) goto cleanup; if (exec_checkra1n()) goto cleanup;
if (checkrain_options_enabled(host_flags, host_option_pongo_exit | host_option_demote)) if (checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_demote))
goto normal_exit; goto normal_exit;
set_spin(1); set_spin(1);
sleep(2); sleep(2);
+51 -13
View File
@@ -19,8 +19,10 @@ checkrain_option_p host_flags_p = &host_flags;
static bool force_use_verbose_boot = false; static bool force_use_verbose_boot = false;
static struct option longopts[] = { static struct option longopts[] = {
#ifdef ROOTFUL
{"setup-partial-fakefs", no_argument, NULL, 'B'}, {"setup-partial-fakefs", no_argument, NULL, 'B'},
{"setup-fakefs", no_argument, NULL, 'c'}, {"setup-fakefs", no_argument, NULL, 'c'},
#endif
{"dfuhelper", no_argument, NULL, 'D'}, {"dfuhelper", no_argument, NULL, 'D'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"pongo-shell", no_argument, NULL, 'p'}, {"pongo-shell", no_argument, NULL, 'p'},
@@ -28,7 +30,9 @@ static struct option longopts[] = {
{"debug-logging", no_argument, NULL, 'v'}, {"debug-logging", no_argument, NULL, 'v'},
{"verbose-boot", no_argument, NULL, 'V'}, {"verbose-boot", no_argument, NULL, 'V'},
{"boot-args", required_argument, NULL, 'e'}, {"boot-args", required_argument, NULL, 'e'},
#ifdef ROOTFUL
{"fakefs", no_argument, NULL, 'f'}, {"fakefs", no_argument, NULL, 'f'},
#endif
{"rootless", no_argument, NULL, 'l'}, {"rootless", no_argument, NULL, 'l'},
{"jbinit-log-to-file", no_argument, NULL, 'L'}, {"jbinit-log-to-file", no_argument, NULL, 'L'},
{"demote", no_argument, NULL, 'd'}, {"demote", no_argument, NULL, 'd'},
@@ -48,6 +52,9 @@ static struct option longopts[] = {
#ifdef DEV_BUILD #ifdef DEV_BUILD
{"test1", no_argument, NULL, '1'}, {"test1", no_argument, NULL, '1'},
{"test2", no_argument, NULL, '2'}, {"test2", no_argument, NULL, '2'},
{"ignore-ssv", no_argument, NULL, palerain_option_case_ignore_ssv},
{"rootless-livefs", no_argument, NULL, palerain_option_case_rootless_livefs},
{"force-fakefs", no_argument, NULL, palerain_option_case_force_fakefs},
#endif #endif
#ifdef TUI #ifdef TUI
{"tui", no_argument, NULL, 't'}, {"tui", no_argument, NULL, 't'},
@@ -71,10 +78,13 @@ static int usage(int e, char* prog_name)
#endif #endif
"] [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n 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" "Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n"
"iOS/iPadOS 15.0-16.4.1 arm64 jailbreaking tool\n\n" "iOS/iPadOS 15.0-16.4 arm64 jailbreaking tool\n\n"
"\t--version\t\t\t\tPrint version\n" "\t--version\t\t\t\tPrint version\n"
"\t--force-revert\t\t\t\tRemove jailbreak\n" "\t--force-revert\t\t\t\tRemove jailbreak\n"
#ifdef DEV_BUILD #ifdef DEV_BUILD
"\t--ignore-ssv\t\t\t\tAssume the platform has no SSV\n"
"\t--force-fakefs\t\t\t\tAllow fakefs to be created and used even on platforms without SSV\n"
"\t--rootless-livefs\t\t\t\tMount the root livefs on rootless\n"
"\t-1, --test1\t\t\t\tSet palerain_option_test1\n" "\t-1, --test1\t\t\t\tSet palerain_option_test1\n"
"\t-2, --test2\t\t\t\tSet palerain_option_test2\n" "\t-2, --test2\t\t\t\tSet palerain_option_test2\n"
#endif #endif
@@ -87,13 +97,13 @@ static int usage(int e, char* prog_name)
"\t-e, --boot-args <boot arguments>\tXNU boot arguments\n" "\t-e, --boot-args <boot arguments>\tXNU boot arguments\n"
"\t-E, --enter-recovery\t\t\tEnter recovery mode\n" "\t-E, --enter-recovery\t\t\tEnter recovery mode\n"
#ifdef ROOTFUL #ifdef ROOTFUL
"\t-f, --fakefs \t\t\t\tBoots fakefs\n" "\t-f, --rootful \t\t\t\tSet jailbreak mode to rootful.\n"
#endif #endif
"\t-h, --help\t\t\t\tShow this help\n" "\t-h, --help\t\t\t\tShow this help\n"
"\t-i, --override-checkra1n <file>\t\tOverride checkra1n\n" "\t-i, --override-checkra1n <file>\t\tOverride checkra1n\n"
"\t-k, --override-pongo <file>\t\tOverride Pongo image\n" "\t-k, --override-pongo <file>\t\tOverride Pongo image\n"
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\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, --rootless\t\t\t\tSet jailbreak mode to rootless.\n"
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\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-n, --exit-recovery\t\t\tExit recovery mode\n"
"\t-I, --device-info\t\t\tPrint info about the connected device\n" "\t-I, --device-info\t\t\tPrint info about the connected device\n"
@@ -126,10 +136,13 @@ int optparse(int argc, char* argv[]) {
#ifdef DEV_BUILD #ifdef DEV_BUILD
"12" "12"
#endif #endif
#ifdef ROOTFUL
"fcB" "fcB"
#endif
,longopts, NULL)) != -1) ,longopts, NULL)) != -1)
{ {
switch (opt) { switch (opt) {
#ifdef ROOTFUL
case 'B': case 'B':
palerain_flags |= palerain_option_setup_partial_root; palerain_flags |= palerain_option_setup_partial_root;
palerain_flags |= palerain_option_setup_rootful; palerain_flags |= palerain_option_setup_rootful;
@@ -139,6 +152,7 @@ int optparse(int argc, char* argv[]) {
palerain_flags |= palerain_option_setup_rootful; palerain_flags |= palerain_option_setup_rootful;
kpf_flags |= checkrain_option_verbose_boot; kpf_flags |= checkrain_option_verbose_boot;
break; break;
#endif
case 'p': case 'p':
host_flags |= host_option_pongo_exit; host_flags |= host_option_pongo_exit;
break; break;
@@ -168,13 +182,17 @@ int optparse(int argc, char* argv[]) {
} }
snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg); snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg);
break; break;
#ifdef ROOTFUL
case 'f': case 'f':
snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg); snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg);
snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg); snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg);
palerain_flags |= palerain_option_rootful; palerain_flags |= palerain_option_rootful;
break; break;
#endif
case 'l': case 'l':
palerain_flags &= ~palerain_option_rootful; #ifdef ROOTFUL
palerain_flags |= palerain_option_rootless;
#endif
break; break;
case 'L': case 'L':
palerain_flags |= palerain_option_jbinit_log_to_file; palerain_flags |= palerain_option_jbinit_log_to_file;
@@ -284,6 +302,15 @@ int optparse(int argc, char* argv[]) {
case '2': case '2':
palerain_flags |= palerain_option_test2; palerain_flags |= palerain_option_test2;
break; break;
case palerain_option_case_force_fakefs:
palerain_flags |= palerain_option_case_force_fakefs;
break;
case palerain_option_case_rootless_livefs:
palerain_flags |= palerain_option_case_rootless_livefs;
break;
case palerain_option_case_ignore_ssv:
palerain_flags |= palerain_option_no_ssv;
break;
#endif #endif
case palerain_option_case_force_revert: case palerain_option_case_force_revert:
checkrain_flags |= checkrain_option_force_revert; checkrain_flags |= checkrain_option_force_revert;
@@ -296,7 +323,7 @@ int optparse(int argc, char* argv[]) {
break; break;
} }
} }
if (checkrain_options_enabled(host_flags, host_option_palerain_version)) { if (checkrain_option_enabled(host_flags, host_option_palerain_version)) {
printf( printf(
"palera1n " PALERAIN_VERSION "\n" "palera1n " PALERAIN_VERSION "\n"
BUILD_COMMIT " " BUILD_NUMBER " (" BUILD_BRANCH ")\n\n" BUILD_COMMIT " " BUILD_NUMBER " (" BUILD_BRANCH ")\n\n"
@@ -314,7 +341,7 @@ int optparse(int argc, char* argv[]) {
return 0; return 0;
} }
if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) { if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
kpf_flags &= ~checkrain_option_verbose_boot; kpf_flags &= ~checkrain_option_verbose_boot;
} }
@@ -338,17 +365,28 @@ int optparse(int argc, char* argv[]) {
LOG(LOG_VERBOSE4, "overlay override ptr %p -> %p", override_overlay.orig_ptr, **overlay_to_upload); LOG(LOG_VERBOSE4, "overlay override ptr %p -> %p", override_overlay.orig_ptr, **overlay_to_upload);
} }
if (!checkrain_options_enabled(palerain_flags, palerain_option_rootful)) { if (checkrain_option_enabled(palerain_flags, palerain_option_rootful) && checkrain_option_enabled(palerain_flags, palerain_option_rootless)) {
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful) || checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful_forced)) { LOG(LOG_FATAL, "cannot have rootful and rootless at the same time");
return -1;
}
if (!checkrain_option_enabled(palerain_flags, palerain_option_rootful) && !checkrain_option_enabled(palerain_flags, palerain_option_rootless)) {
LOG(LOG_FATAL, "must have either rootful or rootless, use --help for help");
return -1;
}
if (!checkrain_option_enabled(palerain_flags, palerain_option_rootful)) {
if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful) || checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful_forced)) {
LOG(LOG_FATAL, "Cannot setup rootful when rootless is requested. Use -f to enable rootful mode."); LOG(LOG_FATAL, "Cannot setup rootful when rootless is requested. Use -f to enable rootful mode.");
return -1; return -1;
} }
} }
if (!( if (!(
checkrain_options_enabled(host_flags, host_option_dfuhelper_only) || checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
checkrain_options_enabled(host_flags, host_option_enter_recovery) || checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
checkrain_options_enabled(host_flags, host_option_exit_recovery) || checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
checkrain_options_enabled(host_flags, host_option_reboot_device))) checkrain_option_enabled(host_flags, host_option_reboot_device)))
{ {
#ifdef NO_CHECKRAIN #ifdef NO_CHECKRAIN
if (checkra1n_len == 0 && ext_checkra1n == NULL) if (checkra1n_len == 0 && ext_checkra1n == NULL)
@@ -356,7 +394,7 @@ int optparse(int argc, char* argv[]) {
LOG(LOG_FATAL, "checkra1n omitted in build but no override specified"); LOG(LOG_FATAL, "checkra1n omitted in build but no override specified");
return -1; return -1;
} }
if (!(checkrain_options_enabled(host_flags, host_option_pongo_exit) || checkrain_options_enabled(host_flags, host_option_pongo_exit))) if (!(checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_pongo_exit)))
{ {
#ifdef NO_KPF #ifdef NO_KPF
if (checkra1n_kpf_pongo_len == 0) if (checkra1n_kpf_pongo_len == 0)
+10 -10
View File
@@ -29,15 +29,15 @@ void* pongo_helper(void* ptr) {
return NULL; return NULL;
} }
void *pongo_usb_callback(stuff_t *arg) { void *pongo_usb_callback(void *arg) {
if (get_found_pongo()) if (get_found_pongo())
return NULL; return NULL;
set_found_pongo(1); set_found_pongo(1);
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) { if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1); strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1);
} }
LOG(LOG_INFO, "Found PongoOS USB Device"); LOG(LOG_INFO, "Found PongoOS USB Device");
usb_device_handle_t handle = arg->handle; usb_device_handle_t handle = (((stuff_t *)arg)->handle);
issue_pongo_command(handle, NULL); issue_pongo_command(handle, NULL);
issue_pongo_command(handle, "fuse lock"); issue_pongo_command(handle, "fuse lock");
issue_pongo_command(handle, "sep auto"); issue_pongo_command(handle, "sep auto");
@@ -46,7 +46,7 @@ void *pongo_usb_callback(stuff_t *arg) {
issue_pongo_command(handle, kpf_flags_cmd); issue_pongo_command(handle, kpf_flags_cmd);
issue_pongo_command(handle, checkrain_flags_cmd); issue_pongo_command(handle, checkrain_flags_cmd);
issue_pongo_command(handle, palerain_flags_cmd); issue_pongo_command(handle, palerain_flags_cmd);
if (checkrain_options_enabled(palerain_flags, palerain_option_rootful)) if (checkrain_option_enabled(palerain_flags, palerain_option_rootful))
{ {
issue_pongo_command(handle, "rootfs"); issue_pongo_command(handle, "rootfs");
} }
@@ -66,13 +66,13 @@ void *pongo_usb_callback(stuff_t *arg) {
issue_pongo_command(handle, "overlay"); issue_pongo_command(handle, "overlay");
} }
issue_pongo_command(handle, xargs_cmd); issue_pongo_command(handle, xargs_cmd);
if (checkrain_options_enabled(host_flags, host_option_pongo_full)) goto done; if (checkrain_option_enabled(host_flags, host_option_pongo_full)) goto done;
issue_pongo_command(handle, "bootx"); issue_pongo_command(handle, "bootx");
LOG(LOG_INFO, "Booting Kernel..."); LOG(LOG_INFO, "Booting Kernel...");
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_partial_root)) { 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, "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."); LOG(LOG_INFO, "Once the device boots up to iOS, run again without the -B (Create BindFS) option to jailbreak.");
} else if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) { } 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, "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."); LOG(LOG_INFO, "Once the device boots up to iOS, run again without the -c (Create FakeFS) option to jailbreak.");
} }
@@ -83,7 +83,7 @@ void *pongo_usb_callback(stuff_t *arg) {
done: done:
device_has_booted = true; device_has_booted = true;
#ifdef USE_LIBUSB #ifdef USE_LIBUSB
libusb_unref_device(arg->dev); libusb_unref_device(((stuff_t *)arg)->dev);
#endif #endif
set_spin(0); set_spin(0);
return NULL; return NULL;
@@ -163,7 +163,7 @@ int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned i
if (verbose < 3 || verbose > 4) { if (verbose < 3 || verbose > 4) {
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len); LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
} else { } else {
if (checkrain_options_enabled(host_flags, host_option_no_colors)) 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); printf("/send mem:%p:%p\nUploaded %llu bytes]\n", (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
else else
printf("/send mem:%p:%p\n" BCYN "[Uploaded %llu bytes]\n" CRESET, (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len); printf("/send mem:%p:%p\n" BCYN "[Uploaded %llu bytes]\n" CRESET, (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
@@ -176,7 +176,7 @@ int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned i
void io_start(stuff_t *stuff) void io_start(stuff_t *stuff)
{ {
int r = pthread_create(&stuff->th, NULL, (pthread_start_t)pongo_usb_callback, stuff); int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, stuff);
if(r != 0) if(r != 0)
{ {
ERR("pthread_create: %s", strerror(r)); ERR("pthread_create: %s", strerror(r));