refactor: yolodfu detection, pongo compression

Update run.c
This commit is contained in:
CLARATION committed 2026-06-28 22:32:44 -07:00
1 parent 93d66b893b
commit 54ae6c7fd2
13 files changed
+278 -236

No files matched your search

+35 -37
View File
@@ -9,34 +9,31 @@
#include "AppFrame.hpp"
#include "../m8/run.h"
#include "../utils.h"
static const char* stage_to_string(int stage)
{
switch (stage) {
case STAGE_PREPARE: return "Checking if device is ready";
case STAGE_RESET: return "Checking if device is ready";
case STAGE_SETUP: return "Setting up the exploit (this is the heap spray)";
case STAGE_SPRAY: return "Setting up the exploit (this is the heap spray)";
case STAGE_PATCH: return "Right before trigger (this is the real bug setup)";
case STAGE_PONGO: return "Booting...";
case STAGE_JAILBREAK: return "Booting...";
case STAGE_DONE: return "Done.";
default: return "Working...";
case STAGE_SETUP: return "Checking if device is ready";
case STAGE_SPRAY: return "Setting up the exploit (this is the heap spray)";
case STAGE_PATCH: return "Right before trigger (this is the real bug setup)";
case STAGE_YOLODFU: return "Booting PongoOS...";
case STAGE_PONGO: return "Booting...";
case STAGE_DONE: return "Done.";
default: return "Idle.";
}
}
static int stage_to_progress(int stage)
{
switch (stage) {
case STAGE_PREPARE: return 5;
case STAGE_RESET: return 15;
case STAGE_SETUP: return 30;
case STAGE_SPRAY: return 50;
case STAGE_PATCH: return 70;
case STAGE_PONGO: return 90;
case STAGE_JAILBREAK: return 95;
case STAGE_DONE: return 100;
default: return 0;
case STAGE_SETUP: return 30;
case STAGE_SPRAY: return 40;
case STAGE_PATCH: return 50;
case STAGE_YOLODFU: return 60;
case STAGE_PONGO: return 70;
case STAGE_DONE: return 100;
default: return 0;
}
}
@@ -67,7 +64,11 @@ ExploitPanel::ExploitPanel(MainFrame* frame, wxWindow* parent)
root->Add(m_progressBar, 0, wxALL | wxEXPAND, 20);
root->AddStretchSpacer();
root->Add(m_backButton, 0, wxALL | wxALIGN_RIGHT, 12);
auto* bottomRow = new wxBoxSizer(wxHORIZONTAL);
bottomRow->AddStretchSpacer();
bottomRow->Add(m_backButton, 0, wxRIGHT | wxLEFT | wxBOTTOM, 12);
root->Add(bottomRow, 0, wxEXPAND);
SetSizer(root);
}
@@ -82,7 +83,6 @@ void ExploitPanel::SetDeviceState(const DeviceState& state)
void ExploitPanel::StartExploit()
{
m_statusText->SetLabel("Starting...");
m_backButton->Disable();
std::thread([this]()
@@ -91,38 +91,36 @@ void ExploitPanel::StartExploit()
if (!deviceState.connected || deviceState.mode != DeviceMode::DFU)
return;
shared_t state{};
atomic_init(&state.result, 0);
atomic_init(&state.stop, false);
atomic_init(&state.exploit_done, false);
atomic_init(&state.pongo_done, false);
atomic_init(&state.stage, STAGE_PREPARE);
auto state = std::make_shared<shared_t>();
atomic_init(&state->stage, STAGE_RESET);
atomic_init(&state->stop, false);
atomic_init(&state->result, 0);
std::thread worker([&]() {
exploit(&state);
std::thread worker([state]()
{
exploit(state.get());
});
worker.detach();
while (true)
{
int stage = atomic_load(&state.stage);
int stage = atomic_load(&state->stage);
int progress = stage_to_progress(stage);
wxTheApp->CallAfter([this, stage, progress]() {
wxTheApp->CallAfter([this, stage, progress]()
{
m_statusText->SetLabel(stage_to_string(stage));
m_progressBar->SetValue(progress);
if (stage == STAGE_DONE) m_backButton->Enable();
});
if (stage == STAGE_DONE) {
wxTheApp->CallAfter([this]() {
m_backButton->Enable();
});
if (stage == STAGE_DONE)
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
if (worker.joinable())
worker.join();
}).detach();
}