Skip to content
Merged
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
51 changes: 32 additions & 19 deletions src/modules/wifi/evil_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,23 @@ bool EvilPortal::setup() {
if (apGateway == IPAddress((uint32_t)0)) {
if (!apGateway.fromString(bruceConfig.evilPortalGatewayIp)) apGateway = IPAddress(172, 0, 0, 1);
}
if (apName.isEmpty()) {
apName_from_keyboard();
if (apName.isEmpty()) apName = "Free Wifi";
if (apName.isEmpty() && !_autoMode) {
if (bruceConfig.evilWifiNames.empty()) {
apName_from_keyboard();
} else {
options = {
{"Custom Wifi", [this]() { apName_from_keyboard(); }}
};
for (const auto &_wifi : bruceConfig.evilWifiNames) {
options.emplace_back(_wifi.c_str(), [this, _wifi]() { this->apName = _wifi; });
}
loopOptions(options);
}
}
if (apName.isEmpty()) apName = "Free Wifi";
if (apName.length() > 32) apName = apName.substring(0, 32);

if (!_autoMode && !_verifyPwd) apPassword_from_keyboard();

if (_autoMode) {
if (apName.indexOf("router") != -1 || apName.indexOf("update") != -1 ||
Expand Down Expand Up @@ -94,20 +107,6 @@ bool EvilPortal::setup() {
memcpy(deauth_frame, deauth_frame_default, sizeof(deauth_frame_default));
wsl_bypasser_send_raw_frame(&ap_record, _channel);

if (apName == "") {
if (bruceConfig.evilWifiNames.empty()) {
apName_from_keyboard();
} else {
options = {
{"Custom Wifi", [this]() { apName_from_keyboard(); }}
};
for (const auto &_wifi : bruceConfig.evilWifiNames) {
options.emplace_back(_wifi.c_str(), [this, _wifi]() { this->apName = _wifi; });
}
loopOptions(options);
}
}

options = {
{"Default",
[this]() {
Expand All @@ -134,7 +133,7 @@ void EvilPortal::beginAP() {
if (!WiFi.softAPConfig(apGateway, apGateway, IPAddress(255, 255, 255, 0))) {
Serial.println("[PORTAL] softAPConfig failed");
}
if (!WiFi.softAP(apName, emptyString, _channel)) {
if (!WiFi.softAP(apName, apPassword.isEmpty() ? emptyString : apPassword, _channel)) {
Serial.printf("[PORTAL] softAP failed for SSID '%s' on ch%d\n", apName.c_str(), _channel);
}
wifiConnected = true;
Expand Down Expand Up @@ -265,7 +264,7 @@ void EvilPortal::restartWiFi(bool reset) {
_captiveHandler = nullptr;

wifiDisconnect();
WiFi.softAP(apName, emptyString, _channel);
WiFi.softAP(apName, apPassword.isEmpty() ? emptyString : apPassword, _channel);
vTaskDelay(100 / portTICK_PERIOD_MS);

setupRoutes();
Expand Down Expand Up @@ -805,6 +804,20 @@ void EvilPortal::apName_from_keyboard() {
if (apName == "\x1B") apName = "Free Wifi";
}

void EvilPortal::apPassword_from_keyboard() {
String pwd = "";
while (true) {
pwd = keyboard(pwd, 63, "AP Password (empty=open, 8-63):");
if (pwd == "\x1B") {
pwd = "";
break;
}
if (pwd.isEmpty() || (pwd.length() >= 8 && pwd.length() <= 63)) break;
displayWarning("Password must be 8-63 chars or empty", true);
}
apPassword = pwd;
}

bool EvilPortal::verifyCreds(String &Ssid, String &Password) {
bool isConnected = false;
bool temp = _deauth;
Expand Down
2 changes: 2 additions & 0 deletions src/modules/wifi/evil_portal.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class EvilPortal {

private:
String apName = "";
String apPassword = "";
uint8_t _channel;
bool _deauth;
bool isDeauthHeld = false;
Expand Down Expand Up @@ -109,6 +110,7 @@ class EvilPortal {
String ssid_POST(void);

void apName_from_keyboard(void);
void apPassword_from_keyboard(void);
};

#endif