From 8a47c8ce8abd0af41b67151aa7087b8dd3bc893c Mon Sep 17 00:00:00 2001 From: C Date: Thu, 17 Sep 2026 19:28:01 -0700 Subject: [PATCH] feat(cli): add ra1n dfu-helper for cli supports going from recovery to dfu, only. --- src/exploit.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/exploit.c b/src/exploit.c index 4be458d..a1bfa4b 100644 --- a/src/exploit.c +++ b/src/exploit.c @@ -132,7 +132,7 @@ const char* err_to_string(int err) { int exploit(int *stage) { - LOG("Waiting for devices..."); + LOG("Waiting for DFU mode devices..."); *stage = STAGE_RESET; @@ -158,7 +158,20 @@ int exploit(int *stage) if (!usb_get_client_flag(client, &flag)) goto reloop; - if (flag & kDeviceDFUModeFlag) { + // no reason to use this for tui/gui + if ((flag & kDeviceRecoveryModeFlag) && (palerain_flags & palerain_option_cli)) { + cr = ra1n_enter_dfu(client); + if (cr == RA1N_CLIENT_ERR_NONE) { + LOG("Found DFU mode device"); + usb_close(client); + *stage = STAGE_RESET; + continue; + } + LOG_ERROR("Failed to enter DFU mode (rv=%d, reason=%s)", cr, err_to_string(cr)); + usb_close(client); + *stage = STAGE_ERROR; + break; // err + } else if (flag & kDeviceDFUModeFlag) { if (flag & kDeviceStandardPwnedDFUModeFlag) { // we cant do shit sorry LOG_ERROR("Found an unknown pwned DFU mode device"); @@ -273,10 +286,9 @@ int exploit(int *stage) usb_close(client); continue; } else { - LOG_ERROR("Found unknown device"); usb_close(client); - *stage = STAGE_ERROR; - break; // err + *stage = STAGE_RESET; + continue; // unknown mode, just reloop } reloop: @@ -313,7 +325,7 @@ int exploit(int *stage) int exploit(int *stage) { - LOG("Waiting for devices..."); + LOG("Waiting for DFU mode devices..."); struct DeviceConfiguration deviceConfig; struct PayloadConfiguration payloadConfig;