Skip to content

Commit afcf33b

Browse files
authored
Merge pull request esp8266#76 from spacehuhn/testing
Merge Testing Branch
2 parents 46e3a0f + f2b13a5 commit afcf33b

34 files changed

+3391
-546
lines changed

README.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,20 @@ It doesn’t matter which board you use, as long as it has an ESP8266 on it.
100100

101101
**don't forget to save!**
102102

103-
**12** Download and open `esp8266_deauther` > `esp8266_deauther.ino` in Arduino
103+
**12** Download the project
104104

105-
**13** Select your ESP8266 board at `Tools` > `Board` and the right port at `Tools` > `Port`
105+
**13** Go to the SDK_fix folder of this project
106+
107+
**14** Copy ESP8266WiFi.cpp and ESP8266WiFi.h
108+
109+
**15** Past these files here `packages` > `esp8266` > `hardware` > `esp8266` > `2.0.0` > `libraries` > `ESP8266WiFi` > `src`
110+
111+
**16** Open `esp8266_deauther` > `esp8266_deauther.ino` in Arduino
112+
113+
**17** Select your ESP8266 board at `Tools` > `Board` and the right port at `Tools` > `Port`
106114
If no port shows up you may have to reinstall the drivers.
107115

108-
**14** Upload!
116+
**18** Upload!
109117

110118
**Your ESP8266 Deauther is now ready!**
111119

@@ -134,13 +142,13 @@ Happy hacking :)
134142

135143
## FAQ
136144

137-
**Could it deauth multiple APs in the range?**
145+
**Could it auto-deauth all APs in the range?**
138146

139-
It definitely could! But I will not implement this 'feature' for ethical and legal reasons.
147+
Yes, but I will not implement this 'feature' for ethical and legal reasons.
140148

141149
**Can it sniff handshakes?**
142150

143-
The ESP8266 has a promiscuous mode in which you can sniff nearly all packets, but handshake packets are dropped and there is no other way to get them with the functions provided by the SDK.
151+
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.
144152
Maybe someone will find a way around this barrier but I wasn't able to.
145153

146154
**espcomm_sync failed/espcomm_open when uploading**
@@ -152,7 +160,7 @@ Which drivers you need depends on the board, most boards use a cp2102, cp2104 or
152160

153161
**AP scan doesn't work**
154162

155-
There is a reported issue with the Internet Explorer: https://github.com/spacehuhn/esp8266_deauther/issues/5
163+
There is a reported issue on this: https://github.com/spacehuhn/esp8266_deauther/issues/5
156164
Try out switching the browser or open the website with another device.
157165

158166
**Deauth attack won't work**

esp8266_deauther/APScan.cpp

+123-29
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,73 @@ APScan::APScan(){
55
}
66

