mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2026-06-12 11:01:36 -07:00
Merge pull request #1302 from justcallmekoko/develop
file loggers use const char
This commit is contained in:
@@ -6,23 +6,23 @@ Buffer::Buffer(){
|
||||
bufB = (uint8_t*)malloc(BUF_SIZE);
|
||||
}
|
||||
|
||||
void Buffer::createFile(String name, bool is_pcap, bool is_gpx){
|
||||
void Buffer::createFile(const char* name, bool is_pcap, bool is_gpx){
|
||||
int i=0;
|
||||
if (is_pcap) {
|
||||
do{
|
||||
fileName = "/"+name+"_"+(String)i+".pcap";
|
||||
fileName = "/"+String(name)+"_"+(String)i+".pcap";
|
||||
i++;
|
||||
} while(fs->exists(fileName));
|
||||
}
|
||||
else if ((!is_pcap) && (!is_gpx)) {
|
||||
do{
|
||||
fileName = "/"+name+"_"+(String)i+".log";
|
||||
fileName = "/"+String(name)+"_"+(String)i+".log";
|
||||
i++;
|
||||
} while(fs->exists(fileName));
|
||||
}
|
||||
else {
|
||||
do{
|
||||
fileName = "/"+name+"_"+(String)i+".gpx";
|
||||
fileName = "/"+String(name)+"_"+(String)i+".gpx";
|
||||
i++;
|
||||
} while(fs->exists(fileName));
|
||||
}
|
||||
@@ -56,7 +56,7 @@ String Buffer::getFileName() {
|
||||
return this->fileName;
|
||||
}
|
||||
|
||||
void Buffer::openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap, bool is_gpx) {
|
||||
void Buffer::openFile(const char* 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;
|
||||
@@ -76,15 +76,15 @@ void Buffer::openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap, b
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::pcapOpen(String file_name, fs::FS* fs, bool serial) {
|
||||
void Buffer::pcapOpen(const char* file_name, fs::FS* fs, bool serial) {
|
||||
openFile(file_name, fs, serial, true);
|
||||
}
|
||||
|
||||
void Buffer::logOpen(String file_name, fs::FS* fs, bool serial) {
|
||||
void Buffer::logOpen(const char* file_name, fs::FS* fs, bool serial) {
|
||||
openFile(file_name, fs, serial, false);
|
||||
}
|
||||
|
||||
void Buffer::gpxOpen(String file_name, fs::FS* fs, bool serial) {
|
||||
void Buffer::gpxOpen(const char* file_name, fs::FS* fs, bool serial) {
|
||||
openFile(file_name, fs, serial, false, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,17 @@ extern Settings settings_obj;
|
||||
class Buffer {
|
||||
public:
|
||||
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 pcapOpen(const char* file_name, fs::FS* fs, bool serial);
|
||||
void logOpen(const char* file_name, fs::FS* fs, bool serial);
|
||||
void gpxOpen(const char* file_name, fs::FS* fs, bool serial);
|
||||
void append(wifi_promiscuous_pkt_t *packet, int len);
|
||||
void append(String log);
|
||||
void save();
|
||||
String getFileName();
|
||||
private:
|
||||
void createFile(String name, bool is_pcap, bool is_gpx = false);
|
||||
void createFile(const char* 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, bool is_gpx = false);
|
||||
void openFile(const char* 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);
|
||||
|
||||
+33
-33
@@ -2833,7 +2833,7 @@ String WiFiScan::security_int_to_string(int security_type) {
|
||||
return authtype;
|
||||
}
|
||||
|
||||
void WiFiScan::startPcap(String file_name) {
|
||||
void WiFiScan::startPcap(const char* file_name) {
|
||||
buffer_obj.pcapOpen(
|
||||
file_name,
|
||||
#if defined(HAS_SD)
|
||||
@@ -2844,7 +2844,7 @@ void WiFiScan::startPcap(String file_name) {
|
||||
);
|
||||
}
|
||||
|
||||
void WiFiScan::startLog(String file_name) {
|
||||
void WiFiScan::startLog(const char* file_name) {
|
||||
buffer_obj.logOpen(
|
||||
file_name,
|
||||
#if defined(HAS_SD)
|
||||
@@ -2855,7 +2855,7 @@ void WiFiScan::startLog(String file_name) {
|
||||
);
|
||||
}
|
||||
|
||||
void WiFiScan::startGPX(String file_name) {
|
||||
void WiFiScan::startGPX(const char* file_name) {
|
||||
buffer_obj.gpxOpen(
|
||||
file_name,
|
||||
#if defined(HAS_SD)
|
||||
@@ -2919,9 +2919,9 @@ void WiFiScan::prepareScanStage(uint16_t color_1, uint16_t color_2) {
|
||||
|
||||
void WiFiScan::RunPingScan(uint8_t scan_mode, uint16_t color) {
|
||||
if (scan_mode == WIFI_PING_SCAN)
|
||||
startLog(F("pingscan"));
|
||||
startLog("pingscan");
|
||||
else if (scan_mode == WIFI_ARP_SCAN)
|
||||
startLog(F("arpscan"));
|
||||
startLog("arpscan");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
/*#ifdef HAS_FLIPPER_LED
|
||||
@@ -2966,21 +2966,21 @@ void WiFiScan::RunPingScan(uint8_t scan_mode, uint16_t color) {
|
||||
|
||||
void WiFiScan::RunPortScanAll(uint8_t scan_mode, uint16_t color) {
|
||||
if (scan_mode == WIFI_SCAN_SSH)
|
||||
startLog(F("sshscan"));
|
||||
startLog("sshscan");
|
||||
else if (scan_mode == WIFI_SCAN_TELNET)
|
||||
startLog(F("telnetscan"));
|
||||
startLog("telnetscan");
|
||||
else if (scan_mode == WIFI_SCAN_SMTP)
|
||||
startLog(F("smtp"));
|
||||
startLog("smtp");
|
||||
else if (scan_mode == WIFI_SCAN_DNS)
|
||||
startLog(F("dns"));
|
||||
startLog("dns");
|
||||
else if (scan_mode == WIFI_SCAN_HTTP)
|
||||
startLog(F("http"));
|
||||
startLog("http");
|
||||
else if (scan_mode == WIFI_SCAN_HTTPS)
|
||||
startLog(F("https"));
|
||||
startLog("https");
|
||||
else if (scan_mode == WIFI_SCAN_RDP)
|
||||
startLog(F("rdp"));
|
||||
startLog("rdp");
|
||||
else
|
||||
startLog(F("portscan"));
|
||||
startLog("portscan");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
/*#ifdef HAS_FLIPPER_LED
|
||||
@@ -3107,7 +3107,7 @@ void WiFiScan::RunSaveATList(bool save_as) {
|
||||
if (save_as) {
|
||||
sd_obj.removeFile(F("/Airtags_0.log"));
|
||||
|
||||
this->startLog(F("Airtags"));
|
||||
this->startLog("Airtags");
|
||||
|
||||
DynamicJsonDocument jsonDocument(2048);
|
||||
|
||||
@@ -3240,7 +3240,7 @@ void WiFiScan::RunSaveAPList(bool save_as) {
|
||||
if (save_as) {
|
||||
sd_obj.removeFile(F("/APs_0.log"));
|
||||
|
||||
this->startLog(F("APs"));
|
||||
this->startLog("APs");
|
||||
|
||||
DynamicJsonDocument jsonDocument(2048);
|
||||
|
||||
@@ -3333,7 +3333,7 @@ void WiFiScan::RunSaveSSIDList(bool save_as) {
|
||||
if (save_as) {
|
||||
sd_obj.removeFile(F("/SSIDs_0.log"));
|
||||
|
||||
this->startLog(F("SSIDs"));
|
||||
this->startLog("SSIDs");
|
||||
|
||||
for (int i = 0; i < ssids->size(); i++) {
|
||||
String targ_essid = ssids->get(i).essid;
|
||||
@@ -3361,7 +3361,7 @@ void WiFiScan::RunSaveSSIDList(bool save_as) {
|
||||
}
|
||||
|
||||
void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color) {
|
||||
startLog(F("evil_portal"));
|
||||
startLog("evil_portal");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
|
||||
@@ -3386,9 +3386,9 @@ void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color) {
|
||||
// Function to start running a beacon scan
|
||||
void WiFiScan::RunAPScan(uint8_t scan_mode, uint16_t color) {
|
||||
if (scan_mode != WIFI_SCAN_AP_STA)
|
||||
startPcap(F("ap"));
|
||||
startPcap("ap");
|
||||
else
|
||||
startPcap(F("ap_sta"));
|
||||
startPcap("ap_sta");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
#ifdef HAS_SCREEN
|
||||
@@ -3968,10 +3968,10 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color) {
|
||||
#endif*/
|
||||
|
||||
if (scan_mode == WIFI_SCAN_PACKET_RATE)
|
||||
startPcap(F("packet_rate"));
|
||||
startPcap("packet_rate");
|
||||
|
||||
if (scan_mode == WIFI_PACKET_MONITOR)
|
||||
startPcap(F("packet_monitor"));
|
||||
startPcap("packet_monitor");
|
||||
|
||||
#ifdef HAS_ILI9341
|
||||
if ((scan_mode != WIFI_SCAN_PACKET_RATE) &&
|
||||
@@ -4123,7 +4123,7 @@ void WiFiScan::RunEapolScan(uint8_t scan_mode, uint16_t color) {
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
#endif
|
||||
#else*/
|
||||
startPcap(F("eapol"));
|
||||
startPcap("eapol");
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
this->setupScanDisplayArea(TFT_WHITE, color);
|
||||
@@ -4162,7 +4162,7 @@ void WiFiScan::RunEapolScan(uint8_t scan_mode, uint16_t color) {
|
||||
void WiFiScan::RunPineScan(uint8_t scan_mode, uint16_t color) {
|
||||
this->clearList(CLEAR_PINE);
|
||||
|
||||
startPcap(F("pinescan"));
|
||||
startPcap("pinescan");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
/*#ifdef HAS_FLIPPER_LED
|
||||
@@ -4207,7 +4207,7 @@ void WiFiScan::RunPineScan(uint8_t scan_mode, uint16_t color) {
|
||||
void WiFiScan::RunMultiSSIDScan(uint8_t scan_mode, uint16_t color) {
|
||||
this->clearList(CLEAR_MULTI);
|
||||
|
||||
startPcap(F("multissid"));
|
||||
startPcap("multissid");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
|
||||
@@ -4232,7 +4232,7 @@ void WiFiScan::RunMultiSSIDScan(uint8_t scan_mode, uint16_t color) {
|
||||
}
|
||||
|
||||
void WiFiScan::RunPwnScan(uint8_t scan_mode, uint16_t color) {
|
||||
startPcap(F("pwnagotchi"));
|
||||
startPcap("pwnagotchi");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
|
||||
@@ -4995,11 +4995,11 @@ void WiFiScan::displayWardriveStats() {
|
||||
// Function to start running a beacon scan
|
||||
void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color) {
|
||||
if (scan_mode == WIFI_SCAN_AP)
|
||||
startPcap(F("beacon"));
|
||||
startPcap("beacon");
|
||||
else if (scan_mode == WIFI_SCAN_WAR_DRIVE) {
|
||||
#ifdef HAS_GPS
|
||||
if (gps_obj.getGpsModuleStatus()) {
|
||||
startLog(F("wardrive"));
|
||||
startLog("wardrive");
|
||||
buffer_obj.append(this->header_line);
|
||||
this->openPoiFile();
|
||||
} else {
|
||||
@@ -5059,7 +5059,7 @@ void WiFiScan::startWardriverWiFi() {
|
||||
|
||||
void WiFiScan::RunRawScan(uint8_t scan_mode, uint16_t color) {
|
||||
if (scan_mode != WIFI_SCAN_SIG_STREN)
|
||||
startPcap(F("raw"));
|
||||
startPcap("raw");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
|
||||
@@ -5105,7 +5105,7 @@ void WiFiScan::RunRawScan(uint8_t scan_mode, uint16_t color) {
|
||||
}
|
||||
|
||||
void WiFiScan::RunDeauthScan(uint8_t scan_mode, uint16_t color) {
|
||||
startPcap(F("deauth"));
|
||||
startPcap("deauth");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
|
||||
@@ -5136,7 +5136,7 @@ void WiFiScan::RunDeauthScan(uint8_t scan_mode, uint16_t color) {
|
||||
|
||||
void WiFiScan::RunSAEScan(uint8_t scan_mode, uint16_t color) {
|
||||
if (scan_mode == WIFI_SCAN_SAE_COMMIT)
|
||||
this->startPcap(F("sae_commit"));
|
||||
this->startPcap("sae_commit");
|
||||
else if (scan_mode != WIFI_ATTACK_SAE_COMMIT)
|
||||
return;
|
||||
|
||||
@@ -5207,11 +5207,11 @@ void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color) {
|
||||
probe_req_ssids->clear();
|
||||
|
||||
if (scan_mode == WIFI_SCAN_PROBE)
|
||||
startPcap(F("probe"));
|
||||
startPcap("probe");
|
||||
else if (scan_mode == BT_SCAN_FLOCK)
|
||||
startPcap(F("flock"));
|
||||
startPcap("flock");
|
||||
else if (scan_mode == WIFI_SCAN_DETECT_FOLLOW)
|
||||
startPcap(F("mac_track"));
|
||||
startPcap("mac_track");
|
||||
|
||||
this->setLEDMode(MODE_SNIFF);
|
||||
|
||||
|
||||
@@ -922,9 +922,9 @@ class WiFiScan
|
||||
void tagPOI(const char* label = nullptr);
|
||||
|
||||
bool save_serial = false;
|
||||
void startPcap(String file_name);
|
||||
void startLog(String file_name);
|
||||
void startGPX(String file_name);
|
||||
void startPcap(const char* file_name);
|
||||
void startLog(const char* file_name);
|
||||
void startGPX(const char* file_name);
|
||||
|
||||
static WiFiEventId_t eventId;
|
||||
static String lastClientMAC;
|
||||
|
||||
Reference in New Issue
Block a user