Espressif Systems is a Shanghai-based Chinese company that created the popular ESP8266, ESP32, ESP32-S, ESP32-C, and ESP32-H series of chips, modules, and development boards. These boards are a cheap solution for Wi-Fi and Bluetooth capabilities. They can be programmed with Arduino IDE, Visual Studio Code, MicroPython, Espressif Mesh Development Framework, Espruino, Lua Network/IoT toolkit, Mongoose OS, mruby, NodeMCU, Zerynth, and .Net nanoFramework.
This lesson will walk through the programming of ESP8266 and ESP32 boards with the Arduino IDE and cover the following topics:
- Generating Wi-Fi beacons
- Wi-Fi deauthentication
- Generating Wi-Fi probe requests
- Bluetooth writing
- Bluetooth scanning
- Bluetooth beacon spamming
- References
- ESP8266 Beacon Spammer
- ESP8266 Deauther v2
- ESP32 BLE Write
- ESP32 BLE Beacon Scanner
- ESP32-BLEBeaconSpam
- ESP32 Bluetooth Classic Sniffer
- https://en.wikipedia.org/wiki/ESP32
- https://github.com/spacehuhn/esp8266_beaconSpam
- https://github.com/SpacehuhnTech/esp8266_deauther
- https://github.com/tobozo/ESP32-BLEBeaconSpam
- https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/
- https://learn.sparkfun.com/tutorials/esp32-thing-plus-hookup-guide/arduino-example-esp32-ble
- https://github.com/Matheus-Garbelini/esp32_bluetooth_classic_sniffer
Install
The following commands are one way to install the Arduino IDE:
wget -P ~/ https://downloads.arduino.cc/arduino-1.8.15-linux64.tar.xz
cd ~/
tar -xf arduino-1.8.15-linux64.tar.xz
cd arduino-1.8.15/
sudo ./install.sh
Programming
FISSURE contains an example program that is a modified ESP8266 Beacon Spammer. This program transmits a series of beacon frames over multiple frequency channels with a long list of SSID names. Once activated by a serial command, the program will transmit indefinitely until deactivated by another serial command. The following steps will upload the program to the ESP8266 board.
- Open the Arduino IDE by navigating the FISSURE menu to Tools>>802.11>>ESP8266 Beacon Spammer.
- Go to File>>Preferences and add
http://arduino.esp8266.com/stable/package_esp8266com_index.json
to the “Additional Boards Manager URLs” field. - Go to Tools>>Boards>>Board Manager and type in "esp8266" to see the esp8266 package. Click the "Install" button.
- Go to Tools>>Boards and select your board. For the "ESP8266 ESP-12E Development Board WiFi WLAN Wireless Module CP2102 for NodeMCU for ESP-12E for Arduino" product, choose NodeMCU 0.9 or NodeMCU 1.0.
- Go to Tools>>Port and choose the proper port (it might be
/dev/ttyUSB0
). - Plug in the board.
- Click the Upload button in the Arduino IDE (the right arrow).
- Verify no errors were present while uploading.
Interacting
The Esp8266_listen_trigger.ino file is a modified ESP8266 Beacon Spammer that can be manually started and stopped over serial. By default nothing is transmitting until an "attack" command is issued. The following steps will control the program:
- Open PuTTy with Tools>>Hardware>>PuTTY or with the
putty
command. - Under Session, select Serial.
- Change the Serial line to the proper port (
/dev/ttyUSB0
). - Change the speed to 115200.
- Select "Open".
- Type "attack" and press the Control key on the keyboard. Note: the text will not be visible while typing. If successful,
Packets/s: ###
will stream and fake Wi-Fi networks will appear on listening devices. - Type "stop" to end the program. Type "attack" and Control to resume.
Programming
FISSURE downloads the ESP2866 Deauther v2 program as part of its installer (Installed_by_FISSURE folder). This program will create a wireless network and provide a web interface to the user for scanning, deauthenticating, and generating beacons and probe requests. FISSURE has menu items for opening the .ino file, accessing the web interface, and displaying the credentials for the wireless network. The following steps will upload the program to the ESP8266 board.
- Open the Arduino IDE by navigating the FISSURE menu to Tools>>802.11>>ESP8266 Deauther v2.
- Go to File>>Preferences and add
https://raw.githubusercontent.com/SpacehuhnTech/arduino/main/package_spacehuhn_index.json
to the “Additional Boards Manager URLs” field. - Go to Tools>>Boards>>Board Manager and type in "deauther" to see the Deauther ESP2866 Boards package. Click the "Install" button.
- Go to Tools>>Boards>>Deauther ESP8266 Boards and select your board. For the "ESP8266 ESP-12E Development Board WiFi WLAN Wireless Module CP2102 for NodeMCU for ESP-12E for Arduino" product, choose Generic ESP8266.
- Go to Tools>>Port and choose the proper port (it might be
/dev/ttyUSB0
). - Plug in the board.
- Click the Upload button in the Arduino IDE (the right arrow).
- Verify no errors were present while uploading.
Interacting
The wireless network and web interface will start automatically after the ESP8266 is programmed. The network may go down temporarily after commands are issued in the web interface. To avoid having to manually reconnect after each command, make sure to connect automatically to this network and no other networks. The following are steps for accessing and interacting with the web interface.
- On a Wi-Fi device, connect to the network named "pwned" using the password "deauther".
- Open a browser or use FISSURE to navigate to 192.168.4.1.
- Click "I HAVE READ AND UNDERSTOOD THE NOTICE ABOVE"
- Click "SCAN APS" to discover access points. Refresh the browser.
- Click "SCAN STATIONS" to discover stations. Refresh the browser.
- Click the "ADD" button to select APs and stations as targets for attacks.
- At the top of the page, click "SSIDs" to choose which names will be used in the beacon and probe attacks.
- Click "Attack" at the top of the page to start/stop deauth, beacon, and probe attacks for previously specified targets and SSID names.
This example will demonstrate how to write messages to an ESP32 board over Bluetooth. This was tested on a ESP32-WROOM-32D. See the SparkFun reference.
Programming
- Open the Arduino IDE with the
arduino
command. - Open the BLE_Write program by going to File>>Examples>>ESP32 BLE Arduino>>BLE_Write.
- Go to File>>Preferences and add
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
to the “Additional Boards Manager URLs” field. - Go to Tools>>Boards>>Board Manager and type in "esp32" to see the esp32 package. Click the "Install" button.
- Go to Tools>>Boards and select your board. For the "ESP32-WROOM-32D" product, choose ESP32 Dev Module.
- Go to Tools>>Port and choose the proper port (it might be
/dev/ttyUSB0
). - Plug in the board.
- Click the Upload button in the Arduino IDE (the right arrow).
- Verify no errors were present while uploading (requires
pip install pyserial
)
Interacting
- Open PuTTy with Tools>>Hardware>>PuTTY or with the
putty
command. - Under Session, select Serial.
- Change the Serial line to the proper port (
/dev/ttyUSB0
). - Change the speed to 115200.
- Select "Open".
- Download a BLE Scanner App (BLE Scanner 4.0 on iPhone worked).
- Scan and connect to "MyESP32".
- Select "CUSTOM SERVICE".
- Select "Write,Read".
- Select "Write Value".
- Select "Text", enter text, and select "Write" to send.
- View
New value: <text>
in PuTTY.
Programming
- Repeat programming steps 1-8 in ESP32 BLE Write but load File>>Examples>>ESP32 BLE_Beacon_Scanner.
Interacting
- Repeat interacting steps 1-5 in ESP32 BLE Write and view scan results in PuTTY.
- Still troubleshooting...
The BrakTooth ESP32 BR/EDR Active Sniffer/Injector acts as a simple "Monitor mode" for Bluetooth Classic. It can sniff or inject BR/EDR Baseband packets in ESP32 BT connections. It comes with the firmware for flashing the ESP32 board and can be run from the FISSURE menu item: Tools>>Bluetooth>>ESP32 Bluetooth Classic Sniffer>>Flash ESP32 Board. The installer includes a Wireshark dissector for decoding the baseband packets.
This is an active sniffer and requires a connection/the start of a connection to capture traffic. It will interact with the BT network (piconet). It is not a passive sniffer and will not detect Bluetooth traffic unless it is targeted.
The command for launching the sniffer can be accessed from the FISSURE menu item: Tools>>Bluetooth>>ESP32 Bluetooth Classic Sniffer>>BTSnifferBDEDR
sudo ./BTSnifferBREDR.py --port=/dev/ttyUSB0 --live-terminal --live-wireshark