Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby st0ff3r » Thu Mar 04, 2021 9:18 pm
-> wifi_start_scan(WIFI_SCAN_INTERVAL)
@@ set csa state to CSA done
-> wifi_scan_timer_func()
RSSI: -65
@@ set csa state to CSA start 2
@@ add csa 1
@@ add csa 1
@@ add csa 3
@@ add csa 1
@@ add csa 1
@@ add csa 3
@@ add csa 1
@@ add csa 1
@@ add csa 3
@@ add csa 1
@@ add csa 1
@@ add csa 3
@@ add csa 1
@@ add csa 1
switch to channel 2
scandone
-> wifi_scan_done_cb(3fff37b8, 1)
-> wifi_start_scan(WIFI_SCAN_INTERVAL)
@@ set csa state to CSA done
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby ESP_Faye » Fri Mar 12, 2021 3:44 pm
- libnet80211.a.zip
- (112.81 KiB) Downloaded 6746 times
And provide the entire logs for debugging?
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby st0ff3r » Sat Mar 13, 2021 7:16 am
- Attachments
-
- serial_log.txt.zip
- (4.63 KiB) Downloaded 1674 times
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby ESP_Faye » Fri Mar 26, 2021 4:13 pm
Could you have a try with the new test lib?
- libnet80211-test2.a.zip
- (113.11 KiB) Downloaded 6570 times
If possible, could you provide captured Wi-Fi packets for analyzing?
Thanks.
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby st0ff3r » Mon Mar 29, 2021 11:55 pm
1. esp 8266 connected to ssid "Loppen Public" on channel 1
2. "beacon_spammer" sending out CSA's on channel 2
3. tcpdump running on same host as "beacon_spammer" on channel 2
Thanx a lot for your help to debug

- Attachments
-
- beacon_spammer_experiment.zip
- (6.99 KiB) Downloaded 1535 times
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby Her Mary » Fri Apr 23, 2021 10:46 am
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby st0ff3r » Sun Nov 28, 2021 9:04 am
Here is a simple program:
Code: Select all
static os_timer_t wifi_scan_timer;
static void wifi_scan_timer_func(void *arg);
ICACHE_FLASH_ATTR
void wifi_scan_done_cb(void *arg, STATUS status) {
struct bss_info *info;
if ((arg != NULL) && (status == OK)) {
info = (struct bss_info *)arg;
while (info != NULL) {
os_printf("channel: %d, ssid: %s, bssid %02x:%02x:%02x:%02x:%02x:%02x, rssi: %d, freq_offset: %d, freqcal_val: %d\n\r", info->channel,
info->ssid,
info->bssid[0],
info->bssid[1],
info->bssid[2],
info->bssid[3],
info->bssid[4],
info->bssid[5],
info->rssi,
info->freq_offset,
info->freqcal_val
);
info = info->next.stqe_next;
}
}
}
static void ICACHE_FLASH_ATTR wifi_scan_timer_func(void *arg) {
wifi_station_scan(NULL, wifi_scan_done_cb);
}
ICACHE_FLASH_ATTR void system_init_done(void) {
struct station_config stationConf;
wifi_set_opmode_current(STATIONAP_MODE);
memset(&stationConf, 0, sizeof(struct station_config));
wifi_station_get_config(&stationConf);
os_memcpy(&stationConf.ssid, "Loppen Public", 32);
os_memcpy(&stationConf.password, "", 64);
wifi_station_set_config_current(&stationConf);
wifi_station_connect();
os_timer_disarm(&wifi_scan_timer);
os_timer_setfn(&wifi_scan_timer, (os_timer_func_t *)wifi_scan_timer_func, NULL);
os_timer_arm(&wifi_scan_timer, 5000, 1);
}
ICACHE_FLASH_ATTR void user_init(void) {
system_update_cpu_freq(160);
uart_init(BIT_RATE_115200, BIT_RATE_115200);
wifi_set_opmode_current(NULL_MODE);
wifi_station_disconnect();
system_init_done_cb(&system_init_done);
}
and this is the output, while it runs simultaniously with another one also scanning. So as my earlier debugging shows (https://github.com/espressif/ESP8266_NONOS_SDK/issues/312) the code honour 802.11 beacons containing CSA when scanning, even if its sent from another ap than its connected to:
mode : sta(ec:fa:bc:21:27:94) + softAP(ee:fa:bc:21:27:94)
add if0
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
connected with Loppen Public, channel 1
dhcp client start...
cnt
ip:10.0.1.177,mask:255.255.255.0,gw:10.0.1.1
switch to channel 6
scandone
switch to channel 6
scandone
switch to channel 6
scandone
switch to channel 6
scandone
scandone
switch to channel 6
scandone
switch to channel 6
scandone
[...]
Re: Wrongly reacting to and sending 802.11 beacons with Channel Switch Announcement
Postby st0ff3r » Tue Nov 30, 2021 8:38 am
So in a desparate try to force the esp to _not_ sending out CSA while scanning, I patched the function ieee80211_add_csa() in ieee80211_output.o like this:
40214748 <ieee80211_add_csa>:
40214748: f00d ret.n
so it completely skips the adding of CSA.
It worked!
I am not seeing "switch to channel X" anymore if there are no ESP's with unpatched ieee80211_add_csa close.
But a better solution would be if it would not _react_ to CSA's sent from other ESP's acting as an access points, when the client is not connected to that specific access point.
Any chances you could look into it? As it is now, the ESP's connection to an access point can be disconnected by anybody sending "evil" beacon packages.
Who is online
Users browsing this forum: No registered users and 5 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.