Skip to content

Commit

Permalink
Single buffer_obj.append() with overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Jan 2, 2024
1 parent 558fe18 commit 9d92c5c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions esp32_marauder/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ void Buffer::add(const uint8_t* buf, uint32_t len, bool is_pcap){
write(buf, len); // packet payload
}

void Buffer::pcapAdd(wifi_promiscuous_pkt_t *packet, int len) {
void Buffer::append(wifi_promiscuous_pkt_t *packet, int len) {
bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
if (save_packet) {
add(packet->payload, len, true);
}
}

void Buffer::logAdd(String log) {
void Buffer::append(String log) {
bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
if (save_packet) {
add((const uint8_t*)log.c_str(), log.length(), false);
Expand Down
4 changes: 2 additions & 2 deletions esp32_marauder/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Buffer {
Buffer();
void pcapOpen(String file_name, fs::FS* fs, bool serial);
void logOpen(String file_name, fs::FS* fs, bool serial);
void pcapAdd(wifi_promiscuous_pkt_t *packet, int len);
void logAdd(String log);
void append(wifi_promiscuous_pkt_t *packet, int len);
void append(String log);
void save();
private:
void createFile(String name, bool is_pcap);
Expand Down
2 changes: 1 addition & 1 deletion esp32_marauder/EvilPortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void EvilPortal::main(uint8_t scan_mode) {
String logValue2 = "p: " + this->password;
String full_string = logValue1 + " " + logValue2 + "\n";
Serial.print(full_string);
buffer_obj.logAdd(full_string);
buffer_obj.append(full_string);
#ifdef HAS_SCREEN
this->sendToDisplay(full_string);
#endif
Expand Down
38 changes: 19 additions & 19 deletions esp32_marauder/WiFiScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ extern "C" {
Serial.print(wardrive_line);

if (do_save)
buffer_obj.logAdd(wardrive_line);
buffer_obj.append(wardrive_line);
}
}
#endif
Expand Down Expand Up @@ -1804,7 +1804,7 @@ void WiFiScan::executeWarDrive() {
Serial.print((String)this->mac_history_cursor + " | " + wardrive_line);

if (do_save) {
buffer_obj.logAdd(wardrive_line);
buffer_obj.append(wardrive_line);
}
}
}
Expand All @@ -1826,7 +1826,7 @@ void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
if (gps_obj.getGpsModuleStatus()) {
startLog("wardrive");
String header_line = "WigleWifi-1.4,appRelease=" + (String)MARAUDER_VERSION + ",model=ESP32 Marauder,release=" + (String)MARAUDER_VERSION + ",device=ESP32 Marauder,display=SPI TFT,board=ESP32 Marauder,brand=JustCallMeKoko\nMAC,SSID,AuthMode,FirstSeen,Channel,RSSI,CurrentLatitude,CurrentLongitude,AltitudeMeters,AccuracyMeters,Type\n";
buffer_obj.logAdd(header_line);
buffer_obj.append(header_line);
} else {
return;
}
Expand Down Expand Up @@ -2034,7 +2034,7 @@ void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
if (gps_obj.getGpsModuleStatus()) {
startLog("station_wardrive");
String header_line = "WigleWifi-1.4,appRelease=" + (String)MARAUDER_VERSION + ",model=ESP32 Marauder,release=" + (String)MARAUDER_VERSION + ",device=ESP32 Marauder,display=SPI TFT,board=ESP32 Marauder,brand=JustCallMeKoko\nMAC,SSID,AuthMode,FirstSeen,Channel,RSSI,CurrentLatitude,CurrentLongitude,AltitudeMeters,AccuracyMeters,Type\n";
buffer_obj.logAdd(header_line);
buffer_obj.append(header_line);
} else {
return;
}
Expand Down Expand Up @@ -2181,7 +2181,7 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
startLog("bt_wardrive_cont");
}
String header_line = "WigleWifi-1.4,appRelease=" + (String)MARAUDER_VERSION + ",model=ESP32 Marauder,release=" + (String)MARAUDER_VERSION + ",device=ESP32 Marauder,display=SPI TFT,board=ESP32 Marauder,brand=JustCallMeKoko\nMAC,SSID,AuthMode,FirstSeen,Channel,RSSI,CurrentLatitude,CurrentLongitude,AltitudeMeters,AccuracyMeters,Type\n";
buffer_obj.logAdd(header_line);
buffer_obj.append(header_line);
} else {
return;
}
Expand Down Expand Up @@ -2349,7 +2349,7 @@ void WiFiScan::pwnSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
}
}
Expand Down Expand Up @@ -2508,7 +2508,7 @@ void WiFiScan::apSnifferCallbackFull(void* buf, wifi_promiscuous_pkt_type_t type

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
}
}
Expand Down Expand Up @@ -2634,7 +2634,7 @@ void WiFiScan::apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
}
}
Expand Down Expand Up @@ -2755,7 +2755,7 @@ void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_WAR_DRIVE) {
#ifdef HAS_GPS
Expand Down Expand Up @@ -2830,7 +2830,7 @@ void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type
}
String wardrive_line = (String)addr + "," + essid + "," + wifi_scan_obj.security_int_to_string(snifferPacket->rx_ctrl.channel) + "," + gps_obj.getDatetime() + "," + (String)snifferPacket->rx_ctrl.channel + "," + (String)snifferPacket->rx_ctrl.rssi + "," + gps_obj.getLat() + "," + gps_obj.getLon() + "," + gps_obj.getAlt() + "," + gps_obj.getAccuracy() + ",WIFI";
Serial.println(wardrive_line);
//buffer_obj.logAdd(wardrive_line);
//buffer_obj.append(wardrive_line);
}
}
#endif
Expand Down Expand Up @@ -2994,7 +2994,7 @@ void WiFiScan::stationSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t typ

