Explorar o código

Add more cmd, clean serial, add ascii

Just Call Me Koko %!s(int64=3) %!d(string=hai) anos
pai
achega
ae8f8e870f

+ 60 - 3
esp32_marauder/CommandLine.cpp

@@ -4,6 +4,14 @@ CommandLine::CommandLine() {
 }
 
 void CommandLine::RunSetup() {
+  Serial.println(this->ascii_art);
+
+  Serial.println(F("\n\n--------------------------------\n"));
+  Serial.println(F("         ESP32 Marauder      \n"));
+  Serial.println("            " + version_number + "\n");
+  Serial.println(F("       By: justcallmekoko\n"));
+  Serial.println(F("--------------------------------\n\n"));
+  
   Serial.print("> ");
 }
 
@@ -26,12 +34,12 @@ void CommandLine::main(uint32_t currentTime) {
     Serial.print("> ");
 }
 
-LinkedList<String> CommandLine::parseCommand(String input) {
+LinkedList<String> CommandLine::parseCommand(String input, char* delim) {
   LinkedList<String> cmd_args;
   
   if (input != "") {
     
-    char delim[] = " ";
+    //char delim[] = " ";
 
     char fancy[input.length() + 1] = {};
     input.toCharArray(fancy, input.length() + 1);
@@ -70,7 +78,7 @@ void CommandLine::runCommand(String input) {
   else
     return;
 
-  LinkedList<String> cmd_args = this->parseCommand(input);
+  LinkedList<String> cmd_args = this->parseCommand(input, " ");
 
   //// Admin commands
 
@@ -103,6 +111,10 @@ void CommandLine::runCommand(String input) {
     wifi_scan_obj.RunClearAPs();
   }
 
+  else if (cmd_args.get(0) == REBOOT_CMD) {
+    ESP.restart();
+  }
+
   //// WiFi Scan commands
   if (!wifi_scan_obj.scanning()) {
 
@@ -135,4 +147,49 @@ void CommandLine::runCommand(String input) {
       wifi_scan_obj.StartScan(WIFI_SCAN_EAPOL, TFT_VIOLET);
     }
   }
+
+  //// WiFi aux commands
+
+  // List access points
+  if (cmd_args.get(0) == LIST_AP_CMD) {
+    for (int i = 0; i < access_points->size(); i++) {
+      if (access_points->get(i).selected)
+        Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " (selected)");
+      else
+        Serial.println("[" + (String)i + "] " + access_points->get(i).essid);
+    }
+  }
+  // Select access points or stations
+  else if (cmd_args.get(0) == SEL_CMD) {
+    // Get switches
+    int ap_sw = this->argSearch(&cmd_args, "-a");
+    int st_sw = this->argSearch(&cmd_args, "-s");
+
+    // Access points
+    if (ap_sw != -1) {
+      // Get list of indices
+      LinkedList<String> ap_index = this->parseCommand(cmd_args.get(ap_sw + 1), ",");
+
+      // Mark APs as selected
+      for (int i = 0; i < ap_index.size(); i++) {
+        int index = ap_index.get(i).toInt();
+        if (access_points->get(index).selected) {
+          // Unselect "selected" ap
+          AccessPoint new_ap = access_points->get(index);
+          new_ap.selected = false;
+          access_points->set(index, new_ap);
+        }
+        else {
+          // Select "unselected" ap
+          AccessPoint new_ap = access_points->get(index);
+          new_ap.selected = true;
+          access_points->set(index, new_ap);
+        }
+      }
+    }
+    // Stations
+    else if (st_sw != -1) {
+      
+    }
+  }
 }

+ 43 - 3
esp32_marauder/CommandLine.h

@@ -16,22 +16,62 @@
 #endif
 
 extern WiFiScan wifi_scan_obj;
+extern LinkedList<AccessPoint>* access_points;
+extern const String PROGMEM version_number;
 
-// Commands
+//// Commands
+
+// Admin
 const char PROGMEM CH_CMD[] = "channel";
+const char PROGMEM CLEARAP_CMD[] = "clearap";
+const char PROGMEM REBOOT_CMD[] = "reboot";
+
+// WiFi sniff/scan
 const char PROGMEM SCANAP_CMD[] = "scanap";
 const char PROGMEM SNIFF_BEACON_CMD[] = "sniffbeacon";
 const char PROGMEM SNIFF_DEAUTH_CMD[] = "sniffdeauth";
 const char PROGMEM SNIFF_PMKID_CMD[] = "sniffpmkid";
 const char PROGMEM STOPSCAN_CMD[] = "stopscan";
-const char PROGMEM CLEARAP_CMD[] = "clearap";
+
+// WiFi attack
+
+// WiFi Aux
+const char PROGMEM LIST_AP_CMD[] = "listap";
+const char PROGMEM SEL_CMD[] = "select";
 
 class CommandLine {
   private:
     String getSerialInput();
-    LinkedList<String> parseCommand(String input);
+    LinkedList<String> parseCommand(String input, char* delim);
     void runCommand(String input);
     int argSearch(LinkedList<String>* cmd_args, String key);
+
+    const char* ascii_art =
+    "\n"
+    "              @@@@@@                        \n"
+    "              @@@@@@@@                      \n"
+    "              @@@@@@@@@@@                   \n"
+    "             @@@@@@  @@@@@@                 \n"
+    "          @@@@@@@      @@@@@@@              \n"
+    "        @@@@@@            @@@@@@            \n"
+    "     @@@@@@@                @@@@@@@         \n"
+    "   @@@@@@                      @@@@@@       \n"
+    "@@@@@@@              @@@@@@@@@@@@@@@@       \n"
+    "@@@@@                 @@@@@@@@@@@@@@@       \n"
+    "@@@@@                   @@@@@@@             \n"
+    "@@@@@                      @@@@@@           \n"
+    "@@@@@@                       @@@@@@@        \n"
+    "  @@@@@@                        @@@@@@@@@@@@\n"
+    "    @@@@@@@                         (@@@@@@ \n"
+    "       @@@@@@                     @@@@@@.   \n"
+    "         @@@@@@@               #@@@@@@      \n"
+    "            @@@@@@           @@@@@@         \n"
+    "              @@@@@@@     #@@@@@@           \n"
+    "                 @@@@@@ @@@@@@,             \n"
+    "                   @@@@@@@@@                \n"
+    "                      @@@@@@                \n"
+    "                        @@@@                \n"
+    "\n";
         
   public:
     CommandLine();

+ 17 - 17
esp32_marauder/Display.cpp

@@ -24,10 +24,10 @@ void Display::RunSetup()
 
     #ifdef TFT_SHIELD
       uint16_t calData[5] = { 275, 3494, 361, 3528, 4 }; // tft.setRotation(0); // Portrait with TFT Shield
-      Serial.println(F("Using TFT Shield"));
+      //Serial.println(F("Using TFT Shield"));
     #else if defined(TFT_DIY)
       uint16_t calData[5] = { 339, 3470, 237, 3438, 2 }; // tft.setRotation(0); // Portrait with DIY TFT
-      Serial.println(F("Using TFT DIY"));
+      //Serial.println(F("Using TFT DIY"));
     #endif
     tft.setTouch(calData);
 
@@ -36,9 +36,9 @@ void Display::RunSetup()
   //tft.fillScreen(TFT_BLACK);
   clearScreen();
 
-  Serial.println("SPI_FREQUENCY: " + (String)SPI_FREQUENCY);
-  Serial.println("SPI_READ_FREQUENCY:" + (String)SPI_READ_FREQUENCY);
-  Serial.println("SPI_TOUCH_FREQUENCY: " + (String)SPI_TOUCH_FREQUENCY);
+  //Serial.println("SPI_FREQUENCY: " + (String)SPI_FREQUENCY);
+  //Serial.println("SPI_READ_FREQUENCY:" + (String)SPI_READ_FREQUENCY);
+  //Serial.println("SPI_TOUCH_FREQUENCY: " + (String)SPI_TOUCH_FREQUENCY);
 
   #ifdef KIT
     pinMode(KIT_LED_BUILTIN, OUTPUT);
@@ -247,7 +247,7 @@ void Display::touchToExit()
 // Function to just draw the screen black
 void Display::clearScreen()
 {
-  Serial.println(F("clearScreen()"));
+  //Serial.println(F("clearScreen()"));
   tft.fillScreen(TFT_BLACK);
   tft.setCursor(0, 0);
 }
@@ -289,7 +289,7 @@ void Display::showCenterText(String text, int y)
 
 void Display::initScrollValues(bool tte)
 {
-  Serial.println(F("initScrollValues()"));
+  //Serial.println(F("initScrollValues()"));
   yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
 
   xPos = 0;
@@ -345,10 +345,10 @@ int Display::scroll_line(uint32_t color) {
 
 // Function to setup hardware scroll for TFT screen
 void Display::setupScrollArea(uint16_t tfa, uint16_t bfa) {
-  Serial.println(F("setupScrollArea()"));
-  Serial.println("   tfa: " + (String)tfa);
-  Serial.println("   bfa: " + (String)bfa);
-  Serial.println("yStart: " + (String)this->yStart);
+  //Serial.println(F("setupScrollArea()"));
+  //Serial.println("   tfa: " + (String)tfa);
+  //Serial.println("   bfa: " + (String)bfa);
+  //Serial.println("yStart: " + (String)this->yStart);
   #ifndef MARAUDER_MINI
     tft.writecommand(ILI9341_VSCRDEF); // Vertical scroll definition
     tft.writedata(tfa >> 8);           // Top Fixed Area line count
@@ -399,9 +399,9 @@ void Display::drawJpeg(const char *filename, int xpos, int ypos) {
     // render the image onto the screen at given coordinates
     jpegRender(xpos, ypos);
   }
-  else {
-    Serial.println(F("Jpeg file format not supported!"));
-  }
+  //else {
+  //  Serial.println(F("Jpeg file format not supported!"));
+  //}
 }
 
 void Display::setupDraw() {
@@ -421,7 +421,7 @@ void Display::drawStylus()
   boolean pressed = tft.getTouch(&x, &y);
 
   if ((x <= 10) && (y <= 10) && (pressed)) {
-    Serial.println(F("Exit draw function"));
+    //Serial.println(F("Exit draw function"));
     this->draw_tft = false;
     this->exit_draw = true;
     return;
@@ -554,7 +554,7 @@ void Display::jpegRender(int xpos, int ypos) {
 //   Print information decoded from the Jpeg image
 //====================================================================================
 void Display::jpegInfo() {
-
+/*
   Serial.println("===============");
   Serial.println("JPEG image info");
   Serial.println("===============");
@@ -568,7 +568,7 @@ void Display::jpegInfo() {
   Serial.print  ("MCU height :"); Serial.println(JpegDec.MCUHeight);
   Serial.println("===============");
   Serial.println("");
-  
+  */
 }
 
 //====================================================================================

+ 1 - 1
esp32_marauder/LedInterface.cpp

@@ -5,7 +5,7 @@ LedInterface::LedInterface() {
 }
 
 void LedInterface::RunSetup() {
-  Serial.println("Setting neopixel to black...");
+  //Serial.println("Setting neopixel to black...");
   strip.setBrightness(0);
   strip.begin();
   strip.setPixelColor(0, strip.Color(0, 0, 0));

+ 7 - 11
esp32_marauder/MenuFunctions.cpp

@@ -879,7 +879,7 @@ void MenuFunctions::main(uint32_t currentTime)
           (wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
           (wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS))
       {
-        Serial.println("Stopping scan...");
+        //Serial.println("Stopping scan...");
         wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
   
         // If we don't do this, the text and button coordinates will be off
@@ -923,7 +923,7 @@ void MenuFunctions::main(uint32_t currentTime)
           (wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
           (wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS))
       {
-        Serial.println("Stopping scan...");
+        //Serial.println("Stopping scan...");
         wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
   
         // If we don't do this, the text and button coordinates will be off
@@ -1014,7 +1014,6 @@ void MenuFunctions::main(uint32_t currentTime)
         current_menu->selected--;
         this->buttonSelected(current_menu->selected);
         this->buttonNotSelected(current_menu->selected + 1);
-        Serial.println("Current menu index: " + (String)current_menu->selected);
       }
     }
     if (d_btn.justPressed()){
@@ -1022,11 +1021,9 @@ void MenuFunctions::main(uint32_t currentTime)
         current_menu->selected++;
         this->buttonSelected(current_menu->selected);
         this->buttonNotSelected(current_menu->selected - 1);
-        Serial.println("Current menu index: " + (String)current_menu->selected);
       }
     }
     if(c_btn_press){
-      Serial.println("CENTER");
       current_menu->list->get(current_menu->selected).callable();
     }
 
@@ -1309,7 +1306,6 @@ void MenuFunctions::drawStatusBar()
 
 void MenuFunctions::orientDisplay()
 {
-  Serial.println(F("orientDisplay()"));
   display_obj.tft.init();
 
   display_obj.tft.setRotation(0); // Portrait
@@ -1319,10 +1315,10 @@ void MenuFunctions::orientDisplay()
   #ifndef MARAUDER_MINI
     #ifdef TFT_SHIELD
       uint16_t calData[5] = { 275, 3494, 361, 3528, 4 }; // tft.setRotation(0); // Portrait with TFT Shield
-      Serial.println("Using TFT Shield");
+      //Serial.println("Using TFT Shield");
     #else if defined(TFT_DIY)
       uint16_t calData[5] = { 339, 3470, 237, 3438, 2 }; // tft.setRotation(0); // Portrait with DIY TFT
-      Serial.println("Using TFT DIY");
+      //Serial.println("Using TFT DIY");
     #endif
 
     display_obj.tft.setTouch(calData);
@@ -1332,7 +1328,7 @@ void MenuFunctions::orientDisplay()
 }
 
 void MenuFunctions::runBoolSetting(String key) {
-  Serial.println("Building bool setting screen...");
+  //Serial.println("Building bool setting screen...");
   display_obj.tftDrawRedOnOffButton();
   //display_obj.tftDrawGreenOnOffButton();
 }
@@ -1884,7 +1880,7 @@ void MenuFunctions::addNodes(Menu * menu, String name, uint16_t color, Menu * ch
 
 void MenuFunctions::buildButtons(Menu * menu)
 {
-  Serial.println("Bulding buttons...");
+  //Serial.println("Bulding buttons...");
   if (menu->list != NULL)
   {
     //for (int i = 0; i < sizeof(key); i++)
@@ -1913,7 +1909,7 @@ void MenuFunctions::buildButtons(Menu * menu)
 
 void MenuFunctions::displayCurrentMenu()
 {
-  Serial.println(F("Displaying current menu..."));
+  //Serial.println(F("Displaying current menu..."));
   display_obj.clearScreen();
   display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY);
   this->drawStatusBar();

+ 9 - 9
esp32_marauder/SDInterface.cpp

@@ -24,18 +24,18 @@ bool SDInterface::initSD() {
   else {
     this->supported = true;
     this->cardType = SD.cardType();
-    if (cardType == CARD_MMC)
-      Serial.println(F("SD: MMC Mounted"));
-    else if(cardType == CARD_SD)
-        Serial.println(F("SD: SDSC Mounted"));
-    else if(cardType == CARD_SDHC)
-        Serial.println(F("SD: SDHC Mounted"));
-    else
-        Serial.println(F("SD: UNKNOWN Card Mounted"));
+    //if (cardType == CARD_MMC)
+    //  Serial.println(F("SD: MMC Mounted"));
+    //else if(cardType == CARD_SD)
+    //    Serial.println(F("SD: SDSC Mounted"));
+    //else if(cardType == CARD_SDHC)
+    //    Serial.println(F("SD: SDHC Mounted"));
+    //else
+    //    Serial.println(F("SD: UNKNOWN Card Mounted"));
 
     this->cardSizeMB = SD.cardSize() / (1024 * 1024);
     
-    Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB);
+    //Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB);
 
     if (this->supported) {
       const int NUM_DIGITS = log10(this->cardSizeMB) + 1;

+ 5 - 5
esp32_marauder/WiFiScan.cpp

@@ -250,13 +250,13 @@ int WiFiScan::generateSSIDs() {
 void WiFiScan::initWiFi(uint8_t scan_mode) {
   // Set the channel
   if (scan_mode != WIFI_SCAN_OFF) {
-    Serial.println(F("Initializing WiFi settings..."));
+    //Serial.println(F("Initializing WiFi settings..."));
     this->changeChannel();
   
     this->force_pmkid = settings_obj.loadSetting<bool>(text_table4[5]);
     this->force_probe = settings_obj.loadSetting<bool>(text_table4[6]);
     this->save_pcap = settings_obj.loadSetting<bool>(text_table4[7]);
-    Serial.println(F("Initialization complete"));
+    //Serial.println(F("Initialization complete"));
   }
 }
 
@@ -424,7 +424,7 @@ void WiFiScan::StopScan(uint8_t scan_mode)
 
   #ifdef HAS_SCREEN
     display_obj.display_buffer->clear();
-    Serial.print("display_buffer->size(): ");
+    //Serial.print("display_buffer->size(): ");
     Serial.println(display_obj.display_buffer->size());
   
     display_obj.tteBar = false;
@@ -808,10 +808,10 @@ void WiFiScan::RunEapolScan(uint8_t scan_mode, uint16_t color)
   #ifdef HAS_SCREEN
     #ifdef TFT_SHIELD
       uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield
-      Serial.println("Using 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");
+      //Serial.println("Using TFT DIY");
     #endif
     display_obj.tft.setTouch(calData);
   

+ 2 - 2
esp32_marauder/configs.h

@@ -4,8 +4,8 @@
 
   #define POLISH_POTATO
   
-  //#define MARAUDER_MINI
-  #define MARAUDER_V4
+  #define MARAUDER_MINI
+  //#define MARAUDER_V4
   //#define MARAUDER_V6
   //#define MARAUDER_KIT
   //#define GENERIC_ESP32

+ 29 - 43
esp32_marauder/esp32_marauder.ino

@@ -124,15 +124,15 @@ void setup()
   
   //Serial.begin(115200);
 
-  Serial.println("\n\nHello, World!\n");
+  //Serial.println("\n\nHello, World!\n");
 
   Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
 
-  #ifdef HAS_SCREEN
-    Serial.println("Has Screen");
-  #else
-    Serial.println("Does not have screen");
-  #endif
+  //#ifdef HAS_SCREEN
+  //  Serial.println("Has Screen");
+  //#else
+  //  Serial.println("Does not have screen");
+  //#endif
 
   #ifdef HAS_SCREEN
     display_obj.RunSetup();
@@ -159,9 +159,9 @@ void setup()
 
   backlightOn(); // Need this
 
-  delay(2000);
-
   #ifdef HAS_SCREEN
+    delay(2000);
+
     display_obj.clearScreen();
   
     display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
@@ -174,26 +174,20 @@ void setup()
   
     display_obj.tft.println(text_table0[1]);
   #endif
-  
-  Serial.println(F("\n\n--------------------------------\n"));
-  Serial.println(F("         ESP32 Marauder      \n"));
-  Serial.println("            " + version_number + "\n");
-  Serial.println(F("       By: justcallmekoko\n"));
-  Serial.println(F("--------------------------------\n\n"));
 
   //Serial.println("Internal Temp: " + (String)((temprature_sens_read() - 32) / 1.8));
 
   settings_obj.begin();
 
-  Serial.println("This is a test Channel: " + (String)settings_obj.loadSetting<uint8_t>("Channel"));
-  if (settings_obj.loadSetting<bool>( "Force PMKID"))
-    Serial.println("This is a test Force PMKID: true");
-  else
-    Serial.println("This is a test Force PMKID: false");
+  //Serial.println("This is a test Channel: " + (String)settings_obj.loadSetting<uint8_t>("Channel"));
+  //if (settings_obj.loadSetting<bool>( "Force PMKID"))
+  //  Serial.println("This is a test Force PMKID: true");
+  //else
+  //  Serial.println("This is a test Force PMKID: false");
 
   wifi_scan_obj.RunSetup();
 
-  Serial.println(wifi_scan_obj.freeRAM());
+  //Serial.println(wifi_scan_obj.freeRAM());
 
   #ifdef HAS_SCREEN
     display_obj.tft.println(F(text_table0[2]));
@@ -201,7 +195,7 @@ void setup()
 
   // Do some SD stuff
   if(sd_obj.initSD()) {
-    Serial.println(F("SD Card supported"));
+    //Serial.println(F("SD Card supported"));
     #ifdef HAS_SCREEN
       display_obj.tft.println(F(text_table0[3]));
     #endif
@@ -215,14 +209,6 @@ void setup()
     #endif
   }
 
-  // Run display setup
-  Serial.println(wifi_scan_obj.freeRAM());
-
-  // Build menus
-  Serial.println(wifi_scan_obj.freeRAM());
-
-  // Battery stuff
-  Serial.println(wifi_scan_obj.freeRAM());
   battery_obj.RunSetup();
 
   #ifdef HAS_SCREEN
@@ -230,7 +216,6 @@ void setup()
   #endif
 
   // Temperature stuff
-  Serial.println(wifi_scan_obj.freeRAM());
   #ifndef MARAUDER_FLIPPER
     temp_obj.RunSetup();
   #endif
@@ -239,31 +224,26 @@ void setup()
     display_obj.tft.println(F(text_table0[6]));
   #endif
 
-  Serial.println("Bat lvl");
-
   #ifndef MARAUDER_FLIPPER
     battery_obj.battery_level = battery_obj.getBatteryLevel();
   
-    if (battery_obj.i2c_supported) {
-      Serial.println(F("IP5306 I2C Supported: true"));
-    }
-    else
-      Serial.println(F("IP5306 I2C Supported: false"));
+//    if (battery_obj.i2c_supported) {
+//      Serial.println(F("IP5306 I2C Supported: true"));
+//    }
+//    else
+//      Serial.println(F("IP5306 I2C Supported: false"));
   #endif
 
-  Serial.println(wifi_scan_obj.freeRAM());
-
   // Do some LED stuff
   #ifndef MARAUDER_FLIPPER
-    Serial.println("LED");
     led_obj.RunSetup();
   #endif
 
   #ifdef HAS_SCREEN
     display_obj.tft.println(F(text_table0[7]));
-  #endif
 
-  delay(500);
+    delay(500);
+  #endif
 
   #ifdef HAS_SCREEN
     display_obj.tft.println(F(text_table0[8]));
@@ -277,7 +257,13 @@ void setup()
     menu_function_obj.RunSetup();
   #endif
 
-  Serial.println("CLI");
+  //Serial.println(F("\n\n--------------------------------\n"));
+  //Serial.println(F("         ESP32 Marauder      \n"));
+  //Serial.println("            " + version_number + "\n");
+  //Serial.println(F("       By: justcallmekoko\n"));
+  //Serial.println(F("--------------------------------\n\n"));
+  
+  Serial.println("CLI Ready");
   cli_obj.RunSetup();
 }
 

+ 2 - 2
esp32_marauder/settings.cpp

@@ -38,8 +38,8 @@ bool Settings::begin() {
   DynamicJsonDocument jsonBuffer(1024);
   DeserializationError error = deserializeJson(jsonBuffer, settingsFile);
   serializeJson(jsonBuffer, json_string);
-  Serial.println("Settings: " + (String)json_string + "\n");
-  this->printJsonSettings(json_string);
+  //Serial.println("Settings: " + (String)json_string + "\n");
+  //this->printJsonSettings(json_string);
 
   this->json_settings_string = json_string;