77
bool APScan::start(){
8+
if(debug){
9+
Serial.println("starting AP scan...");
10+
Serial.println("MAC - Ch - RSSI - Encrypt. - SSID - Hidden");// - Vendor");
11+
}
812
aps._clear();
9-
selected = -1;
10-
results = WiFi.scanNetworks();
13+
for(int i=0;i<maxAPScanResults;i++) selected[i] = false;
14+
results = WiFi.scanNetworks(false, settings.apScanHidden); // lets scanNetworks return hidden APs. (async = false & show_hidden = true)
1115

12-
for(int i=0;i<results && i<maxResults;i++){
16+
for(int i=0;i<results && i<maxAPScanResults;i++){
1317
Mac _ap;
1418
_ap.set(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2],WiFi.BSSID(i)[3],WiFi.BSSID(i)[4],WiFi.BSSID(i)[5]);
1519
aps.add(_ap);
1620
channels[i] = WiFi.channel(i);
1721
rssi[i] = WiFi.RSSI(i);
18-
getEncryption(WiFi.encryptionType(i)).toCharArray(encryption[i],5);
19-
WiFi.SSID(i).toCharArray(names[i],33);
20-
data_getVendor(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2]).toCharArray(vendors[i],9);
22+
encryption[i] = WiFi.encryptionType(i);
23+
hidden[i] = WiFi.isHidden(i);
24+
String _ssid = WiFi.SSID(i);
25+
_ssid.replace("\"","\\\"");
26+
_ssid.toCharArray(names[i],33);
27+
//data_getVendor(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2]).toCharArray(vendors[i],9);
28+
if(debug){
29+
_ap._print();
30+
Serial.print(" - ");
31+
Serial.print(channels[i]);
32+
Serial.print(" - ");
33+
Serial.print(rssi[i]);
34+
Serial.print(" - ");
35+
Serial.print(getEncryption(encryption[i]));
36+
Serial.print(" - ");
37+
Serial.print(names[i]);
38+
Serial.print(" - ");
39+
Serial.print(hidden[i]);
40+
//Serial.print(" - ");
41+
//Serial.print(vendors[i]);
42+
Serial.println();
43+
}
2144
}
45+
46+
//for debugging the APScan crash bug
47+
/*if(debug){
48+
for(int i=results;i<maxAPScanResults;i++){
49+
Mac _ap;
50+
_ap.set(random(255),random(255),random(255),random(255),random(255),random(255));
51+
aps.add(_ap);
52+
channels[i] = random(1,12);
53+
rssi[i] = random(-30,-90);
54+
encryption[i] = ENC_TYPE_NONE;
55+
String _ssid = "test_dbeJwq3tPtJsuWtgULgShD9dxXV";
56+
_ssid.toCharArray(names[i],33);
57+
58+
_ap._print();
59+
Serial.print(" - ");
60+
Serial.print(channels[i]);
61+
Serial.print(" - ");
62+
Serial.print(rssi[i]);
63+
Serial.print(" - ");
64+
Serial.print(getEncryption(encryption[i]));
65+
Serial.print(" - ");
66+
Serial.print(names[i]);
67+
Serial.println();
68+
69+
results++;
70+
}
71+
}*/
72+
73+
if(debug) Serial.println("scan done");
74+
if(debug) Serial.println(getResults());
2275
return true;
2376
}
2477

@@ -39,46 +92,87 @@ String APScan::getEncryption(int code){
3992
case ENC_TYPE_AUTO:
4093
return "WPA*";
4194
break;
42-
}
95+
}
96+
return "?";
4397
}
4498

