mirror of
https://github.com/jjshoots/RemoteIDSpoofer.git
synced 2026-01-13 15:37:06 +00:00
add webserver configuration
This commit is contained in:
parent
da62e7ca68
commit
d4412e18c0
@ -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);
|
||||
|
||||
93
RemoteIDSpoofer/frontend.cpp
Normal file
93
RemoteIDSpoofer/frontend.cpp
Normal file
@ -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(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">
|
||||
<title>Remote ID Spoofer</title>
|
||||
<style>
|
||||
html{font-family:Helvetica; display:inline-block; margin:0px auto; text-align:center;}
|
||||
body{margin-top: 50px;} h1{color: #444444; margin: 50px auto 30px;} h3{color:#444444; margin-bottom: 50px;}
|
||||
.button{display:block; width:80px; background-color:#f48100; border:none; color:white; padding: 13px 30px; text-decoration:none; font-size:25px; margin: 0px auto 35px; cursor:pointer; border-radius:4px;}
|
||||
.button-on{background-color:#f48100;}
|
||||
.button-on:active{background-color:#f48100;}
|
||||
.button-off{background-color:#26282d;}
|
||||
.button-off:active{background-color:#26282d;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Remote ID Spoofer</h1>
|
||||
<form action="/getlocation">
|
||||
Latitude: <input type="text" name="latitude">
|
||||
Longitude: <input type="text" name="longitude">
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
)rawliteral";
|
||||
|
||||
msg += "<p>Current Coordinates: ";
|
||||
msg += String(latitude);
|
||||
msg += ", ";
|
||||
msg += String(longitude);
|
||||
msg += "</p>\n";
|
||||
|
||||
msg += "<p>Pressing this button will cause the device to turn off the web server and enter spoofing only mode.</p>\n";
|
||||
msg += "<p>Please confirm your GPS coordinates before doing so.</p>\n";
|
||||
msg += "<p>You will not be able to reconnect to this page without a power cycle.</p>\n";
|
||||
msg += "<a class=\"button button-on\" href=\"/start\">Start Spoofing</a>\n";
|
||||
|
||||
msg += R"rawliteral(
|
||||
</body>
|
||||
</html>
|
||||
)rawliteral";
|
||||
|
||||
return msg;
|
||||
}
|
||||
24
RemoteIDSpoofer/frontend.h
Normal file
24
RemoteIDSpoofer/frontend.h
Normal file
@ -0,0 +1,24 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
#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
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -34,7 +34,8 @@ class Spoofer {
|
||||
String getID();
|
||||
|
||||
public:
|
||||
Spoofer();
|
||||
void init();
|
||||
void updateLocation(float latitude, float longitude);
|
||||
void update();
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user