Add channel analyzer and v7 enclosure

This commit is contained in:
Just Call Me Koko
2025-03-22 01:53:08 -04:00
parent ae8a93a6d2
commit 404ceb03ff
11 changed files with 266 additions and 87 deletions

View File

@@ -760,6 +760,11 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
RunPacketMonitor(scan_mode, color);
#endif
}
else if (scan_mode == WIFI_SCAN_CHAN_ANALYZER) {
#ifdef HAS_SCREEN
RunPacketMonitor(scan_mode, color);
#endif
}
else if (scan_mode == WIFI_ATTACK_BEACON_LIST)
this->startWiFiAttacks(scan_mode, color, text_table1[50]);
else if (scan_mode == WIFI_ATTACK_BEACON_SPAM)
@@ -968,9 +973,14 @@ void WiFiScan::StopScan(uint8_t scan_mode)
(currentScanMode == WIFI_ATTACK_MIMIC) ||
(currentScanMode == WIFI_ATTACK_RICK_ROLL) ||
(currentScanMode == WIFI_PACKET_MONITOR) ||
(currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(currentScanMode == LV_JOIN_WIFI))
{
this->shutdownWiFi();
for (int i = 0; i < TFT_WIDTH; i++) {
this->_analyzer_values[i] = 0;
}
}
@@ -1953,7 +1963,8 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
led_obj.setMode(MODE_SNIFF);
#endif
startPcap("packet_monitor");
if (scan_mode == WIFI_PACKET_MONITOR)
startPcap("packet_monitor");
#ifdef HAS_ILI9341
@@ -1999,7 +2010,10 @@ 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_table1[45],120,16,2);
if (scan_mode == WIFI_PACKET_MONITOR)
display_obj.tft.drawCentreString(text_table1[45],120,16,2);
else if (scan_mode == WIFI_SCAN_CHAN_ANALYZER)
display_obj.tft.drawCentreString("Channel Analyzer", 120, 16, 2);
#endif
#ifdef HAS_ILI9341
display_obj.touchToExit();
@@ -4558,6 +4572,7 @@ void WiFiScan::sendDeauthAttack(uint32_t currentTime, String dst_mac_str) {
void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
{
extern WiFiScan wifi_scan_obj;
wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
@@ -4571,85 +4586,90 @@ void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
int buff = 0;
#endif
if (type == WIFI_PKT_MGMT)
{
len -= 4;
int fctl = ntohs(frameControl->fctl);
const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
const WifiMgmtHdr *hdr = &ipkt->hdr;
if (wifi_scan_obj.currentScanMode != WIFI_SCAN_CHAN_ANALYZER) {
if (type == WIFI_PKT_MGMT)
{
len -= 4;
int fctl = ntohs(frameControl->fctl);
const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
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_SCREEN
#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++;
}
#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
}
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();
// If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
#ifdef HAS_SCREEN
#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++;
}
#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;");
// 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);
}
else {
#ifdef HAS_SCREEN
#ifndef HAS_ILI9341
display_string.concat(";wht;");
#endif
#endif
wifi_scan_obj._analyzer_value++;
}
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)
@@ -5248,6 +5268,23 @@ char* WiFiScan::stringToChar(String string) {
return buf;
}
void WiFiScan::addAnalyzerValue(uint8_t value, int rssi_avg, uint8_t target_array[], int array_size) {
// Shift all elements up by one index
for (int i = array_size - 1; i > 0; i--) {
target_array[i] = target_array[i - 1];
}
// Add the new value to the start of the array
target_array[0] = value;
}
void WiFiScan::channelAnalyzerLoop(uint32_t tick) {
if (tick - this->initTime >= BANNER_TIME) {
this->initTime = millis();
this->addAnalyzerValue(this->_analyzer_value * BASE_MULTIPLIER, -72, this->_analyzer_values, TFT_WIDTH);
this->_analyzer_value = 0;
}
}
// Function for updating scan status
void WiFiScan::main(uint32_t currentTime)
@@ -5269,6 +5306,9 @@ void WiFiScan::main(uint32_t currentTime)
channelHop();
}
}
else if ((currentScanMode == WIFI_SCAN_CHAN_ANALYZER)) {
this->channelAnalyzerLoop(currentTime);
}
else if ((currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) ||
(currentScanMode == BT_ATTACK_SOUR_APPLE) ||
(currentScanMode == BT_ATTACK_SPAM_ALL) ||