Skip to content

Commit 401d5c1

Browse files
author
Spacehuhn
committed
Refactored wifi.h into module
1 parent 74067f0 commit 401d5c1

File tree

8 files changed

+484
-432
lines changed

8 files changed

+484
-432
lines changed

esp8266_deauther/CLI.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <LittleFS.h>
44
#include "settings.h"
5+
#include "wifi.h"
56

67
/*
78
Shitty code used less resources so I will keep this clusterfuck as it is,
@@ -869,7 +870,7 @@ void CLI::runCommand(String input) {
869870
prnt(int(f.size()));
870871
prntln(str(CLI_BYTES));
871872
}
872-
printWifiStatus();
873+
wifi::printStatus();
873874
prntln(CLI_SYSTEM_FOOTER);
874875
}
875876

@@ -1093,7 +1094,7 @@ void CLI::runCommand(String input) {
10931094
// ------- loop function ----- //
10941095
currentTime = millis();
10951096

1096-
wifiUpdate(); // manage access point
1097+
wifi::update(); // manage access point
10971098
scan.update(); // run scan
10981099
attack.update(); // run attacks
10991100
ssids.update(); // run random mode, if enabled
@@ -1217,12 +1218,12 @@ void CLI::runCommand(String input) {
12171218
}
12181219
}
12191220

1220-
startAP(path, ssid, password, ch, hidden, captivePortal);
1221+
wifi::startNewAP(path, ssid, password, ch, hidden, captivePortal);
12211222
}
12221223

12231224
// stopap
12241225
else if (eqlsCMD(0, CLI_STOPAP)) {
1225-
stopAP();
1226+
wifi::stopAP();
12261227
}
12271228

12281229
// ===== SCREEN ===== //

esp8266_deauther/CLI.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ extern bool appendFile(String path, String& buf);
4141
extern bool removeLines(String path, int lineFrom, int lineTo);
4242
extern bool replaceLine(String path, int line, String& buf);
4343
extern bool equalsKeyword(const char* str, const char* keyword);
44-
extern void printWifiStatus();
45-
extern void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal);
46-
extern void wifiUpdate();
4744

4845
class CLI {
4946
public:

esp8266_deauther/Scan.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "Scan.h"
22

33
#include "settings.h"
4+
#include "wifi.h"
45

56
Scan::Scan() {
67
list = new SimpleList<uint16_t>;
@@ -104,7 +105,7 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
104105
prntln();
105106

106107
// enable sniffer
107-
stopAP();
108+
wifi::stopAP();
108109
wifi_promiscuous_enable(true);
109110
}
110111

@@ -120,15 +121,15 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
120121
prntln(channelHop ? str(SC_ONE_TO) + (String)14 : (String)wifi_channel);
121122

122123
// enable sniffer
123-
stopAP();
124+
wifi::stopAP();
124125
wifi_promiscuous_enable(true);
125126
}
126127

127128
/* Stop scan */
128129
else if (mode == SCAN_MODE_OFF) {
129130
wifi_promiscuous_enable(false);
130131

131-
if (settings::getWebSettings().enabled) resumeAP();
132+
if (settings::getWebSettings().enabled) wifi::resumeAP();
132133
prntln(SC_STOPPED);
133134
save(true);
134135

esp8266_deauther/Scan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ extern void setWifiChannel(uint8_t ch);
2929
extern bool appendFile(String path, String& buf);
3030
extern bool writeFile(String path, String& buf);
3131
extern void readFileToSerial(const String path);
32-
extern void resumeAP();
33-
extern void stopAP();
3432
extern String escape(String str);
3533

3634
class Scan {

esp8266_deauther/esp8266_deauther.ino

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ extern "C" {
3333
#include "CLI.h"
3434
#include "DisplayUI.h"
3535
#include "A_config.h"
36-
#include "webfiles.h"
3736

3837
#include "LED.h"
3938

@@ -108,13 +107,7 @@ void setup() {
108107
settings::save();
109108
#endif // ifndef RESET_SETTINGS
110109

111-
// set mac address
112-
wifi_set_macaddr(STATION_IF, (uint8_t*)settings::getWifiSettings().mac_st);
113-
wifi_set_macaddr(SOFTAP_IF, (uint8_t*)settings::getWifiSettings().mac_ap);
114-
115-
// start WiFi
116-
WiFi.mode(WIFI_OFF);
117-
wifi_set_opmode(STATION_MODE);
110+
wifi::begin();
118111
wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) {
119112
scan.sniffer(buf, len);
120113
});
@@ -126,7 +119,7 @@ void setup() {
126119
}
127120

128121
// copy web files to SPIFFS
129-
copyWebFiles(false);
122+
//copyWebFiles(false);
130123

131124
// load everything else
132125
names.load();
@@ -139,9 +132,6 @@ void setup() {
139132
// set channel
140133
setWifiChannel(settings::getWifiSettings().channel);
141134

142-
// load Wifi settings: SSID, password,...
143-
loadWifiConfigDefaults();
144-
145135
// dis/enable serial command interface
146136
if (settings::getCLISettings().enabled) {
147137
cli.enable();
@@ -152,7 +142,7 @@ void setup() {
152142
}
153143

154144
// start access point/web interface
155-
if (settings::getWebSettings().enabled) startAP();
145+
if (settings::getWebSettings().enabled) wifi::startAP();
156146

157147
// STARTED
158148
prntln(SETUP_STARTED);
@@ -168,7 +158,7 @@ void loop() {
168158
currentTime = millis();
169159

170160
led.update(); // update LED color
171-
wifiUpdate(); // manage access point
161+
wifi::update(); // manage access point
172162
attack.update(); // run attacks
173163
displayUI.update();
174164
cli.update(); // read and run serial input

esp8266_deauther/language.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,36 @@ const char W_BAD_ARGS[] PROGMEM = "BAD ARGS";
541541
const char W_BAD_PATH[] PROGMEM = "BAD PATH";
542542
const char W_FILE_NOT_FOUND[] PROGMEM = "ERROR 404 File Not Found";
543543
const char W_STARTED_AP[] PROGMEM = "Started AP";
544+
const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files
545+
const char W_DEFAULT_LANG[] PROGMEM = "/lang/default.lang";
546+
547+
const char W_HTML[] PROGMEM = "text/html";
548+
const char W_CSS[] PROGMEM = "text/css";
549+
const char W_JS[] PROGMEM = "application/javascript";
550+
const char W_PNG[] PROGMEM = "image/png";
551+
const char W_GIF[] PROGMEM = "image/gif";
552+
const char W_JPG[] PROGMEM = "image/jpeg";
553+
const char W_ICON[] PROGMEM = "image/x-icon";
554+
const char W_XML[] PROGMEM = "text/xml";
555+
const char W_XPDF[] PROGMEM = "application/x-pdf";
556+
const char W_XZIP[] PROGMEM = "application/x-zip";
557+
const char W_GZIP[] PROGMEM = "application/x-gzip";
558+
const char W_JSON[] PROGMEM = "application/json";
559+
const char W_TXT[] PROGMEM = "text/plain";
560+
561+
const char W_DOT_HTM[] PROGMEM = ".htm";
562+
const char W_DOT_HTML[] PROGMEM = ".html";
563+
const char W_DOT_CSS[] PROGMEM = ".css";
564+
const char W_DOT_JS[] PROGMEM = ".js";
565+
const char W_DOT_PNG[] PROGMEM = ".png";
566+
const char W_DOT_GIF[] PROGMEM = ".gif";
567+
const char W_DOT_JPG[] PROGMEM = ".jpg";
568+
const char W_DOT_ICON[] PROGMEM = ".ico";
569+
const char W_DOT_XML[] PROGMEM = ".xml";
570+
const char W_DOT_PDF[] PROGMEM = ".pdf";
571+
const char W_DOT_ZIP[] PROGMEM = ".zip";
572+
const char W_DOT_GZIP[] PROGMEM = ".gz";
573+
const char W_DOT_JSON[] PROGMEM = ".json";
544574

545575
// ===== SETTINGS ====== //
546576
// Version

0 commit comments

Comments
 (0)