Kaynağa Gözat

Show and clear client list

Just Call Me Koko 3 yıl önce
ebeveyn
işleme
52c44d69c2

+ 21 - 4
esp32_marauder/CommandLine.cpp

@@ -110,6 +110,7 @@ void CommandLine::runCommand(String input) {
     Serial.println(HELP_SETTINGS_CMD);
     Serial.println(HELP_CLEARAP_CMD_A);
     Serial.println(HELP_CLEARAP_CMD_B);
+    Serial.println(HELP_CLEARAP_CMD_C);
     Serial.println(HELP_REBOOT_CMD);
     Serial.println(HELP_UPDATE_CMD_A);
     Serial.println(HELP_UPDATE_CMD_B);
@@ -185,12 +186,28 @@ void CommandLine::runCommand(String input) {
   else if (cmd_args.get(0) == CLEARAP_CMD) {
     int ap_sw = this->argSearch(&cmd_args, "-a"); // APs
     int ss_sw = this->argSearch(&cmd_args, "-s"); // SSIDs
+    int cl_sw = this->argSearch(&cmd_args, "-c"); // Stations
 
-    if (ap_sw != -1)
+    if (ap_sw != -1) {
+      #ifdef HAS_SCREEN
+        menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu);
+      #endif
       wifi_scan_obj.RunClearAPs();
+    }
 
-    if (ss_sw != -1)
+    if (ss_sw != -1) {
+      #ifdef HAS_SCREEN
+        menu_function_obj.changeMenu(&menu_function_obj.clearSSIDsMenu);
+      #endif
       wifi_scan_obj.RunClearSSIDs();
+    }
+
+    if (cl_sw != -1) {
+      #ifdef HAS_SCREEN
+        menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu);
+      #endif
+      wifi_scan_obj.RunClearStations();
+    }
   }
 
   else if (cmd_args.get(0) == SETTINGS_CMD) {
@@ -536,12 +553,12 @@ void CommandLine::runCommand(String input) {
         for (int i = 0; i < access_points->get(x).stations->size(); i++) {
           wifi_scan_obj.getMAC(sta_mac, stations->get(access_points->get(x).stations->get(i)).mac, 0);
           if (stations->get(i).selected) {
-            Serial.print("  [" + (String)i + "] ");
+            Serial.print("  [" + (String)access_points->get(x).stations->get(i) + "] ");
             Serial.print(sta_mac);
             Serial.println(" (selected)");
           }
           else {
-            Serial.print("  [" + (String)i + "] ");
+            Serial.print("  [" + (String)access_points->get(x).stations->get(i) + "] ");
             Serial.println(sta_mac);
           }
         }

+ 1 - 0
esp32_marauder/CommandLine.h

@@ -72,6 +72,7 @@ const char PROGMEM HELP_HEAD[] = "============ Commands ============";
 const char PROGMEM HELP_CH_CMD[] = "channel [-s <channel>]";
 const char PROGMEM HELP_CLEARAP_CMD_A[] = "clearlist -a";
 const char PROGMEM HELP_CLEARAP_CMD_B[] = "clearlist -s";
+const char PROGMEM HELP_CLEARAP_CMD_C[] = "clearlist -c";
 const char PROGMEM HELP_REBOOT_CMD[] = "reboot";
 const char PROGMEM HELP_UPDATE_CMD_A[] = "update -s";
 const char PROGMEM HELP_UPDATE_CMD_B[] = "update -w";

+ 4 - 0
esp32_marauder/MenuFunctions.cpp

@@ -1666,6 +1666,10 @@ void MenuFunctions::RunSetup()
     changeMenu(&clearAPsMenu);
     wifi_scan_obj.RunClearAPs();
   });
