Krolyxon
Commit a97b224

Branches

Tags

Refs →

orion-rffirmwaremenu.cpp

302 lines · 7.0 KB · C++

1#include <Arduino.h>
2#include "menu.h"
3#include "display.h"
4#include "buttons.h"
5#include "badusb.h"
6#include "nrf24.h"
7#include "cc1101.h"
8#include "blescanner.h"
9#include "wifi_scan.h"
10#include "wifi_analyzer.h"
11#include "device_check.h"
12#include "blemouse.h"
13#include "sysinfo.h"
14
15// ================= MENU DATA =================
16
17// Root menu
18const char *mainMenuItems[] = {
19 "BadUSB",
20 "RF Capture",
21 "NRF Jammer",
22 "BLE Scan",
23 "Wifi Scan",
24 "Wifi Analyzer",
25 "System Info",
26 "Device Check",
27 "Restart",
28 "Ble Mouse"
29};
30
31Menu mainMenu = {mainMenuItems, sizeof(mainMenuItems) / sizeof(mainMenuItems[0])};
32
33// BadUSB submenu
34//const char *badusbItems[] = {
35// "Demo",
36// "Open CMD",
37// "Rickroll"};
38
39 const char *badusbItems[] = {"DEMO",
40 "KEYBOARD",
41 "HID SCRIPT",
42 "Open Notepad",
43 "Open CMD",
44 "Show IP",
45 "Shutdown",
46 "RickRoll",
47 "Create Admin",
48 "Disable Defender",
49 "Open YouTube",
50 "Lock PC",
51 "Fake Update",
52 "Endless Notepad",
53 "Fake BSOD",
54 "Flip Screen",
55 "Matrix Effect",
56 "I'm Watching U",
57 "Open Google",
58 "Open telegram",
59 "Play Alarm Sound",
60 "Endless CMD",
61 "Type Gibberish",
62 "Spam CAPSLOCK",
63 "Open Calc",
64 "Auto 'Hacked!'",
65 "Turn Off Monitor",
66 "Open RegEdit",
67 "Kill Explorer",
68 "Flash Screen",
69 "Rename Desktop",
70 "Toggle WiFi",
71 "Auto Screenshot",
72 "Spam Emojis",
73 "Open Ctrl Panel",
74 "Troll Wallpaper",
75 "Open MS Paint",
76 "Tab Switcher"};
77
78
79Menu badusbMenu = {badusbItems, sizeof(badusbItems) / sizeof(badusbItems[0])};
80
81// ================= MENU STATE =================
82
83Menu *currentMenu = &mainMenu;
84
85int menuIndex = 0;
86int menuOffset = 0;
87
88#define MENU_VISIBLE_ROWS 4
89
90bool insideFeature = false;
91
92// ================= DRAW =================
93
94void drawMenu()
95{
96 u8g2.clearBuffer();
97
98 // scroll handling
99 if (menuIndex < menuOffset)
100 menuOffset = menuIndex;
101
102 if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS)
103 menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1;
104
105 for (int i = 0; i < MENU_VISIBLE_ROWS; i++)
106 {
107 int item = menuOffset + i;
108
109 if (item >= currentMenu->size)
110 break;
111
112 if (item == menuIndex)
113 u8g2.drawStr(0, 14 + i * 14, ">");
114
115 u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]);
116 }
117
118 // scroll indicators
119 if (menuOffset > 0)
120 u8g2.drawStr(118, 10, "^");
121
122 if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size)
123 u8g2.drawStr(118, 62, "v");
124
125 u8g2.sendBuffer();
126}
127
128// ================= FEATURE EXECUTION =================
129
130void launchFeature()
131{
132 insideFeature = true;
133
134 if (currentMenu == &mainMenu)
135 {
136 switch (menuIndex)
137 {
138 case 0: // BadUSB → enter submenu
139 currentMenu = &badusbMenu;
140 menuIndex = 0;
141 menuOffset = 0;
142 break;
143
144 case 1:
145 if (!isCC1101Ready()) {
146 if (!initCC1101()) {
147 Serial.println("CC1101 failed");
148 return;
149 }
150 }
151
152 Serial.println("Ready to capture...");
153
154 startCapture();
155 delay(5000);
156 stopCapture();
157 printCapture();
158 break;
159 case 2:
160 startNRFJammer();
161 break;
162
163 case 3:
164 ble_scan();
165 ble_drawMenu();
166 while (1) {
167 ble_loop();
168 if (btnBack())
169 break;
170 }
171 break;
172
173 case 4:
174 {
175 // Start scan once
176 wifi_scan_start();
177 wifi_scan_draw();
178
179 while (1) {
180 wifi_scan_loop();
181 // EXIT condition handled ONLY here
182 if (btnBack()) {
183 delay(150); // debounce
184 break;
185 }
186 }
187 break;
188 }
189 case 5:
190 {
191
192 wifi_analyzer_start();
193
194 bool prevBack = false;
195 while (1)
196 {
197 wifi_analyzer_loop();
198 bool nowBack = btnBack();
199 if (nowBack && !prevBack)
200 {
201 delay(150);
202 break;
203 }
204 prevBack = nowBack;
205 }
206 break;
207 }
208
209 case 6:
210 runSystemInfoFeature();
211 break;
212 case 7:
213 device_check_run();
214 break;
215 case 8:
216 u8g2.clearBuffer();
217 u8g2.setFont(u8g2_font_6x13_tr);
218 u8g2.drawStr(30, 30, "Restarting...");
219 u8g2.sendBuffer();
220 delay(1000);
221 ESP.restart();
222 break;
223 case 9:
224 ble_mouse_run();
225 break;
226 }
227 }
228 else if (currentMenu == &badusbMenu)
229 {
230 badUSBMenu(menuIndex);
231 }
232
233 insideFeature = false;
234
235 drawMenu();
236}
237
238// ================= INIT =================
239
240void menuInit()
241{
242 currentMenu = &mainMenu;
243 menuIndex = 0;
244 menuOffset = 0;
245
246 drawMenu();
247}
248
249// ================= LOOP =================
250
251void menuLoop()
252{
253 static uint32_t lastPress = 0;
254
255 if (insideFeature)
256 return;
257
258 if (millis() - lastPress < 150)
259 return;
260
261 if (btnUp())
262 {
263 menuIndex--;
264
265 if (menuIndex < 0)
266 menuIndex = currentMenu->size - 1;
267
268 drawMenu();
269 lastPress = millis();
270 }
271
272 else if (btnDown())
273 {
274 menuIndex++;
275
276 if (menuIndex >= currentMenu->size)
277 menuIndex = 0;
278
279 drawMenu();
280 lastPress = millis();
281 }
282
283 else if (btnSelect())
284 {
285 launchFeature();
286 lastPress = millis();
287 }
288
289 else if (btnBack())
290 {
291 if (currentMenu != &mainMenu)
292 {
293 currentMenu = &mainMenu;
294 menuIndex = 0;
295 menuOffset = 0;
296
297 drawMenu();
298 }
299
300 lastPress = millis();
301 }
302}