Compare commits
No commits in common. "fix/checkm8-usbipd-pause" and "main" have entirely different histories.
fix/checkm
...
main
2 changed files with 3 additions and 77 deletions
|
|
@ -4,7 +4,6 @@
|
||||||
* Gaster typically converges in a handful of iterations; 100 is generous. */
|
* Gaster typically converges in a handful of iterations; 100 is generous. */
|
||||||
#define MAX_STALL_RETRIES 100
|
#define MAX_STALL_RETRIES 100
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -180,35 +179,6 @@ int checkm8_no_leak(libusb_device_handle *usb, uint8_t iserial_idx)
|
||||||
/* Stage 3: Heap spray */
|
/* Stage 3: Heap spray */
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
/*
|
|
||||||
* usbipd_present -- true when the device is reached through usbipd.
|
|
||||||
*
|
|
||||||
* WSL_DISTRO_NAME alone is not enough: sudo resets the environment by
|
|
||||||
* default, so the variable disappears exactly when the tool is run the
|
|
||||||
* way most of the reports run it. /proc/version keeps a marker that
|
|
||||||
* survives sudo.
|
|
||||||
*/
|
|
||||||
static int usbipd_present(void)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
char buf[256];
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
if (getenv("WSL_DISTRO_NAME") != NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
f = fopen("/proc/version", "r");
|
|
||||||
if (!f)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
n = fread(buf, 1, sizeof(buf) - 1, f);
|
|
||||||
fclose(f);
|
|
||||||
buf[n] = '\0';
|
|
||||||
|
|
||||||
return strstr(buf, "microsoft") != NULL ||
|
|
||||||
strstr(buf, "Microsoft") != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int checkm8_stage_spray(exploit_ctx_t *ctx)
|
int checkm8_stage_spray(exploit_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
libusb_device_handle *usb;
|
libusb_device_handle *usb;
|
||||||
|
|
@ -325,20 +295,9 @@ int checkm8_stage_spray(exploit_ctx_t *ctx)
|
||||||
* io_buffer cannot land at insecure_memory_base.
|
* io_buffer cannot land at insecure_memory_base.
|
||||||
*
|
*
|
||||||
* Wait 1 second to ensure all spray buffers are freed by the
|
* Wait 1 second to ensure all spray buffers are freed by the
|
||||||
* device before stage 4's DFU_DNLOAD allocation. This is the setup
|
* device before stage 4's DFU_DNLOAD allocation.
|
||||||
* the delay was written for: the vhci layer adds latency and the
|
|
||||||
* buffers are freed late.
|
|
||||||
*
|
|
||||||
* On a native host there is no evidence that the same wait is
|
|
||||||
* needed, and no measurement has been taken either way. One
|
|
||||||
* hypothesis is that the idle second is a window in which the
|
|
||||||
* device can leave dfuIDLE on its own, which would surface as
|
|
||||||
* NO_DEVICE (-4) at stage 4; that is unconfirmed. What this change
|
|
||||||
* claims is narrower: do not keep a delay on transports that never
|
|
||||||
* asked for it, so a native run behaves like the bus it runs on.
|
|
||||||
*/
|
*/
|
||||||
if (usbipd_present())
|
usleep(1000000); /* 1 s */
|
||||||
usleep(1000000); /* 1 s -- usbipd only */
|
|
||||||
|
|
||||||
ctx->phase = EXPLOIT_PHASE_SPRAY;
|
ctx->phase = EXPLOIT_PHASE_SPRAY;
|
||||||
log_info("checkm8: stage 3 complete -- heap spray done");
|
log_info("checkm8: stage 3 complete -- heap spray done");
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libusb-1.0/libusb.h>
|
#include <libusb-1.0/libusb.h>
|
||||||
|
|
||||||
|
|
@ -38,37 +37,15 @@ int usb_ctrl_transfer_raw(libusb_device_handle *dev,
|
||||||
unsigned int timeout_ms)
|
unsigned int timeout_ms)
|
||||||
{
|
{
|
||||||
unsigned int effective_timeout_ms = timeout_ms;
|
unsigned int effective_timeout_ms = timeout_ms;
|
||||||
struct timespec t0, t1;
|
|
||||||
long elapsed_us;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return LIBUSB_ERROR_INVALID_PARAM;
|
return LIBUSB_ERROR_INVALID_PARAM;
|
||||||
if (effective_timeout_ms == 0)
|
if (effective_timeout_ms == 0)
|
||||||
effective_timeout_ms = 1;
|
effective_timeout_ms = 1;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &t0);
|
return libusb_control_transfer(dev, bmRequestType, bRequest,
|
||||||
ret = libusb_control_transfer(dev, bmRequestType, bRequest,
|
|
||||||
wValue, wIndex, data, wLength,
|
wValue, wIndex, data, wLength,
|
||||||
effective_timeout_ms);
|
effective_timeout_ms);
|
||||||
clock_gettime(CLOCK_MONOTONIC, &t1);
|
|
||||||
|
|
||||||
elapsed_us = (long)((t1.tv_sec - t0.tv_sec) * 1000000L
|
|
||||||
+ (t1.tv_nsec - t0.tv_nsec) / 1000L);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Trace every control transfer of the sequence with its result and
|
|
||||||
* how long it took. A -4 (NO_DEVICE) tells nothing on its own: it
|
|
||||||
* is the same code whether the device left the bus mid-transfer or
|
|
||||||
* between stages. The elapsed time of this transfer and of the one
|
|
||||||
* before it is what separates the two cases.
|
|
||||||
*/
|
|
||||||
log_debug("usb: bmRT=0x%02X bReq=0x%02X wVal=0x%04X wIdx=0x%04X "
|
|
||||||
"len=%u timeout=%ums ret=%d elapsed=%ldus",
|
|
||||||
bmRequestType, bRequest, wValue, wIndex, wLength,
|
|
||||||
effective_timeout_ms, ret, elapsed_us);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_ctrl_transfer_no_data_raw(libusb_device_handle *dev,
|
int usb_ctrl_transfer_no_data_raw(libusb_device_handle *dev,
|
||||||
|
|
@ -225,16 +202,6 @@ int usb_ctrl_transfer_dnload_abort(libusb_device_handle *dev,
|
||||||
if (completed)
|
if (completed)
|
||||||
actual_len = (int)transfer->actual_length;
|
actual_len = (int)transfer->actual_length;
|
||||||
|
|
||||||
/*
|
|
||||||
* The setup stage decides the pad length from this value. Log the
|
|
||||||
* three states separately: completed with a length, cancelled
|
|
||||||
* (actual_len reported as 0), and submit failure. A cancel that
|
|
||||||
* reports 0 makes the pad the whole overwrite_pad, which is a
|
|
||||||
* different state than the reference reaches on most attempts.
|
|
||||||
*/
|
|
||||||
log_debug("usb: async DNLOAD abort=%ums completed=%d actual_len=%d",
|
|
||||||
abort_ms, completed, actual_len);
|
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
libusb_free_transfer(transfer);
|
libusb_free_transfer(transfer);
|
||||||
return actual_len;
|
return actual_len;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue