From c0dac9c172a19e558e961f04abcb6db1b27bcb99 Mon Sep 17 00:00:00 2001 From: debian Date: Sun, 29 Nov 2026 16:52:46 -0300 Subject: [PATCH] exp(checkm8): carry the serial index across re-acquisition and log the address The descriptor index of the serial string is not stable across enumerations, which is why both retry paths in checkm8_exploit write it back; the PWND check reads it through dev->iserial_index. Logging the device address before and after the re-open makes the re-enumeration visible in the run instead of inferred from dmesg, and the window grows to ten seconds to match the waits used elsewhere for re-enumeration. --- src/exploit/checkm8.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/exploit/checkm8.c b/src/exploit/checkm8.c index d580d40..aefd5ec 100644 --- a/src/exploit/checkm8.c +++ b/src/exploit/checkm8.c @@ -74,20 +74,41 @@ static int exploit_reacquire(exploit_ctx_t *ctx) { device_info_t *dev = ctx->dev; uint8_t iserial = 0; + unsigned old_addr = 0; int i; if (dev->usb) { + libusb_device *old = libusb_get_device(dev->usb); + + if (old) + old_addr = (unsigned)libusb_get_device_address(old); + usb_dfu_close(dev->usb); dev->usb = NULL; } - for (i = 0; i < 60; i++) { /* up to ~3 s at 50 ms */ + for (i = 0; i < 100; i++) { /* up to ~10 s at 100 ms */ if (usb_dfu_find(&dev->usb, &iserial) == 0) { - log_info("exploit_deliver: device re-acquired (iserial %u)", - (unsigned)iserial); + libusb_device *now = libusb_get_device(dev->usb); + unsigned new_addr = 0; + + if (now) + new_addr = (unsigned)libusb_get_device_address(now); + + /* + * The descriptor index of the serial string is not stable + * across enumerations; the retry paths in checkm8_exploit + * carry it forward for that reason, and the PWND check + * reads it back through dev->iserial_index. + */ + dev->iserial_index = iserial; + + log_info("exploit_deliver: device re-acquired " + "(iserial %u, address %u -> %u)", + (unsigned)iserial, old_addr, new_addr); return 0; } - usleep(50000); + usleep(100000); } log_error("exploit_deliver: device did not come back after re-acquiring");