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 |
Supplicant |
wpa_supplicant 2.10 |
Hostapd |
hostapd 2.10 |
Send De-Authentication packet once every 30 seconds
Call flow for send de-authentication packet once every 30 seconds
ieee80211_add_iface ()
ieee80211_if_add ()
ieee80211_setup_sdata ()
ieee80211_iface_work ()
ieee80211_iface_process_skb ()
ieee80211_sta_rx_queued_mgmt ()
ieee80211_rx_mgmt_assoc_resp ()
drv_deauth_detection_work ()
Download the below patch file
send_deauth_pkt_every_30sec.patch
See the full content of patch file
Binary files original/net/mac80211/agg-rx.o and changed/net/mac80211/agg-rx.o differ
Binary files original/net/mac80211/agg-tx.o and changed/net/mac80211/agg-tx.o differ
Binary files original/net/mac80211/airtime.o and changed/net/mac80211/airtime.o differ
diff -crB original/net/mac80211/cfg.c changed/net/mac80211/cfg.c
*** original/net/mac80211/cfg.c 2024-07-11 19:39:07.644259000 +0530
--- changed/net/mac80211/cfg.c 2024-08-01 23:20:52.808738661 +0530
***************
*** 4800,4805 ****
--- 4800,4833 ----
ieee80211_color_change_finalize(sdata);
}
+ void drv_deauth_detection_work(struct work_struct *work)
+ {
+ struct delayed_work *delayed_work = to_delayed_work(work);
+ struct ieee80211_link_data *link =
+ container_of(delayed_work, struct ieee80211_link_data,
+ drv_deauth_work);
+ struct ieee80211_sub_if_data *sdata = link->sdata;
+ struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+
+ ieee80211_queue_delayed_work(&sdata->local->hw,
+ &link->drv_deauth_work,
+ msecs_to_jiffies(30000));
+ u8 bssid[ETH_ALEN];
+ struct cfg80211_deauth_request req = {
+ .reason_code = WLAN_REASON_DEAUTH_LEAVING,
+ .bssid = bssid,
+ };
+
+ memcpy(bssid, sdata->vif.cfg.ap_addr, ETH_ALEN);
+
+ sdata_info(sdata,
+ "DEBUG : association with %pM (Reason: %u=%s)\n",
+ req.bssid, req.reason_code,
+ ieee80211_get_reason_code_string(req.reason_code));
+
+ ieee80211_mgd_deauth(sdata, &req);
+ }
+
void ieee80211_color_collision_detection_work(struct work_struct *work)
{
struct delayed_work *delayed_work = to_delayed_work(work);
Binary files original/net/mac80211/cfg.o and changed/net/mac80211/cfg.o differ
Binary files original/net/mac80211/chan.o and changed/net/mac80211/chan.o differ
Binary files original/net/mac80211/debugfs_key.o and changed/net/mac80211/debugfs_key.o differ
Binary files original/net/mac80211/debugfs_netdev.o and changed/net/mac80211/debugfs_netdev.o differ
Binary files original/net/mac80211/debugfs.o and changed/net/mac80211/debugfs.o differ
Binary files original/net/mac80211/debugfs_sta.o and changed/net/mac80211/debugfs_sta.o differ
Binary files original/net/mac80211/driver-ops.o and changed/net/mac80211/driver-ops.o differ
Binary files original/net/mac80211/eht.o and changed/net/mac80211/eht.o differ
Binary files original/net/mac80211/ethtool.o and changed/net/mac80211/ethtool.o differ
Binary files original/net/mac80211/fils_aead.o and changed/net/mac80211/fils_aead.o differ
Binary files original/net/mac80211/he.o and changed/net/mac80211/he.o differ
Binary files original/net/mac80211/ht.o and changed/net/mac80211/ht.o differ
Binary files original/net/mac80211/ibss.o and changed/net/mac80211/ibss.o differ
diff -crB original/net/mac80211/ieee80211_i.h changed/net/mac80211/ieee80211_i.h
*** original/net/mac80211/ieee80211_i.h 2024-07-11 19:39:07.644259000 +0530
--- changed/net/mac80211/ieee80211_i.h 2024-08-01 23:20:52.636824663 +0530
***************
*** 599,604 ****
--- 599,605 ----
/* dialog token enumerator for neg TTLM request */
u8 dialog_token_alloc;
struct wiphy_delayed_work neg_ttlm_timeout_work;
+ int drv_sta_data ;
};
struct ieee80211_if_ibss {
***************
*** 1041,1046 ****
--- 1042,1048 ----
struct wiphy_work color_change_finalize_work;
struct delayed_work color_collision_detect_work;
+ struct delayed_work drv_deauth_work;
u64 color_bitmap;
/* context reservation -- protected with wiphy mutex */
***************
*** 1984,1990 ****
void ieee80211_color_change_finalize_work(struct wiphy *wiphy,
struct wiphy_work *work);
void ieee80211_color_collision_detection_work(struct work_struct *work);
!
/* interface handling */
#define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
NETIF_F_HW_CSUM | NETIF_F_SG | \
--- 1986,1992 ----
void ieee80211_color_change_finalize_work(struct wiphy *wiphy,
struct wiphy_work *work);
void ieee80211_color_collision_detection_work(struct work_struct *work);
! void drv_deauth_detection_work(struct work_struct *work);
/* interface handling */
#define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
NETIF_F_HW_CSUM | NETIF_F_SG | \
Binary files original/net/mac80211/iface.o and changed/net/mac80211/iface.o differ
Binary files original/net/mac80211/key.o and changed/net/mac80211/key.o differ
Binary files original/net/mac80211/led.o and changed/net/mac80211/led.o differ
diff -crB original/net/mac80211/link.c changed/net/mac80211/link.c
*** original/net/mac80211/link.c 2024-07-11 19:39:07.644259000 +0530
--- changed/net/mac80211/link.c 2024-08-01 23:20:52.636824663 +0530
***************
*** 43,48 ****
--- 43,50 ----
ieee80211_color_change_finalize_work);
INIT_DELAYED_WORK(&link->color_collision_detect_work,
ieee80211_color_collision_detection_work);
+ INIT_DELAYED_WORK(&link->drv_deauth_work,
+ drv_deauth_detection_work);
INIT_LIST_HEAD(&link->assigned_chanctx_list);
INIT_LIST_HEAD(&link->reserved_chanctx_list);
wiphy_delayed_work_init(&link->dfs_cac_timer_work,
***************
*** 73,78 ****
--- 75,81 ----
ieee80211_mgd_stop_link(link);
cancel_delayed_work_sync(&link->color_collision_detect_work);
+ cancel_delayed_work_sync(&link->drv_deauth_work);
wiphy_work_cancel(link->sdata->local->hw.wiphy,
&link->csa_finalize_work);
ieee80211_link_release_channel(link);
***************
*** 250,258 ****
ieee80211_link_setup(&link->data);
}
! if (new_links == 0)
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
ret = ieee80211_check_dup_link_addrs(sdata);
if (!ret) {
--- 253,262 ----
ieee80211_link_setup(&link->data);
}
! if (new_links == 0) {
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
+ }
ret = ieee80211_check_dup_link_addrs(sdata);
if (!ret) {
***************
*** 291,299 ****
links[link_id] = NULL;
}
deinit:
! if (use_deflink)
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
return ret;
}
--- 295,304 ----
links[link_id] = NULL;
}
deinit:
! if (use_deflink) {
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
+ }
return ret;
}
Binary files original/net/mac80211/link.o and changed/net/mac80211/link.o differ
Binary files original/net/mac80211/mac80211.ko and changed/net/mac80211/mac80211.ko differ
diff -crB original/net/mac80211/mac80211.mod.c changed/net/mac80211/mac80211.mod.c
*** original/net/mac80211/mac80211.mod.c 2024-07-11 19:39:07.824257000 +0530
--- changed/net/mac80211/mac80211.mod.c 2024-08-01 23:20:52.636824663 +0530
***************
*** 716,719 ****
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "BB095EE77446E94801FEB4A");
--- 716,719 ----
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "45836E81CE65082E6BAD045");
Binary files original/net/mac80211/mac80211.mod.o and changed/net/mac80211/mac80211.mod.o differ
Binary files original/net/mac80211/mac80211.o and changed/net/mac80211/mac80211.o differ
Binary files original/net/mac80211/main.o and changed/net/mac80211/main.o differ
Binary files original/net/mac80211/mesh_hwmp.o and changed/net/mac80211/mesh_hwmp.o differ
Binary files original/net/mac80211/mesh.o and changed/net/mac80211/mesh.o differ
Binary files original/net/mac80211/mesh_pathtbl.o and changed/net/mac80211/mesh_pathtbl.o differ
Binary files original/net/mac80211/mesh_plink.o and changed/net/mac80211/mesh_plink.o differ
Binary files original/net/mac80211/mesh_ps.o and changed/net/mac80211/mesh_ps.o differ
Binary files original/net/mac80211/mesh_sync.o and changed/net/mac80211/mesh_sync.o differ
diff -crB original/net/mac80211/mlme.c changed/net/mac80211/mlme.c
*** original/net/mac80211/mlme.c 2024-07-11 19:39:07.648259000 +0530
--- changed/net/mac80211/mlme.c 2024-08-01 23:20:52.740772662 +0530
***************
*** 5466,5473 ****
event.u.mlme.status = MLME_SUCCESS;
drv_event_callback(sdata->local, sdata, &event);
sdata_info(sdata, "associated\n");
-
info.success = 1;
}
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
--- 5466,5481 ----
event.u.mlme.status = MLME_SUCCESS;
drv_event_callback(sdata->local, sdata, &event);
sdata_info(sdata, "associated\n");
info.success = 1;
+ static int check_timer = 0;
+ ifmgd->drv_sta_data = 45;
+ if (!check_timer) {
+ check_timer = 1;
+ struct ieee80211_link_data *link = &sdata->deflink;
+ ieee80211_queue_delayed_work(&sdata->local->hw,
+ &link->drv_deauth_work,
+ msecs_to_jiffies(30000));
+ }
}
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
Binary files original/net/mac80211/mlme.o and changed/net/mac80211/mlme.o differ
Binary files original/net/mac80211/ocb.o and changed/net/mac80211/ocb.o differ
Binary files original/net/mac80211/offchannel.o and changed/net/mac80211/offchannel.o differ
Binary files original/net/mac80211/parse.o and changed/net/mac80211/parse.o differ
Binary files original/net/mac80211/pm.o and changed/net/mac80211/pm.o differ
Binary files original/net/mac80211/rate.o and changed/net/mac80211/rate.o differ
Binary files original/net/mac80211/rc80211_minstrel_ht.o and changed/net/mac80211/rc80211_minstrel_ht.o differ
Binary files original/net/mac80211/rx.o and changed/net/mac80211/rx.o differ
Binary files original/net/mac80211/s1g.o and changed/net/mac80211/s1g.o differ
Binary files original/net/mac80211/scan.o and changed/net/mac80211/scan.o differ
Binary files original/net/mac80211/spectmgmt.o and changed/net/mac80211/spectmgmt.o differ
Binary files original/net/mac80211/sta_info.o and changed/net/mac80211/sta_info.o differ
Binary files original/net/mac80211/status.o and changed/net/mac80211/status.o differ
Binary files original/net/mac80211/tdls.o and changed/net/mac80211/tdls.o differ
Binary files original/net/mac80211/tkip.o and changed/net/mac80211/tkip.o differ
Binary files original/net/mac80211/trace.o and changed/net/mac80211/trace.o differ
Binary files original/net/mac80211/tx.o and changed/net/mac80211/tx.o differ
diff -crB original/net/mac80211/util.c changed/net/mac80211/util.c
*** original/net/mac80211/util.c 2024-07-11 19:39:07.652259000 +0530
--- changed/net/mac80211/util.c 2024-08-01 23:20:52.636824663 +0530
***************
*** 1234,1240 ****
*offset);
if (skb_tailroom(skb) < noffset - *offset)
return -ENOBUFS;
! skb_put_data(skb, ie + *offset, noffset - *offset);
*offset = noffset;
}
--- 1234,1240 ----
*offset);
if (skb_tailroom(skb) < noffset - *offset)
return -ENOBUFS;
!
*offset = noffset;
}
Binary files original/net/mac80211/util.o and changed/net/mac80211/util.o differ
Binary files original/net/mac80211/vht.o and changed/net/mac80211/vht.o differ
Binary files original/net/mac80211/wbrf.o and changed/net/mac80211/wbrf.o differ
Binary files original/net/mac80211/wep.o and changed/net/mac80211/wep.o differ
Binary files original/net/mac80211/wme.o and changed/net/mac80211/wme.o differ
Binary files original/net/mac80211/wpa.o and changed/net/mac80211/wpa.o differ
test:~$ pwd
/home/test/
Compile Linux
Change directory to linux-6.9.2
test:~$ cd linux-6.9.2/
Note : Your present working directory should be linux-6.9.2
test:~$ pwd
/home/test/linux-6.9.2/
Remove mac80211 module
test:~$ sudo systemctl stop NetworkManager.service
test:~$ sudo rmmod mac80211
Run the below command to apply patch
test:~$ sudo patch -p1 < send_deauth_pkt_every_30sec.patch
patching file net/mac80211/cfg.c
patching file net/mac80211/ieee80211_i.h
patching file net/mac80211/link.c
patching file net/mac80211/mac80211.mod.c
patching file net/mac80211/mlme.c
patching file net/mac80211/util.c
Compile mac80211 folder
test:~$ sudo make -C . M=net/mac80211/
Insert mac80211 module
test:~$ sudo insmod ./net/mac80211/mac80211.ko
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
