Skip to content

Commit

Permalink
Merge pull request #390 from rennancockles/dev
Browse files Browse the repository at this point in the history
Config enhancements
  • Loading branch information
pr3y authored Nov 6, 2024
2 parents 3415c84 + 8c323fe commit 0b74b69
Show file tree
Hide file tree
Showing 67 changed files with 1,933 additions and 1,633 deletions.
30 changes: 15 additions & 15 deletions html/AsyncWebServer/evil_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class CaptiveRequestHandler : public AsyncWebHandler {
saveToCSV("/Bruce_creds.csv", csvLine);
capturedCredentialsHtml = html_temp + capturedCredentialsHtml;
totalCapturedCredentials++;
request->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
}
request->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
}
else {
request->redirect("/");
request->redirect("/");
}
}
};
Expand All @@ -74,12 +74,12 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
};
delay(200);
loopOptions(options);

while(checkNextPress()){ yield(); } // debounce
delay(200);
// tssid="" means that are opening a virgin Evil Portal
if (tssid=="") {
AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
if (tssid=="") {
AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
}
else { // tssid != "" means that is was cloned and can deploy Deauth
//memcpy(ap_record.bssid, bssid, 6);
Expand All @@ -90,13 +90,13 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {

wifiConnected=true;
drawMainBorder();
displayRedStripe("Starting..",TFT_WHITE,FGCOLOR);
displayRedStripe("Starting..",TFT_WHITE,bruceConfig.priColor);

IPAddress AP_GATEWAY(172, 0, 0, 1);
WiFi.mode(WIFI_MODE_AP);
WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0));
WiFi.softAP(AP_name,emptyString,channel);

tmp=millis();
while(millis() - tmp < 3000) yield();
dnsServer.start(53, "*", WiFi.softAPIP());
Expand Down Expand Up @@ -125,7 +125,7 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
previousTotalCapturedCredentials=-1; // redesenha a tela
});

