| 1 | #include <Arduino.h> |
| 2 | #include "menu.h" |
| 3 | #include "display.h" |
| 4 | #include "utils/buttons.h" |
| 5 | #include "hid/badusb.h" |
| 6 | #include "rf/nrf24.h" |
| 7 | #include "rf/cc1101.h" |
| 8 | #include "wifi/wifi_scan.h" |
| 9 | #include "wifi/wifi_analyzer.h" |
| 10 | #include "utils/device_check.h" |
| 11 | #include "bluetooth/ble_mouse.h" |
| 12 | #include "bluetooth/blescanner.h" |
| 13 | #include "utils/sysinfo.h" |
| 14 | #include "BleMouse.h" |
| 15 | #include "nfc/nfc.h" |
| 16 | |
| 17 | // ================= MENU DATA ================= |
| 18 | extern BleMouse bleMouse; |
| 19 | |
| 20 | // Root menu |
| 21 | const char *mainMenuItems[] = { |
| 22 | "BadUSB", |
| 23 | "RF Capture", |
| 24 | "NRF Tools", |
| 25 | "BLE Scan", |
| 26 | "Wifi Scan", |
| 27 | "Wifi Analyzer", |
| 28 | "System Info", |
| 29 | "Device Check", |
| 30 | "Restart", |
| 31 | "Ble Mouse", |
| 32 | "NFC Tools" |
| 33 | }; |
| 34 | |
| 35 | Menu mainMenu = {mainMenuItems, sizeof(mainMenuItems) / sizeof(mainMenuItems[0])}; |
| 36 | |
| 37 | |
| 38 | // NRF Tools menu |
| 39 | const char *nrfToolsItems[] = { |
| 40 | "BLE Jammer", |
| 41 | "Bluetooth Jammer", |
| 42 | "Wifi Jammer", |
| 43 | "USB Wireless", |
| 44 | "Video TX", |
| 45 | "Zigbee", |
| 46 | "RC" |
| 47 | |
| 48 | }; |
| 49 | |
| 50 | Menu nrfToolsMenu = {nrfToolsItems, sizeof(nrfToolsItems) / sizeof(nrfToolsItems[0])}; |
| 51 | |
| 52 | |
| 53 | // BadUSB submenu |
| 54 | const char *badusbItems[] = {"DEMO", |
| 55 | "KEYBOARD", |
| 56 | "HID SCRIPT", |
| 57 | "Open Notepad", |
| 58 | "Open CMD", |
| 59 | "Show IP", |
| 60 | "Shutdown", |
| 61 | "RickRoll", |
| 62 | "Create Admin", |
| 63 | "Disable Defender", |
| 64 | "Open YouTube", |
| 65 | "Lock PC", |
| 66 | "Fake Update", |
| 67 | "Endless Notepad", |
| 68 | "Fake BSOD", |
| 69 | "Flip Screen", |
| 70 | "Matrix Effect", |
| 71 | "I'm Watching U", |
| 72 | "Open Google", |
| 73 | "Open telegram", |
| 74 | "Play Alarm Sound", |
| 75 | "Endless CMD", |
| 76 | "Type Gibberish", |
| 77 | "Spam CAPSLOCK", |
| 78 | "Open Calc", |
| 79 | "Auto 'Hacked!'", |
| 80 | "Turn Off Monitor", |
| 81 | "Open RegEdit", |
| 82 | "Kill Explorer", |
| 83 | "Flash Screen", |
| 84 | "Rename Desktop", |
| 85 | "Toggle WiFi", |
| 86 | "Auto Screenshot", |
| 87 | "Spam Emojis", |
| 88 | "Open Ctrl Panel", |
| 89 | "Troll Wallpaper", |
| 90 | "Open MS Paint", |
| 91 | "Tab Switcher"}; |
| 92 | |
| 93 | |
| 94 | Menu badusbMenu = {badusbItems, sizeof(badusbItems) / sizeof(badusbItems[0])}; |
| 95 | |
| 96 | // ================= MENU STATE ================= |
| 97 | |
| 98 | Menu *currentMenu = &mainMenu; |
| 99 | |
| 100 | int menuIndex = 0; |
| 101 | int menuOffset = 0; |
| 102 | |
| 103 | #define MENU_VISIBLE_ROWS 4 |
| 104 | |
| 105 | bool insideFeature = false; |
| 106 | |
| 107 | // ================= DRAW ================= |
| 108 | |
| 109 | void drawMenu() |
| 110 | { |
| 111 | u8g2.clearBuffer(); |
| 112 | |
| 113 | // scroll handling |
| 114 | if (menuIndex < menuOffset) |
| 115 | menuOffset = menuIndex; |
| 116 | |
| 117 | if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS) |
| 118 | menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1; |
| 119 | |
| 120 | for (int i = 0; i < MENU_VISIBLE_ROWS; i++) |
| 121 | { |
| 122 | int item = menuOffset + i; |
| 123 | |
| 124 | if (item >= currentMenu->size) |
| 125 | break; |
| 126 | |
| 127 | if (item == menuIndex) |
| 128 | u8g2.drawStr(0, 14 + i * 14, ">"); |
| 129 | |
| 130 | u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]); |
| 131 | } |
| 132 | |
| 133 | // scroll indicators |
| 134 | if (menuOffset > 0) |
| 135 | u8g2.drawStr(118, 10, "^"); |
| 136 | |
| 137 | if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size) |
| 138 | u8g2.drawStr(118, 62, "v"); |
| 139 | |
| 140 | u8g2.sendBuffer(); |
| 141 | } |
| 142 | |
| 143 | // ================= FEATURE EXECUTION ================= |
| 144 | |
| 145 | void launchFeature() |
| 146 | { |
| 147 | insideFeature = true; |
| 148 | |
| 149 | if (currentMenu == &mainMenu) |
| 150 | { |
| 151 | switch (menuIndex) |
| 152 | { |
| 153 | case 0: // BadUSB → enter submenu |
| 154 | currentMenu = &badusbMenu; |
| 155 | menuIndex = 0; |
| 156 | menuOffset = 0; |
| 157 | break; |
| 158 | |
| 159 | case 1: |
| 160 | if (!isCC1101Ready()) { |
| 161 | if (!initCC1101()) { |
| 162 | Serial.println("CC1101 failed"); |
| 163 | return; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | Serial.println("Ready to capture..."); |
| 168 | |
| 169 | startCapture(); |
| 170 | delay(5000); |
| 171 | stopCapture(); |
| 172 | printCapture(); |
| 173 | delay(5000); |
| 174 | replaySignal(); |
| 175 | break; |
| 176 | |
| 177 | case 2: |
| 178 | // startNRFJammer(); |
| 179 | //startBleJammer(); |
| 180 | //startBluetoothJammer(); |
| 181 | currentMenu = &nrfToolsMenu; |
| 182 | menuIndex = 0; |
| 183 | menuOffset = 0; |
| 184 | break; |
| 185 | |
| 186 | break; |
| 187 | case 3: |
| 188 | ble_scan(); |
| 189 | ble_drawMenu(); |
| 190 | while (1) { |
| 191 | ble_loop(); |
| 192 | if (btnBack()) |
| 193 | break; |
| 194 | } |
| 195 | break; |
| 196 | |
| 197 | case 4: |
| 198 | { |
| 199 | // Start scan once |
| 200 | wifi_scan_start(); |
| 201 | wifi_scan_draw(); |
| 202 | |
| 203 | while (1) { |
| 204 | wifi_scan_loop(); |
| 205 | // EXIT condition handled ONLY here |
| 206 | if (btnBack()) { |
| 207 | delay(150); // debounce |
| 208 | break; |
| 209 | } |
| 210 | } |
| 211 | break; |
| 212 | } |
| 213 | case 5: |
| 214 | { |
| 215 | |
| 216 | wifi_analyzer_start(); |
| 217 | |
| 218 | bool prevBack = false; |
| 219 | while (1) |
| 220 | { |
| 221 | wifi_analyzer_loop(); |
| 222 | bool nowBack = btnBack(); |
| 223 | if (nowBack && !prevBack) |
| 224 | { |
| 225 | delay(150); |
| 226 | break; |
| 227 | } |
| 228 | prevBack = nowBack; |
| 229 | } |
| 230 | break; |
| 231 | } |
| 232 | |
| 233 | case 6: |
| 234 | runSystemInfoFeature(); |
| 235 | break; |
| 236 | case 7: |
| 237 | device_check_run(); |
| 238 | break; |
| 239 | case 8: |
| 240 | { |
| 241 | // wait for button release |
| 242 | delay(200); |
| 243 | |
| 244 | while (btnSelect()) |
| 245 | delay(10); |
| 246 | bool confirm = false; |
| 247 | |
| 248 | while (1) |
| 249 | { |
| 250 | u8g2.clearBuffer(); |
| 251 | u8g2.setFont(u8g2_font_6x13_tr); |
| 252 | |
| 253 | u8g2.drawStr(18, 18, "Restart Device?"); |
| 254 | |
| 255 | if (confirm) |
| 256 | { |
| 257 | u8g2.drawBox(10, 35, 45, 15); |
| 258 | u8g2.setDrawColor(0); |
| 259 | u8g2.drawStr(20, 47, "YES"); |
| 260 | u8g2.setDrawColor(1); |
| 261 | |
| 262 | u8g2.drawStr(75, 47, "NO"); |
| 263 | } |
| 264 | else |
| 265 | { |
| 266 | u8g2.drawStr(20, 47, "YES"); |
| 267 | |
| 268 | u8g2.drawBox(65, 35, 45, 15); |
| 269 | u8g2.setDrawColor(0); |
| 270 | u8g2.drawStr(78, 47, "NO"); |
| 271 | u8g2.setDrawColor(1); |
| 272 | } |
| 273 | |
| 274 | u8g2.sendBuffer(); |
| 275 | |
| 276 | if (btnLeft() || btnUp()) |
| 277 | { |
| 278 | confirm = true; |
| 279 | delay(150); |
| 280 | } |
| 281 | |
| 282 | if (btnRight() || btnDown()) |
| 283 | { |
| 284 | confirm = false; |
| 285 | delay(150); |
| 286 | } |
| 287 | |
| 288 | if (btnSelect()) |
| 289 | { |
| 290 | delay(150); |
| 291 | |
| 292 | if (confirm) |
| 293 | { |
| 294 | u8g2.clearBuffer(); |
| 295 | u8g2.drawStr(28, 30, "Restarting..."); |
| 296 | u8g2.sendBuffer(); |
| 297 | |
| 298 | delay(1000); |
| 299 | ESP.restart(); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | break; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if (btnBack()) |
| 308 | { |
| 309 | delay(150); |
| 310 | break; |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | break; |
| 315 | |
| 316 | case 9: |
| 317 | // Begin Ble mouse |
| 318 | bleMouse.begin(); |
| 319 | ble_mouse_run(); |
| 320 | break; |
| 321 | case 10: |
| 322 | pn532_scan_loop(); |
| 323 | break; |
| 324 | } |
| 325 | } |
| 326 | else if (currentMenu == &badusbMenu) |
| 327 | { |
| 328 | badUSBMenu(menuIndex); |
| 329 | } else if (currentMenu == &nrfToolsMenu) { |
| 330 | NRFToolsMenu(menuIndex); |
| 331 | } |
| 332 | |
| 333 | insideFeature = false; |
| 334 | |
| 335 | drawMenu(); |
| 336 | } |
| 337 | |
| 338 | // ================= INIT ================= |
| 339 | |
| 340 | void menuInit() |
| 341 | { |
| 342 | currentMenu = &mainMenu; |
| 343 | menuIndex = 0; |
| 344 | menuOffset = 0; |
| 345 | |
| 346 | drawMenu(); |
| 347 | } |
| 348 | |
| 349 | // ================= LOOP ================= |
| 350 | |
| 351 | void menuLoop() |
| 352 | { |
| 353 | static uint32_t lastPress = 0; |
| 354 | |
| 355 | if (insideFeature) |
| 356 | return; |
| 357 | |
| 358 | if (millis() - lastPress < 150) |
| 359 | return; |
| 360 | |
| 361 | if (btnUp()) |
| 362 | { |
| 363 | menuIndex--; |
| 364 | |
| 365 | if (menuIndex < 0) |
| 366 | menuIndex = currentMenu->size - 1; |
| 367 | |
| 368 | drawMenu(); |
| 369 | lastPress = millis(); |
| 370 | } |
| 371 | |
| 372 | else if (btnDown()) |
| 373 | { |
| 374 | menuIndex++; |
| 375 | |
| 376 | if (menuIndex >= currentMenu->size) |
| 377 | menuIndex = 0; |
| 378 | |
| 379 | drawMenu(); |
| 380 | lastPress = millis(); |
| 381 | } |
| 382 | |
| 383 | else if (btnSelect()) |
| 384 | { |
| 385 | launchFeature(); |
| 386 | lastPress = millis(); |
| 387 | } |
| 388 | |
| 389 | else if (btnBack()) |
| 390 | { |
| 391 | if (currentMenu != &mainMenu) |
| 392 | { |
| 393 | currentMenu = &mainMenu; |
| 394 | menuIndex = 0; |
| 395 | menuOffset = 0; |
| 396 | |
| 397 | drawMenu(); |
| 398 | } |
| 399 | |
| 400 | lastPress = millis(); |
| 401 | } |
| 402 | } |