+  addNodes(&wifiGeneralMenu, text_table1[60], TFT_BLUE, NULL, CLEAR_ICO, [this]() {
+    changeMenu(&clearAPsMenu);
+    wifi_scan_obj.RunClearStations();
+  });
   #ifndef MARAUDER_MINI
     // Select APs on OG
     addNodes(&wifiGeneralMenu, text_table1[56], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){

+ 2 - 2
esp32_marauder/MenuFunctions.h

@@ -167,8 +167,6 @@ class MenuFunctions
     Menu shutdownWiFiMenu;
     Menu shutdownBLEMenu;
     Menu generateSSIDsMenu;
-    Menu clearSSIDsMenu;
-    Menu clearAPsMenu;
 
     static void lv_tick_handler();
 
@@ -192,6 +190,8 @@ class MenuFunctions
     MenuFunctions();
 
     Menu* current_menu;
+    Menu clearSSIDsMenu;
+    Menu clearAPsMenu;
 
     Ticker tick;
 

+ 52 - 21
esp32_marauder/WiFiScan.cpp

@@ -149,6 +149,18 @@ void WiFiScan::RunSetup() {
   this->initWiFi(1);
 }
 
+int WiFiScan::clearStations() {
+  int num_cleared = stations->size();
+  stations->clear();
+  Serial.println("stations: " + (String)stations->size());
+
+  // Now clear stations list from APs
+  for (int i = 0; i < access_points->size(); i++)
+    access_points->get(i).stations->clear();
+    
+  return num_cleared;
+}
+
 int WiFiScan::clearAPs() {
   int num_cleared = access_points->size();
   access_points->clear();
@@ -600,6 +612,21 @@ void WiFiScan::RunAPScan(uint8_t scan_mode, uint16_t color)
   }
 #endif
 
+void WiFiScan::RunClearStations() {
+  #ifdef HAS_SCREEN
+    display_obj.tft.setTextWrap(false);
+    display_obj.tft.setFreeFont(NULL);
+    display_obj.tft.setCursor(0, 100);
+    display_obj.tft.setTextSize(1);
+    display_obj.tft.setTextColor(TFT_CYAN);
+  
+    display_obj.tft.println(F(text_table4[45]));
+    display_obj.tft.println(text_table4[46] + (String)this->clearStations());
+  #else
+    this->clearStations();
+  #endif
+}
+
 void WiFiScan::RunClearAPs() {
   #ifdef HAS_SCREEN
     display_obj.tft.setTextWrap(false);
@@ -610,8 +637,11 @@ void WiFiScan::RunClearAPs() {
   
     display_obj.tft.println(F(text_table4[9]));
     display_obj.tft.println(text_table4[10] + (String)this->clearAPs());
+    display_obj.tft.println(F(text_table4[45]));
+    display_obj.tft.println(text_table4[46] + (String)this->clearStations());
   #else
     this->clearAPs();
+    this->clearStations();
   #endif
 }
 
@@ -1119,7 +1149,7 @@ void WiFiScan::RunStationScan(uint8_t scan_mode, uint16_t color)
     display_obj.tft.setTextColor(TFT_WHITE, color);
     #ifndef MARAUDER_MINI
       display_obj.tft.fillRect(0,16,240,16, color);
-      display_obj.tft.drawCentreString(text_table1[58],120,16,2);
+      display_obj.tft.drawCentreString(text_table1[59],120,16,2);
       display_obj.touchToExit();
     #endif
     display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
@@ -1939,25 +1969,6 @@ void WiFiScan::stationSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t typ
     else
       frame_offset = 10;
   }
-  /*else {
-    // Check to make sure frame does not go to broadcast
-    char sta_addr[] = "00:00:00:00:00:00";
-    getMAC(dst_addr, snifferPacket->payload, 4);
-    if (strcmp(dst_addr, "ff:ff:ff:ff:ff:ff") == 0)
-      Serial.print("Frame destination is broadcast -> ");
-    if (ap_is_src) {
-      Serial.print("src: ");
-      getMAC(sta_addr, snifferPacket->payload, 4);
-    }
-    else {
-      Serial.print("dst: ");
-      getMAC(sta_addr, snifferPacket->payload, 10);
-    }
-    Serial.print(ap_addr);
-    Serial.print(" sta: ");
-    Serial.println(sta_addr);
-  }*/
-
   /*  Stuff to care about now
    *  ap_is_src
    *  ap_index
@@ -2020,6 +2031,25 @@ void WiFiScan::stationSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t typ
     Serial.print(" -> ap: ");
     Serial.println(ap_addr);
   }
+  display_string.concat(sta_addr);
+
+  int temp_len = display_string.length();
+
+  #ifdef HAS_SCREEN
+    for (int i = 0; i < 40 - temp_len; i++)
+    {
+      display_string.concat(" ");
+    }
+
+    Serial.print(" ");
+
+    if (display_obj.display_buffer->size() == 0)
+    {
+      display_obj.loading = true;
+      display_obj.display_buffer->add(display_string);
+      display_obj.loading = false;
+    }
+  #endif
 
   // Add station index to AP in list
   //access_points->get(ap_index).stations->add(stations->size() - 1);
@@ -2029,7 +2059,8 @@ void WiFiScan::stationSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t typ
 
   access_points->set(ap_index, ap);
 
-  //Serial.println(access_points->get(ap_index).essid + ": " + (String)access_points->get(ap_index).stations->size());
+  if (save_packet)
+    sd_obj.addPacket(snifferPacket->payload, len);
 }
 
 void WiFiScan::rawSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)

+ 2 - 0
esp32_marauder/WiFiScan.h

@@ -304,6 +304,7 @@ class WiFiScan
     void RunSetup();
     int clearSSIDs();
     int clearAPs();
+    int clearStations();
     bool addSSID(String essid);
     int generateSSIDs(int count = 20);
     bool shutdownWiFi();
@@ -321,6 +322,7 @@ class WiFiScan
     void RunGenerateSSIDs(int count = 20);
     void RunClearSSIDs();
     void RunClearAPs();
+    void RunClearStations();
     void channelHop();
     uint8_t currentScanMode = 0;
     void main(uint32_t currentTime);

+ 5 - 2
esp32_marauder/lang_var.h

@@ -98,6 +98,7 @@ PROGMEM const char text1_56[] = "Select APs";
 PROGMEM const char text1_57[] = "AP Clone Spam";
 PROGMEM const char text1_58[] = "Raw Capture";
 PROGMEM const char text1_59[] = "Station Sniff";
+PROGMEM const char text1_60[] = "Clear Stations";
 
 
 //SDInterface.cpp texts
@@ -171,12 +172,14 @@ PROGMEM const char text4_41[] = " Bluetooth Sniff ";
 PROGMEM const char text4_42[] = " Detect Card Skimmers ";
 PROGMEM const char text4_43[] = "Scanning for\nBluetooth-enabled skimmers\nHC-03, HC-05, and HC-06...";
 PROGMEM const char text4_44[] = " AP Scan ";
+PROGMEM const char text4_45[] = "Clearing Stations...";
+PROGMEM const char text4_46[] = "Stations Cleared: ";
 
 //Making tables
 PROGMEM const char *text_table0[] = {text0_0,text0_1, text0_2, text0_3, text0_4, text0_5, text0_6, text0_7, text0_8};
-PROGMEM const char *text_table1[] = {text1_0,text1_1,text1_2,text1_3,text1_4,text1_5,text1_6,text1_7,text1_8,text1_9,text1_10,text1_11,text1_12,text1_13,text1_14,text1_15,text1_16,text1_17,text1_18,text1_19,text1_20,text1_21,text1_22,text1_23,text1_24,text1_25,text1_26,text1_27,text1_28,text1_29,text1_30,text1_31,text1_32,text1_33,text1_34,text1_35,text1_36,text1_37,text1_38,text1_39,text1_40,text1_41,text1_42,text1_43,text1_44,text1_45,text1_46,text1_47,text1_48,text1_49,text1_50,text1_51,text1_52,text1_53,text1_54,text1_55,text1_56,text1_57,text1_58,text1_59};
+PROGMEM const char *text_table1[] = {text1_0,text1_1,text1_2,text1_3,text1_4,text1_5,text1_6,text1_7,text1_8,text1_9,text1_10,text1_11,text1_12,text1_13,text1_14,text1_15,text1_16,text1_17,text1_18,text1_19,text1_20,text1_21,text1_22,text1_23,text1_24,text1_25,text1_26,text1_27,text1_28,text1_29,text1_30,text1_31,text1_32,text1_33,text1_34,text1_35,text1_36,text1_37,text1_38,text1_39,text1_40,text1_41,text1_42,text1_43,text1_44,text1_45,text1_46,text1_47,text1_48,text1_49,text1_50,text1_51,text1_52,text1_53,text1_54,text1_55,text1_56,text1_57,text1_58,text1_59,text1_60};
 PROGMEM const char *text_table2[] = {text2_0,text2_1,text2_2,text2_3,text2_4,text2_5,text2_6,text2_7,text2_8,text2_9,text2_10,text2_11,text2_12,text2_13,text2_14};
 PROGMEM const char *text_table3[] = {text3_0,text3_1,text3_2,text3_3,text3_4,text3_5};
-PROGMEM const char *text_table4[] = {text4_0,text4_1,text4_2,text4_3,text4_4,text4_5,text4_6,text4_7,text1_54,text4_9,text4_10,text4_11,text4_12,text4_13,text4_14,text4_15,text4_16,text4_17,text4_18,text4_19,text4_20,text4_21,text4_22,text4_23,text4_24,text4_25,text4_26,text4_27,text4_28,text4_29,text4_30,text4_31,text4_32,text4_33,text4_34,text4_35,text4_36,text4_37,text4_38,text4_39,text4_40,text4_41,text4_42,text4_43,text4_44};
+PROGMEM const char *text_table4[] = {text4_0,text4_1,text4_2,text4_3,text4_4,text4_5,text4_6,text4_7,text1_54,text4_9,text4_10,text4_11,text4_12,text4_13,text4_14,text4_15,text4_16,text4_17,text4_18,text4_19,text4_20,text4_21,text4_22,text4_23,text4_24,text4_25,text4_26,text4_27,text4_28,text4_29,text4_30,text4_31,text4_32,text4_33,text4_34,text4_35,text4_36,text4_37,text4_38,text4_39,text4_40,text4_41,text4_42,text4_43,text4_44,text4_45,text4_46};
 
 #endif