mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 15:10:06 +01:00
Renamed SerialInterface to CLI
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "SerialInterface.h"
|
||||
#include "CLI.h"
|
||||
|
||||
/*
|
||||
A short introduction for the reader:
|
||||
@@ -14,42 +14,42 @@
|
||||
Also: NEVER CHANGE A RUNNING SYSTEM!
|
||||
*/
|
||||
|
||||
SerialInterface::SerialInterface() {
|
||||
CLI::CLI() {
|
||||
list = new SimpleList<String>;
|
||||
}
|
||||
|
||||
void SerialInterface::load() {
|
||||
void CLI::load() {
|
||||
checkFile(execPath, String());
|
||||
executing = true;
|
||||
}
|
||||
|
||||
void SerialInterface::load(String filepath) {
|
||||
void CLI::load(String filepath) {
|
||||
execPath = filepath;
|
||||
load();
|
||||
}
|
||||
|
||||
void SerialInterface::enable() {
|
||||
void CLI::enable() {
|
||||
enabled = true;
|
||||
prntln(CLI_SERIAL_ENABLED);
|
||||
}
|
||||
|
||||
void SerialInterface::disable() {
|
||||
void CLI::disable() {
|
||||
enabled = true;
|
||||
prntln(CLI_SERIAL_DISABLED);
|
||||
}
|
||||
|
||||
void SerialInterface::error(String message) {
|
||||
void CLI::error(String message) {
|
||||
prnt(CLI_ERROR);
|
||||
prntln(message);
|
||||
}
|
||||
|
||||
void SerialInterface::parameterError(String parameter) {
|
||||
void CLI::parameterError(String parameter) {
|
||||
prnt(CLI_ERROR_PARAMETER);
|
||||
prnt(parameter);
|
||||
prntln(DOUBLEQUOTES);
|
||||
}
|
||||
|
||||
bool SerialInterface::isInt(String str) {
|
||||
bool CLI::isInt(String str) {
|
||||
if (eqls(str, STR_TRUE) || eqls(str, STR_FALSE)) return true;
|
||||
|
||||
for (uint32_t i = 0; i < str.length(); i++)
|
||||
@@ -58,13 +58,13 @@ bool SerialInterface::isInt(String str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int SerialInterface::toInt(String str) {
|
||||
int CLI::toInt(String str) {
|
||||
if (eqls(str, STR_TRUE)) return 1;
|
||||
else if (eqls(str, STR_FALSE)) return 0;
|
||||
else return str.toInt();
|
||||
}
|
||||
|
||||
uint32_t SerialInterface::getTime(String time) {
|
||||
uint32_t CLI::getTime(String time) {
|
||||
int value = time.toInt();
|
||||
|
||||
if (value < 0) value = -value;
|
||||
@@ -75,11 +75,11 @@ uint32_t SerialInterface::getTime(String time) {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool SerialInterface::eqlsCMD(int i, const char* keyword) {
|
||||
bool CLI::eqlsCMD(int i, const char* keyword) {
|
||||
return eqls(list->get(i).c_str(), keyword);
|
||||
}
|
||||
|
||||
void SerialInterface::stopScript() {
|
||||
void CLI::stopScript() {
|
||||
if (continuously) {
|
||||
continuously = false;
|
||||
prnt(CLI_STOPPED_SCRIPT);
|
||||
@@ -90,7 +90,7 @@ void SerialInterface::stopScript() {
|
||||
}
|
||||
}
|
||||
|
||||
void SerialInterface::update() {
|
||||
void CLI::update() {
|
||||
if (executing) {
|
||||
if (execPath.charAt(0) != SLASH) execPath = SLASH + execPath;
|
||||
prnt(CLI_EXECUTING);
|
||||
@@ -130,7 +130,7 @@ void SerialInterface::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void SerialInterface::runCommands(String input) {
|
||||
void CLI::runCommands(String input) {
|
||||
String tmp;
|
||||
|
||||
for (uint32_t i = 0; i < input.length(); i++) {
|
||||
@@ -150,7 +150,7 @@ void SerialInterface::runCommands(String input) {
|
||||
if (tmp.length() > 0) runCommand(tmp);
|
||||
}
|
||||
|
||||
void SerialInterface::runCommand(String input) {
|
||||
void CLI::runCommand(String input) {
|
||||
input.replace(String(NEWLINE), String());
|
||||
input.replace(String(CARRIAGERETURN), String());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef SerialInterface_h
|
||||
#define SerialInterface_h
|
||||
#ifndef CLI_h
|
||||
#define CLI_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -44,9 +44,9 @@ extern void printWifiStatus();
|
||||
extern void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal);
|
||||
extern void wifiUpdate();
|
||||
|
||||
class SerialInterface {
|
||||
class CLI {
|
||||
public:
|
||||
SerialInterface();
|
||||
CLI();
|
||||
void enable();
|
||||
void load();
|
||||
void load(String filepath);
|
||||
@@ -81,4 +81,4 @@ class SerialInterface {
|
||||
bool eqlsCMD(int i, const char* keyword);
|
||||
};
|
||||
|
||||
#endif // ifndef SerialInterface_h
|
||||
#endif // ifndef CLI_h
|
||||
@@ -35,7 +35,7 @@ void Settings::load() {
|
||||
|
||||
if (data.containsKey(keyword(S_DISPLAY_TIMEOUT))) setDisplayTimeout(data.get<uint32_t>(keyword(S_DISPLAY_TIMEOUT)));
|
||||
|
||||
if (data.containsKey(keyword(S_SERIALINTERFACE))) setSerialInterface(data.get<bool>(keyword(S_SERIALINTERFACE)));
|
||||
if (data.containsKey(keyword(S_SERIALINTERFACE))) setCLI(data.get<bool>(keyword(S_SERIALINTERFACE)));
|
||||
|
||||
if (data.containsKey(keyword(S_SERIAL_ECHO))) setSerialEcho(data.get<bool>(keyword(S_SERIAL_ECHO)));
|
||||
|
||||
@@ -117,7 +117,7 @@ void Settings::reset() {
|
||||
setAutosaveTime(10000);
|
||||
setDisplayInterface(USE_DISPLAY);
|
||||
setDisplayTimeout(600);
|
||||
setSerialInterface(true);
|
||||
setCLI(true);
|
||||
setSerialEcho(true);
|
||||
setWebInterface(true);
|
||||
setWebSpiffs(false);
|
||||
@@ -163,7 +163,7 @@ String Settings::getJsonStr() {
|
||||
data.set(keyword(S_AUTOSAVETIME), autosaveTime);
|
||||
data.set(keyword(S_DISPLAYINTERFACE), displayInterface);
|
||||
data.set(keyword(S_DISPLAY_TIMEOUT), displayTimeout);
|
||||
data.set(keyword(S_SERIALINTERFACE), serialInterface);
|
||||
data.set(keyword(S_SERIALINTERFACE), cli);
|
||||
data.set(keyword(S_SERIAL_ECHO), serialEcho);
|
||||
data.set(keyword(S_WEBINTERFACE), webInterface);
|
||||
data.set(keyword(S_WEB_SPIFFS), webSpiffs);
|
||||
@@ -230,7 +230,7 @@ void Settings::set(const char* str, String value) {
|
||||
if (eqls(str, S_BEACONCHANNEL)) setBeaconChannel(s2b(value));
|
||||
else if (eqls(str, S_AUTOSAVE)) setAutosave(s2b(value));
|
||||
else if (eqls(str, S_BEACONINTERVAL)) setBeaconInterval(s2b(value));
|
||||
else if (eqls(str, S_SERIALINTERFACE)) setSerialInterface(s2b(value));
|
||||
else if (eqls(str, S_SERIALINTERFACE)) setCLI(s2b(value));
|
||||
else if (eqls(str, S_DISPLAYINTERFACE)) setDisplayInterface(s2b(value));
|
||||
else if (eqls(str, S_WEBINTERFACE)) setWebInterface(s2b(value));
|
||||
else if (eqls(str, S_RANDOMTX)) setRandomTX(s2b(value));
|
||||
@@ -282,7 +282,7 @@ String Settings::get(const char* str) {
|
||||
else if (eqls(str, S_BEACONCHANNEL)) return b2s(beaconChannel);
|
||||
else if (eqls(str, S_AUTOSAVE)) return b2s(autosave);
|
||||
else if (eqls(str, S_BEACONINTERVAL)) return b2s(beaconInterval);
|
||||
else if (eqls(str, S_SERIALINTERFACE)) return b2s(serialInterface);
|
||||
else if (eqls(str, S_SERIALINTERFACE)) return b2s(cli);
|
||||
else if (eqls(str, S_DISPLAYINTERFACE)) return b2s(displayInterface);
|
||||
else if (eqls(str, S_WEBINTERFACE)) return b2s(webInterface);
|
||||
else if (eqls(str, S_RANDOMTX)) return b2s(randomTX);
|
||||
@@ -371,8 +371,8 @@ String Settings::getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
bool Settings::getSerialInterface() {
|
||||
return serialInterface;
|
||||
bool Settings::getCLI() {
|
||||
return cli;
|
||||
}
|
||||
|
||||
bool Settings::getDisplayInterface() {
|
||||
@@ -516,8 +516,8 @@ void Settings::setPassword(String password) {
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setSerialInterface(bool serialInterface) {
|
||||
Settings::serialInterface = serialInterface;
|
||||
void Settings::setCLI(bool cli) {
|
||||
Settings::cli = cli;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class Settings {
|
||||
uint8_t getChannel();
|
||||
String getSSID();
|
||||
String getPassword();
|
||||
bool getSerialInterface();
|
||||
bool getCLI();
|
||||
bool getDisplayInterface();
|
||||
bool getWebInterface();
|
||||
uint16_t getChTime();
|
||||
@@ -78,7 +78,7 @@ class Settings {
|
||||
void setChannel(uint8_t channel);
|
||||
void setSSID(String ssid);
|
||||
void setPassword(String password);
|
||||
void setSerialInterface(bool serialInterface);
|
||||
void setCLI(bool cli);
|
||||
void setDisplayInterface(bool displayInterface);
|
||||
void setWebInterface(bool webInterface);
|
||||
void setChTime(uint16_t chTime);
|
||||
@@ -106,7 +106,7 @@ class Settings {
|
||||
bool beaconChannel = false;
|
||||
bool autosave = true;
|
||||
bool beaconInterval = false;
|
||||
bool serialInterface = true;
|
||||
bool cli = true;
|
||||
bool displayInterface = USE_DISPLAY;
|
||||
bool webInterface = true;
|
||||
bool webSpiffs = false;
|
||||
|
||||
@@ -16,7 +16,7 @@ extern "C" {
|
||||
#include "SSIDs.h"
|
||||
#include "Scan.h"
|
||||
#include "Attack.h"
|
||||
#include "SerialInterface.h"
|
||||
#include "CLI.h"
|
||||
#include "DisplayUI.h"
|
||||
#include "A_config.h"
|
||||
#include "webfiles.h"
|
||||
@@ -32,7 +32,7 @@ Accesspoints accesspoints;
|
||||
Stations stations;
|
||||
Scan scan;
|
||||
Attack attack;
|
||||
SerialInterface serialInterface;
|
||||
CLI cli;
|
||||
DisplayUI displayUI;
|
||||
|
||||
#include "wifi.h"
|
||||
@@ -100,7 +100,7 @@ void setup() {
|
||||
// load everything else
|
||||
names.load();
|
||||
ssids.load();
|
||||
serialInterface.load();
|
||||
cli.load();
|
||||
|
||||
// create scan.json
|
||||
scan.setup();
|
||||
@@ -119,8 +119,8 @@ void setup() {
|
||||
loadWifiConfigDefaults();
|
||||
|
||||
// dis/enable serial command interface
|
||||
if (settings.getSerialInterface()) {
|
||||
serialInterface.enable();
|
||||
if (settings.getCLI()) {
|
||||
cli.enable();
|
||||
} else {
|
||||
prntln(SETUP_SERIAL_WARNING);
|
||||
Serial.flush();
|
||||
@@ -144,7 +144,7 @@ void loop() {
|
||||
|
||||
attack.update(); // run attacks
|
||||
displayUI.update();
|
||||
serialInterface.update(); // read and run serial input
|
||||
cli.update(); // read and run serial input
|
||||
scan.update(); // run scan
|
||||
ssids.update(); // run random mode, if enabled
|
||||
led->update(); // update LED color
|
||||
|
||||
@@ -389,7 +389,7 @@ void startAP(String path, String ssid, String password, uint8_t ch, bool hidden,
|
||||
|
||||
server.on(String(F("/run")).c_str(), HTTP_GET, []() {
|
||||
server.send(200, str(W_TXT), str(W_OK).c_str());
|
||||
serialInterface.runCommands(server.arg("cmd"));
|
||||
cli.runCommands(server.arg("cmd"));
|
||||
});
|
||||
|
||||
server.on(String(F("/attack.json")).c_str(), HTTP_GET, []() {
|
||||
|
||||
Reference in New Issue
Block a user