Skip to content

Commit e640555

Browse files
authored
Merge pull request #45 from runcom/update-marauder-0310
update esp32_marauder to v0.13.10
2 parents 56bcf20 + dd34ade commit e640555

File tree

86 files changed

+5626
-7816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+5626
-7816
lines changed

esp32cam_marauder/Assets.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ PROGMEM static const unsigned char menu_icons[][66] = {
200200
0x1F, 0xD0, 0x3F, 0x3F, 0xE0, 0x3F, 0x5F, 0xF0, 0x3F, 0xEF, 0xE8, 0x3F,
201201
0xF7, 0xE5, 0x3B, 0xFB, 0xDE, 0x3A, 0x7D, 0xFF, 0x3A, 0xBB, 0x7F, 0x3B,
202202
0xD7, 0x9F, 0x3D, 0xEF, 0xFF, 0x3E, 0xFF, 0x0F, 0x3F, 0xFF, 0xFF, 0x3F,
203-
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F}
203+
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F},
204+
{0xFF, 0xFF, 0xFD, 0xBF, 0x0B, 0xD0, 0xE7, 0xE7, 0xEF, 0xF7, 0xCF, 0xF3, // DISABLED TOUCH: 34
205+
0xAF, 0xF5, 0x6F, 0xF6, 0x6F, 0xF6, 0xAF, 0xF5, 0xCF, 0xF3, 0x0F, 0xF0,
206+
0xE7, 0xE7, 0x0B, 0xD0, 0xFD, 0xBF, 0xFF, 0xFF}
204207
};
205208

206209
#ifndef MARAUDER_MINI

esp32cam_marauder/Buffer.cpp

Lines changed: 93 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Buffer::Buffer(){
66
bufB = (uint8_t*)malloc(BUF_SIZE);
77
}
88

