Q3-Send-deauth
Topics in this section,
In this section, you are going to learn
How to send de-authentication packet once every 30 seconds
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux Kernel |
6.9.2 |
Hostapd |
hostapd 2.10 |
Send De-Authentication packet once every 30 seconds
Call flow for send de-authentication packet once every 30 seconds
nl80211_global_init ()
wpa_driver_nl80211_init_nl_global ()
i802_init ()
wpa_driver_nl80211_drv_init ()
nl80211_init_bss ()
wpa_driver_nl80211_set_ap ()
send_and_recv_msgs_connect_handle ()
process_global_event ()
do_process_drv_event ()
mlme_event ()
mlme_event_mgmt_tx_status ()
process_bss_event ()
mlme_event ()
mlme_event_mgmt ()
wpa_supplicant_event ()
hostapd_mgmt_tx_cb ()
ieee802_11_mgmt_cb ()
handle_assoc_cb ()
ap_sta_set_authorized ()
ap_send_deauth ()
Download the below patch file
send_deauth_pkt_every_30sec.patch
See the full content of patch file
diff -crB original/hostapd-2.10/hostapd/config_file.c changed/hostapd-2.10/hostapd/config_file.c
*** original/hostapd-2.10/hostapd/config_file.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/hostapd/config_file.c 2024-07-26 11:15:26.876545770 +0530
***************
*** 2353,2359 ****
struct hostapd_bss_config *bss,
const char *buf, char *pos, int line)
{
! if (os_strcmp(buf, "interface") == 0) {
os_strlcpy(conf->bss[0]->iface, pos,
sizeof(conf->bss[0]->iface));
} else if (os_strcmp(buf, "bridge") == 0) {
--- 2353,2361 ----
struct hostapd_bss_config *bss,
const char *buf, char *pos, int line)
{
! if (os_strcmp(buf, "periodic_deauth") == 0) {
! conf->periodic_deauth = atoi(pos);
! } else if (os_strcmp(buf, "interface") == 0) {
os_strlcpy(conf->bss[0]->iface, pos,
sizeof(conf->bss[0]->iface));
} else if (os_strcmp(buf, "bridge") == 0) {
diff -crB original/hostapd-2.10/src/ap/ap_config.h changed/hostapd-2.10/src/ap/ap_config.h
*** original/hostapd-2.10/src/ap/ap_config.h 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/ap_config.h 2024-07-26 11:28:32.852533573 +0530
***************
*** 1100,1105 ****
--- 1100,1106 ----
unsigned int airtime_update_interval;
#define AIRTIME_MODE_MAX (__AIRTIME_MODE_MAX - 1)
#endif /* CONFIG_AIRTIME_POLICY */
+ int periodic_deauth;
};
diff -crB original/hostapd-2.10/src/ap/ieee802_11.c changed/hostapd-2.10/src/ap/ieee802_11.c
*** original/hostapd-2.10/src/ap/ieee802_11.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/ieee802_11.c 2024-07-26 11:03:16.940557096 +0530
***************
*** 5502,5508 ****
capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
listen_interval = le_to_host16(
mgmt->u.assoc_req.listen_interval);
! wpa_printf(MSG_DEBUG, "association request: STA=" MACSTR
" capab_info=0x%02x listen_interval=%d "
"seq_ctrl=0x%x%s",
MAC2STR(mgmt->sa), capab_info, listen_interval,
--- 5502,5508 ----
capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
listen_interval = le_to_host16(
mgmt->u.assoc_req.listen_interval);
! wpa_printf(MSG_INFO, "association request: STA=" MACSTR
" capab_info=0x%02x listen_interval=%d "
"seq_ctrl=0x%x%s",
MAC2STR(mgmt->sa), capab_info, listen_interval,
diff -crB original/hostapd-2.10/src/ap/sta_info.c changed/hostapd-2.10/src/ap/sta_info.c
*** original/hostapd-2.10/src/ap/sta_info.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/sta_info.c 2024-07-26 11:30:06.828532115 +0530
***************
*** 1259,1264 ****
--- 1259,1276 ----
return psk->keyid;
}
+ static int onetime_deauth_entry;
+
+ static void ap_send_deauth(void *eloop_ctx, void *timeout_ctx)
+ {
+ struct hostapd_data *hapd = eloop_ctx;
+ struct sta_info *sta = timeout_ctx;
+
+ ap_get_curtime();
+ hostapd_drv_sta_deauth(hapd, sta->addr, WLAN_REASON_UNSPECIFIED);
+
+ eloop_register_timeout(hapd->iconf->periodic_deauth, 0, ap_send_deauth, hapd, sta);
+ }
void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
int authorized)
***************
*** 1321,1327 ****
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s",
buf, ip_addr, keyid_buf);
!
if (hapd->msg_ctx_parent &&
hapd->msg_ctx_parent != hapd->msg_ctx)
wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
--- 1333,1343 ----
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s",
buf, ip_addr, keyid_buf);
! if (!(onetime_deauth_entry)) {
! onetime_deauth_entry = 1;
! eloop_register_timeout(hapd->iconf->periodic_deauth, 0, ap_send_deauth, hapd, sta);
! return ;
! }
if (hapd->msg_ctx_parent &&
hapd->msg_ctx_parent != hapd->msg_ctx)
wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
diff -crB original/hostapd-2.10/src/utils/os.h changed/hostapd-2.10/src/utils/os.h
*** original/hostapd-2.10/src/utils/os.h 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/utils/os.h 2024-07-26 11:30:22.668531869 +0530
***************
*** 35,40 ****
--- 35,42 ----
*/
int os_get_time(struct os_time *t);
+ void ap_get_curtime();
+
/**
* os_get_reltime - Get relative time (sec, usec)
* @t: Pointer to buffer for the time
diff -crB original/hostapd-2.10/src/utils/os_unix.c changed/hostapd-2.10/src/utils/os_unix.c
*** original/hostapd-2.10/src/utils/os_unix.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/utils/os_unix.c 2024-07-26 11:30:46.324531502 +0530
***************
*** 72,77 ****
--- 72,88 ----
return res;
}
+ void ap_get_curtime()
+ {
+ struct timeval tv;
+ struct timezone tz;
+ struct tm *today;
+
+ gettimeofday(&tv, &tz);
+
+ today = localtime(&tv.tv_sec);
+
+ }
int os_get_reltime(struct os_reltime *t)
{
test:~$ pwd
/home/test
Make sure internet is available in laptop to download hostapd package
test:~$ sudo wget http://w1.fi/releases/hostapd-2.10.tar.gz
Create a directory
test:~$ mkdir hostapd
Change directory to hostapd
test:~$ cd hostapd
Note : Your present working directory should be hostapd
test:~$ pwd
/home/test/hostapd/
Extract hostapd
test:~$ sudo tar -xvf ~/hostapd-2.10.tar.gz
Run the below command to apply patch
test:~$ patch -p1 < send_deauth_pkt_every_30sec.patch
patching file hostapd-2.10/hostapd/config_file.c
patching file hostapd-2.10/src/ap/ap_config.h
patching file hostapd-2.10/src/ap/ieee802_11.c
patching file hostapd-2.10/src/ap/sta_info.c
patching file hostapd-2.10/src/utils/os.h
patching file hostapd-2.10/src/utils/os_unix.c
Change directory to hostapd
test:~$ cd hostapd-2.10/hostapd/
Check the current working directory using pwd command
Make sure your current working directory is hostapd
test:~$ pwd
/home/test/hostapd/hostapd-2.10/hostapd/
Copy the contents of defconfig file to .config file
test:~$ sudo cp defconfig .config
Compile hostapd
test:~$ sudo make
Create run_hostapd.conf
test:~$ sudo vim ./run_hostapd.conf
ctrl_interface=/run/hostapd
interface=wlan0
driver=nl80211
ssid=test_open
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
periodic_deauth=30
Run hostapd
test:~$ sudo ./hostapd ./run_hostapd.conf
Download file to check wireshark output
send_deauth_pkt_every_30sec.pcapng
Check for de-authentication packet
Apply display filter
wlan.addr == 02:00:00:00:01:00 && wlan.fc.type_subtype == 12

Observe the de-authentication packets with 30 sec time interval
