Network Monitoring: Wi-Fi Security

Hello everyone

in a previous blog post, we talked briefly about Wi-Fi security. The problem with our very creative Lyr modules is that they are easy to abuse. Since we don't want to put anyone on "stupid thoughts" we have deliberately skipped this topic in the past. We don't want to attract a new generation of script kiddy to penetrate the corporate networks. We would like our customers to deal with and comply with the respective laws applicable to them. Disruption of public infrastructure, for example, is a dangerous offence punishable by up to 5 years imprisonment, in serious cases up to 10 years, and the attempt is already a criminal offence! We do not pursue the goal of forcing companies to act by publishing vulnerabilities.

Today we are only showing you how to detect a possible way to manipulate a Wi-Fi in order to be able to act accordingly.

Do you find that your Wi-Fi connection is canceled for inexplicable reasons and you can no longer connect to your network? This happens from time to time due to many possible disturbances. However, if this happens constantly and continuously, the suspicion is close to the intention behind it. Today, we provide code to detect this using a NodeMCU.

For all the knowledgeable among you: Deauth frame detector due to missing 802.11w implementation, plays out completely on layer 2. 

If the NODEMCU LED flashes, an attack is taking place in your environment!

We need:

  • NodeMCU with ESP8266 e.g. v2/v3/d1
  • LED (BuildInLED is sufficient)

Of course, you can customize this sketch for the detection of other packages that are of interest to you.

Here is the code:

 

#include <ESP8266WiFi.H>


External "C" {   #include "user_interface.h"
}

===== SETTINGS =====/
#define Channel 1 the channel it should scan on (1-14)
#define channelHopping True scan on all channels
#define maxChannel 13 US = 11, EU = 13, Japan = 14
#define ledPin 2 led pin ( 2 = built-in LED)
#define Inverted True invert HIGH/LOW for the LED
#define packetRate 3 min. packets before it gets recognized as an attack

#define scanTime 500 scan time per channel in ms


Unsigned Long C = 0;
Unsigned Long prevTime = 0;
Unsigned Long curTime = 0;
Int curChannel = Channel;

Void Sniffer(uint8_t *Buf, uint16_t Len) {   if(len>27)"     from.set(buf[16],buf[17],buf[18],buf[19],buf[20],buf[21]);     to.set(buf[22],buf[23],buf[24],buf[25],buf[26],buf[27]);     If(Buf[12] == 0xA0 || Buf[12] == 0xC0){              C++;     }        //}
}

Void Setup() {   Serial.Begin(115200);   wifi_set_opmode(STATION_MODE);   wifi_promiscuous_enable(0);   Wifi.disconnect();   wifi_set_promiscuous_rx_cb(Sniffer);   wifi_set_channel(curChannel);   wifi_promiscuous_enable(1);   pinMode(ledPin, Output);      Serial.println("Start!");

}

Void Loop() {   curTime = millis();      If(curTime - prevTime >= scanTime){     prevTime = curTime;     Serial.println((String)C);          If(C >= packetRate){       If(Inverted) digitalWrite(ledPin, Low);       else digitalWrite(ledPin, High);     }else{       If(Inverted) digitalWrite(ledPin, High);       else digitalWrite(ledPin, Low);     }          C = 0;     If(channelHopping){       curChannel++;       If(curChannel > maxChannel) curChannel = 1;       wifi_set_channel(curChannel);     }   }

}

 

We hope this is useful for you and say goodbye to the next post :)

Moritz Spranger
Team AZ-Delivery

Esp-8266Projects for advanced

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN