ESP8266 Packet Sniffing

As I said in the To-Do list section, one of my goals was to capture some packets from the ESP8266 temperature sensor setup to show that the data is indeed very easy to read.

This took more time than I expected, as I decided to set up a raspberry pi as an acces point for the Esp8266 and use it to capture the traffic going through. I mainly did this because setting up mirroring on the router(s) I’d be using was a bit of a pain, plus there was a LOT of background traffic to have to sift through, since it was a shared router.

There wasn’t a huge amount to it: I basically just followed these instructions, although you’ll want to omit the step titled “Update hostapd” if you’re not using an Adafruit WiFi adapter (which I wasn’t).

Following this, I just installed tshark on the raspberry pi with:

sudo apt-get install tshark

After this, I added a user to the “wireshark” group with:

sudo usermod -a -G wireshark <username>

After doing this, remember to log out and then log back in for the changes to take effect, else they won’t, and you won’t be able to run tshark… Which is why I wasted a few minutes googling the problem…

Next, I just modified and uploaded my sketch in the Arduino IDE to use the SSID and password for the raspberry pi access point (see the “Configure Access Point” step of the “Install Software” section of the Adafruit guide to change these).

I set up the ESP8266 and temperature sensor as before and used the serial management console in Arduino to make sure it connects to the access point.

Now we’re ready to capture some packets:

tshark -i wlan0 -w /home/pi/espcapture.pcap

This will capture all packets being sent between the Pi and the Esp8266. You could change the interface to eth0 to see what’s going between your router and the pi, but frankly it will largely be the same stuff you see, alongside any other traffic being sent/received by background processes on the Pi. Hit Ctrl+C after a minute or so and you should have a good sample.

Finally, make sure you’ve installed Wireshark on your computer, then grab the file from the Pi (I use WinSCP because of personal preference, but FileZilla and other FTP clients are great too) and open it using Wireshark to see the contents of the files. Since they’re unsecured HTTP GET requests, they pretty much get sent in plain text, which should appear as follows:


This snippet of the output from Wireshark shows clearly the private key that I was using, as well as the temperature reading, completely unobscured, and obtained with completely free software!

Definitely not the way to go if you’re sending sensitive or critical information, and it could also compromise the security of other systems (i.e. the private key)…

Next, I will probably try to set up a simple web server on the raspberry pi and send information there so that I can try to implement some security measures in the ESP8266 firmware, and modify the server-side code to be able to handle this. If I find that something like HTTPS can be used, the Pi might not be necessary, but we’ll see!


A Newbie’s Guide to WiFi Sensors

The “things” in the Internet of Things can be found just about anywhere; in your home, in an industrial plant, an office… Maybe you want to monitor the temperature of your house to save on bills? Maybe you want to have your house send you an e-mail to let you know that you’ve left something on, and remotely shut it off? Or maybe you want to booby-trap your house like some kind of 21st century Home Alone scenario.

Definitely don’t try this

To be more specific,the “things” in question are generally sensors and actuators. Broadly, a sensor is something that gathers raw data, like temperature or power usage, and an actuator can be thought of as something that moves or takes some (generally physical) action, for example remotely turning off a plug socket (in the UK) or automatically torching the hats of any unsuspecting Joe Pescis.

Of course, sensors on their own aren’t very useful; they need a middle-man to take their readings, transmit them, and in some cases interpret them.

I’m going to be focusing on using a particular type of middle-man; namely the ESP8266 WiFi chip, or at least a variant of it as you’ll soon find out. The idea is to learn about how to use these chips in combination with sensors and send the information to a web server. Once I’ve managed this, I’ll be moving on to looking at other aspects of IoT data transmission.

I mentioned before that these chips could have a industrial or commercial uses, which is why I will also be investigating how to securely transmit this data. The potential issue here is the fact that some security measures, like encryption, can be computationally expensive, especially in combination with real-time data transfer.

Once I’ve got a setup where there’s at least one or two sensors feeding data to some server, I’ll begin investigating what security measures can be implemented to avoid things like packet sniffing or the Chromecast Attack which has been demonstrated to work on the ESP8266.

If I manage this in good time, I’ll continue to look into optimizing the setup to give maximal battery life, as well as making the setup more robust when it comes to switching out the sensors (e.g. switching from digital to analogue temperature sensors, or taking different measurements).

I’ll be posting info about my experiences with the chip, so to anyone who reads this; your mileage may vary!

The Olimex Board

At the moment I’ve managed to get an Olimex ESP8266-EVB up and running (with one or two hitches). By “up and running” I mean that I’ve managed to connect it to my network and upload some code to it using the Arduino IDE. I’ll make another post detailing exactly what I did, as the instructions I used to get this working were somewhat scattered.


Next on the list:

  • try out more examples, particularly WiFi related ones
  • find a server to use and communicate with it (I’m thinking thingspeak is viable)
  • hook up a temperature sensor and get the chip to pass on this data (ideally in real time)