| 1 | #include "menu.h" |
| 2 | #include "BleMouse.h" |
| 3 | #include "bluetooth/ble_mouse.h" |
| 4 | #include "bluetooth/blescanner.h" |
| 5 | #include "display.h" |
| 6 | #include "hid/badusb.h" |
| 7 | #include "nfc/nfc.h" |
| 8 | #include "rf/cc1101.h" |
| 9 | #include "rf/nrf24.h" |
| 10 | #include "utils/buttons.h" |
| 11 | #include "utils/device_check.h" |
| 12 | #include "utils/sysinfo.h" |
| 13 | #include "wifi/wifi_analyzer.h" |
| 14 | #include "wifi/wifi_scan.h" |
| 15 | #include <Arduino.h> |
| 16 | |
| 17 | // ================= MENU DATA ================= |
| 18 | extern BleMouse bleMouse; |
| 19 | |
| 20 | // Root menu |
| 21 | const char *mainMenuItems[] = {"BadUSB", "RF Capture", "NRF Tools", |
| 22 | "BLE Scan", "Wifi Scan", "Wifi Analyzer", |
| 23 | "System Info", "Device Check", "Restart", |
| 24 | "Ble Mouse", "NFC Tools"}; |
| 25 | |
| 26 | Menu mainMenu = {mainMenuItems, |
| 27 | sizeof(mainMenuItems) / sizeof(mainMenuItems[0])}; |
| 28 | |
| 29 | // NRF Tools menu |
| 30 | const char *nrfToolsItems[] = { |
| 31 | "BLE Jammer", "Bluetooth Jammer", "Wifi Jammer", "USB Wireless", |
| 32 | "Video TX", "Zigbee", "RC" |
| 33 | |
| 34 | }; |
| 35 | |
| 36 | Menu nrfToolsMenu = {nrfToolsItems, |
| 37 | sizeof(nrfToolsItems) / sizeof(nrfToolsItems[0])}; |
| 38 | |
| 39 | const char *badusbItems[] = {"ORION Demo", |
| 40 | "RickRoll", |
| 41 | "Matrix Rain", |
| 42 | "Fake Terminal", |
| 43 | "Wifi Password Extractor", |
| 44 | "Fake Update", |
| 45 | "Fake BSOD", |
| 46 | "Glitch Screen", |
| 47 | "ASCII Spam", |
| 48 | "Hacker Typer", |
| 49 | "PWN Reverse shell", |
| 50 | "Phishing attack", |
| 51 | "Desktop Ghost", |
| 52 | "System Stresser"}; |
| 53 | |
| 54 | Menu badusbMenu = {badusbItems, sizeof(badusbItems) / sizeof(badusbItems[0])}; |
| 55 | |
| 56 | // ================= MENU STATE ================= |
| 57 | |
| 58 | Menu *currentMenu = &mainMenu; |
| 59 | |
| 60 | int menuIndex = 0; |
| 61 | int menuOffset = 0; |
| 62 | |
| 63 | #define MENU_VISIBLE_ROWS 4 |
| 64 | |
| 65 | bool insideFeature = false; |
| 66 | |
| 67 | // ================= DRAW ================= |
| 68 | |
| 69 | void drawMenu() { |
| 70 | u8g2.clearBuffer(); |
| 71 | |
| 72 | // scroll handling |
| 73 | if (menuIndex < menuOffset) |
| 74 | menuOffset = menuIndex; |
| 75 | |
| 76 | if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS) |
| 77 | menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1; |
| 78 | |
| 79 | for (int i = 0; i < MENU_VISIBLE_ROWS; i++) { |
| 80 | int item = menuOffset + i; |
| 81 | |
| 82 | if (item >= currentMenu->size) |
| 83 | break; |
| 84 | |
| 85 | if (item == menuIndex) |
| 86 | u8g2.drawStr(0, 14 + i * 14, ">"); |
| 87 | |
| 88 | u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]); |
| 89 | } |
| 90 | |
| 91 | // scroll indicators |
| 92 | if (menuOffset > 0) |
| 93 | u8g2.drawStr(118, 10, "^"); |
| 94 | |
| 95 | if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size) |
| 96 | u8g2.drawStr(118, 62, "v"); |
| 97 | |
| 98 | u8g2.sendBuffer(); |
| 99 | } |
| 100 | |
| 101 | // ================= FEATURE EXECUTION ================= |
| 102 | |
| 103 | void launchFeature() { |
| 104 | insideFeature = true; |
| 105 | |
| 106 | if (currentMenu == &mainMenu) { |
| 107 | switch (menuIndex) { |
| 108 | case 0: // BadUSB → enter submenu |
| 109 | currentMenu = &badusbMenu; |
| 110 | menuIndex = 0; |
| 111 | menuOffset = 0; |
| 112 | break; |
| 113 | |
| 114 | case 1: |
| 115 | handleMenu(); |
| 116 | break; |
| 117 | case 2: |
| 118 | // startNRFJammer(); |
| 119 | // startBleJammer(); |
| 120 | // startBluetoothJammer(); |
| 121 | currentMenu = &nrfToolsMenu; |
| 122 | menuIndex = 0; |
| 123 | menuOffset = 0; |
| 124 | break; |
| 125 | |
| 126 | break; |
| 127 | case 3: |
| 128 | ble_scan(); |
| 129 | ble_drawMenu(); |
| 130 | while (1) { |
| 131 | ble_loop(); |
| 132 | if (btnBack()) |
| 133 | break; |
| 134 | } |
| 135 | break; |
| 136 | |
| 137 | case 4: { |
| 138 | // Start scan once |
| 139 | wifi_scan_start(); |
| 140 | wifi_scan_draw(); |
| 141 | |
| 142 | while (1) { |
| 143 | wifi_scan_loop(); |
| 144 | // EXIT condition handled ONLY here |
| 145 | if (btnBack()) { |
| 146 | delay(150); // debounce |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | break; |
| 151 | } |
| 152 | case 5: { |
| 153 | |
| 154 | wifi_analyzer_start(); |
| 155 | |
| 156 | bool prevBack = false; |
| 157 | while (1) { |
| 158 | wifi_analyzer_loop(); |
| 159 | bool nowBack = btnBack(); |
| 160 | if (nowBack && !prevBack) { |
| 161 | delay(150); |
| 162 | break; |
| 163 | } |
| 164 | prevBack = nowBack; |
| 165 | } |
| 166 | break; |
| 167 | } |
| 168 | |
| 169 | case 6: |
| 170 | runSystemInfoFeature(); |
| 171 | break; |
| 172 | case 7: |
| 173 | device_check_run(); |
| 174 | break; |
| 175 | case 8: { |
| 176 | // wait for button release |
| 177 | delay(200); |
| 178 | |
| 179 | while (btnSelect()) |
| 180 | delay(10); |
| 181 | bool confirm = false; |
| 182 | |
| 183 | while (1) { |
| 184 | u8g2.clearBuffer(); |
| 185 | u8g2.setFont(u8g2_font_6x13_tr); |
| 186 | |
| 187 | u8g2.drawStr(18, 18, "Restart Device?"); |
| 188 | |
| 189 | if (confirm) { |
| 190 | u8g2.drawBox(10, 35, 45, 15); |
| 191 | u8g2.setDrawColor(0); |
| 192 | u8g2.drawStr(20, 47, "YES"); |
| 193 | u8g2.setDrawColor(1); |
| 194 | |
| 195 | u8g2.drawStr(75, 47, "NO"); |
| 196 | } else { |
| 197 | u8g2.drawStr(20, 47, "YES"); |
| 198 | |
| 199 | u8g2.drawBox(65, 35, 45, 15); |
| 200 | u8g2.setDrawColor(0); |
| 201 | u8g2.drawStr(78, 47, "NO"); |
| 202 | u8g2.setDrawColor(1); |
| 203 | } |
| 204 | |
| 205 | u8g2.sendBuffer(); |
| 206 | |
| 207 | if (btnLeft() || btnUp()) { |
| 208 | confirm = true; |
| 209 | delay(150); |
| 210 | } |
| 211 | |
| 212 | if (btnRight() || btnDown()) { |
| 213 | confirm = false; |
| 214 | delay(150); |
| 215 | } |
| 216 | |
| 217 | if (btnSelect()) { |
| 218 | delay(150); |
| 219 | |
| 220 | if (confirm) { |
| 221 | u8g2.clearBuffer(); |
| 222 | u8g2.drawStr(28, 30, "Restarting..."); |
| 223 | u8g2.sendBuffer(); |
| 224 | |
| 225 | delay(1000); |
| 226 | ESP.restart(); |
| 227 | } else { |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | if (btnBack()) { |
| 233 | delay(150); |
| 234 | break; |
| 235 | } |
| 236 | } |
| 237 | } break; |
| 238 | |
| 239 | case 9: |
| 240 | // Begin Ble mouse |
| 241 | bleMouse.begin(); |
| 242 | ble_mouse_run(); |
| 243 | break; |
| 244 | case 10: |
| 245 | pn532_scan_loop(); |
| 246 | break; |
| 247 | } |
| 248 | } else if (currentMenu == &badusbMenu) { |
| 249 | badUSBMenu(menuIndex); |
| 250 | } else if (currentMenu == &nrfToolsMenu) { |
| 251 | NRFToolsMenu(menuIndex); |
| 252 | } |
| 253 | |
| 254 | insideFeature = false; |
| 255 | |
| 256 | drawMenu(); |
| 257 | } |
| 258 | |
| 259 | // ================= INIT ================= |
| 260 | |
| 261 | void menuInit() { |
| 262 | currentMenu = &mainMenu; |
| 263 | menuIndex = 0; |
| 264 | menuOffset = 0; |
| 265 | |
| 266 | drawMenu(); |
| 267 | } |
| 268 | |
| 269 | // ================= LOOP ================= |
| 270 | |
| 271 | void menuLoop() { |
| 272 | static uint32_t lastPress = 0; |
| 273 | |
| 274 | if (insideFeature) |
| 275 | return; |
| 276 | |
| 277 | if (millis() - lastPress < 150) |
| 278 | return; |
| 279 | |
| 280 | if (btnUp()) { |
| 281 | menuIndex--; |
| 282 | |
| 283 | if (menuIndex < 0) |
| 284 | menuIndex = currentMenu->size - 1; |
| 285 | |
| 286 | drawMenu(); |
| 287 | lastPress = millis(); |
| 288 | } |
| 289 | |
| 290 | else if (btnDown()) { |
| 291 | menuIndex++; |
| 292 | |
| 293 | if (menuIndex >= currentMenu->size) |
| 294 | menuIndex = 0; |
| 295 | |
| 296 | drawMenu(); |
| 297 | lastPress = millis(); |
| 298 | } |
| 299 | |
| 300 | else if (btnSelect()) { |
| 301 | launchFeature(); |
| 302 | lastPress = millis(); |
| 303 | } |
| 304 | |
| 305 | else if (btnBack()) { |
| 306 | if (currentMenu != &mainMenu) { |
| 307 | currentMenu = &mainMenu; |
| 308 | menuIndex = 0; |
| 309 | menuOffset = 0; |
| 310 | |
| 311 | drawMenu(); |
| 312 | } |
| 313 | |
| 314 | lastPress = millis(); |
| 315 | } |
| 316 | } |