Skip to content

Commit 479e7eb

Browse files
committed
More updates
0 parents  commit 479e7eb

17 files changed

+1068
-0
lines changed

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 bigbrodude6119
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Flipper Zero Evil Portal
2+
3+
An evil captive portal Wi-Fi access point using the Flipper Zero and Wi-Fi dev board
4+
5+
## About
6+
7+
**This project is a work in progress.**
8+
9+
This project will turn your Wi-Fi dev board into an open access point. When users try to connect to this access point they will be served a fake login screen. User credentials are sent to the Flipper and logged on the SD card.
10+
11+
## Disclaimer
12+
13+
I am not a C developer and I am using this project as a way to learn more about esp32, flipper zero and, C programming.
14+
15+
This program is for educational purposes only.
16+
17+
## Getting Started
18+
19+
There are pre-built .fap files for the official FW (untested) as well as unleashed FW (tested).
20+
21+
You will need to manually flash the Wi-Fi dev board.
22+
23+
### Install pre-built app on the flipper
24+
25+
Go to the releases section on this repo and download and extract either the `ofw-evil_portal.fap.zip` file or the `unleashed-evil_portal.fap.zip` file depending on if you are using the official firmware (ofw) or the unleashed firmware. These files will contain the `evil_portal.fap` file for your firmware.
26+
27+
You will also need to download and extract the `evil_portal_sd_folder.zip` folder. This will contain necessary files for the app to run.
28+
29+
Put the `evil_portal.fap` file into the `apps/GPIO/` folder on your Flipper SD card.
30+
31+
Put the `evil_portal` folder into the `apps_data` folder.
32+
This is an example of your Flipper SD card if done correctly.
33+
34+
```
35+
apps/
36+
GPIO/
37+
evil_portal.fap
38+
apps_data/
39+
evil_portal/
40+
ap.config.txt
41+
index.html
42+
logs/
43+
<empty>
44+
```
45+
46+
You should be able to see the `[ESP32] Evil Portal` app on your flipper zero now.
47+
48+
If you want to create your own `index.html` file keep in mind that there is a limit of 4000 characters for the file. I plan to increase this later but I ran into some issues with larger files.
49+
50+
## Installing/flashing the Wi-Fi dev board
51+
52+
If you've already flashed your Wi-Fi dev board with the Marauder firmware or something else you will need to erase it before installing the new firmware here. Follow [the guide here](#erasing-firmware) for that.
53+
54+
Follow the steps below to flash the Wi-Fi dev board with the evil portal firmware via Windows. The instructions below are for the Flipper Zero Wi-Fi Wrover Development Module (**ESP32-S2**), you may have to adjust the steps for your specific board:
55+
56+
1. Download and install the Arduino IDE from [here][link-arduino].
57+
2. Download zip/clone dependency [AsyncTCP][link-asynctcp] to file.
58+
3. Download zip/clone dependency [ESPAsyncWebServer][link-espasyncwebserver] to file.
59+
4. Unzip both dependencies to your Arduino library folder.
60+
- On Windows this is usually `C:\Users\<username>\Documents\Arduino\libraries`.
61+
5. Go to the releases section on this repo and download the `EvilPortal.ino` file, open it with Arduino IDE.
62+
6. Go to `File > Preferences` and paste the following two URL's into the `Additional Boards Manager URLs` field:
63+
```
64+
https://dl.espressif.com/dl/package_esp32_index.json
65+
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
66+
```
67+
7. Go to `Tools > Board > Boards Manager...` and search for `esp32` and install `esp32 by Espressif Systems`.
68+
8. Go to `Tools > Board` and select `ESP32S2 Dev Module`.
69+
9. On your ESP32-S2 Wi-Fi module, hold the BOOT button.
70+
10. Connect your ESP32-S2 to your computer, keep holding the BOOT button (holding for just 3-5 seconds and releasing may be fine, continuously holding worked better for me).
71+
11. Go to `Tools > Port` and select the port that appeared when you connected your ESP32-S2.
72+
12. Click the "Upload" button in the top left corner of the Arduino IDE.
73+
13. On success, you will see:
74+
```
75+
Hash of data verified.
76+
Leaving...
77+
WARNING: ESP32-S2 (revision v0.0) chip was placed into download mode...
78+
```
79+
14. Plug in the Wi-Fi Dev board to the flipper, press the reset button on the Wi-Fi dev board and you should now see a solid blue light.
80+
81+
## Installing/flashing an ESP32 Wroom board
82+
83+
Reddit user dellycem [compiled binaries](https://old.reddit.com/r/flipperzero/comments/14ni93r/i_made_a_evil_portal_app_for_the_fz_wifi_dev_board/jqd42fi/?context=3) for the ESP32 Wroom board if you would like to use that instead of the Wi-Fi devboard.
84+
85+
1. Download the bin files from [this link](https://wetransfer.com/downloads/4d3dd914f2df43dc6c84efa452043f4220230702094742/33a478)
86+
2. Go to [ESPWebTool](https://esp.huhn.me/) and get your board connected.
87+
3. Add each of the bin files at the following locations
88+
```
89+
EvilPortal.bootloader.bin - 0x1000
90+
EvilPortal.partitions.bin - 0x8000
91+
boot_app0.bin - 0xe000
92+
EvilPortal.bin - 0x10000
93+
```
94+
4. Press the program button and wait while your board is flashed.
95+
5. Once complete, hook up the 3.3v, GND, RX0, and TX0 pins to the flipper zero. Remember that the RX/TX pins should go to the opposite pins on the flipper zero. RX -> TX, TX -> RX.
96+
97+
## Usage
98+
99+
Plug in the Wi-Fi Dev board to the flipper.
100+
101+
Open the app on the Flipper and press `Start portal` on the main menu. After a few seconds you should start to see logs coming in from your Wi-Fi dev board and the AP will start and the LED will turn green.
102+
103+
The AP will take the name that is in the `ap.config.txt` file located on your Flipper in the `apps_data/evil_portal/` folder.
104+
105+
When you connect to the AP a web page will open after a few seconds. This web page contains the HTML located in the `index.html` file located on your Flipper in the `apps_data/evil_portal/` folder.
106+
107+
You can stop the portal by pressing `Stop portal` on the main menu. The LED should turn blue.
108+
109+
You can manually save logs using the `Save logs` command. Logs will be stored in the `logs` folder that is in your `apps_data/evil_portal/` folder.
110+
111+
Logs will automatically be saved when exiting the app or when the current log reaches 4000 characters.
112+
113+
## Building for different firmware
114+
115+
If you are not using the official flipper zero firmware or the unleashed firmware you can build the .fap file yourself by following [these instructions](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/AppsOnSDCard.md).
116+
117+
Note that you will need to use the firmware repo that you wish to build for.
118+
119+
You can also download builds for each firmware via [flipc](https://flipc.org/bigbrodude6119/flipper-zero-evil-portal?branch=main&root=flipper%2Fflipper-evil-portal).
120+
121+
## Erasing firmware <a name="erasing-firmware"></a>
122+
123+
Assuming you have the Flipper Zero Wi-Fi Wrover Development Module (**ESP32-S2**):
124+
125+
1. Install [Python][link-python].
126+
2. Open a command terminal as an administrator:
127+
- On Windows press ⊞Win+R, type "cmd", and press CTRL+SHIFT+ENTER.
128+
3. In the terminal type the following to install [esptool][link-esptool] via Python package manager:
129+
```
130+
pip install esptool
131+
```
132+
4. Install [setuptools][link-setuptools] dependencies:
133+
```
134+
pip install setuptools
135+
```
136+
5. Enter the following command into your terminal, do not run it yet:
137+
```
138+
python -m esptool --chip esp32s2 erase_flash
139+
```
140+
6. On your ESP32-S2 Wi-Fi module, hold the BOOT button.
141+
7. Connect your ESP32-S2 to your computer, keep holding the BOOT button.
142+
8. In your terminal press enter to run the command from step 5.
143+
9. When successful you will get the message `Chip erase completed successfully in ___s` (time in seconds suffixed with "s").
144+
10. Unplug/reset your board.
145+
146+
## Issues
147+
148+
If you run into any issues make sure that you have the required files set up on the Flipper `apps_data` folder on the Flipper SD card.
149+
150+
Logs will not be saved if there is no `logs` folder in `apps_data/evil_portal/`.
151+
152+
If the AP won't start or you have other issues try pressing reset on the Wi-Fi dev board, waiting a few seconds, and pressing `Start portal` on the main menu.
153+
154+
It is important to give the devboard some time to load the html files from the Flipper.
155+
156+
If you have the Marauder firmware on your dev board you may need to enable `Erase All Flash Before Sketch Upload` before flashing.
157+
158+
Some users are reporting that the captive portal login does not open on some Android phones.
159+
160+
## Todo
161+
162+
I plan on working on this in my free time. Here is my todo list.
163+
164+
- Support for multiple portals
165+
- Enter AP name on the Flipper
166+
- Add a config file for general app settings
167+
- Create cleaner log files that are easier to read
168+
- Clean up code & implement best practices
169+
170+
## License
171+
172+
Distributed under the MIT License. See `LICENSE.txt` for more information.
173+
174+
## Acknowledgments
175+
176+
I was only able to create this using the following apps as examples
177+
178+
- [flipperzero-wifi-marauder](https://github.com/0xchocolate/flipperzero-wifi-marauder)
179+
- [UART_Terminal](https://github.com/cool4uma/UART_Terminal)
180+
- [flipper-zero-fap-boilerplate](https://github.com/leedave/flipper-zero-fap-boilerplate)
181+
- [Create Captive Portal Using ESP32](https://iotespresso.com/create-captive-portal-using-esp32/)
182+
183+
## Contact me
184+
185+
You can message me on my reddit account bigbrodude6119
186+
187+
<!-- LINKS -->
188+
189+
[link-arduino]: https://www.arduino.cc/en/software
190+
[link-asynctcp]: https://github.com/me-no-dev/AsyncTCP
191+
[link-espasyncwebserver]: https://github.com/me-no-dev/ESPAsyncWebServer
192+
[link-esptool]: https://pypi.org/project/esptool/
193+
[link-python]: https://www.python.org/downloads/
194+
[link-setuptools]: https://pypi.org/project/setuptools/

application.fam

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
App(
2+
appid="evil_portal",
3+
name="[ESP32] Evil Portal",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="evil_portal_app",
6+
cdefines=["APP_EVIL_PORTAL"],
7+
requires=["gui"],
8+
stack_size=1 * 1024,
9+
order=90,
10+
fap_icon="icons/evil_portal_10px.png",
11+
fap_category="GPIO",
12+
)

evil_portal_app.c

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#include "evil_portal_app_i.h"
2+
#include "helpers/evil_portal_storage.h"
3+
4+
#include <furi.h>
5+
#include <furi_hal.h>
6+
7+
static bool evil_portal_app_custom_event_callback(void* context, uint32_t event) {
8+
furi_assert(context);
9+
Evil_PortalApp* app = context;
10+
return scene_manager_handle_custom_event(app->scene_manager, event);
11+
}
12+
13+
static bool evil_portal_app_back_event_callback(void* context) {
14+
furi_assert(context);
15+
Evil_PortalApp* app = context;
16+
return scene_manager_handle_back_event(app->scene_manager);
17+
}
18+
19+
static void evil_portal_app_tick_event_callback(void* context) {
20+
furi_assert(context);
21+
Evil_PortalApp* app = context;
22+
scene_manager_handle_tick_event(app->scene_manager);
23+
}
24+
25+
Evil_PortalApp* evil_portal_app_alloc() {
26+
Evil_PortalApp* app = malloc(sizeof(Evil_PortalApp));
27+
28+
app->sent_html = false;
29+
app->sent_ap = false;
30+
app->sent_reset = false;
31+
app->has_command_queue = false;
32+
app->command_index = 0;
33+
app->portal_logs = furi_string_alloc();
34+
35+
app->gui = furi_record_open(RECORD_GUI);
36+
37+
app->view_dispatcher = view_dispatcher_alloc();
38+
app->scene_manager = scene_manager_alloc(&evil_portal_scene_handlers, app);
39+
view_dispatcher_enable_queue(app->view_dispatcher);
40+
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
41+
42+
view_dispatcher_set_custom_event_callback(
43+
app->view_dispatcher, evil_portal_app_custom_event_callback);
44+
view_dispatcher_set_navigation_event_callback(
45+
app->view_dispatcher, evil_portal_app_back_event_callback);
46+
view_dispatcher_set_tick_event_callback(
47+
app->view_dispatcher, evil_portal_app_tick_event_callback, 100);
48+
49+
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
50+
51+
app->var_item_list = variable_item_list_alloc();
52+
view_dispatcher_add_view(
53+
app->view_dispatcher,
54+
Evil_PortalAppViewVarItemList,
55+
variable_item_list_get_view(app->var_item_list));
56+
57+
for(int i = 0; i < NUM_MENU_ITEMS; ++i) {
58+
app->selected_option_index[i] = 0;
59+
}
60+
61+
app->text_box = text_box_alloc();
62+
view_dispatcher_add_view(
63+
app->view_dispatcher, Evil_PortalAppViewConsoleOutput, text_box_get_view(app->text_box));
64+
app->text_box_store = furi_string_alloc();
65+
furi_string_reserve(app->text_box_store, EVIL_PORTAL_TEXT_BOX_STORE_SIZE);
66+
67+
scene_manager_next_scene(app->scene_manager, Evil_PortalSceneStart);
68+
69+
return app;
70+
}
71+
72+
void evil_portal_app_free(Evil_PortalApp* app) {
73+
// save latest logs
74+
if(furi_string_utf8_length(app->portal_logs) > 0) {
75+
write_logs(app->portal_logs);
76+
furi_string_free(app->portal_logs);
77+
}
78+
79+
// Send reset event to dev board
80+
evil_portal_uart_tx((uint8_t*)(RESET_CMD), strlen(RESET_CMD));
81+
evil_portal_uart_tx((uint8_t*)("\n"), 1);
82+
83+
furi_assert(app);
84+
85+
// Views
86+
view_dispatcher_remove_view(app->view_dispatcher, Evil_PortalAppViewVarItemList);
87+
view_dispatcher_remove_view(app->view_dispatcher, Evil_PortalAppViewConsoleOutput);
88+
89+
text_box_free(app->text_box);
90+
furi_string_free(app->text_box_store);
91+
92+
// View dispatcher
93+
view_dispatcher_free(app->view_dispatcher);
94+
scene_manager_free(app->scene_manager);
95+
96+
evil_portal_uart_free(app->uart);
97+
98+
// Close records
99+
furi_record_close(RECORD_GUI);
100+
101+
free(app);
102+
}
103+
104+
int32_t evil_portal_app(void* p) {
105+
UNUSED(p);
106+
107+
// Enable 5v on startup
108+
uint8_t attempts = 0;
109+
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
110+
furi_hal_power_enable_otg();
111+
furi_delay_ms(10);
112+
}
113+
furi_delay_ms(200);
114+
115+
Evil_PortalApp* evil_portal_app = evil_portal_app_alloc();
116+
117+
evil_portal_app->uart = evil_portal_uart_init(evil_portal_app);
118+
119+
view_dispatcher_run(evil_portal_app->view_dispatcher);
120+
121+
evil_portal_app_free(evil_portal_app);
122+
123+
if(furi_hal_power_is_otg_enabled()) {
124+
furi_hal_power_disable_otg();
125+
}
126+
127+
return 0;
128+
}

evil_portal_app.h

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
typedef struct Evil_PortalApp Evil_PortalApp;
8+
9+
#ifdef __cplusplus
10+
}
11+
#endif

0 commit comments

Comments
 (0)