ep->on("/clear", HTTP_GET, [](AsyncWebServerRequest * request) {
ep->on("/clear", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send(200, "text/html", clear_GET());
});

Expand All @@ -148,8 +148,8 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
new (ep) AsyncWebServer(80);

ep->begin();
tft.fillRect(6, 27, WIDTH-12, HEIGHT-33, BGCOLOR);
tft.fillRect(6, 27, WIDTH-12, HEIGHT-33, bruceConfig.bgColor);

bool hold_deauth = false;
tmp=millis(); // one deauth frame each 30ms at least
redraw=true;
Expand All @@ -160,7 +160,7 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
tft.setTextColor(TFT_RED);
tft.drawCentreString("Evil Portal",WIDTH/2, 29, SMOOTH_FONT);
tft.setCursor(7,49);
tft.setTextColor(FGCOLOR);
tft.setTextColor(bruceConfig.priColor);
tft.println("AP: " + AP_name);
tft.setCursor(7,tft.getCursorY());
tft.println("->" + WiFi.softAPIP().toString() + "/creds");
Expand All @@ -177,7 +177,7 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
if (deauth){
if (hold_deauth) {
tft.setTextSize(FP);
tft.setTextColor(FGCOLOR);
tft.setTextColor(bruceConfig.priColor);
tft.drawRightString("Deauth OFF", WIDTH-7,HEIGHT-14,SMOOTH_FONT);
} else {
tft.setTextSize(FP);
Expand All @@ -190,7 +190,7 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
redraw=false;
}

if(!hold_deauth && (millis()-tmp) >5) {
if(!hold_deauth && (millis()-tmp) >5) {
wsl_bypasser_send_raw_frame(deauth_frame, 26); // sends deauth frames if needed.
tmp=millis();
}
Expand Down Expand Up @@ -232,7 +232,7 @@ void saveToCSV(const String &filename, const String &csvLine) {
}

String getHtmlContents(String body) {
PROGMEM String html =
PROGMEM String html =
"<!DOCTYPE html>"
"<html>"
"<head>"
Expand Down
24 changes: 12 additions & 12 deletions html/AsyncWebServer/webInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool update;

size_t file_size;
// WiFi as a Client
String default_httpuser = "admin";
String default_httpuser = "admin";
String default_httppassword = "bruce";
const int default_webserverporthttp = 80;

Expand All @@ -44,13 +44,13 @@ String uploadFolder="";
**********************************************************************/
void webUIMyNet() {
if (WiFi.status() != WL_CONNECTED) {
if(wifiConnectMenu()) startWebUi(false);
if(wifiConnectMenu()) startWebUi(false);
else {
displayError("Wifi Offline");
}
} else {
//If it is already connected, just start the network
startWebUi(false);
startWebUi(false);
}
sprite.createSprite(WIDTH-20,HEIGHT-20);
// On fail installing will run the following line
Expand Down Expand Up @@ -165,7 +165,7 @@ String processor(const String& var) {
else if (var == "FREESD") return humanReadableSize(SD.totalBytes() - SD.usedBytes());
else if (var == "USEDSD") return humanReadableSize(SD.usedBytes());
else if (var == "TOTALSD") return humanReadableSize(SD.totalBytes());
else return "Attribute not configured";
else return "Attribute not configured";
}


Expand All @@ -188,7 +188,7 @@ bool checkUserWebAuth(AsyncWebServerRequest * request) {
**********************************************************************/
void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
// make sure authenticated before allowing upload
Serial.println("Folder: " + uploadFolder);
Serial.println("Folder: " + uploadFolder);
if (uploadFolder=="/") uploadFolder = "";

if (checkUserWebAuth(request)) {
Expand Down Expand Up @@ -229,7 +229,7 @@ void notFound(AsyncWebServerRequest *request) {
void configureWebServer() {

MDNS.begin(host);

// if url isn't found
server->onNotFound([](AsyncWebServerRequest * request) {
request->redirect("/");
Expand All @@ -249,7 +249,7 @@ void configureWebServer() {
});

server->on("/rename", HTTP_POST, [](AsyncWebServerRequest * request) {
if (request->hasParam("fileName", true) && request->hasParam("filePath", true)) {
if (request->hasParam("fileName", true) && request->hasParam("filePath", true)) {
String fileName = request->getParam("fileName", true)->value().c_str();
String filePath = request->getParam("filePath", true)->value().c_str();
String filePath2 = filePath.substring(0,filePath.lastIndexOf('/')+1) + fileName;
Expand Down Expand Up @@ -317,7 +317,7 @@ void configureWebServer() {
} else if (strcmp(fileAction, "delete") == 0) {
if(deleteFromSd(fileName)) { request->send(200, "text/plain", "Deleted : " + String(fileName)); }
else { request->send(200, "text/plain", "FAIL delating: " + String(fileName));}

} else if (strcmp(fileAction, "create") == 0) {
if(SD.mkdir(fileName)) {
} else { request->send(200, "text/plain", "FAIL creating folder: " + String(fileName));}
Expand All @@ -340,7 +340,7 @@ void configureWebServer() {
const char *ssid = request->getParam("usr")->value().c_str();
const char *pwd = request->getParam("pwd")->value().c_str();
SD.remove(fileconf);
File file = SD.open(fileconf, FILE_WRITE);
File file = SD.open(fileconf, FILE_WRITE);
file.print(String(ssid) + ";" + String(pwd) + ";\n");
config.httpuser = ssid;
config.httppassword = pwd;
Expand Down Expand Up @@ -395,7 +395,7 @@ file_size = 0;
// Choose wifi access mode
wifiConnectMenu(mode_ap);
}

// configure web server
Serial.println("Configuring Webserver ...");
#if defined(CARDPUTER) || defined(STICK_C_PLUS2)
Expand All @@ -413,8 +413,8 @@ file_size = 0;
String txt;
if(!mode_ap) txt = WiFi.localIP().toString();
else txt = WiFi.softAPIP().toString();
tft.setTextColor(FGCOLOR);
tft.setTextColor(bruceConfig.priColor);

#ifndef STICK_C
tft.drawCentreString("http://bruce.local", WIDTH/2,25,1);
setTftDisplay(7,47);
Expand Down
18 changes: 9 additions & 9 deletions html/WebServer/evil_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void handleCreds() {
saveToCSV("/Bruce_creds.csv", csvLine);
capturedCredentialsHtml = html_temp + capturedCredentialsHtml;
totalCapturedCredentials++;
ep->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
ep->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
}

void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
Expand All @@ -58,8 +58,8 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
while(checkNextPress()){ yield(); } // debounce

// tssid="" means that are opening a virgin Evil Portal
if (tssid=="") {
AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
if (tssid=="") {
AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
}
else { // tssid != "" means that is was cloned and can deploy Deauth
//memcpy(ap_record.bssid, bssid, 6);
Expand Down Expand Up @@ -109,19 +109,19 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
});

ep->begin();

bool hold_deauth = false;
int tmp=millis(); // one deauth frame each 30ms at least
redraw=true;
while(1) {
if(redraw) {
drawMainBorder();

tft.setTextSize(FM);
tft.setTextColor(TFT_RED);
tft.drawCentreString("Evil Portal",WIDTH/2, 29, SMOOTH_FONT);
tft.setCursor(8,46);
tft.setTextColor(FGCOLOR);
tft.setTextColor(bruceConfig.priColor);
tft.println("AP: " + AP_name);
tft.setCursor(8,tft.getCursorY());
tft.println("->" + WiFi.softAPIP().toString() + "/creds");
Expand All @@ -138,7 +138,7 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
if (deauth){
if (hold_deauth) {
tft.setTextSize(FP);
tft.setTextColor(FGCOLOR);
tft.setTextColor(bruceConfig.priColor);
tft.drawRightString("Deauth OFF", WIDTH-6,HEIGHT-8,SMOOTH_FONT);
} else {
tft.setTextSize(FP);
Expand All @@ -150,7 +150,7 @@ void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
redraw=false;
}

if(!hold_deauth && (millis()-tmp) >5) {
if(!hold_deauth && (millis()-tmp) >5) {
wsl_bypasser_send_raw_frame(deauth_frame, 26); // sends deauth frames if needed.
tmp=millis();
}
Expand Down Expand Up @@ -192,7 +192,7 @@ void saveToCSV(const String &filename, const String &csvLine) {
}

String getHtmlContents(String body) {
PROGMEM String html =
PROGMEM String html =
"<!DOCTYPE html>"
"<html>"
"<head>"
Expand Down
22 changes: 11 additions & 11 deletions html/WebServer/webInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Config {

File uploadFile;
// WiFi as a Client
String default_httpuser = "admin";
String default_httpuser = "admin";
String default_httppassword = "bruce";
const int default_webserverporthttp = 80;

Expand All @@ -36,13 +36,13 @@ String uploadFolder="";
**********************************************************************/
void webUIMyNet() {
if (WiFi.status() != WL_CONNECTED) {
if(wifiConnectMenu()) startWebUi(false);
if(wifiConnectMenu()) startWebUi(false);
else {
displayError("Wifi Offline");
}
} else {
//If it is already connected, just start the network
startWebUi(false);
startWebUi(false);
}
// On fail installing will run the following line
}
Expand Down Expand Up @@ -158,7 +158,7 @@ String processor(const String& var) {
processedHtml.replace("%FREESD%", humanReadableSize(SD.totalBytes() - SD.usedBytes()));
processedHtml.replace("%USEDSD%", humanReadableSize(SD.usedBytes()));
processedHtml.replace("%TOTALSD%", humanReadableSize(SD.totalBytes()));

return processedHtml;
}

Expand Down Expand Up @@ -256,13 +256,13 @@ void configureWebServer() {

// Route to rename a file
server->on("/rename", HTTP_POST, []() {
if (server->hasArg("fileName") && server->hasArg("filePath")) {
if (server->hasArg("fileName") && server->hasArg("filePath")) {
String fileName = server->arg("fileName").c_str();
String filePath = server->arg("filePath").c_str();
String filePath2 = filePath.substring(0,filePath.lastIndexOf('/')+1) + fileName;
if(!SD.begin()) {
server->send(200, "text/plain", "Fail starting SD Card.");
}
}
else {
// Rename the file of folder
if (SD.rename(filePath, filePath2)) {
Expand Down Expand Up @@ -311,7 +311,7 @@ void configureWebServer() {
server->send(200, "text/plain", "Created new folder: " + String(fileName));
} else {
server->send(200, "text/plain", "FAIL creating folder: " + String(fileName));
}
}
} else server->send(400, "text/plain", "ERROR: file does not exist");

} else {
Expand Down Expand Up @@ -407,23 +407,23 @@ void startWebUi(bool mode_ap) {
// Choose wifi access mode
wifiConnectMenu(mode_ap);
}

// configure web server
Serial.println("Configuring Webserver ...");
server = (WebServer*)malloc(sizeof(WebServer));
new (server) WebServer(config.webserverporthttp);

configureWebServer();

tft.fillScreen(BGCOLOR);
tft.fillScreen(bruceConfig.bgColor);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,ALCOLOR);
setTftDisplay(0,0,ALCOLOR,FM);
tft.drawCentreString("BRUCE WebUI",WIDTH/2,7,1);
String txt;
if(!mode_ap) txt = WiFi.localIP().toString();
else txt = WiFi.softAPIP().toString();
tft.setTextColor(FGCOLOR);
tft.setTextColor(bruceConfig.priColor);

#ifndef STICK_C
tft.drawCentreString("http://bruce.local", WIDTH/2,25,1);
setTftDisplay(7,47);
Expand Down
3 changes: 1 addition & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ build_flags =
-DEEPROMSIZE=128
-DLH=8
-DLW=6
-DCONFIG_FILE='"/bruce.conf"'
-w
-Wl,--print-memory-usage
-Wl,--gc-sections
Expand Down Expand Up @@ -1261,7 +1260,7 @@ build_flags =
; SERIAL (GPS) dedicated pins
-DSERIAL_TX=1
-DSERIAL_RX=3

;Battery ADC read pin
;-DBAT_PIN=10

Expand Down
Loading

0 comments on commit 0b74b69

Please sign in to comment.