Skip to content

Commit

Permalink
Add semi-automatic firmware updates
Browse files Browse the repository at this point in the history
  • Loading branch information
exploitagency committed Aug 1, 2017
1 parent 2ce2ac2 commit aa1f272
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion source/ESP_Code/ESP_Code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <ESP8266HTTPUpdateServer.h>
#include <ESP8266mDNS.h>
#include <FS.h>
Expand All @@ -58,6 +60,10 @@ ESP8266WebServer server(80);
ESP8266WebServer httpServer(1337);
ESP8266HTTPUpdateServer httpUpdater;

HTTPClient http;
String version = "2.3.0";
String latestversion = "";

const char* update_path = "/update";
int accesspointmode;
char ssid[32];
Expand Down Expand Up @@ -482,9 +488,31 @@ void setup(void)
server.on("/settings", handleSettings);

server.on("/firmware", [](){
server.send(200, "text/html", String()+"<html><body style=\"height: 100%;\"><a href=\"/\"><- BACK TO INDEX</a><br><br>Open Arduino IDE.<br>Pull down Sketch Menu then select Export Compiled Binary.<br>Open Sketch Folder and upload the exported BIN file.<br>You may need to manually reboot the device to reconnect.<br><iframe style =\"border: 0; height: 100%;\" src=\"http://"+local_IPstr+":1337/update\"><a href=\"http://"+local_IPstr+":1337/update\">Click here to Upload Firmware</a></iframe></body></html>");
latestversion = "";
http.begin("http://legacysecuritygroup.com/esploit.php");
int httpCode = http.GET();
if (httpCode > 0) {
latestversion = http.getString();
}
http.end();
if (version == latestversion && latestversion != "") {
server.send(200, "text/html", String()+"<html><body><a href=\"/\"><- BACK TO INDEX</a><br><br><table><tr><th colspan=\"2\">ESPloit Firmware Info</th></tr><tr><td>Version Installed:</td><td>"+version+"</td></tr><tr><td>Latest Version:</td><td>"+latestversion+"</td></tr></table>Firmware is up to date<br><br><iframe name=\"iframe\" style =\"border: 0;\" src=\"http://"+local_IPstr+":1337/update\"><a href=\"http://"+local_IPstr+":1337/update\">Click here to Upload Firmware</a></iframe><br><br>Manually install firmware:<br>Open Arduino IDE.<br>Pull down Sketch Menu then select Export Compiled Binary.<br>Open Sketch Folder and upload the exported BIN file.<br>You may need to manually reboot the device to reconnect.</body></html>");
}
else if (version != latestversion && latestversion != "") {
server.send(200, "text/html", String()+"<html><body><a href=\"/\"><- BACK TO INDEX</a><br><br><table><tr><th colspan=\"2\">ESPloit Firmware Info</th></tr><tr><td>Version Installed:</td><td>"+version+"</td></tr><tr><td>Latest Version:</td><td>"+latestversion+"</td></tr></table><a href=\"/autoupdatefirmware\" target=\"iframe\">Click to automatically update firmware</a><br><br><iframe name=\"iframe\" style =\"border: 0;\" src=\"http://"+local_IPstr+":1337/update\"><a href=\"http://"+local_IPstr+":1337/update\">Click here to Upload Firmware</a></iframe><br><br>Manually install firmware:<br>Open Arduino IDE.<br>Pull down Sketch Menu then select Export Compiled Binary.<br>Open Sketch Folder and upload the exported BIN file.<br>You may need to manually reboot the device to reconnect.</body></html>");
}
else if (httpCode < 0) {
server.send(200, "text/html", String()+"<html><body><a href=\"/\"><- BACK TO INDEX</a><br><br><table><tr><th colspan=\"2\">ESPloit Firmware Info</th></tr><tr><td>Version Installed:</td><td>"+version+"</td></tr><tr><td>Latest Version:</td><td>?????</td></tr></table>Could not connect to the update server<br><br><iframe name=\"iframe\" style =\"border: 0;\" src=\"http://"+local_IPstr+":1337/update\"><a href=\"http://"+local_IPstr+":1337/update\">Click here to Upload Firmware</a></iframe><br><br>Manually install firmware:<br>Open Arduino IDE.<br>Pull down Sketch Menu then select Export Compiled Binary.<br>Open Sketch Folder and upload the exported BIN file.<br>You may need to manually reboot the device to reconnect.</body></html>");
}
});

server.on("/autoupdatefirmware", [](){
if(!server.authenticate(update_username, update_password))
return server.requestAuthentication();
server.send(200, "text/html", String()+"<html><body>Upgrading firmware...");
ESPhttpUpdate.update("http://legacysecuritygroup.com/esploit.php?tag=" + version);
});

server.on("/livepayload", [](){
server.send(200, "text/html", String()+"<html><body style=\"height: 100%;\"><a href=\"/\"><- BACK TO INDEX</a><br><br><a href=\"/listpayloads\">List Payloads</a><br><br><a href=\"/uploadpayload\">Upload Payload</a><br><br><FORM action=\"/runlivepayload\" method=\"post\" id=\"live\" target=\"iframe\">Payload: <br><textarea style =\"width: 100%;\" form=\"live\" rows=\"4\" cols=\"50\" name=\"livepayload\"></textarea><br><br><INPUT type=\"radio\" name=\"livepayloadpresent\" value=\"1\" hidden=\"1\" checked=\"checked\"><INPUT type=\"submit\" value=\"Run Payload\"></form><br><hr><br><iframe style =\"border: 0; height: 100%; width: 100%;\" src=\"http://"+local_IPstr+"/runlivepayload\" name=\"iframe\"></iframe></body></html>");
});
Expand Down
Binary file modified source/ESP_Code/ESP_Code.ino.generic.bin
Binary file not shown.

0 comments on commit aa1f272

Please sign in to comment.