diff --git a/RemoteIDSpoofer/RemoteIDSpoofer.ino b/RemoteIDSpoofer/RemoteIDSpoofer.ino index 1f8f9bd..974083e 100644 --- a/RemoteIDSpoofer/RemoteIDSpoofer.ino +++ b/RemoteIDSpoofer/RemoteIDSpoofer.ino @@ -1,16 +1,32 @@ // ESP8266 RemoteID spoofer -// Heavily adapted from https://github.com/sxjack/uav_electronic_ids +#include "frontend.h" #include "spoofer.h" const int num_spoofers = 16; -static Spoofer spoofers[num_spoofers]; +Spoofer spoofers[num_spoofers]; void setup() { Serial.begin(115200); + + // start the frontend and don't exit until either timer elapse or user ends it + // the timer here is set at 2 minutes + unsigned long timer = millis(); + Frontend frontend; + while (!frontend.do_spoof && (millis() - timer < 120000)) { + frontend.handleClient(); + } + + // instantiate the spoofers and change locations + Serial.println("Starting Spoofers"); + for (int i = 0; i < num_spoofers; i++) { + spoofers[i].init(); + spoofers[i].updateLocation(frontend.latitude, frontend.longitude); + } } void loop() { + // do the spoofing for (int i = 0; i < num_spoofers; i++) { spoofers[i].update(); delay(200 / num_spoofers); diff --git a/RemoteIDSpoofer/frontend.cpp b/RemoteIDSpoofer/frontend.cpp new file mode 100644 index 0000000..ebecedd --- /dev/null +++ b/RemoteIDSpoofer/frontend.cpp @@ -0,0 +1,93 @@ +#include "frontend.h" + +Frontend::Frontend() + : server(80) +{ + // AP parameters + Serial.print("Setting soft-AP ... "); + if(WiFi.softAP("ESP_RIDS", "makkauhijau")) { + Serial.print("Access Point IP: "); + Serial.println(WiFi.softAPIP()); + Serial.println("Ready"); + } else { + Serial.println("Failed!"); + } + + // Specify the functions which will be executed upon corresponding GET request + server.on("/", std::bind(&Frontend::handleOnConnect, this)); + server.on("/getlocation", std::bind(&Frontend::handleForm, this)); + server.on("/start", std::bind(&Frontend::startSpoof, this)); + server.onNotFound(std::bind(&Frontend::handleNotFound, this)); + + // Starting the Server + server.begin(); +} + +void Frontend::handleClient() { + server.handleClient(); +} + +void Frontend::handleOnConnect() { + Serial.println("Client Connected"); + server.send(200, "text/html", HTML()); +} + +void Frontend::handleNotFound() { + server.send(404, "text/plain", "Not found"); +} + +void Frontend::startSpoof() { + do_spoof = true; + WiFi.softAPdisconnect (true); +} + +void Frontend::handleForm() { + latitude = server.arg("latitude").toFloat(); + longitude = server.arg("longitude").toFloat(); + server.send(200, "text/html", HTML()); +} + +String Frontend::HTML() { + String msg = R"rawliteral( + + +
+ +Current Coordinates: "; + msg += String(latitude); + msg += ", "; + msg += String(longitude); + msg += "
\n"; + + msg += "Pressing this button will cause the device to turn off the web server and enter spoofing only mode.
\n"; + msg += "Please confirm your GPS coordinates before doing so.
\n"; + msg += "You will not be able to reconnect to this page without a power cycle.
\n"; + msg += "Start Spoofing\n"; + + msg += R"rawliteral( + + + )rawliteral"; + + return msg; +} \ No newline at end of file diff --git a/RemoteIDSpoofer/frontend.h b/RemoteIDSpoofer/frontend.h new file mode 100644 index 0000000..d3c15b6 --- /dev/null +++ b/RemoteIDSpoofer/frontend.h @@ -0,0 +1,24 @@ +#include