chore: add some code documentation

This commit is contained in:
CLARATION committed 2026-07-22 19:27:01 -07:00
1 parent 8ca699b84c
commit 6dbc791c07
5 files changed
+57 -3

No files matched your search

+38
View File
@@ -85,6 +85,7 @@ int stage_to_progress(int stage)
}
const char* err_to_string(int err) {
// error codes should be the same between both checkm8 backends
switch (err) {
case 0: return "";
case 1: return "-p1_client_err_abort_success";
@@ -112,6 +113,14 @@ const char* err_to_string(int err) {
#if WITH_CIDERRAIN
// MARK: exploit (libciderra1n)
// NOTE: this backend is NOT publicly available
// ciderra1n is based on the checkra1n 1337 implementation
// of the checkm8 exploit using DFU aborts instead of usb resets
// this supports Linux (liteusb), and Darwin (IOKit)
// this also supports A7 devices.
int exploit(int *stage)
{
LOG("Waiting for devices...");
@@ -142,6 +151,7 @@ int exploit(int *stage)
if (flag & kDeviceDFUModeFlag) {
if (flag & kDeviceStandardPwnedDFUModeFlag) {
// we cant do shit sorry
LOG_ERROR("Found an unknown pwned DFU mode device");
usb_close(client);
*stage = STAGE_ERROR;
@@ -149,6 +159,7 @@ int exploit(int *stage)
}
if (flag & kDevicePwnedDFUModeFlag) {
// we cant do shit sorry
LOG_ERROR("Detected pwned DFU mode device, please enter normal DFU mode.");
usb_close(client);
*stage = STAGE_ERROR;
@@ -156,6 +167,7 @@ int exploit(int *stage)
}
if (!(flag & kDeviceNotSoftDFUModeFlag)) {
// we cant do shit sorry
LOG_ERROR("Found soft-DFU mode device");
usb_close(client);
*stage = STAGE_ERROR;
@@ -240,6 +252,11 @@ int exploit(int *stage)
*stage = STAGE_ERROR;
break; // err
}
// assume everything went well, though
// depending on the components sent to
// the device, the device may not even
// boot at all (not our fault xD)
*stage = STAGE_DONE;
break; // success
}
@@ -262,6 +279,15 @@ int exploit(int *stage)
#else // WITH_CIDERRAIN
// MARK: exploit (libopenra1n)
// NOTE: this backend is publicly available
// openra1n is based on the gaster implementation of the exploit
// which is the more well-known implementation of checkm8
// this supports Windows (Libusb), Linux (Libusb), and Darwin (IOKit)
// on the contrary while gaster *does* support A7, openra1n does not.
// (yet to be implemented, cc @Mineek)
int exploit(int *stage)
{
LOG("Waiting for devices...");
@@ -279,10 +305,14 @@ int exploit(int *stage)
init_usb_handle(&pongoHandle, VID_APPLE, PID_PONGO);
for (;;) {
// pongoOS is checked first
if (wait_usb_handle(&pongoHandle)) {
LOG("Found pongo mode device");
*stage = STAGE_PONGO;
if (palera1n_flags & palerain_option_pongo_exit)
goto pongo_done;
cr = send_full_pongo_jailbreak(&pongoHandle);
if (cr != CHECKM8_ERR_NONE) {
LOG_ERROR("Failed to boot device (rv=%d, reason=%s)", cr, err_to_string(cr));
@@ -290,10 +320,16 @@ int exploit(int *stage)
goto cleanup;
}
// assume everything went well, though
// depending on the components sent to
// the device, the device may not even
// boot at all (not our fault xD)
pongo_done:
*stage = STAGE_DONE;
goto cleanup;
}
// DFU is checked second
if (wait_usb_handle(&dfuHandle)) {
char *sn = get_usb_serial_number(&dfuHandle);
if (!sn) goto reloop;
@@ -307,6 +343,7 @@ int exploit(int *stage)
}
if (dfu_serial_number_is_pwned(sn)) {
// we cant do shit sorry
LOG_ERROR("Detected pwned DFU mode device, please enter normal DFU mode.");
free(sn);
*stage = STAGE_ERROR;
@@ -343,6 +380,7 @@ int exploit(int *stage)
*stage = STAGE_RESET;
goto reloop;
}
*stage = STAGE_SPRAY;
goto reloop;
case STAGE_SPRAY: