Krolyxon
Commit 45d23ef

Branches

Tags

Refs →

orion-rfsrcuimenu.cpp

363 lines · 8.0 KB · C++

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