Skip to content

Commit 24f8f66

Browse files
author
Stefan Kremser
committed
Merge branch 'testing'
2 parents 49a4baa + 529fc76 commit 24f8f66

27 files changed

+1265
-1156
lines changed

README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ESP8266 Deauther
2-
Build your own WiFi jammer with an ESP8266.
2+
Deauthentication attack and other hacks using an ESP8266.
33

44
![esp8266 deauther with a smartphone](https://raw.githubusercontent.com/spacehuhn/esp8266_deauther/master/screenshots/smartphone_esp_1.jpg)
55

@@ -24,39 +24,40 @@ Build your own WiFi jammer with an ESP8266.
2424

2525
Basically it’s a device which performs a [deauth attack](https://en.wikipedia.org/wiki/Wi-Fi_deauthentication_attack).
2626
You select the clients you want to disconnect from their network and start the attack. As long as the attack is running, the
27-
selected devices are unable to connect to their network.
27+
selected devices are unable to connect to their network.
28+
Other attacks also have been implemented, such as beacon or probe request flooding.
2829

2930
### How it works
3031

31-
The 802.11 WiFi protocol contains a so called [deauthentication frame](https://mrncciew.com/2014/10/11/802-11-mgmt-deauth-disassociation-frames/). It is used to disconnect clients safely from a wireless
32+
The 802.11 Wi-Fi protocol contains a so called [deauthentication frame](https://mrncciew.com/2014/10/11/802-11-mgmt-deauth-disassociation-frames/). It is used to disconnect clients safely from a wireless
3233
network.
3334

34-
Because these packets are unencrypted, you just need the mac address of the WiFi router and of the client device which you want to disconnect from the network. You don’t need to be in the network or know the password, it’s enough to be in its range.
35+
Because these management packets are unencrypted, you just need the mac address of the Wi-Fi router and of the client device which you want to disconnect from the network. You don’t need to be in the network or know the password, it’s enough to be in its range.
3536

3637
### What an ESP8266 is
3738

38-
The [ESP8266](https://de.wikipedia.org/wiki/ESP8266) is a very cheap micro controller with build in WiFi. It contains a powerfull 160 MHz processor and you can program it
39-
with the [Arduino IDE](https://www.arduino.cc/en/Main/Software). This makes it perfect for this project.
39+
The [ESP8266](https://de.wikipedia.org/wiki/ESP8266) is a cheap micro controller with built-in Wi-Fi. It contains a powerfull 160 MHz processor and it can be programmed using [Arduino](https://www.arduino.cc/en/Main/Software).
4040

4141
You can buy these chips for under $2 from China!
4242

4343
### How to protect against it
4444

45-
With [802.11w-2009](https://en.wikipedia.org/wiki/IEEE_802.11w-2009) WiFi got an update to encrypt management frames.
46-
So make sure your router is up to date and has management frame protection enabled. But be sure that your client device
47-
supports it too, both ends need to have it enabled!
45+
With [802.11w-2009](https://en.wikipedia.org/wiki/IEEE_802.11w-2009) Wi-Fi got an update to encrypt management frames.
46+
So make sure your router is up to date and has management frame protection enabled. But note that your client device needs to
47+
support it too, both ends need to have it enabled!
4848

49-
The only problem is that most devices don’t use it. I tested it with different WiFi networks and devices, it worked every time! It seems that even newer devices which support frame protection don’t use it by default.
49+
The only problem is that most devices don’t use it. I tested it with different Wi-Fi networks and devices, it worked every time! It seems that even newer devices which support frame protection don’t use it by default.
5050

5151
## Disclaimer
5252

53-
Use it only for testing purposes on your own devices!
53+
Use it only for testing purposes on your own devices!
54+
I don't take any responsibility for what you do with this program.
5455

5556
Please check the legal regulations in your country before using it. Jamming transmitters are illegal in most countries
5657
and this device can fall into the same category (even if it’s technically not the same).
5758

5859
My intention with this project is to draw attention to this issue.
59-
This attack shows how vulnerable the 802.11 WiFi standard is and that it has to be fixed.
60+
This attack shows how vulnerable the 802.11 Wi-Fi standard is and that it has to be fixed.
6061
**A solution is already there, why don’t we use it?**
6162

6263
## Installation
@@ -111,19 +112,19 @@ Make sure you select the right com-port, the right upload size of your ESP8266 a
111112
**11** Scroll down and before `#endif` add following lines:
112113

113114
`typedef void (*freedom_outside_cb_t)(uint8 status);`
114-
`int wifi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb);`
115-
`void wifi_unregister_send_pkt_freedom_cb(void);`
116-
`int wifi_send_pkt_freedom(uint8 *buf, int len, bool sys_seq);`
115+
`int Wi-Fi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb);`
116+
`void Wi-Fi_unregister_send_pkt_freedom_cb(void);`
117+
`int Wi-Fi_send_pkt_freedom(uint8 *buf, int len, bool sys_seq);`
117118

118119
![screenshot of notepad, copy paste the right code](https://raw.githubusercontent.com/spacehuhn/esp8266_deauther/master/screenshots/notepad_screenshot_1.JPG)
119120

120121
**don't forget to save!**
121122

122123
**12** Go to the SDK_fix folder of this project
123124

124-
**13** Copy ESP8266WiFi.cpp and ESP8266WiFi.h
125+
**13** Copy ESP8266Wi-Fi.cpp and ESP8266Wi-Fi.h
125126

126-
**14** Past these files here `packages` > `esp8266` > `hardware` > `esp8266` > `2.0.0` > `libraries` > `ESP8266WiFi` > `src`
127+
**14** Past these files here `packages` > `esp8266` > `hardware` > `esp8266` > `2.0.0` > `libraries` > `ESP8266Wi-Fi` > `src`
127128

128129
**15** Open `esp8266_deauther` > `esp8266_deauther.ino` in Arduino
129130

@@ -143,7 +144,7 @@ First start your ESP8266 by giving it power.
143144
You can use your smartphone if you have a USB OTG cable.
144145
![esp8266 deauther with a smartphone](https://raw.githubusercontent.com/spacehuhn/esp8266_deauther/master/screenshots/smartphone_esp_2.jpg)
145146

146-
Scan for WiFi networks and connect to `pwned`. The password is `deauther`.
147+
Scan for Wi-Fi networks and connect to `pwned`. The password is `deauther`.
147148
Once connected, you can open up your browser and go to `192.168.4.1`.
148149

149150
You can now scan for networks...
@@ -152,7 +153,7 @@ You can now scan for networks...
152153
scan for client devices...
153154
![webinterface client scanner](https://raw.githubusercontent.com/spacehuhn/esp8266_deauther/master/screenshots/web_screenshot_2.JPG)
154155

155-
Note: While scanning the ESP8266 will shut down its access point, so you may have to go to your settings and reconnect to the WiFi network manually.
156+
Note: While scanning the ESP8266 will shut down its access point, so you may have to go to your settings and reconnect to the Wi-Fi network manually.
156157

157158
...and start different attacks.
158159
![webinterface attack menu](https://raw.githubusercontent.com/spacehuhn/esp8266_deauther/master/screenshots/web_screenshot_3.JPG)
@@ -168,14 +169,14 @@ Yes, but I will not implement this 'feature' for ethical and legal reasons.
168169
**Can it sniff handshakes?**
169170

170171
The ESP8266 has a promiscuous mode in which you can sniff packets, but handshake packets are dropped and there is no other way to get them with the functions provided by the SDK.
171-
Maybe someone will find a way around this barrier but I wasn't able to.
172+
Maybe someone will find a way around this barrier.
172173

173174
**espcomm_sync failed/espcomm_open when uploading**
174175

175176
The ESP upload tool can't communicate with the chip, make sure the right port is selected!
176177
You can also try out different USB ports and cables.
177178
If this doesn't solve it you may have to install USB drivers.
178-
Which drivers you need depends on the board, most boards use a cp2102, cp2104 or ch340.
179+
Which drivers you need depends on the board, most boards use a cp2102 or ch340.
179180

180181
**AP scan doesn't work**
181182

@@ -184,16 +185,16 @@ Try out switching the browser or open the website with another device.
184185

185186
**Deauth attack won't work**
186187

187-
If you see 0 pkts/s on the website you have made a mistake. Check if you have followed the the installation steps correctly and that the right SDK installed, it must be version 2.0.0!
188-
If it can send packets but your target don't loose its connection then the WiFi router uses [802.11w](#how-to-protect-against-it) and it's protected against such attacks or they communicate via 5 GHz WiFi, which the ESP8266 doesn't support.
188+
If you see 0 pkts/s on the website you've made a mistake. Check if you have followed the the installation steps correctly and that the right SDK installed, it must be version 2.0.0!
189+
If it can send packets but your target don't loose its connection then the Wi-Fi router uses [802.11w](#how-to-protect-against-it) and it's protected against such attacks or they communicate via 5 GHz Wi-Fi, which the ESP8266 doesn't support.
189190

190191

191192
###If you have other questions or problems with the ESP8266 you can also check out the official [community forum](http://www.esp8266.com/).
192193

193194

194195
## License
195196

196-
This project is licensed under the MIT License - see the [license file](LICENSE) file for details
197+
This project is licensed under the MIT License - see the [license file](LICENSE) file for details.
197198

198199
## Sources and additional links
199200

@@ -207,14 +208,15 @@ ESP8266:
207208

208209
packet injection with ESP8266:
209210
* http://hackaday.com/2016/01/14/inject-packets-with-an-esp8266/
210-
* http://bbs.espressif.com/viewtopic.php?f=7&t=1357&p=10205&hilit=wifi_pkt_freedom#p10205
211+
* http://bbs.espressif.com/viewtopic.php?f=7&t=1357&p=10205&hilit=Wi-Fi_pkt_freedom#p10205
211212
* https://github.com/pulkin/esp8266-injection-example
212213

213214
802.11w-2009: https://en.wikipedia.org/wiki/IEEE_802.11w-2009
214215

215-
wifi_send_pkt_freedom function limitations: http://esp32.com/viewtopic.php?f=13&t=586&p=2648&hilit=wifi_send_pkt_freedom#p2648
216+
Wi-Fi_send_pkt_freedom function limitations: http://esp32.com/viewtopic.php?f=13&t=586&p=2648&hilit=Wi-Fi_send_pkt_freedom#p2648
216217

217-
esp32 esp_wifi_internal function limitations: http://esp32.com/viewtopic.php?f=13&t=586&p=2648&hilit=wifi_send_pkt_freedom#p2648
218+
esp32 esp_Wi-Fi_internal function limitations: http://esp32.com/viewtopic.php?f=13&t=586&p=2648&hilit=Wi-Fi_send_pkt_freedom#p2648
218219

219220
Videos:
220-
[![Cheap Wifi 'Jammer' Device | NodeMCU](https://img.youtube.com/vi/oQQhBdCQOTM/0.jpg)](https://www.youtube.com/watch?v=oQQhBdCQOTM)
221+
[![Cheap Wi-Fi 'Jammer' Device | NodeMCU](https://img.youtube.com/vi/oQQhBdCQOTM/0.jpg)](https://www.youtube.com/watch?v=oQQhBdCQOTM)
222+
[![Wifi 'Jammer' Device V1.1 | Setup Tutorial](https://img.youtube.com/vi/r5aoV5AolNo/0.jpg)](https://www.youtube.com/watch?v=r5aoV5AolNo)

esp8266_deauther/APScan.cpp

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ bool APScan::start(){
2626
_ssid.toCharArray(names[i],33);
2727
//data_getVendor(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2]).toCharArray(vendors[i],9);
2828
if(debug){
29+
Serial.print((String)i);
30+
Serial.print(" - ");
2931
_ap._print();
3032
Serial.print(" - ");
3133
Serial.print(channels[i]);
@@ -44,7 +46,8 @@ bool APScan::start(){
4446
}
4547

4648
//for debugging the APScan crash bug
47-
/*if(debug){
49+
/*
50+
if(debug){
4851
for(int i=results;i<maxAPScanResults;i++){
4952
Mac _ap;
5053
_ap.set(random(255),random(255),random(255),random(255),random(255),random(255));
@@ -55,6 +58,8 @@ bool APScan::start(){
5558
String _ssid = "test_dbeJwq3tPtJsuWtgULgShD9dxXV";
5659
_ssid.toCharArray(names[i],33);
5760
61+
Serial.print((String)i);
62+
Serial.print(" - ");
5863
_ap._print();
5964
Serial.print(" - ");
6065
Serial.print(channels[i]);
@@ -68,10 +73,10 @@ bool APScan::start(){
6873
6974
results++;
7075
}
71-
}*/
76+
}
77+
*/
7278

7379
if(debug) Serial.println("scan done");
74-
if(debug) Serial.println(getResults());
7580
return true;
7681
}
7782

@@ -115,6 +120,67 @@ int APScan::getFirstTarget(){
115120
return -1;
116121
}
117122

123+
void APScan::sendResults(){
124+
if(debug) Serial.print("sending AP scan result JSON ");
125+
126+
size_t _size = 10; // {"aps":[]}
127+
for(int i=0;i<results && i<maxAPScanResults;i++){
128+
/*
129+
_size++; // {
130+
_size += 5; // "i": ,
131+
_size += String(i).length();
132+
_size += 5; // "c": ,
133+
_size += String(getAPChannel(i)).length();
134+
_size += 24; // "m":"d4:21:22:da:85:f3",
135+
_size += 8; // "ss":" ",
136+
_size += getAPName(i).length();
137+
_size += 5; // "r": ,
138+
_size += String(getAPRSSI(i)).length();
139+
_size += 6; // "e": ,
140+
_size += 6; // "se":0
141+
_size++; // }*/
142+
_size += 61;
143+
_size += String(i).length();
144+
_size += String(getAPChannel(i)).length();
145+
_size += getAPName(i).length();
146+
_size += String(getAPRSSI(i)).length();
147+
148+
if((i!=results-1) && (i!=maxAPScanResults-1)) _size++; // ,
149+
}
150+
151+
sendHeader(200, "text/json", _size);
152+
153+
String json;
154+
int bufc = 0; //bufferCounter
155+
json = "{\"aps\":[";
156+
157+
sendToBuffer(json);
158+
159+
for(int i=0;i<results && i<maxAPScanResults;i++){
160+
if(debug) Serial.print(".");
161+
json = "{";
162+
json += "\"i\":"+(String)i+",";
163+
json += "\"c\":"+(String)getAPChannel(i)+",";
164+
json += "\"m\":\""+getAPMac(i)+"\",";
165+
json += "\"ss\":\""+getAPName(i)+"\",";
166+
json += "\"r\":"+(String)getAPRSSI(i)+",";
167+
json += "\"e\":"+(String)encryption[i]+",";
168+
//json += "\"v\":\""+getAPVendor(i)+"\",";
169+
json += "\"se\":"+(String)getAPSelected(i);
170+
json += "}";
171+
if((i!=results-1) && (i!=maxAPScanResults-1)) json += ",";
172+
173+
sendToBuffer(json);
174+
175+
}
176+
json = "]}";
177+
sendToBuffer(json);
178+
sendBuffer();
179+
180+
if(debug) Serial.println("done");
181+
182+
}
183+
118184
String APScan::getResults(){
119185
if(debug) Serial.print("getting AP scan result JSON ");
120186
String json = "{ \"aps\":[ ";
@@ -175,4 +241,4 @@ void APScan::select(int num){
175241

176242
bool APScan::isSelected(int num){
177243
return selected[num];
178-
}
244+
}

esp8266_deauther/APScan.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#ifndef APScan_h
22
#define APScan_h
33

4-
#define maxAPScanResults 30
4+
#define maxAPScanResults 80
55

66
#include <ESP8266WiFi.h>
77
#include "Mac.h"
88
#include "MacList.h"
99
#include "Settings.h"
10+
#include <ESP8266WebServer.h>
1011

1112
extern String data_getVendor(uint8_t first,uint8_t second,uint8_t third);
13+
extern ESP8266WebServer server;
14+
extern void sendBuffer();
15+
extern void sendToBuffer(String str);
16+
extern void sendHeader(int code, String type, size_t _size);
1217
extern const bool debug;
1318

1419
extern Settings settings;
@@ -21,6 +26,7 @@ class APScan{
2126
String getResults();
2227
String getResult(int i);
2328
void select(int num);
29+
void sendResults();
2430

2531
String getAPName(int num);
2632
String getAPEncryption(int num);
@@ -38,6 +44,7 @@ class APScan{
3844
int selectedSum;
3945
MacList aps;
4046
private:
47+
4148
int channels[maxAPScanResults];
4249
int rssi[maxAPScanResults];
4350
char names[maxAPScanResults][33];
@@ -47,6 +54,7 @@ class APScan{
4754
String getEncryption(int code);
4855

4956
bool selected[maxAPScanResults];
57+
5058
};
5159

52-
#endif
60+
#endif

esp8266_deauther/Attack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void Attack::generate(){
1111
uint8_t _randomMacBuffer[6];
1212
beaconAdrs._clear();
1313

14-
for(int i=0;i<macListLen;i++) channels[i] = random(1,12);
14+
for(int i=0;i<macListLen;i++) channels[i] = random(1,maxChannel);
1515
do{
1616
getRandomVendorMac(_randomMacBuffer);
1717
for(int i=0;i<6;i++) _randomBeaconMac.setAt(_randomMacBuffer[i],i);
@@ -136,7 +136,7 @@ void Attack::run(){
136136
_selectedClients++;
137137

138138
if(settings.channelHop){
139-
for(int j=1;j<12;j++){
139+
for(int j=1;j<maxChannel;j++){
140140
wifi_set_channel(j);
141141

142142
buildDeauth(_ap, clientScan.getClientMac(i), 0xc0, settings.deauthReason );
@@ -160,7 +160,7 @@ void Attack::run(){
160160
_client.set(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
161161

162162
if(settings.channelHop){
163-
for(int j=1;j<12;j++){
163+
for(int j=1;j<maxChannel;j++){
164164
wifi_set_channel(j);
165165

166166
buildDeauth(_ap, _client, 0xc0, settings.deauthReason );

esp8266_deauther/Attack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef Attack_h
22
#define Attack_h
33

4+
#define maxChannel 11
5+
46
#include <ESP8266WiFi.h>
57

68
extern "C" {

esp8266_deauther/ClientScan.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ void ClientScan::start(int _time){
2525
curChannel = 0;
2626

2727
for(int i=0;i<apScan.results;i++){
28-
if(!intInArray(apScan.getAPChannel(i),channels)){
29-
channels[channelsNum] = apScan.getAPChannel(i);
30-
channelsNum++;
28+
if(apScan.isSelected(i)){
29+
if(!intInArray(apScan.getAPChannel(i),channels)){
30+
channels[channelsNum] = apScan.getAPChannel(i);
31+
channelsNum++;
32+
}
3133
}
3234
}
3335

0 commit comments

Comments
 (0)