Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added sd_files/portals/media/gorilla.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sd_files/portals/media/rickroll.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 52 additions & 1 deletion src/modules/wifi/evil_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ bool EvilPortal::setup() {
}

options = {
{"Custom Html", [this]() { loadCustomHtml(); }}
{"Custom Html", [this]() { loadCustomHtml(); }},
{"Meme Portal", [this]() { loadMemeHtml(); }}
};
addOptionToMainMenu();

Expand Down Expand Up @@ -200,6 +201,19 @@ void EvilPortal::setupRoutes() {
request->send(response);
});

webServer.on("/media/*", HTTP_GET, [](AsyncWebServerRequest *request) {
String path = "/portals/media" + request->url().substring(6);
if (SD.exists(path)) {
String contentType = "image/jpeg";
if (path.endsWith(".gif")) contentType = "image/gif";
else if (path.endsWith(".png")) contentType = "image/png";
else if (path.endsWith(".mp4")) contentType = "video/mp4";
request->send(SD, path, contentType);
} else {
request->send(404, "text/plain", "Not found");
}
});

webServer.on("/", [this](AsyncWebServerRequest *request) { portalController(request); });
webServer.on("/post", [this](AsyncWebServerRequest *request) { credsController(request); });

Expand Down Expand Up @@ -488,6 +502,43 @@ void EvilPortal::loadCustomHtml() {
}
}

void EvilPortal::loadMemeHtml() {
FS *fs;
if (!getFsStorage(fs)) { loadDefaultHtml(); return; }

if (!fs->exists("/portals/media")) { loadDefaultHtml(); return; }

apName = "";
apName_from_keyboard();
if (returnToMenu) return;

File dir = fs->open("/portals/media");
std::vector<String> files;
while (true) {
File f = dir.openNextFile();
if (!f) break;
if (!f.isDirectory()) files.push_back(String(f.name()));
}
dir.close();

if (files.empty()) { displayTextLine("No files in /portals/media"); loadDefaultHtml(); return; }

std::vector<Option> fileOptions;
for (const auto &name : files) {
fileOptions.push_back({name, [this, name]() {
String ext = name;
ext.toLowerCase();
String tag;
if (ext.endsWith(".mp4")) tag = "<video autoplay loop src='/media/" + name + "'></video>";
else tag = "<img src='/media/" + name + "'>";
htmlPage = "<html><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width,initial-scale=1'><style>body{margin:0;background:#000;display:flex;justify-content:center;align-items:center;height:100vh;}img,video{max-width:100%;max-height:100vh;}</style></head><body>" + tag + "</body></html>";
outputFile = "meme_creds.csv";
isDefaultHtml = true;
}});
}
loopOptions(fileOptions);
}

String EvilPortal::wifiLoadPage() {
return String(
"<!DOCTYPE html><html><head> <meta charset='UTF-8'> <meta name='viewport' "
Expand Down
1 change: 1 addition & 0 deletions src/modules/wifi/evil_portal.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class EvilPortal {
void printDeauthStatus(void);
void printLastCapturedCredential(void);
void loadCustomHtml(void);
void loadMemeHtml(void);
void loadDefaultHtml(void);
void loadDefaultHtml_one(void);
String wifiLoadPage(void);
Expand Down