MenuFunctions.cpp 19 KB

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