From 4858b01f0940a1608be188568803205827834ca0 Mon Sep 17 00:00:00 2001 From: 0xchocolate <109879152+0xchocolate@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:22:04 -0800 Subject: [PATCH 1/2] EP: allow loading HTML over serial --- esp32_marauder/CommandLine.cpp | 5 +++++ esp32_marauder/EvilPortal.cpp | 13 +++++++++++++ esp32_marauder/EvilPortal.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/esp32_marauder/CommandLine.cpp b/esp32_marauder/CommandLine.cpp index 92e89e6d1..b5a10c672 100644 --- a/esp32_marauder/CommandLine.cpp +++ b/esp32_marauder/CommandLine.cpp @@ -497,6 +497,7 @@ void CommandLine::runCommand(String input) { if (html_sw != -1) { String target_html_name = cmd_args.get(html_sw + 1); evil_portal_obj.target_html_name = target_html_name; + evil_portal_obj.using_serial_html = false; Serial.println("Set html file as " + evil_portal_obj.target_html_name); } //else { @@ -513,8 +514,12 @@ void CommandLine::runCommand(String input) { else if (et_command == "sethtml") { String target_html_name = cmd_args.get(cmd_sw + 2); evil_portal_obj.target_html_name = target_html_name; + evil_portal_obj.using_serial_html = false; Serial.println("Set html file as " + evil_portal_obj.target_html_name); } + else if (et_command == "sethtmlstr") { + evil_portal_obj.setHtmlFromSerial(); + } else if (et_command == "setap") { } diff --git a/esp32_marauder/EvilPortal.cpp b/esp32_marauder/EvilPortal.cpp index f97c4a275..5801f1008 100644 --- a/esp32_marauder/EvilPortal.cpp +++ b/esp32_marauder/EvilPortal.cpp @@ -62,7 +62,20 @@ void EvilPortal::setupServer() { Serial.println("web server up"); } +void EvilPortal::setHtmlFromSerial() { + Serial.println("Setting HTML from serial..."); + const char *htmlStr = Serial.readString().c_str(); + strncpy(index_html, htmlStr, strlen(htmlStr)); + this->has_html = true; + this->using_serial_html = true; + Serial.println("html set"); +} + bool EvilPortal::setHtml() { + if (this->using_serial_html) { + Serial.println("html previously set"); + return true; + } Serial.println("Setting HTML..."); #ifndef WRITE_PACKETS_SERIAL File html_file = sd_obj.getFile("/" + this->target_html_name); diff --git a/esp32_marauder/EvilPortal.h b/esp32_marauder/EvilPortal.h index 19e3f7cb9..293b6877b 100644 --- a/esp32_marauder/EvilPortal.h +++ b/esp32_marauder/EvilPortal.h @@ -83,6 +83,7 @@ class EvilPortal { bool has_html; bool has_ap; + bool using_serial_html; DNSServer dnsServer; @@ -106,6 +107,7 @@ class EvilPortal { void addLog(String log, int len); bool begin(LinkedList* ssids, LinkedList* access_points); void main(uint8_t scan_mode); + void setHtmlFromSerial(); }; From 91e861155fe6b11772dc27eedfda400f6a8503bc Mon Sep 17 00:00:00 2001 From: 0xchocolate <109879152+0xchocolate@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:30:55 -0800 Subject: [PATCH 2/2] Make new member variable public --- esp32_marauder/EvilPortal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp32_marauder/EvilPortal.h b/esp32_marauder/EvilPortal.h index 293b6877b..f704e9ac8 100644 --- a/esp32_marauder/EvilPortal.h +++ b/esp32_marauder/EvilPortal.h @@ -83,7 +83,6 @@ class EvilPortal { bool has_html; bool has_ap; - bool using_serial_html; DNSServer dnsServer; @@ -102,6 +101,8 @@ class EvilPortal { String target_html_name = "index.html"; + bool using_serial_html; + String get_user_name(); String get_password(); void addLog(String log, int len);