mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 07:10:47 -08:00
Add detect pwnagotchi back
This commit is contained in:
@@ -1258,6 +1258,9 @@ void MenuFunctions::RunSetup()
|
|||||||
// WiFi menu stuff
|
// WiFi menu stuff
|
||||||
wifiSnifferMenu.list = new LinkedList<MenuNode>();
|
wifiSnifferMenu.list = new LinkedList<MenuNode>();
|
||||||
wifiAttackMenu.list = new LinkedList<MenuNode>();
|
wifiAttackMenu.list = new LinkedList<MenuNode>();
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
wardrivingMenu.list = new LinkedList<MenuNode>();
|
||||||
|
#endif
|
||||||
wifiGeneralMenu.list = new LinkedList<MenuNode>();
|
wifiGeneralMenu.list = new LinkedList<MenuNode>();
|
||||||
wifiAPMenu.list = new LinkedList<MenuNode>();
|
wifiAPMenu.list = new LinkedList<MenuNode>();
|
||||||
#ifndef HAS_ILI9341
|
#ifndef HAS_ILI9341
|
||||||
@@ -1323,6 +1326,7 @@ void MenuFunctions::RunSetup()
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
gpsInfoMenu.name = "GPS Data";
|
gpsInfoMenu.name = "GPS Data";
|
||||||
|
wardrivingMenu.name = "Wardriving";
|
||||||
#endif
|
#endif
|
||||||
htmlMenu.name = "EP HTML List";
|
htmlMenu.name = "EP HTML List";
|
||||||
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
|
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
|
||||||
@@ -1357,6 +1361,9 @@ void MenuFunctions::RunSetup()
|
|||||||
this->addNodes(&wifiMenu, text_table1[31], TFT_YELLOW, NULL, SNIFFERS, [this]() {
|
this->addNodes(&wifiMenu, text_table1[31], TFT_YELLOW, NULL, SNIFFERS, [this]() {
|
||||||
this->changeMenu(&wifiSnifferMenu);
|
this->changeMenu(&wifiSnifferMenu);
|
||||||
});
|
});
|
||||||
|
this->addNodes(&wifiMenu, "Wardriving", TFT_GREEN, NULL, BEACON_SNIFF, [this]() {
|
||||||
|
this->changeMenu(&wardrivingMenu);
|
||||||
|
});
|
||||||
this->addNodes(&wifiMenu, text_table1[32], TFT_RED, NULL, ATTACKS, [this]() {
|
this->addNodes(&wifiMenu, text_table1[32], TFT_RED, NULL, ATTACKS, [this]() {
|
||||||
this->changeMenu(&wifiAttackMenu);
|
this->changeMenu(&wifiAttackMenu);
|
||||||
});
|
});
|
||||||
@@ -1403,13 +1410,13 @@ void MenuFunctions::RunSetup()
|
|||||||
wifi_scan_obj.StartScan(WIFI_PACKET_MONITOR, TFT_BLUE);
|
wifi_scan_obj.StartScan(WIFI_PACKET_MONITOR, TFT_BLUE);
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAS_ILI9341
|
//#ifndef HAS_ILI9341
|
||||||
this->addNodes(&wifiSnifferMenu, text_table1[47], TFT_RED, NULL, PWNAGOTCHI, [this]() {
|
this->addNodes(&wifiSnifferMenu, text_table1[47], TFT_RED, NULL, PWNAGOTCHI, [this]() {
|
||||||
display_obj.clearScreen();
|
display_obj.clearScreen();
|
||||||
this->drawStatusBar();
|
this->drawStatusBar();
|
||||||
wifi_scan_obj.StartScan(WIFI_SCAN_PWN, TFT_RED);
|
wifi_scan_obj.StartScan(WIFI_SCAN_PWN, TFT_RED);
|
||||||
});
|
});
|
||||||
#endif
|
//#endif
|
||||||
this->addNodes(&wifiSnifferMenu, text_table1[49], TFT_MAGENTA, NULL, BEACON_SNIFF, [this]() {
|
this->addNodes(&wifiSnifferMenu, text_table1[49], TFT_MAGENTA, NULL, BEACON_SNIFF, [this]() {
|
||||||
display_obj.clearScreen();
|
display_obj.clearScreen();
|
||||||
this->drawStatusBar();
|
this->drawStatusBar();
|
||||||
@@ -1432,9 +1439,15 @@ void MenuFunctions::RunSetup()
|
|||||||
wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_CYAN);
|
wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_CYAN);
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Build Wardriving menu
|
||||||
|
wardrivingMenu.parentMenu = &wifiMenu; // Main Menu is second menu parent
|
||||||
|
this->addNodes(&wardrivingMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() {
|
||||||
|
this->changeMenu(wardrivingMenu.parentMenu);
|
||||||
|
});
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
if (gps_obj.getGpsModuleStatus()) {
|
if (gps_obj.getGpsModuleStatus()) {
|
||||||
this->addNodes(&wifiSnifferMenu, "Wardrive", TFT_GREEN, NULL, BEACON_SNIFF, [this]() {
|
this->addNodes(&wardrivingMenu, "Wardrive", TFT_GREEN, NULL, BEACON_SNIFF, [this]() {
|
||||||
display_obj.clearScreen();
|
display_obj.clearScreen();
|
||||||
this->drawStatusBar();
|
this->drawStatusBar();
|
||||||
wifi_scan_obj.StartScan(WIFI_SCAN_WAR_DRIVE, TFT_GREEN);
|
wifi_scan_obj.StartScan(WIFI_SCAN_WAR_DRIVE, TFT_GREEN);
|
||||||
@@ -1443,7 +1456,7 @@ void MenuFunctions::RunSetup()
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
if (gps_obj.getGpsModuleStatus()) {
|
if (gps_obj.getGpsModuleStatus()) {
|
||||||
this->addNodes(&wifiSnifferMenu, "Station Wardrive", TFT_ORANGE, NULL, PROBE_SNIFF, [this]() {
|
this->addNodes(&wardrivingMenu, "Station Wardrive", TFT_ORANGE, NULL, PROBE_SNIFF, [this]() {
|
||||||
display_obj.clearScreen();
|
display_obj.clearScreen();
|
||||||
this->drawStatusBar();
|
this->drawStatusBar();
|
||||||
wifi_scan_obj.StartScan(WIFI_SCAN_STATION_WAR_DRIVE, TFT_ORANGE);
|
wifi_scan_obj.StartScan(WIFI_SCAN_STATION_WAR_DRIVE, TFT_ORANGE);
|
||||||
|
|||||||
@@ -146,6 +146,9 @@ class MenuFunctions
|
|||||||
// WiFi menu stuff
|
// WiFi menu stuff
|
||||||
Menu wifiSnifferMenu;
|
Menu wifiSnifferMenu;
|
||||||
Menu wifiAttackMenu;
|
Menu wifiAttackMenu;
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
Menu wardrivingMenu;
|
||||||
|
#endif
|
||||||
Menu wifiGeneralMenu;
|
Menu wifiGeneralMenu;
|
||||||
Menu wifiAPMenu;
|
Menu wifiAPMenu;
|
||||||
#ifndef HAS_ILI9341
|
#ifndef HAS_ILI9341
|
||||||
|
|||||||
@@ -1918,7 +1918,7 @@ void WiFiScan::RunPwnScan(uint8_t scan_mode, uint16_t color)
|
|||||||
esp_wifi_start();
|
esp_wifi_start();
|
||||||
esp_wifi_set_promiscuous(true);
|
esp_wifi_set_promiscuous(true);
|
||||||
esp_wifi_set_promiscuous_filter(&filt);
|
esp_wifi_set_promiscuous_filter(&filt);
|
||||||
esp_wifi_set_promiscuous_rx_cb(&pwnSnifferCallback);
|
esp_wifi_set_promiscuous_rx_cb(&beaconSnifferCallback);
|
||||||
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
||||||
this->wifi_initialized = true;
|
this->wifi_initialized = true;
|
||||||
initTime = millis();
|
initTime = millis();
|
||||||
@@ -2907,6 +2907,74 @@ void WiFiScan::apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String WiFiScan::processPwnagotchiBeacon(const uint8_t* frame, int length) {
|
||||||
|
// Approximate the start of JSON payload within the beacon frame
|
||||||
|
int jsonStartIndex = 36; // Adjust based on actual frame structure if necessary
|
||||||
|
int jsonEndIndex = length;
|
||||||
|
|
||||||
|
// Locate the actual JSON boundaries by finding '{' and '}'
|
||||||
|
while (jsonStartIndex < length && frame[jsonStartIndex] != '{') jsonStartIndex++;
|
||||||
|
while (jsonEndIndex > jsonStartIndex && frame[jsonEndIndex - 1] != '}') jsonEndIndex--;
|
||||||
|
|
||||||
|
if (jsonStartIndex >= jsonEndIndex) {
|
||||||
|
Serial.println("JSON payload not found.");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract JSON substring from frame directly
|
||||||
|
String jsonString = String((char*)frame + jsonStartIndex, jsonEndIndex - jsonStartIndex);
|
||||||
|
|
||||||
|
// Estimate an appropriate JSON document size based on payload length
|
||||||
|
size_t jsonCapacity = jsonString.length() * 1.5; // Adding buffer for ArduinoJson needs
|
||||||
|
|
||||||
|
// Check if we have enough memory before creating StaticJsonDocument
|
||||||
|
if (jsonCapacity > ESP.getFreeHeap()) {
|
||||||
|
Serial.println("Insufficient memory to parse JSON.");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse JSON payload using ArduinoJson library
|
||||||
|
StaticJsonDocument<2048> doc;
|
||||||
|
DeserializationError error = deserializeJson(doc, jsonString);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
Serial.print("Failed to parse JSON: ");
|
||||||
|
Serial.println(error.c_str());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for Pwnagotchi keys "name" and "pwnd_tot"
|
||||||
|
if (doc.containsKey("name") && doc.containsKey("pwnd_tot")) {
|
||||||
|
const char* name = doc["name"];
|
||||||
|
const char* ver = doc["version"];
|
||||||
|
int pwnd_tot = doc["pwnd_tot"];
|
||||||
|
bool deauth = doc["policy"]["deauth"];
|
||||||
|
int uptime = doc["uptime"];
|
||||||
|
|
||||||
|
// Print and return the Pwnagotchi name and pwnd_tot
|
||||||
|
Serial.print("Pwnagotchi Name: ");
|
||||||
|
Serial.println(name);
|
||||||
|
Serial.print("Pwnd Totals: ");
|
||||||
|
Serial.println(pwnd_tot);
|
||||||
|
|
||||||
|
display_obj.display_buffer->add(String("Pwnagotchi: ") + name + ", ");
|
||||||
|
display_obj.display_buffer->add(" Pwnd: " + String(pwnd_tot) + ", ");
|
||||||
|
display_obj.display_buffer->add(" Uptime: " + String(uptime) + ", ");
|
||||||
|
if (deauth)
|
||||||
|
display_obj.display_buffer->add(" Deauth: true, ");
|
||||||
|
else
|
||||||
|
display_obj.display_buffer->add(" Deauth: false, ");
|
||||||
|
|
||||||
|
display_obj.display_buffer->add(String(" Ver: ") + ver + " ");
|
||||||
|
|
||||||
|
return String("Pwnagotchi: ") + name + ", \nPwnd: " + String(pwnd_tot) + ", \nVer: " + ver;
|
||||||
|
} else {
|
||||||
|
Serial.println("Not a Pwnagotchi frame.");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
||||||
{
|
{
|
||||||
extern WiFiScan wifi_scan_obj;
|
extern WiFiScan wifi_scan_obj;
|
||||||
@@ -2937,11 +3005,34 @@ void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type
|
|||||||
#else
|
#else
|
||||||
int buff = 0;
|
int buff = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint8_t target_mac[6] = {0xde, 0xad, 0xbe, 0xef, 0xde, 0xad};
|
||||||
|
|
||||||
// It is a beacon
|
// It is a beacon
|
||||||
if ((snifferPacket->payload[0] == 0x80) && (buff == 0))
|
if ((snifferPacket->payload[0] == 0x80) && (buff == 0))
|
||||||
{
|
{
|
||||||
|
bool mac_match = true;
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
if (snifferPacket->payload[10 + i] != target_mac[i]) {
|
||||||
|
mac_match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If MAC matches, call processPwnagotchiBeacon with frame data
|
||||||
|
if (mac_match) {
|
||||||
|
Serial.println("Pwnagotchi beacon detected!");
|
||||||
|
wifi_scan_obj.processPwnagotchiBeacon(snifferPacket->payload, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_PWN) {
|
||||||
|
buffer_obj.append(snifferPacket, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Do signal strength stuff first
|
// Do signal strength stuff first
|
||||||
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN) {
|
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
uint8_t targ_index = 0;
|
uint8_t targ_index = 0;
|
||||||
AccessPoint targ_ap;
|
AccessPoint targ_ap;
|
||||||
@@ -2993,6 +3084,7 @@ void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type
|
|||||||
char addr[] = "00:00:00:00:00:00";
|
char addr[] = "00:00:00:00:00:00";
|
||||||
getMAC(addr, snifferPacket->payload, 10);
|
getMAC(addr, snifferPacket->payload, 10);
|
||||||
Serial.print(addr);
|
Serial.print(addr);
|
||||||
|
Serial.print(" ESSID Len: " + (String)snifferPacket->payload[37]);
|
||||||
Serial.print(" ESSID: ");
|
Serial.print(" ESSID: ");
|
||||||
if (snifferPacket->payload[37] <= 0)
|
if (snifferPacket->payload[37] <= 0)
|
||||||
display_string.concat(addr);
|
display_string.concat(addr);
|
||||||
@@ -3014,12 +3106,12 @@ void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type
|
|||||||
|
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
|
|
||||||
if (display_obj.display_buffer->size() == 0)
|
//if (display_obj.display_buffer->size() == 0)
|
||||||
{
|
//{
|
||||||
display_obj.loading = true;
|
display_obj.loading = true;
|
||||||
display_obj.display_buffer->add(display_string);
|
display_obj.display_buffer->add(display_string);
|
||||||
display_obj.loading = false;
|
display_obj.loading = false;
|
||||||
}
|
//}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ class WiFiScan
|
|||||||
void startWardriverWiFi();
|
void startWardriverWiFi();
|
||||||
void generateRandomMac(uint8_t* mac);
|
void generateRandomMac(uint8_t* mac);
|
||||||
void generateRandomName(char *name, size_t length);
|
void generateRandomName(char *name, size_t length);
|
||||||
|
String processPwnagotchiBeacon(const uint8_t* frame, int length);
|
||||||
|
|
||||||
void startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_string);
|
void startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_string);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user