Q5-Deauth after auth response
Topics in this section,
In this section, you are going to learn
How to send de-authentication packet on reception of authentication response packet from AP
# |
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 on reception of Authentication response packet from AP
Call flow for send de-authentication packet on reception of Authentication response packet from AP
ieee80211_add_iface
ieee80211_if_add
ieee80211_setup_sdata
ieee80211_iface_work
ieee80211_iface_process_skb
ieee80211_sta_rx_queued_mgmt
ieee80211_rx_mgmt_auth
drv_deauth
Download the below patch file
send_deauth_after_auth_res.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
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:57:33.171979781 +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 {
diff -crB original/net/mac80211/iface.c changed/net/mac80211/iface.c
*** original/net/mac80211/iface.c 2024-07-11 19:39:07.644259000 +0530
--- changed/net/mac80211/iface.c 2024-08-01 23:57:33.072029782 +0530
***************
*** 1655,1662 ****
if (skb->protocol == cpu_to_be16(ETH_P_TDLS))
ieee80211_process_tdls_channel_switch(sdata, skb);
! else
ieee80211_iface_process_skb(local, sdata, skb);
kfree_skb(skb);
kcov_remote_stop();
--- 1655,1663 ----
if (skb->protocol == cpu_to_be16(ETH_P_TDLS))
ieee80211_process_tdls_channel_switch(sdata, skb);
! else {
ieee80211_iface_process_skb(local, sdata, skb);
+ }
kfree_skb(skb);
kcov_remote_stop();
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:57:33.072029782 +0530
***************
*** 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) {
--- 250,259 ----
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;
}
--- 292,301 ----
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:57:33.072029782 +0530
***************
*** 716,719 ****
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "BB095EE77446E94801FEB4A");
--- 716,719 ----
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "6F149685AD0F248A15E244A");
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:57:33.171979781 +0530
***************
*** 3841,3846 ****
--- 3841,3880 ----
return true;
}
+ void drv_deauth(struct ieee80211_sub_if_data *sdata);
+
+ void drv_deauth(struct ieee80211_sub_if_data *sdata)
+ {
+ struct ieee80211_local *local = sdata->local;
+ struct sk_buff *skb;
+ u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
+ struct ieee80211_mgmt *mgmt = (void *)frame_buf;
+ struct ieee80211_hdr *hdr;
+ skb = dev_alloc_skb(local->hw.extra_tx_headroom +
+ IEEE80211_DEAUTH_FRAME_LEN);
+ if (!skb)
+ return;
+
+ hdr = (struct ieee80211_hdr *) skb->data;
+
+ /* build frame */
+ mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
+ mgmt->duration = 0; /* initialize only */
+ mgmt->seq_ctrl = 0; /* initialize only */
+ memcpy(mgmt->da, hdr->addrs.addr1, ETH_ALEN);
+ memcpy(mgmt->sa, hdr->addrs.addr2, ETH_ALEN);
+ memcpy(mgmt->bssid, hdr->addrs.addr3, ETH_ALEN);
+ mgmt->u.deauth.reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING);
+
+ skb_reserve(skb, local->hw.extra_tx_headroom);
+
+ /* copy in frame */
+ skb_put_data(skb, mgmt, IEEE80211_DEAUTH_FRAME_LEN);
+
+ ieee80211_tx_skb(sdata, skb);
+
+ }
+
static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt, size_t len)
{
***************
*** 3855,3861 ****
};
lockdep_assert_wiphy(sdata->local->hw.wiphy);
!
if (len < 24 + 6)
return;
--- 3889,3896 ----
};
lockdep_assert_wiphy(sdata->local->hw.wiphy);
! drv_deauth(sdata);
! return;
if (len < 24 + 6)
return;
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:57:33.076027782 +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_after_auth_res.patch
patching file net/mac80211/ieee80211_i.h
patching file net/mac80211/iface.c
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_after_auth_res.pcapng
Check for deauthentication packet
Check packet 141 and 142
Observe 141 is authentication response packet and 142 is deauthentication packet
