mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 07:29:14 -08:00
Fix packet monitor for non ILI9341
This commit is contained in:
@@ -283,11 +283,42 @@ void Display::scrollScreenBuffer(bool down) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void Display::processAndPrintString(TFT_eSPI& tft, const String& originalString) {
|
||||
// Define colors
|
||||
uint16_t text_color = TFT_GREEN; // Default text color
|
||||
uint16_t background_color = TFT_BLACK; // Default background color
|
||||
|
||||
String new_string = originalString;
|
||||
|
||||
// Check for color macros at the start of the string
|
||||
if (new_string.startsWith(RED_KEY)) {
|
||||
text_color = TFT_RED;
|
||||
new_string.remove(0, strlen(RED_KEY)); // Remove the macro
|
||||
} else if (new_string.startsWith(GREEN_KEY)) {
|
||||
text_color = TFT_GREEN;
|
||||
new_string.remove(0, strlen(GREEN_KEY)); // Remove the macro
|
||||
} else if (new_string.startsWith(CYAN_KEY)) {
|
||||
text_color = TFT_CYAN;
|
||||
new_string.remove(0, strlen(CYAN_KEY)); // Remove the macro
|
||||
} else if (new_string.startsWith(WHITE_KEY)) {
|
||||
text_color = TFT_WHITE;
|
||||
new_string.remove(0, strlen(WHITE_KEY)); // Remove the macro
|
||||
} else if (new_string.startsWith(MAGENTA_KEY)) {
|
||||
text_color = TFT_MAGENTA;
|
||||
new_string.remove(0, strlen(MAGENTA_KEY)); // Remove the macro
|
||||
}
|
||||
|
||||
// Set text color and print the string
|
||||
tft.setTextColor(text_color, background_color);
|
||||
tft.print(new_string);
|
||||
}
|
||||
|
||||
void Display::displayBuffer(bool do_clear)
|
||||
{
|
||||
if (this->display_buffer->size() > 0)
|
||||
{
|
||||
while (display_buffer->size() > 0)
|
||||
int print_count = 10;
|
||||
while ((display_buffer->size() > 0) && (print_count > 0))
|
||||
{
|
||||
|
||||
#ifndef SCREEN_BUFFER
|
||||
@@ -319,10 +350,14 @@ void Display::displayBuffer(bool do_clear)
|
||||
for (int x = 0; x < TFT_WIDTH / CHAR_WIDTH; x++)
|
||||
tft.print(" ");
|
||||
tft.setCursor(xPos, (i * 12) + (SCREEN_HEIGHT / 6));
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.print(this->screen_buffer->get(i));
|
||||
|
||||
this->processAndPrintString(tft, this->screen_buffer->get(i));
|
||||
//tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
//tft.print(this->screen_buffer->get(i));
|
||||
}
|
||||
#endif
|
||||
|
||||
print_count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
#define LV_ADD_SSID 14
|
||||
#define WIFI_ATTACK_BEACON_LIST 15
|
||||
|
||||
#define RED_KEY ";red;"
|
||||
#define GREEN_KEY ";grn;"
|
||||
#define CYAN_KEY ";cyn;"
|
||||
#define MAGENTA_KEY ";mgn;"
|
||||
#define WHITE_KEY ";wht;"
|
||||
|
||||
class Display
|
||||
{
|
||||
private:
|
||||
@@ -58,6 +64,7 @@ class Display
|
||||
#ifdef SCREEN_BUFFER
|
||||
void scrollScreenBuffer(bool down = false);
|
||||
#endif
|
||||
void processAndPrintString(TFT_eSPI& tft, const String& originalString);
|
||||
|
||||
public:
|
||||
Display();
|
||||
|
||||
@@ -1999,7 +1999,7 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
|
||||
display_obj.tft.setTextColor(TFT_WHITE, color);
|
||||
#ifdef HAS_FULL_SCREEN
|
||||
display_obj.tft.fillRect(0,16,240,16, color);
|
||||
display_obj.tft.drawCentreString(text_table4[38],120,16,2);
|
||||
display_obj.tft.drawCentreString(text_table1[45],120,16,2);
|
||||
#endif
|
||||
#ifdef HAS_ILI9341
|
||||
display_obj.touchToExit();
|
||||
@@ -4547,48 +4547,77 @@ void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
||||
const WifiMgmtHdr *hdr = &ipkt->hdr;
|
||||
|
||||
// If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
|
||||
#ifdef HAS_ILI9341
|
||||
if (snifferPacket->payload[0] == 0x80)
|
||||
{
|
||||
num_beacon++;
|
||||
}
|
||||
else if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ))
|
||||
{
|
||||
num_deauth++;
|
||||
}
|
||||
else if (snifferPacket->payload[0] == 0x40)
|
||||
{
|
||||
num_probe++;
|
||||
}
|
||||
#endif
|
||||
|
||||
char addr[] = "00:00:00:00:00:00";
|
||||
getMAC(addr, snifferPacket->payload, 10);
|
||||
display_string.concat(addr);
|
||||
|
||||
int temp_len = display_string.length();
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
for (int i = 0; i < 40 - temp_len; i++)
|
||||
{
|
||||
display_string.concat(" ");
|
||||
}
|
||||
|
||||
//Serial.print(" ");
|
||||
|
||||
#ifdef SCREEN_BUFFER
|
||||
if (display_obj.display_buffer->size() == 0)
|
||||
#ifdef HAS_ILI9341
|
||||
if (snifferPacket->payload[0] == 0x80)
|
||||
{
|
||||
display_obj.loading = true;
|
||||
display_obj.display_buffer->add(display_string);
|
||||
display_obj.loading = false;
|
||||
Serial.println(display_string);
|
||||
num_beacon++;
|
||||
}
|
||||
else if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ))
|
||||
{
|
||||
num_deauth++;
|
||||
}
|
||||
else if (snifferPacket->payload[0] == 0x40)
|
||||
{
|
||||
num_probe++;
|
||||
}
|
||||
#else
|
||||
if (snifferPacket->payload[0] == 0x80)
|
||||
display_string.concat(";grn;");
|
||||
else if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ))
|
||||
display_string.concat(";red;");
|
||||
else if (snifferPacket->payload[0] == 0x40)
|
||||
display_string.concat(";cyn;");
|
||||
else
|
||||
display_string.concat(";mgn;");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
buffer_obj.append(snifferPacket, len);
|
||||
}
|
||||
else {
|
||||
#ifdef HAS_SCREEN
|
||||
#ifndef HAS_ILI9341
|
||||
display_string.concat(";wht;");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
char src_addr[] = "00:00:00:00:00:00";
|
||||
char dst_addr[] = "00:00:00:00:00:00";
|
||||
getMAC(src_addr, snifferPacket->payload, 10);
|
||||
getMAC(dst_addr, snifferPacket->payload, 4);
|
||||
display_string.concat(src_addr);
|
||||
display_string.concat(" -> ");
|
||||
display_string.concat(dst_addr);
|
||||
|
||||
int temp_len = display_string.length();
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
// Fill blank space
|
||||
for (int i = 0; i < 40 - temp_len; i++)
|
||||
{
|
||||
display_string.concat(" ");
|
||||
}
|
||||
|
||||
//Serial.print(" ");
|
||||
|
||||
#ifdef SCREEN_BUFFER
|
||||
//if (display_obj.display_buffer->size() == 0)
|
||||
//{
|
||||
// display_obj.loading = true;
|
||||
//while(display_obj.display_buffer->size() >= 10)
|
||||
// delay(10);
|
||||
if (display_obj.display_buffer->size() >= 10)
|
||||
return;
|
||||
|
||||
display_obj.display_buffer->add(display_string);
|
||||
// display_obj.loading = false;
|
||||
Serial.println(display_string);
|
||||
//}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
buffer_obj.append(snifferPacket, len);
|
||||
//}
|
||||
}
|
||||
|
||||
void WiFiScan::eapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
||||
|
||||
Reference in New Issue
Block a user