mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 23:26:45 -08:00
Added packet monitor
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
//esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
|
||||
|
||||
//int num_beacon = 0;
|
||||
int num_beacon = 0;
|
||||
int num_deauth = 0;
|
||||
int num_probe = 0;
|
||||
|
||||
class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||
String display_string = "";
|
||||
@@ -122,6 +127,8 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
|
||||
RunBeaconScan(scan_mode, color);
|
||||
else if (scan_mode == WIFI_SCAN_DEAUTH)
|
||||
RunDeauthScan(scan_mode, color);
|
||||
else if (scan_mode == WIFI_PACKET_MONITOR)
|
||||
RunPacketMonitor(scan_mode, color);
|
||||
else if (scan_mode == WIFI_ATTACK_BEACON_SPAM)
|
||||
RunBeaconSpam(scan_mode, color);
|
||||
else if (scan_mode == WIFI_ATTACK_RICK_ROLL)
|
||||
@@ -148,7 +155,6 @@ void WiFiScan::StopScan(uint8_t scan_mode)
|
||||
esp_wifi_set_promiscuous(false);
|
||||
WiFi.mode(WIFI_OFF);
|
||||
}
|
||||
|
||||
else if ((currentScanMode == BT_SCAN_ALL) ||
|
||||
(currentScanMode == BT_SCAN_SKIMMERS))
|
||||
{
|
||||
@@ -164,6 +170,41 @@ void WiFiScan::StopScan(uint8_t scan_mode)
|
||||
display_obj.tteBar = false;
|
||||
}
|
||||
|
||||
void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
|
||||
{
|
||||
display_obj.tft.init();
|
||||
display_obj.tft.setRotation(1);
|
||||
display_obj.tft.fillScreen(TFT_BLACK);
|
||||
uint16_t calData[5] = { 391, 3491, 266, 3505, 7 };
|
||||
display_obj.tft.setTouch(calData);
|
||||
|
||||
//display_obj.tft.setFreeFont(1);
|
||||
display_obj.tft.setFreeFont(NULL);
|
||||
display_obj.tft.setTextSize(1);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); // Buttons
|
||||
display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // color key
|
||||
|
||||
delay(10);
|
||||
|
||||
display_obj.tftDrawGraphObjects(x_scale); //draw graph objects
|
||||
display_obj.tftDrawColorKey();
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
|
||||
Serial.println("Running packet scan...");
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
esp_wifi_init(&cfg);
|
||||
esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
||||
esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||
esp_wifi_set_promiscuous(true);
|
||||
esp_wifi_set_promiscuous_filter(&filt);
|
||||
esp_wifi_set_promiscuous_rx_cb(&wifiSnifferCallback);
|
||||
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
||||
uint32_t initTime = millis();
|
||||
}
|
||||
|
||||
void WiFiScan::RunRickRoll(uint8_t scan_mode, uint16_t color)
|
||||
{
|
||||
//Serial.println("Rick Roll...");
|
||||
@@ -643,11 +684,262 @@ void WiFiScan::broadcastRandomSSID(uint32_t currentTime) {
|
||||
}
|
||||
|
||||
|
||||
void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
||||
{
|
||||
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;
|
||||
int len = snifferPacket->rx_ctrl.sig_len;
|
||||
|
||||
if (type == WIFI_PKT_MGMT)
|
||||
{
|
||||
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
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WiFiScan::packetMonitorMain()
|
||||
{
|
||||
//---------MAIN 'FOR' LOOP! THIS IS WHERE ALL THE ACTION HAPPENS! HAS TO BE FAST!!!!!---------\\
|
||||
|
||||
|
||||
for (x_pos = (11 + x_scale); x_pos <= 320; x_pos += x_scale) //go along every point on the x axis and do something, start over when finished
|
||||
{
|
||||
do_break = false;
|
||||
|
||||
y_pos_x = 0;
|
||||
y_pos_y = 0;
|
||||
y_pos_z = 0;
|
||||
boolean pressed = false;
|
||||
|
||||
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
|
||||
|
||||
// Do the touch stuff
|
||||
pressed = display_obj.tft.getTouch(&t_x, &t_y);
|
||||
|
||||
if (pressed) {
|
||||
Serial.print("Got touch | X: ");
|
||||
Serial.print(t_x);
|
||||
Serial.print(" Y: ");
|
||||
Serial.println(t_y);
|
||||
}
|
||||
|
||||
|
||||
// Check buttons for presses
|
||||
for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
|
||||
{
|
||||
if (pressed && display_obj.key[b].contains(t_x, t_y))
|
||||
{
|
||||
display_obj.key[b].press(true);
|
||||
} else {
|
||||
display_obj.key[b].press(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Which buttons pressed
|
||||
for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
|
||||
{
|
||||
if (display_obj.key[b].justPressed())
|
||||
{
|
||||
Serial.println("Bro, key pressed");
|
||||
//do_break = true;
|
||||
}
|
||||
|
||||
if (display_obj.key[b].justReleased())
|
||||
{
|
||||
do_break = true;
|
||||
|
||||
// X - button pressed
|
||||
if (b == 0) {
|
||||
if (x_scale > 1) {
|
||||
x_scale--;
|
||||
delay(70);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// X + button pressed
|
||||
else if (b == 1) {
|
||||
if (x_scale < 6) {
|
||||
x_scale++;
|
||||
delay(70);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Y - button pressed
|
||||
else if (b == 2) {
|
||||
if (y_scale > 1) {
|
||||
y_scale--;
|
||||
delay(70);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
//updateMidway();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Y + button pressed
|
||||
else if (b == 3) {
|
||||
if (y_scale < 6) {
|
||||
y_scale++;
|
||||
delay(70);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
//updateMidway();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Channel - button pressed
|
||||
else if (b == 4) {
|
||||
if (set_channel > 1) {
|
||||
Serial.println("Shit channel down");
|
||||
set_channel--;
|
||||
delay(70);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
changeChannel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Channel + button pressed
|
||||
else if (b == 5) {
|
||||
if (set_channel < MAX_CHANNEL) {
|
||||
Serial.println("Shit channel up");
|
||||
set_channel++;
|
||||
delay(70);
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
|
||||
display_obj.tftDrawXScaleButtons(x_scale);
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
changeChannel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (b == 6) {
|
||||
Serial.println("Exiting packet monitor...");
|
||||
this->StartScan(WIFI_SCAN_OFF);
|
||||
//display_obj.tft.init();
|
||||
this->orient_display = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
y_pos_x = ((-num_beacon * (y_scale * 10)) + (HEIGHT_1 - 2)); // GREEN
|
||||
y_pos_y = ((-num_deauth * (y_scale * 10)) + (HEIGHT_1 - 2)); // RED
|
||||
y_pos_z = ((-num_probe * (y_scale * 10)) + (HEIGHT_1 - 2)); // BLUE
|
||||
|
||||
num_beacon = 0;
|
||||
num_probe = 0;
|
||||
num_deauth = 0;
|
||||
|
||||
//CODE FOR PLOTTING CONTINUOUS LINES!!!!!!!!!!!!
|
||||
//Plot "X" value
|
||||
display_obj.tft.drawLine(x_pos - x_scale, y_pos_x_old, x_pos, y_pos_x, TFT_GREEN);
|
||||
//Plot "Z" value
|
||||
display_obj.tft.drawLine(x_pos - x_scale, y_pos_z_old, x_pos, y_pos_z, TFT_BLUE);
|
||||
//Plot "Y" value
|
||||
display_obj.tft.drawLine(x_pos - x_scale, y_pos_y_old, x_pos, y_pos_y, TFT_RED);
|
||||
|
||||
//Draw preceding black 'boxes' to erase old plot lines, !!!WEIRD CODE TO COMPENSATE FOR BUTTONS AND COLOR KEY SO 'ERASER' DOESN'T ERASE BUTTONS AND COLOR KEY!!!
|
||||
//if ((x_pos <= 90) || ((x_pos >= 198) && (x_pos <= 320))) //above x axis
|
||||
if ((x_pos <= 90) || ((x_pos >= 117) && (x_pos <= 320))) //above x axis
|
||||
{
|
||||
display_obj.tft.fillRect(x_pos+1, 28, 10, 93, TFT_BLACK); //compensate for buttons!
|
||||
}
|
||||
else
|
||||
{
|
||||
display_obj.tft.fillRect(x_pos+1, 0, 10, 121, TFT_BLACK); //don't compensate for buttons!
|
||||
}
|
||||
//if ((x_pos >= 254) && (x_pos <= 320)) //below x axis
|
||||
//if (x_pos <= 90)
|
||||
if (x_pos < 0) // below x axis
|
||||
{
|
||||
//tft.fillRect(x_pos+1, 121, 10, 88, TFT_BLACK);
|
||||
display_obj.tft.fillRect(x_pos+1, 121, 10, 88, TFT_CYAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
//tft.fillRect(x_pos+1, 121, 10, 119, TFT_BLACK);
|
||||
display_obj.tft.fillRect(x_pos+1, 121, 10, 118, TFT_BLACK);
|
||||
}
|
||||
|
||||
//tftDisplayTime();
|
||||
|
||||
if ( (y_pos_x == 120) || (y_pos_y == 120) || (y_pos_z == 120) )
|
||||
{
|
||||
display_obj.tft.drawFastHLine(10, 120, 310, TFT_WHITE); // x axis
|
||||
}
|
||||
|
||||
y_pos_x_old = y_pos_x; //set old y pos values to current y pos values
|
||||
y_pos_y_old = y_pos_y;
|
||||
y_pos_z_old = y_pos_z;
|
||||
|
||||
//delay(50);
|
||||
|
||||
}
|
||||
|
||||
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); //erase XY buttons and any lines behind them
|
||||
//tft.fillRect(56, 0, 66, 32, TFT_ORANGE); //erase time and color key and any stray lines behind them
|
||||
display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // key
|
||||
|
||||
display_obj.tftDrawXScaleButtons(x_scale); //redraw stuff
|
||||
display_obj.tftDrawYScaleButtons(y_scale);
|
||||
display_obj.tftDrawChannelScaleButtons(set_channel);
|
||||
display_obj.tftDrawExitScaleButtons();
|
||||
display_obj.tftDrawColorKey();
|
||||
display_obj.tftDrawGraphObjects(x_scale);
|
||||
}
|
||||
|
||||
|
||||
//void WiFiScan::sniffer_callback(void* buf, wifi_promiscuous_pkt_type_t type) {
|
||||
// wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
|
||||
// showMetadata(snifferPacket, type);
|
||||
//}
|
||||
|
||||
void WiFiScan::changeChannel()
|
||||
{
|
||||
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Function to cycle to the next channel
|
||||
void WiFiScan::channelHop()
|
||||
{
|
||||
@@ -676,6 +968,10 @@ void WiFiScan::main(uint32_t currentTime)
|
||||
channelHop();
|
||||
}
|
||||
}
|
||||
else if (currentScanMode == WIFI_PACKET_MONITOR)
|
||||
{
|
||||
packetMonitorMain();
|
||||
}
|
||||
else if ((currentScanMode == WIFI_ATTACK_BEACON_SPAM))
|
||||
{
|
||||
// Need this for loop because getTouch causes ~10ms delay
|
||||
|
||||
Reference in New Issue
Block a user