45-
String APScan::getAPName(int num){ return names[num]; }
46-
String APScan::getAPEncryption(int num){ return encryption[num]; }
47-
String APScan::getAPVendor(int num){ return vendors[num]; }
48-
String APScan::getAPMac(int num){ return aps._get(num).toString(); }
49-
String APScan::getAPSelected(int num){
50-
if(selected == num) return "true";
51-
else return "false";
99+
String APScan::getAPName(int num){
100+
if(isHidden(num)) return "* Hidden SSID *";
101+
return names[num];
52102
}
103+
String APScan::getAPEncryption(int num){ return getEncryption(encryption[num]); }
104+
//String APScan::getAPVendor(int num){ return vendors[num]; }
105+
String APScan::getAPMac(int num){ return aps._get(num).toString(); }
106+
bool APScan::getAPSelected(int num){ return selected[num]; }
107+
bool APScan::isHidden(int num){ return hidden[num]; }
53108
int APScan::getAPRSSI(int num){ return rssi[num]; }
54109
int APScan::getAPChannel(int num){ return channels[num]; }
55110

56-
Mac APScan::getTarget(){
57-
return aps._get(selected);
111+
int APScan::getFirstTarget(){
112+
for(int i=0;i<maxAPScanResults;i++){
113+
if(isSelected(i)) return i;
114+
}
115+
return -1;
58116
}
59117

60118
String APScan::getResults(){
119+
if(debug) Serial.print("getting AP scan result JSON ");
61120
String json = "{ \"aps\":[ ";
62-
for(int i=0;i<results && i<maxResults;i++){
121+
for(int i=0;i<results && i<maxAPScanResults;i++){
122+
if(debug) Serial.print(".");
63123
json += "{";
64-
json += "\"id\": "+(String)i+",";
65-
json += "\"channel\": "+(String)getAPChannel(i)+",";
66-
json += "\"mac\": \""+getAPMac(i)+"\",";
67-
json += "\"ssid\": \""+getAPName(i)+"\",";
68-
json += "\"rssi\": "+(String)getAPRSSI(i)+",";
69-
json += "\"encryption\": \""+getAPEncryption(i)+"\",";
70-
json += "\"vendor\": \""+getAPVendor(i)+"\",";
71-
json += "\"selected\": "+getAPSelected(i);
124+
json += "\"i\":"+(String)i+",";
125+
json += "\"c\":"+(String)getAPChannel(i)+",";
126+
json += "\"m\":\""+getAPMac(i)+"\",";
127+
json += "\"ss\":\""+getAPName(i)+"\",";
128+
json += "\"r\":"+(String)getAPRSSI(i)+",";
129+
json += "\"e\":"+(String)encryption[i]+",";
130+
//json += "\"v\":\""+getAPVendor(i)+"\",";
131+
json += "\"se\":"+(String)getAPSelected(i);
72132
json += "}";
73-
if((i!=results-1) && (i!=maxResults-1)) json += ",";
133+
if((i!=results-1) && (i!=maxAPScanResults-1)) json += ",";
74134
}
75135
json += "] }";
136+
if(debug){
137+
Serial.println(json);
138+
Serial.println("done");
139+
}
140+
return json;
141+
}
142+
143+
String APScan::getResult(int i){
144+
if(debug) Serial.print("getting AP scan result JSON for ID " + String(i));
145+
String json = "{ \"aps\":[ ";
146+
if(debug) Serial.print(".");
147+
json += "{";
148+
json += "\"i\":"+(String)i+",";
149+
json += "\"c\":"+(String)getAPChannel(i)+",";
150+
json += "\"m\":\""+getAPMac(i)+"\",";
151+
json += "\"ss\":\""+getAPName(i)+"\",";
152+
json += "\"r\":"+(String)getAPRSSI(i)+",";
153+
json += "\"e\":"+(String)encryption[i]+",";
154+
//json += "\"v\":\""+getAPVendor(i)+"\",";
155+
json += "\"se\":"+(String)getAPSelected(i);
156+
json += "}";
157+
json += "] }";
158+
if(debug){
159+
Serial.println(json);
160+
Serial.println("done");
161+
}
76162
return json;
77163
}
78164

79165
void APScan::select(int num){
80-
if(selected != num) selected = num;
81-
else selected = -1;
166+
if(debug) Serial.println("seect "+(String)num+" - "+!selected[num]);
167+
if(selected[num]){
168+
selected[num] = false;
169+
selectedSum--;
170+
}else{
171+
selected[num] = true;
172+
selectedSum++;
173+
}
82174
}
83175

84-
176+
bool APScan::isSelected(int num){
177+
return selected[num];
178+
}

esp8266_deauther/APScan.h

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,52 @@
11
#ifndef APScan_h
22
#define APScan_h
33

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

6-
#include "ESP8266WiFi.h"
6+
#include <ESP8266WiFi.h>
77
#include "Mac.h"
88
#include "MacList.h"
9+
#include "Settings.h"
910

1011
extern String data_getVendor(uint8_t first,uint8_t second,uint8_t third);
12+
extern const bool debug;
13+
14+
extern Settings settings;
1115

1216
class APScan{
1317
public:
1418
APScan();
1519

1620
bool start();
1721
String getResults();
22+
String getResult(int i);
1823
void select(int num);
1924

2025
String getAPName(int num);
2126
String getAPEncryption(int num);
22-
String getAPVendor(int num);
27+
//String getAPVendor(int num);
2328
String getAPMac(int num);
24-
String getAPSelected(int num);
29+
bool getAPSelected(int num);
30+
bool isHidden(int num);
2531
int getAPRSSI(int num);
2632
int getAPChannel(int num);
2733

28-
Mac getTarget();
29-
34+
int getFirstTarget();
35+
bool isSelected(int num);
36+
3037
int results = 0;
31-
int selected = -1;
32-
private:
38+
int selectedSum;
3339
MacList aps;
34-
int channels[maxResults];
35-
int rssi[maxResults];
36-
char names[maxResults][33];
37-
char encryption[maxResults][5];
38-
char vendors[maxResults][9];
39-
40+
private:
41+
int channels[maxAPScanResults];
42+
int rssi[maxAPScanResults];
43+
char names[maxAPScanResults][33];
44+
int encryption[maxAPScanResults];
45+
bool hidden[maxAPScanResults];
46+
4047
String getEncryption(int code);
48+
49+
bool selected[maxAPScanResults];
4150
};
4251

43-
#endif
52+
#endif

0 commit comments

Comments
 (0)