Revert Changes

This commit is contained in:
Just Call Me Koko
2020-03-21 20:20:52 -04:00
parent ca4048983f
commit 96957a2cc1
12 changed files with 40 additions and 421 deletions

View File

@@ -6,7 +6,6 @@
int num_beacon = 0;
int num_deauth = 0;
int num_probe = 0;
int num_eapol = 0;
class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
@@ -128,8 +127,6 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
StopScan(scan_mode);
else if (scan_mode == WIFI_SCAN_PROBE)
RunProbeScan(scan_mode, color);
else if (scan_mode == WIFI_SCAN_EAPOL)
RunEapolScan(scan_mode, color);
else if (scan_mode == WIFI_SCAN_AP)
RunBeaconScan(scan_mode, color);
else if (scan_mode == WIFI_SCAN_DEAUTH)
@@ -153,7 +150,7 @@ void WiFiScan::StopScan(uint8_t scan_mode)
{
if ((currentScanMode == WIFI_SCAN_PROBE) ||
(currentScanMode == WIFI_SCAN_AP) ||
(currentScanMode == WIFI_SCAN_EAPOL) ||
(currentScanMode == WIFI_SCAN_ST) ||
(currentScanMode == WIFI_SCAN_ALL) ||
(currentScanMode == WIFI_SCAN_DEAUTH) ||
(currentScanMode == WIFI_ATTACK_BEACON_SPAM) ||
@@ -163,10 +160,6 @@ void WiFiScan::StopScan(uint8_t scan_mode)
Serial.println("Ahhh yes...promiscuity will end");
esp_wifi_set_promiscuous(false);
WiFi.mode(WIFI_OFF);
esp_wifi_set_mode(WIFI_MODE_NULL);
esp_wifi_stop();
esp_wifi_deinit();
}
else if ((currentScanMode == BT_SCAN_ALL) ||
(currentScanMode == BT_SCAN_SKIMMERS))
@@ -282,6 +275,7 @@ void WiFiScan::RunInfo()
}
else {
display_obj.tft.println(" SD Card: Not Connected");
<<<<<<< HEAD
display_obj.tft.println("SD Card Size: 0");
}
/*
@@ -293,6 +287,10 @@ void WiFiScan::RunInfo()
else
display_obj.tft.println(" IP5306 I2C: not supported");
*/
=======
display_obj.tft.print("SD Card Size: 0");
}
>>>>>>> parent of 40e11b7... Capture EAPOL packets
}
@@ -456,51 +454,6 @@ void WiFiScan::RunDeauthScan(uint8_t scan_mode, uint16_t color)
initTime = millis();
}
void WiFiScan::RunEapolScan(uint8_t scan_mode, uint16_t color)
{
display_obj.tft.init();
display_obj.tft.setRotation(1);
display_obj.tft.fillScreen(TFT_BLACK);
sd_obj.openCapture("eapol");
#ifdef TFT_SHIELD
uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield
Serial.println("Using TFT Shield");
#else if defined(TFT_DIY)
uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY
Serial.println("Using TFT DIY");
#endif
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.tftDrawEapolColorKey();
//display_obj.tftDrawXScaleButtons(x_scale);
//display_obj.tftDrawYScaleButtons(y_scale);
display_obj.tftDrawChannelScaleButtons(set_channel);
display_obj.tftDrawExitScaleButtons();
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_start();
esp_wifi_set_promiscuous(true);
esp_wifi_set_promiscuous_filter(&filt);
esp_wifi_set_promiscuous_rx_cb(&eapolSnifferCallback);
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
initTime = millis();
}
// Function for running probe request scan
void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
@@ -905,102 +858,6 @@ void WiFiScan::broadcastRandomSSID(uint32_t currentTime) {
//Serial.println("Sent packets");
}
void WiFiScan::eapolSnifferCallback(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;
String display_string = "";
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 (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) )){
delay(random(0, 10));
Serial.print((String)random(0, 5) + "EAPOL: ");
char srcaddr[] = "00:00:00:00:00:00";
getMAC(srcaddr, snifferPacket->payload, 10);
Serial.print(srcaddr);
display_string.concat(srcaddr);
Serial.print(" -> ");
display_string.concat(" -> ");
char desaddr[] = "00:00:00:00:00:00";
getMAC(desaddr, snifferPacket->payload, 4);
Serial.print(desaddr);
display_string.concat(desaddr);
// Print spaces because of the rotating lines of the hardware scroll.
// The same characters print from previous lines so I just overwrite them
// with spaces.
for (int i = 0; i < 19 - snifferPacket->payload[37]; i++)
{
display_string.concat(" ");
}
if (display_obj.display_buffer->size() == 0)
{
//while (display_obj.printing)
// delay(1);
display_obj.loading = true;
display_obj.display_buffer->add(display_string);
display_obj.loading = false;
}
Serial.println();
sd_obj.addPacket(snifferPacket->payload, len);
}
*/
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)
{
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
/*
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++;
}
*/
//sd_obj.addPacket(snifferPacket->payload, len);
if (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) ))
Serial.println("Oh god mgmt EAPOL");
}
if (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) )){
Serial.println("EAPOL!!");
sd_obj.addPacket(snifferPacket->payload, len);
num_eapol++;
}
}
void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
{
@@ -1031,19 +888,14 @@ void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
}
sd_obj.addPacket(snifferPacket->payload, len);
if (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) ))
Serial.println("Oh god mgmt EAPOL");
}
if (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) )){
Serial.println("EAPOL!!");
//sd_obj.addPacket(snifferPacket->payload, len);
}
}
void WiFiScan::packetMonitorMain(uint32_t currentTime)
{
//---------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
for (x_pos = (11 + x_scale); x_pos <= 320; x_pos = x_pos)
{
@@ -1268,237 +1120,6 @@ void WiFiScan::packetMonitorMain(uint32_t currentTime)
display_obj.tftDrawGraphObjects(x_scale);
}
void WiFiScan::eapolMonitorMain(uint32_t currentTime)
{
//---------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
for (x_pos = (11 + x_scale); x_pos <= 320; x_pos = x_pos)
{
currentTime = millis();
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 < 9) {
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 (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;
}
}
}
if (currentTime - initTime >= (GRAPH_REFRESH * 5)) {
//Serial.println("-----------------------------------------");
//Serial.println("Time elapsed: " + (String)(currentTime - initTime) + "ms");
x_pos += x_scale;
initTime = millis();
y_pos_x = ((-num_eapol * (y_scale * 3)) + (HEIGHT_1 - 2)); // GREEN
//y_pos_y = ((-num_deauth * (y_scale * 3)) + (HEIGHT_1 - 2)); // RED
//y_pos_z = ((-num_probe * (y_scale * 3)) + (HEIGHT_1 - 2)); // BLUE
//Serial.println("num_beacon: " + (String)num_beacon);
//Serial.println("num_deauth: " + (String)num_deauth);
//Serial.println(" num_probe: " + (String)num_probe);
//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_CYAN);
//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);
}
sd_obj.main();
}
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.tftDrawEapolColorKey();
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;
@@ -1529,6 +1150,7 @@ void WiFiScan::main(uint32_t currentTime)
// WiFi operations
if ((currentScanMode == WIFI_SCAN_PROBE) ||
(currentScanMode == WIFI_SCAN_AP) ||
(currentScanMode == WIFI_SCAN_ST) ||
(currentScanMode == WIFI_SCAN_DEAUTH) ||
(currentScanMode == WIFI_SCAN_ALL))
{
@@ -1542,10 +1164,6 @@ void WiFiScan::main(uint32_t currentTime)
{
packetMonitorMain(currentTime);
}
else if (currentScanMode == WIFI_SCAN_EAPOL)
{
eapolMonitorMain(currentTime);
}
else if ((currentScanMode == WIFI_ATTACK_BEACON_SPAM))
{
// Need this for loop because getTouch causes ~10ms delay