access_points->set(ap_index, ap);

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}

void WiFiScan::rawSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
Expand Down Expand Up @@ -3095,7 +3095,7 @@ void WiFiScan::rawSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}

void WiFiScan::deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
Expand Down Expand Up @@ -3159,7 +3159,7 @@ void WiFiScan::deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
}
}
Expand Down Expand Up @@ -3231,7 +3231,7 @@ void WiFiScan::probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_STATION_WAR_DRIVE) {
#ifdef HAS_GPS
Expand Down Expand Up @@ -3286,7 +3286,7 @@ void WiFiScan::probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
if (do_save) {
String wardrive_line = (String)addr + "," + (String)addr + ",," + gps_obj.getDatetime() + "," + (String)snifferPacket->rx_ctrl.channel + "," + (String)snifferPacket->rx_ctrl.rssi + "," + gps_obj.getLat() + "," + gps_obj.getLon() + "," + gps_obj.getAlt() + "," + gps_obj.getAccuracy() + ",WIFI";
Serial.println(wardrive_line);
buffer_obj.logAdd(wardrive_line);
buffer_obj.append(wardrive_line);
}
}
#endif
Expand Down Expand Up @@ -3377,7 +3377,7 @@ void WiFiScan::beaconListSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t

Serial.println();

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
}
}
Expand Down Expand Up @@ -3838,7 +3838,7 @@ void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
#endif
#endif

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}
}

Expand Down Expand Up @@ -3926,7 +3926,7 @@ void WiFiScan::eapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
#endif
}

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}

void WiFiScan::activeEapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
Expand Down Expand Up @@ -4012,7 +4012,7 @@ void WiFiScan::activeEapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t

}

buffer_obj.pcapAdd(snifferPacket, len);
buffer_obj.append(snifferPacket, len);
}

#ifdef HAS_SCREEN
Expand Down

0 comments on commit 9d92c5c

Please sign in to comment.