Wifi_sniffer_packet_handler(void* buff, wifi_promiscuous_pkt_type_t type)Ĭonst wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff Ĭonst wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)ppkt->payload Ĭonst wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr Wifi_sniffer_packet_type2str(wifi_promiscuous_pkt_type_t type) Wifi_sniffer_set_channel(uint8_t channel)Įsp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE) Wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT() ĮSP_ERROR_CHECK( esp_wifi_set_country(&wifi_country) ) /* set country for channel range */ĮSP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ) ĮSP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) ) Įsp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler) VTaskDelay(WIFI_CHANNEL_SWITCH_INTERVAL / portTICK_PERIOD_MS) Ĭhannel = (channel % WIFI_CHANNEL_MAX) + 1 Įvent_handler(void *ctx, system_event_t *event)ĮSP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ) Gpio_set_level(LED_GPIO_PIN, level ^= 1) Gpio_set_direction(LED_GPIO_PIN, GPIO_MODE_OUTPUT) Static void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type) Static const char *wifi_sniffer_packet_type2str(wifi_promiscuous_pkt_type_t type) Static void wifi_sniffer_set_channel(uint8_t channel) Static esp_err_t event_handler(void *ctx, system_event_t *event) Uint8_t payload /* network data ended with 4 bytes csum (CRC32) */ #define WIFI_CHANNEL_SWITCH_INTERVAL (500) * Copyright (c) 2017, Łukasz Marcin Podkalicki Don’t know how to start ? Please read about how to compile and upload program into ESP32. This code is written in C and can be compiled using xtensa-esp32-elf-gcc. R1 – resistor 560Ω, see LED Resistor Calculator. UPDATE () – sniffer code has been modified to support current version of ESP-IDF (Pre-release 3.0-rc1) The full code using ESP-IDF is on GitHub, click here. Example callback function displays few basic information like packet type (control packet, management packet, etc.), RSSI or MAC addresses. Presented sniffer requires a callback function that will process all received promiscusous packets. Because WiFi module doesn’t implement automated channel switching, additional code has been added in the main loop that switch channels in 500ms intervals. It means that this clever chip allows IEEE802.11 network packets capturing for further analyzing. The heart of this project is WiFi module of ESP32 which is able to work in a promiscusous mode. This experimental project shows how to build a simple and inexpensive WiFi packet analyzer (also known as a WiFi sniffer).
0 Comments
Leave a Reply. |