9-
void Buffer::createPcapFile(fs::FS* fs, String fn, bool log){
9+
void Buffer::createFile(String name, bool is_pcap){
1010
int i=0;
11-
if (!log) {
11+
if (is_pcap) {
1212
do{
13-
fileName = "/"+fn+"_"+(String)i+".pcap";
13+
fileName = "/"+name+"_"+(String)i+".pcap";
1414
i++;
1515
} while(fs->exists(fileName));
1616
}
1717
else {
1818
do{
19-
fileName = "/"+fn+"_"+(String)i+".log";
19+
fileName = "/"+name+"_"+(String)i+".log";
2020
i++;
2121
} while(fs->exists(fileName));
2222
}
@@ -27,15 +27,15 @@ void Buffer::createPcapFile(fs::FS* fs, String fn, bool log){
2727
file.close();
2828
}
2929

30-
void Buffer::open(bool log){
30+
void Buffer::open(bool is_pcap){
3131
bufSizeA = 0;
3232
bufSizeB = 0;
3333

3434
bufSizeB = 0;
3535

3636
writing = true;
3737

38-
if (!log) {
38+
if (is_pcap) {
3939
write(uint32_t(0xa1b2c3d4)); // magic number
4040
write(uint16_t(2)); // major version number
4141
write(uint16_t(4)); // minor version number
@@ -46,14 +46,35 @@ void Buffer::open(bool log){
4646
}
4747
}
4848

49-
void Buffer::close(fs::FS* fs){
50-
if(!writing) return;
51-
forceSave(fs);
52-
writing = false;
53-
Serial.println(text01);
49+
void Buffer::openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap) {
50+
bool save_pcap = settings_obj.loadSetting<bool>("SavePCAP");
51+
if (!save_pcap) {
52+
this->fs = NULL;
53+
this->serial = false;
54+
writing = false;
55+
return;
56+
}
57+
this->fs = fs;
58+
this->serial = serial;
59+
if (this->fs) {
60+
createFile(file_name, is_pcap);
61+
}
62+
if (this->fs || this->serial) {
63+
open(is_pcap);
64+
} else {
65+
writing = false;
66+
}
67+
}
68+
69+
void Buffer::pcapOpen(String file_name, fs::FS* fs, bool serial) {
70+
openFile(file_name, fs, serial, true);
5471
}
5572

56-
void Buffer::addPacket(uint8_t* buf, uint32_t len, bool log){
73+
void Buffer::logOpen(String file_name, fs::FS* fs, bool serial) {
74+
openFile(file_name, fs, serial, false);
75+
}
76+
77+
void Buffer::add(const uint8_t* buf, uint32_t len, bool is_pcap){
5778
// buffer is full -> drop packet
5879
if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
5980
//Serial.print(";");
@@ -74,7 +95,7 @@ void Buffer::addPacket(uint8_t* buf, uint32_t len, bool log){
7495

7596
microSeconds -= seconds*1000*1000; // e.g. 45200400 - 45*1000*1000 = 45200400 - 45000000 = 400us (because we only need the offset)
7697

77-
if (!log) {
98+
if (is_pcap) {
7899
write(seconds); // ts_sec
79100
write(microSeconds); // ts_usec
80101
write(len); // incl_len
@@ -84,6 +105,20 @@ void Buffer::addPacket(uint8_t* buf, uint32_t len, bool log){
84105
write(buf, len); // packet payload
85106
}
86107

108+
void Buffer::append(wifi_promiscuous_pkt_t *packet, int len) {
109+
bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
110+
if (save_packet) {
111+
add(packet->payload, len, true);
112+
}
113+
}
114+
115+
void Buffer::append(String log) {
116+
bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
117+
if (save_packet) {
118+
add((const uint8_t*)log.c_str(), log.length(), false);
119+
}
120+
}
121+
87122
void Buffer::write(int32_t n){
88123
uint8_t buf[4];
89124
buf[0] = n;
@@ -109,8 +144,9 @@ void Buffer::write(uint16_t n){
109144
write(buf,2);
110145
}
111146

112-
void Buffer::write(uint8_t* buf, uint32_t len){
147+
void Buffer::write(const uint8_t* buf, uint32_t len){
113148
if(!writing) return;
149+
while(saving) delay(10);
114150

115151
if(useA){
116152
memcpy(&bufA[bufSizeA], buf, len);
@@ -121,127 +157,86 @@ void Buffer::write(uint8_t* buf, uint32_t len){
121157
}
122158
}
123159

124-
void Buffer::save(fs::FS* fs){
125-
if(saving) return; // makes sure the function isn't called simultaneously on different cores
126-
127-
// buffers are already emptied, therefor saving is unecessary
128-
if((useA && bufSizeB == 0) || (!useA && bufSizeA == 0)){
129-
//Serial.printf("useA: %s, bufA %u, bufB %u\n",useA ? "true" : "false",bufSizeA,bufSizeB); // for debug porpuses
130-
return;
131-
}
132-
133-
//Serial.println("saving file");
134-
135-
uint32_t startTime = millis();
136-
uint32_t finishTime;
137-
138-
file = fs->open(fileName, FILE_APPEND);
139-
if (!file) {
140-
Serial.println(text02 + fileName+"'");
141-
//useSD = false;
142-
return;
143-
}
144-
145-
saving = true;
146-
147-
uint32_t len;
148-
149-
if(useA){
150-
file.write(bufB, bufSizeB);
151-
len = bufSizeB;
152-
bufSizeB = 0;
153-
}
154-
else{
155-
file.write(bufA, bufSizeA);
156-
len = bufSizeA;
157-
bufSizeA = 0;
158-
}
159-
160-
file.close();
161-
162-
finishTime = millis() - startTime;
163-
164-
//Serial.printf("\n%u bytes written for %u ms\n", len, finishTime);
165-
166-
saving = false;
167-
168-
}
169-
170-
void Buffer::forceSave(fs::FS* fs){
171-
uint32_t len = bufSizeA + bufSizeB;
172-
if(len == 0) return;
173-
160+
void Buffer::saveFs(){
174161
file = fs->open(fileName, FILE_APPEND);
175162
if (!file) {
176163
Serial.println(text02+fileName+"'");
177-
//useSD = false;
178164
return;
179165
}
180166

181-
saving = true;
182-
writing = false;
183-
184167
if(useA){
185-
186168
if(bufSizeB > 0){
187169
file.write(bufB, bufSizeB);
188-
bufSizeB = 0;
189170
}
190-
191171
if(bufSizeA > 0){
192172
file.write(bufA, bufSizeA);
193-
bufSizeA = 0;
194173
}
195-
196174
} else {
197-
198175
if(bufSizeA > 0){
199176
file.write(bufA, bufSizeA);
200-
bufSizeA = 0;
201177
}
202-
203178
if(bufSizeB > 0){
204179
file.write(bufB, bufSizeB);
205-
bufSizeB = 0;
206180
}
207-
208181
}
209182

210183
file.close();
211-
212-
//Serial.printf("saved %u bytes\n",len);
213-
214-
saving = false;
215-
writing = true;
216184
}
217185

218-
void Buffer::forceSaveSerial() {
219-
uint32_t len = bufSizeA + bufSizeB;
220-
if(len == 0) return;
221-
222-
saving = true;
223-
writing = false;
186+
void Buffer::saveSerial() {
187+
// Saves to main console UART, user-facing app will ignore these markers
188+
// Uses / and ] in markers as they are illegal characters for SSIDs
189+
const char* mark_begin = "[BUF/BEGIN]";
190+
const size_t mark_begin_len = strlen(mark_begin);
191+
const char* mark_close = "[BUF/CLOSE]";
192+
const size_t mark_close_len = strlen(mark_close);
193+
194+
// Additional buffer and memcpy's so that a single Serial.write() is called
195+
// This is necessary so that other console output isn't mixed into buffer stream
196+
uint8_t* buf = (uint8_t*)malloc(mark_begin_len + bufSizeA + bufSizeB + mark_close_len);
197+
uint8_t* it = buf;
198+
memcpy(it, mark_begin, mark_begin_len);
199+
it += mark_begin_len;
224200

225201
if(useA){
226202
if(bufSizeB > 0){
227-
Serial1.write(bufB, bufSizeB);
228-
bufSizeB = 0;
203+
memcpy(it, bufB, bufSizeB);
204+
it += bufSizeB;
229205
}
230206
if(bufSizeA > 0){
231-
Serial1.write(bufA, bufSizeA);
232-
bufSizeA = 0;
207+
memcpy(it, bufA, bufSizeA);
208+
it += bufSizeA;
233209
}
234210
} else {
235211
if(bufSizeA > 0){
236-
Serial1.write(bufA, bufSizeA);
237-
bufSizeA = 0;
212+
memcpy(it, bufA, bufSizeA);
213+
it += bufSizeA;
238214
}
239215
if(bufSizeB > 0){
240-
Serial1.write(bufB, bufSizeB);
241-
bufSizeB = 0;
216+
memcpy(it, bufB, bufSizeB);
217+
it += bufSizeB;
242218
}
243219
}
244220

221+
memcpy(it, mark_close, mark_close_len);
222+
it += mark_close_len;
223+
Serial.write(buf, it - buf);
224+
free(buf);
225+
}
226+
227+
void Buffer::save() {
228+
saving = true;
229+
230+
if((bufSizeA + bufSizeB) == 0){
231+
saving = false;
232+
return;
233+
}
234+
235+
if(this->fs) saveFs();
236+
if(this->serial) saveSerial();
237+
238+
bufSizeA = 0;
239+
bufSizeB = 0;
240+
245241
saving = false;
246-
writing = true;
247242
}

esp32cam_marauder/Buffer.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "Arduino.h"
77
#include "FS.h"
88
#include "settings.h"
9-
//#include "SD_MMC.h"
9+
#include "esp_wifi_types.h"
1010

1111
#define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
1212
#define SNAP_LEN 2324 // max len of each recieved packet
@@ -18,19 +18,23 @@ extern Settings settings_obj;
1818
class Buffer {
1919
public:
2020
Buffer();
21-
void createPcapFile(fs::FS* fs, String fn = "", bool log = false);
22-
void open(bool log = false);
23-
void close(fs::FS* fs);
24-
void addPacket(uint8_t* buf, uint32_t len, bool log = false);
25-
void save(fs::FS* fs);
26-
void forceSave(fs::FS* fs);
27-
void forceSaveSerial();
21+
void pcapOpen(String file_name, fs::FS* fs, bool serial);
22+
void logOpen(String file_name, fs::FS* fs, bool serial);
23+
void append(wifi_promiscuous_pkt_t *packet, int len);
24+
void append(String log);
25+
void save();
2826
private:
27+
void createFile(String name, bool is_pcap);
28+
void open(bool is_pcap);
29+
void openFile(String file_name, fs::FS* fs, bool serial, bool is_pcap);
30+
void add(const uint8_t* buf, uint32_t len, bool is_pcap);
2931
void write(int32_t n);
3032
void write(uint32_t n);
3133
void write(uint16_t n);
32-
void write(uint8_t* buf, uint32_t len);
33-
34+
void write(const uint8_t* buf, uint32_t len);
35+
void saveFs();
36+
void saveSerial();
37+
3438
uint8_t* bufA;
3539
uint8_t* bufB;
3640

@@ -43,6 +47,8 @@ class Buffer {
4347

4448
String fileName = "/0.pcap";
4549
File file;
50+
fs::FS* fs;
51+
bool serial;
4652
};
4753

4854
#endif

esp32cam_marauder/CommandLine.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifdef HAS_SCREEN
99
#include "MenuFunctions.h"
1010
#include "Display.h"
11-
#endif
11+
#endif
1212

1313
#include "WiFiScan.h"
1414
//#include "Web.h"
@@ -80,6 +80,8 @@ const char PROGMEM ATTACK_TYPE_RR[] = "rickroll";
8080
const char PROGMEM LIST_AP_CMD[] = "list";
8181
const char PROGMEM SEL_CMD[] = "select";
8282
const char PROGMEM SSID_CMD[] = "ssid";
83+
const char PROGMEM SAVE_CMD[] = "save";
84+
const char PROGMEM LOAD_CMD[] = "load";
8385

8486
// Bluetooth sniff/scan
8587
const char PROGMEM BT_SPAM_CMD[] = "blespam";
@@ -131,6 +133,8 @@ const char PROGMEM HELP_LIST_AP_CMD_C[] = "list -c";
131133
const char PROGMEM HELP_SEL_CMD_A[] = "select -a/-s/-c <index (comma separated)>/-f \"equals <String> or contains <String>\"";
132134
const char PROGMEM HELP_SSID_CMD_A[] = "ssid -a [-g <count>/-n <name>]";
133135
const char PROGMEM HELP_SSID_CMD_B[] = "ssid -r <index>";
136+
const char PROGMEM HELP_SAVE_CMD[] = "save -a/-s";
137+
const char PROGMEM HELP_LOAD_CMD[] = "load -a/-s";
134138

135139
// Bluetooth sniff/scan
136140
const char PROGMEM HELP_BT_SNIFF_CMD[] = "sniffbt";
@@ -184,7 +188,7 @@ class CommandLine {
184188
" @@@@@@ \r\n"
185189
" @@@@ \r\n"
186190
"\r\n";
187-
191+
188192
public:
189193
CommandLine();
190194

0 commit comments

Comments
 (0)