mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-05 20:40:25 -08:00
@@ -6,7 +6,7 @@ Buffer::Buffer(){
|
||||
bufB = (uint8_t*)malloc(BUF_SIZE);
|
||||
}
|
||||
|
||||
void Buffer::createFile(String name, bool is_pcap){
|
||||
void Buffer::createFile(String name, bool is_pcap, bool is_gpx){
|
||||
int i=0;
|
||||
if (is_pcap) {
|
||||
do{
|
||||
@@ -14,12 +14,18 @@ void Buffer::createFile(String name, bool is_pcap){
|
||||
i++;
|
||||
} while(fs->exists(fileName));
|
||||
}
|
||||
else {
|
||||
else if ((!is_pcap) && (!is_gpx)) {
|
||||
do{
|
||||
fileName = "/"+name+"_"+(String)i+".log";
|
||||
i++;
|
||||
} while(fs->exists(fileName));
|
||||
}
|
||||
else {
|
||||
do{
|
||||
fileName = "/"+name+"_"+(String)i+".gpx";
|
||||
i++;
|
||||
} while(fs->exists(fileName));
|
||||
}
|
||||
|
||||
Serial.println(fileName);
|
||||
|
||||
@@ -46,7 +52,7 @@ void Buffer::open(bool is_pcap){
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap) {
|
||||
void Buffer::openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap, bool is_gpx) {
|
||||
bool save_pcap = settings_obj.loadSetting<bool>("SavePCAP");
|
||||
if (!save_pcap) {
|
||||
this->fs = NULL;
|
||||
@@ -57,7 +63,7 @@ void Buffer::openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap) {
|
||||
this->fs = fs;
|
||||
this->serial = serial;
|
||||
if (this->fs) {
|
||||
createFile(file_name, is_pcap);
|
||||
createFile(file_name, is_pcap, is_gpx);
|
||||
}
|
||||
if (this->fs || this->serial) {
|
||||
open(is_pcap);
|
||||
@@ -74,6 +80,10 @@ void Buffer::logOpen(String file_name, fs::FS* fs, bool serial) {
|
||||
openFile(file_name, fs, serial, false);
|
||||
}
|
||||
|
||||
void Buffer::gpxOpen(String file_name, fs::FS* fs, bool serial) {
|
||||
openFile(file_name, fs, serial, false, true);
|
||||
}
|
||||
|
||||
void Buffer::add(const uint8_t* buf, uint32_t len, bool is_pcap){
|
||||
// buffer is full -> drop packet
|
||||
if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
|
||||
|
||||
@@ -21,13 +21,14 @@ class Buffer {
|
||||
Buffer();
|
||||
void pcapOpen(String file_name, fs::FS* fs, bool serial);
|
||||
void logOpen(String file_name, fs::FS* fs, bool serial);
|
||||
void gpxOpen(String file_name, fs::FS* fs, bool serial);
|
||||
void append(wifi_promiscuous_pkt_t *packet, int len);
|
||||
void append(String log);
|
||||
void save();
|
||||
private:
|
||||
void createFile(String name, bool is_pcap);
|
||||
void createFile(String name, bool is_pcap, bool is_gpx = false);
|
||||
void open(bool is_pcap);
|
||||
void openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap);
|
||||
void openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap, bool is_gpx = false);
|
||||
void add(const uint8_t* buf, uint32_t len, bool is_pcap);
|
||||
void write(int32_t n);
|
||||
void write(uint32_t n);
|
||||
|
||||
@@ -329,6 +329,7 @@ void CommandLine::runCommand(String input) {
|
||||
#ifdef HAS_GPS
|
||||
if (gps_obj.getGpsModuleStatus()) {
|
||||
int get_arg = this->argSearch(&cmd_args, "-g");
|
||||
int track_arg = this->argSearch(&cmd_args, "-t");
|
||||
int nmea_arg = this->argSearch(&cmd_args, "-n");
|
||||
|
||||
if (get_arg != -1) {
|
||||
@@ -385,6 +386,13 @@ void CommandLine::runCommand(String input) {
|
||||
else
|
||||
Serial.println("You did not provide a valid argument");
|
||||
}
|
||||
else if (track_arg != -1) {
|
||||
wifi_scan_obj.currentScanMode = GPS_TRACKER;
|
||||
#ifdef HAS_SCREEN
|
||||
menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu);
|
||||
#endif
|
||||
wifi_scan_obj.StartScan(GPS_TRACKER, TFT_CYAN);
|
||||
}
|
||||
else if(cmd_args.size()>1)
|
||||
Serial.println("You did not provide a valid flag");
|
||||
else
|
||||
|
||||
@@ -772,6 +772,7 @@ void MenuFunctions::main(uint32_t currentTime)
|
||||
(wifi_scan_obj.currentScanMode == ESP_UPDATE) ||
|
||||
(wifi_scan_obj.currentScanMode == SHOW_INFO) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_DATA) ||
|
||||
(wifi_scan_obj.currentScanMode == GPS_TRACKER) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_NMEA)) {
|
||||
if (wifi_scan_obj.orient_display) {
|
||||
this->orientDisplay();
|
||||
@@ -834,6 +835,7 @@ void MenuFunctions::main(uint32_t currentTime)
|
||||
(wifi_scan_obj.currentScanMode != ESP_UPDATE) &&
|
||||
(wifi_scan_obj.currentScanMode != SHOW_INFO) &&
|
||||
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_DATA) &&
|
||||
(wifi_scan_obj.currentScanMode != GPS_TRACKER) &&
|
||||
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_NMEA))
|
||||
{
|
||||
// Stop the current scan
|
||||
@@ -909,6 +911,7 @@ void MenuFunctions::main(uint32_t currentTime)
|
||||
(wifi_scan_obj.currentScanMode != ESP_UPDATE) &&
|
||||
(wifi_scan_obj.currentScanMode != SHOW_INFO) &&
|
||||
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_DATA) &&
|
||||
(wifi_scan_obj.currentScanMode != GPS_TRACKER) &&
|
||||
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_NMEA))
|
||||
{
|
||||
// Stop the current scan
|
||||
@@ -3183,10 +3186,17 @@ void MenuFunctions::RunSetup()
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_GPS_NMEA, TFT_ORANGE);
|
||||
});
|
||||
|
||||
this->addNodes(&deviceMenu, "GPS Tracker", TFTGREEN, NULL, GPS_MENU, [this]() {
|
||||
wifi_scan_obj.currentScanMode = GPS_TRACKER;
|
||||
this->changeMenu(&gpsInfoMenu);
|
||||
wifi_scan_obj.StartScan(GPS_TRACKER, TFT_CYAN);
|
||||
});
|
||||
|
||||
// GPS Info Menu
|
||||
gpsInfoMenu.parentMenu = &deviceMenu;
|
||||
this->addNodes(&gpsInfoMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
|
||||
wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF;
|
||||
if(wifi_scan_obj.currentScanMode != GPS_TRACKER)
|
||||
wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF;
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
|
||||
this->changeMenu(gpsInfoMenu.parentMenu);
|
||||
});
|
||||
|
||||
@@ -982,6 +982,9 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
|
||||
gps_obj.enable_queue();
|
||||
#endif
|
||||
}
|
||||
else if (scan_mode == GPS_TRACKER) {
|
||||
RunSetupGPSTracker();
|
||||
}
|
||||
else if (scan_mode == WIFI_PING_SCAN)
|
||||
RunPingScan(scan_mode, color);
|
||||
else if (scan_mode == WIFI_PORT_SCAN_ALL)
|
||||
@@ -1206,6 +1209,10 @@ void WiFiScan::StopScan(uint8_t scan_mode)
|
||||
evil_portal_obj.has_ap = false;
|
||||
}
|
||||
|
||||
else if ((currentScanMode == GPS_TRACKER)) {
|
||||
this->writeFooter();
|
||||
}
|
||||
|
||||
|
||||
else if ((currentScanMode == BT_SCAN_ALL) ||
|
||||
(currentScanMode == BT_SCAN_AIRTAG) ||
|
||||
@@ -1424,6 +1431,17 @@ void WiFiScan::startLog(String file_name) {
|
||||
);
|
||||
}
|
||||
|
||||
void WiFiScan::startGPX(String file_name) {
|
||||
buffer_obj.gpxOpen(
|
||||
file_name,
|
||||
#if defined(HAS_SD)
|
||||
sd_obj.supported ? &SD :
|
||||
#endif
|
||||
NULL,
|
||||
save_serial // Set with commandline options
|
||||
);
|
||||
}
|
||||
|
||||
void WiFiScan::parseBSSID(const char* bssidStr, uint8_t* bssid) {
|
||||
sscanf(bssidStr, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
&bssid[0], &bssid[1], &bssid[2],
|
||||
@@ -2119,37 +2137,49 @@ void WiFiScan::RunGenerateSSIDs(int count) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/*void WiFiScan::RunShutdownBLE() {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setFreeFont(NULL);
|
||||
display_obj.tft.setCursor(0, 100);
|
||||
display_obj.tft.setTextSize(1);
|
||||
display_obj.tft.setTextColor(TFT_CYAN);
|
||||
|
||||
display_obj.tft.print(F(text_table4[18]));
|
||||
#endif
|
||||
void WiFiScan::logPoint(String lat, String lon, float alt, String datetime) {
|
||||
datetime.replace(" ", "T");
|
||||
datetime += "Z";
|
||||
|
||||
if (this->ble_initialized) {
|
||||
this->shutdownBLE();
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.tft.setTextColor(TFT_GREEN);
|
||||
display_obj.tft.println(F("OK"));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.tft.setTextColor(TFT_RED);
|
||||
display_obj.tft.println(F(text17));
|
||||
display_obj.tft.println(F(text_table4[19]));
|
||||
#endif
|
||||
}
|
||||
}*/
|
||||
buffer_obj.append(" <trkpt lat=\"" + lat + "\" lon=\"" + lon + "\">\n");
|
||||
buffer_obj.append(" <ele>" + String(alt, 2) + "</ele>\n");
|
||||
buffer_obj.append(" <time>" + datetime + "</time>\n");
|
||||
buffer_obj.append(" </trkpt>\n");
|
||||
//gpxFile.flush();
|
||||
}
|
||||
|
||||
void WiFiScan::RunGPSInfo() {
|
||||
void WiFiScan::writeHeader() {
|
||||
Serial.println("Writing header to GPX file...");
|
||||
buffer_obj.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||
buffer_obj.append("<gpx version=\"1.1\" creator=\"ESP32 GPS Logger\" xmlns=\"http://www.topografix.com/GPX/1/1\">\n");
|
||||
buffer_obj.append(" <trk>\n");
|
||||
buffer_obj.append(" <name>ESP32 Track</name>\n");
|
||||
buffer_obj.append(" <trkseg>\n");
|
||||
}
|
||||
|
||||
void WiFiScan::writeFooter() {
|
||||
Serial.println("Writing footer to GPX file...\n");
|
||||
buffer_obj.append(" </trkseg>\n");
|
||||
buffer_obj.append(" </trk>\n");
|
||||
buffer_obj.append("</gpx>\n");
|
||||
}
|
||||
|
||||
void WiFiScan::RunSetupGPSTracker() {
|
||||
this->startGPX("tracker");
|
||||
this->writeHeader();
|
||||
initTime = millis();
|
||||
}
|
||||
|
||||
void WiFiScan::RunGPSInfo(bool tracker) {
|
||||
#ifdef HAS_GPS
|
||||
String text=gps_obj.getText();
|
||||
|
||||
if (tracker) {
|
||||
if (gps_obj.getFixStatus()) {
|
||||
this->logPoint(gps_obj.getLat(), gps_obj.getLon(), gps_obj.getAlt(), gps_obj.getDatetime());
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Refreshing GPS Data on screen...");
|
||||
#ifdef HAS_SCREEN
|
||||
|
||||
@@ -7569,6 +7599,12 @@ void WiFiScan::main(uint32_t currentTime)
|
||||
this->RunGPSInfo();
|
||||
}
|
||||
}
|
||||
else if (currentScanMode == GPS_TRACKER) {
|
||||
if (currentTime - initTime >= 1000) {
|
||||
this->initTime = millis();
|
||||
this->RunGPSInfo(true);
|
||||
}
|
||||
}
|
||||
else if (currentScanMode == WIFI_SCAN_GPS_NMEA) {
|
||||
if (currentTime - initTime >= 1000) {
|
||||
this->initTime = millis();
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
#define WIFI_CONNECTED 52
|
||||
#define WIFI_PING_SCAN 53
|
||||
#define WIFI_PORT_SCAN_ALL 54
|
||||
#define GPS_TRACKER 55
|
||||
|
||||
#define BASE_MULTIPLIER 4
|
||||
|
||||
@@ -455,7 +456,7 @@ class WiFiScan
|
||||
void broadcastCustomBeacon(uint32_t current_time, AccessPoint custom_ssid);
|
||||
void broadcastSetSSID(uint32_t current_time, const char* ESSID);
|
||||
void RunAPScan(uint8_t scan_mode, uint16_t color);
|
||||
void RunGPSInfo();
|
||||
void RunGPSInfo(bool tracker = false);
|
||||
void RunGPSNmea();
|
||||
void RunMimicFlood(uint8_t scan_mode, uint16_t color);
|
||||
void RunPwnScan(uint8_t scan_mode, uint16_t color);
|
||||
@@ -477,6 +478,9 @@ class WiFiScan
|
||||
void RunPortScanAll(uint8_t scan_mode, uint16_t color);
|
||||
bool checkMem();
|
||||
void parseBSSID(const char* bssidStr, uint8_t* bssid);
|
||||
void logPoint(String lat, String lon, float alt, String datetime);
|
||||
void writeHeader();
|
||||
void writeFooter();
|
||||
|
||||
|
||||
public:
|
||||
@@ -621,6 +625,7 @@ class WiFiScan
|
||||
void RunLoadAPList();
|
||||
void RunSaveATList(bool save_as = true);
|
||||
void RunLoadATList();
|
||||
void RunSetupGPSTracker();
|
||||
void channelHop();
|
||||
uint8_t currentScanMode = 0;
|
||||
void main(uint32_t currentTime);
|
||||
@@ -632,6 +637,7 @@ class WiFiScan
|
||||
bool save_serial = false;
|
||||
void startPcap(String file_name);
|
||||
void startLog(String file_name);
|
||||
void startGPX(String file_name);
|
||||
//String macToString(const Station& station);
|
||||
|
||||
static void getMAC(char *addr, uint8_t* data, uint16_t offset);
|
||||
|
||||
Reference in New Issue
Block a user