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( + + + + + Remote ID Spoofer + + + +

Remote ID Spoofer

+
+ Latitude: + Longitude: + +
+ )rawliteral"; + + msg += "

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 +#include + +#ifndef FRONTEND_H +#define FRONTEND_H + +class Frontend { + private: + ESP8266WebServer server; + String HTML(); + void handleOnConnect(); + void handleNotFound(); + void startSpoof(); + void handleForm(); + + public: + Frontend(); + void handleClient(); + bool do_spoof = false; + double latitude = 52.439100; + double longitude = -1.503900; +}; + +#endif \ No newline at end of file diff --git a/RemoteIDSpoofer/spoofer.cpp b/RemoteIDSpoofer/spoofer.cpp index bc25c14..f32cf48 100644 --- a/RemoteIDSpoofer/spoofer.cpp +++ b/RemoteIDSpoofer/spoofer.cpp @@ -1,6 +1,6 @@ #include "spoofer.h" -Spoofer::Spoofer() { +void Spoofer::init() { // time things memset(&clock_tm,0,sizeof(struct tm)); clock_tm.tm_hour = 10; @@ -19,16 +19,16 @@ Spoofer::Spoofer() { utm_parameters.EU_class = 5; squitter.init(&utm_parameters); memset(&utm_data,0,sizeof(utm_data)); +} - // define location - // 52° 24' 24.4404" -1° 29' 36.564"W - // plus some noise +void Spoofer::updateLocation(float latitude, float longitude) { + // define location plus some noise lat_d = utm_data.latitude_d = - utm_data.base_latitude = 52.0 + (24.0 / 60.0) + (24.4404 / 3600.0) + (float) (rand() % 10 - 5) / 10000.0; + utm_data.base_latitude = latitude + (float) (rand() % 10 - 5) / 10000.0; long_d = utm_data.longitude_d = - utm_data.base_longitude = -1.0 - (29.0 / 60.0) - (36.564 / 3600.0) + (float) (rand() % 10 - 5) / 10000.0; + utm_data.base_longitude = longitude + (float) (rand() % 10 - 5) / 10000.0; utm_data.base_alt_m = (float) (rand() % 1000) / 10.0; utm_data.base_valid = 1; @@ -48,7 +48,7 @@ void Spoofer::update() { utm_data.speed_kn = constrain(utm_data.speed_kn + (rand() % 5) - 2, 1, 20); speed_m_x = ((float) utm_data.speed_kn) * 0.514444 * 0.2; // Because we update every 200 ms. - // randomly pick a direction to head and update the heading + // randomly pick a direction to head float ranf = (float) (rand() % 1000 - 500) / 1000.0; int dir_change = (int) (max_dir_change * ranf); utm_data.heading = (utm_data.heading + dir_change + 360) % 360; @@ -64,7 +64,7 @@ void Spoofer::update() { utm_data.alt_msl_m = utm_data.base_alt_m + z; utm_data.alt_agl_m = z; - // update the x, y + // update the x, y utm_data.latitude_d = utm_data.base_latitude + (y / m_deg_lat); utm_data.longitude_d = utm_data.base_longitude + (x / m_deg_long); diff --git a/RemoteIDSpoofer/spoofer.h b/RemoteIDSpoofer/spoofer.h index d42ca21..de793d3 100644 --- a/RemoteIDSpoofer/spoofer.h +++ b/RemoteIDSpoofer/spoofer.h @@ -34,7 +34,8 @@ class Spoofer { String getID(); public: - Spoofer(); + void init(); + void updateLocation(float latitude, float longitude); void update(); };