MenuFunctions.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. #include "MenuFunctions.h"
  2. //#include "icons.h"
  3. PROGMEM const unsigned char menu_icons[][66] = {
  4. {0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x37, 0xFF, 0xFF, 0x3A, // Attack: 0
  5. 0xFF, 0xFF, 0x39, 0xFF, 0xBF, 0x3C, 0xFF, 0x7F, 0x3E, 0xFF, 0x2F, 0x3F,
  6. 0xFF, 0x9F, 0x3F, 0xFF, 0xCB, 0x3F, 0xFF, 0xE7, 0x3F, 0xCF, 0xF2, 0x3F,
  7. 0xDF, 0xF9, 0x3F, 0xBF, 0xFC, 0x3F, 0x3F, 0xFF, 0x3F, 0x7F, 0xFE, 0x3F,
  8. 0xDF, 0xF9, 0x3F, 0xCF, 0xFB, 0x3F, 0xE7, 0xFF, 0x3F, 0xF3, 0xFF, 0x3F,
  9. 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F},
  10. {0xBF, 0xDD, 0x3E, 0xDF, 0xBE, 0x3D, 0x5F, 0x6B, 0x3D, 0x5F, 0x5D, 0x3D, // Beacon sniff: 1
  11. 0x5F, 0x55, 0x3D, 0xFF, 0xF7, 0x3F, 0x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x7F, 0xDB, 0x3F, 0xFF, 0xEA, 0x3F, 0xFF, 0xF1, 0x3F,
  99. 0xFF, 0xFB, 0x3F, 0xFF, 0xFF, 0x3F},
  100. {0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0xE0, 0x3F, 0x3F, 0x80, 0x3F, // Update: 16
  101. 0x1F, 0x00, 0x3F, 0x0F, 0x00, 0x3E, 0x07, 0x00, 0x3C, 0x07, 0x08, 0x3C,
  102. 0x03, 0x18, 0x38, 0x03, 0x38, 0x38, 0xC3, 0x7F, 0x38, 0xC3, 0x7F, 0x38,
  103. 0x03, 0x38, 0x38, 0x03, 0x18, 0x38, 0x07, 0x08, 0x3C, 0x07, 0x00, 0x3C,
  104. 0x0F, 0x00, 0x3E, 0x1F, 0x00, 0x3F, 0x3F, 0x80, 0x3F, 0xFF, 0xE0, 0x3F,
  105. 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F}};
  106. MenuFunctions::MenuFunctions()
  107. {
  108. }
  109. // Function to check menu input
  110. void MenuFunctions::main()
  111. {
  112. if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
  113. (wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
  114. if (wifi_scan_obj.orient_display) {
  115. this->orientDisplay();
  116. wifi_scan_obj.orient_display = false;
  117. }
  118. display_obj.updateBanner(current_menu->name);
  119. }
  120. //this->displayCurrentMenu();
  121. boolean pressed = false;
  122. // This is code from bodmer's keypad example
  123. uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
  124. // Get the display buffer out of the way
  125. if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF ) &&
  126. (wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM) &&
  127. (wifi_scan_obj.currentScanMode != WIFI_ATTACK_RICK_ROLL))
  128. display_obj.displayBuffer();
  129. // Pressed will be set true is there is a valid touch on the screen
  130. int pre_getTouch = millis();
  131. // getTouch causes a 10ms delay which makes beacon spam less effective
  132. //if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF)
  133. pressed = display_obj.tft.getTouch(&t_x, &t_y);
  134. //if (pressed)
  135. // Serial.println("Pressed, son");
  136. //boolean pressed = false;
  137. //Serial.print("getTouch: ");
  138. //Serial.print(millis() - pre_getTouch);
  139. //Serial.println("ms");
  140. // This is if there are scans/attacks going on
  141. if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF) && (pressed) && (wifi_scan_obj.currentScanMode != OTA_UPDATE))
  142. {
  143. // Stop the current scan
  144. if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
  145. (wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
  146. (wifi_scan_obj.currentScanMode == WIFI_SCAN_ST) ||
  147. (wifi_scan_obj.currentScanMode == WIFI_SCAN_ALL) ||
  148. (wifi_scan_obj.currentScanMode == WIFI_SCAN_DEAUTH) ||
  149. (wifi_scan_obj.currentScanMode == WIFI_ATTACK_BEACON_SPAM) ||
  150. (wifi_scan_obj.currentScanMode == WIFI_ATTACK_RICK_ROLL) ||
  151. (wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
  152. (wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS))
  153. {
  154. Serial.println("Stopping scan...");
  155. wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
  156. // If we don't do this, the text and button coordinates will be off
  157. display_obj.tft.init();
  158. // Take us back to the menu
  159. changeMenu(current_menu);
  160. }
  161. x = -1;
  162. y = -1;
  163. return;
  164. }
  165. // Check if any key coordinate boxes contain the touch coordinates
  166. // This is for when on a menu
  167. if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM) &&
  168. (wifi_scan_obj.currentScanMode != WIFI_ATTACK_RICK_ROLL))
  169. {
  170. // Need this to set all keys to false
  171. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++) {
  172. if (pressed && display_obj.key[b].contains(t_x, t_y)) {
  173. display_obj.key[b].press(true); // tell the button it is pressed
  174. } else {
  175. display_obj.key[b].press(false); // tell the button it is NOT pressed
  176. }
  177. }
  178. // Check if any key has changed state
  179. for (uint8_t b = 0; b < current_menu->list->size(); b++) {
  180. display_obj.tft.setFreeFont(MENU_FONT);
  181. if (display_obj.key[b].justPressed()) {
  182. //display_obj.key[b].drawButton2(current_menu->list->get(b).name, true); // draw invert
  183. display_obj.key[b].drawButton(ML_DATUM, BUTTON_PADDING, current_menu->list->get(b).name, true);
  184. }
  185. // If button was just release, execute the button's function
  186. if (display_obj.key[b].justReleased())
  187. {
  188. //display_obj.key[b].drawButton2(current_menu->list->get(b).name); // draw normal
  189. display_obj.key[b].drawButton(ML_DATUM, BUTTON_PADDING, current_menu->list->get(b).name);
  190. current_menu->list->get(b).callable();
  191. }
  192. display_obj.tft.setFreeFont(NULL);
  193. }
  194. }
  195. x = -1;
  196. y = -1;
  197. }
  198. void MenuFunctions::orientDisplay()
  199. {
  200. display_obj.tft.init();
  201. display_obj.tft.setRotation(0); // Portrait
  202. display_obj.tft.setCursor(0, 0);
  203. uint16_t calData[5] = { 275, 3494, 361, 3528, 4 }; // tft.setRotation(0); // Portrait
  204. display_obj.tft.setTouch(calData);
  205. //display_obj.clearScreen();
  206. changeMenu(current_menu);
  207. }
  208. // Function to build the menus
  209. void MenuFunctions::RunSetup()
  210. {
  211. // root menu stuff
  212. mainMenu.list = new SimpleList<MenuNode>(); // Get list in first menu ready
  213. // Main menu stuff
  214. wifiMenu.list = new SimpleList<MenuNode>(); // Get list in second menu ready
  215. bluetoothMenu.list = new SimpleList<MenuNode>(); // Get list in third menu ready
  216. generalMenu.list = new SimpleList<MenuNode>();
  217. updateMenu.list = new SimpleList<MenuNode>();
  218. // WiFi menu stuff
  219. wifiSnifferMenu.list = new SimpleList<MenuNode>();
  220. wifiScannerMenu.list = new SimpleList<MenuNode>();
  221. wifiAttackMenu.list = new SimpleList<MenuNode>();
  222. // Bluetooth menu stuff
  223. bluetoothSnifferMenu.list = new SimpleList<MenuNode>();
  224. bluetoothScannerMenu.list = new SimpleList<MenuNode>();
  225. // Work menu names
  226. mainMenu.name = " ESP32 Marauder ";
  227. wifiMenu.name = " WiFi ";
  228. generalMenu.name = " General Apps ";
  229. updateMenu.name = " Update Firmware ";
  230. bluetoothMenu.name = " Bluetooth ";
  231. wifiSnifferMenu.name = " WiFi Sniffers ";
  232. wifiScannerMenu.name = " WiFi Scanners";
  233. wifiAttackMenu.name = " WiFi Attacks ";
  234. bluetoothSnifferMenu.name = " Bluetooth Sniffers ";
  235. bluetoothScannerMenu.name = " Bluetooth Scanners ";
  236. // Build Main Menu
  237. mainMenu.parentMenu = NULL;
  238. addNodes(&mainMenu, "WiFi", TFT_GREEN, NULL, WIFI, [this](){changeMenu(&wifiMenu);});
  239. addNodes(&mainMenu, "Bluetooth", TFT_CYAN, NULL, BLUETOOTH, [this](){changeMenu(&bluetoothMenu);});
  240. addNodes(&mainMenu, "General Apps", TFT_MAGENTA, NULL, GENERAL_APPS, [this](){changeMenu(&generalMenu);});
  241. addNodes(&mainMenu, "Update Firmware", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
  242. addNodes(&mainMenu, "Reboot", TFT_LIGHTGREY, NULL, REBOOT, [](){ESP.restart();});
  243. // Build WiFi Menu
  244. wifiMenu.parentMenu = &mainMenu; // Main Menu is second menu parent
  245. addNodes(&wifiMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(wifiMenu.parentMenu);});
  246. addNodes(&wifiMenu, "Sniffers", TFT_YELLOW, NULL, SNIFFERS, [this](){changeMenu(&wifiSnifferMenu);});
  247. addNodes(&wifiMenu, "Scanners", TFT_ORANGE, NULL, SCANNERS, [this](){changeMenu(&wifiScannerMenu);});
  248. addNodes(&wifiMenu, "Attacks", TFT_RED, NULL, ATTACKS, [this](){changeMenu(&wifiAttackMenu);});
  249. // Build WiFi sniffer Menu
  250. wifiSnifferMenu.parentMenu = &wifiMenu; // Main Menu is second menu parent
  251. addNodes(&wifiSnifferMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(wifiSnifferMenu.parentMenu);});
  252. addNodes(&wifiSnifferMenu, "Probe Request Sniff", TFT_CYAN, NULL, PROBE_SNIFF, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_PROBE, TFT_CYAN);});
  253. addNodes(&wifiSnifferMenu, "Beacon Sniff", TFT_MAGENTA, NULL, BEACON_SNIFF, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_AP, TFT_MAGENTA);});
  254. addNodes(&wifiSnifferMenu, "Deauth Sniff", TFT_RED, NULL, DEAUTH_SNIFF, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_DEAUTH, TFT_RED);});
  255. // Build WiFi scanner Menu
  256. wifiScannerMenu.parentMenu = &wifiMenu; // Main Menu is second menu parent
  257. addNodes(&wifiScannerMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(wifiScannerMenu.parentMenu);});
  258. addNodes(&wifiScannerMenu, "Packet Monitor", TFT_BLUE, NULL, PACKET_MONITOR, [this](){wifi_scan_obj.StartScan(WIFI_PACKET_MONITOR, TFT_BLUE);});
  259. // Build WiFi attack menu
  260. wifiAttackMenu.parentMenu = &wifiMenu; // Main Menu is second menu parent
  261. addNodes(&wifiAttackMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(wifiAttackMenu.parentMenu);});
  262. addNodes(&wifiAttackMenu, "Beacon Spam Random", TFT_ORANGE, NULL, BEACON_SPAM, [this](){wifi_scan_obj.StartScan(WIFI_ATTACK_BEACON_SPAM, TFT_ORANGE);});
  263. addNodes(&wifiAttackMenu, "Rick Roll Beacon", TFT_YELLOW, NULL, RICK_ROLL, [this](){wifi_scan_obj.StartScan(WIFI_ATTACK_RICK_ROLL, TFT_YELLOW);});
  264. // Build Bluetooth Menu
  265. bluetoothMenu.parentMenu = &mainMenu; // Second Menu is third menu parent
  266. addNodes(&bluetoothMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(bluetoothMenu.parentMenu);});
  267. addNodes(&bluetoothMenu, "Sniffers", TFT_YELLOW, NULL, SNIFFERS, [this](){changeMenu(&bluetoothSnifferMenu);});
  268. addNodes(&bluetoothMenu, "Scanners", TFT_ORANGE, NULL, SCANNERS, [this](){changeMenu(&bluetoothScannerMenu);});
  269. // Build bluetooth sniffer Menu
  270. bluetoothSnifferMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent
  271. addNodes(&bluetoothSnifferMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(bluetoothSnifferMenu.parentMenu);});
  272. addNodes(&bluetoothSnifferMenu, "Bluetooth Sniffer", TFT_GREEN, NULL, BLUETOOTH_SNIFF, [this](){wifi_scan_obj.StartScan(BT_SCAN_ALL, TFT_GREEN);});
  273. // Build bluetooth scanner Menu
  274. bluetoothScannerMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent
  275. addNodes(&bluetoothScannerMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(bluetoothScannerMenu.parentMenu);});
  276. addNodes(&bluetoothScannerMenu, "Detect Card Skimmers", TFT_MAGENTA, NULL, CC_SKIMMERS, [this](){wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA);});
  277. generalMenu.parentMenu = &mainMenu;
  278. addNodes(&generalMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){display_obj.draw_tft = false; changeMenu(generalMenu.parentMenu);});
  279. addNodes(&generalMenu, "Draw", TFT_WHITE, NULL, DRAW, [this](){display_obj.clearScreen(); display_obj.draw_tft = true;});
  280. updateMenu.parentMenu = &mainMenu;
  281. addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true);});
  282. // Set the current menu to the mainMenu
  283. changeMenu(&mainMenu);
  284. }
  285. // Function to change menu
  286. void MenuFunctions::changeMenu(Menu* menu)
  287. {
  288. display_obj.initScrollValues();
  289. display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
  290. display_obj.tft.init();
  291. current_menu = menu;
  292. buildButtons(menu);
  293. displayCurrentMenu();
  294. }
  295. // Function to show all MenuNodes in a Menu
  296. void MenuFunctions::showMenuList(Menu* menu, int layer)
  297. {
  298. // Iterate through all of the menu nodes in the menu
  299. for (int i = 0; i < menu->list->size(); i++)
  300. {
  301. // Depending on layer, indent
  302. for (int x = 0; x < layer * 4; x++)
  303. Serial.print(" ");
  304. Serial.print("Node: ");
  305. Serial.println(menu->list->get(i).name);
  306. // If the current menu node points to another menu, list that menu
  307. //if (menu->list->get(i).childMenu != NULL)
  308. // showMenuList(menu->list->get(i).childMenu, layer+1);
  309. }
  310. Serial.println();
  311. }
  312. // Function to add MenuNodes to a menu
  313. void MenuFunctions::addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable)
  314. {
  315. TFT_eSPI_Button new_button;
  316. menu->list->add(MenuNode{name, color, place, &new_button, callable});
  317. //strcpy(menu->list->get(-1).icon, bluetooth_icon);
  318. }
  319. void MenuFunctions::buildButtons(Menu* menu)
  320. {
  321. Serial.println("Bulding buttons...");
  322. if (menu->list != NULL)
  323. {
  324. //for (int i = 0; i < sizeof(key); i++)
  325. // key[i] = NULL;
  326. for (int i = 0; i < menu->list->size(); i++)
  327. {
  328. TFT_eSPI_Button new_button;
  329. char buf[menu->list->get(i).name.length() + 1] = {};
  330. menu->list->get(i).name.toCharArray(buf, menu->list->get(i).name.length() + 1);
  331. display_obj.key[i].initButton(&display_obj.tft,
  332. KEY_X + 0 * (KEY_W + KEY_SPACING_X),
  333. KEY_Y + i * (KEY_H + KEY_SPACING_Y), // x, y, w, h, outline, fill, text
  334. KEY_W,
  335. KEY_H,
  336. TFT_BLACK, // Outline
  337. TFT_BLACK, // Fill
  338. menu->list->get(i).color, // Text
  339. buf,
  340. KEY_TEXTSIZE);
  341. }
  342. }
  343. }
  344. void MenuFunctions::displayCurrentMenu()
  345. {
  346. Serial.println("Displaying current menu...");
  347. display_obj.clearScreen();
  348. display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY);
  349. //display_obj.tft.fillRect(0,0,240,16, TFT_DARKGREY);
  350. //display_obj.tft.drawCentreString(" ESP32 Marauder ",120,0,2);
  351. //Serial.println("Getting size...");
  352. //char buf[&current_menu->parentMenu->name.length() + 1] = {};
  353. //Serial.println("Got size...");
  354. //current_menu->parentMenu->name.toCharArray(buf, current_menu->parentMenu->name.length() + 1);
  355. //String current_name = &current_menu->parentMenu->name;
  356. //Serial.println("gottem");
  357. //display_obj.tft.drawCentreString(current_menu->name,120,0,2);
  358. if (current_menu->list != NULL)
  359. {
  360. display_obj.tft.setFreeFont(MENU_FONT);
  361. for (int i = 0; i < current_menu->list->size(); i++)
  362. {
  363. //display_obj.key[i].drawButton2(current_menu->list->get(i).name);
  364. display_obj.key[i].drawButton(ML_DATUM, BUTTON_PADDING, current_menu->list->get(i).name);
  365. if (current_menu->list->get(i).name != "Back")
  366. display_obj.tft.drawXBitmap(0,
  367. KEY_Y + i * (KEY_H + KEY_SPACING_Y) - (ICON_H / 2),
  368. menu_icons[current_menu->list->get(i).icon],
  369. ICON_W,
  370. ICON_H,
  371. TFT_BLACK,
  372. current_menu->list->get(i).color);
  373. }
  374. display_obj.tft.setFreeFont(NULL);
  375. }
  376. }