Getting started with Firmware Emulation for IoT Devices

. 4 min read

In this post, we will have a look at how we can perform Firmware Emulation of a given IoT device.

Firmware Emulation can serve a number of different purposes such as analyzing the firmware in a better way, performing exploitation, performing remote debugging and so on.

With this technique, you can emulate a Firmware originally meant to be run on a different architecture, and interact with it, even without having a physical IoT device.

One of the earlier ways of performing Firmware Emulation was to create a Qemu image and then copy the firmware file system's contents on to the Qemu image and then launch the image.

However, there exists a much simpler alternative which is also prone to give you lesser issues while emulating firmware. Let's have a look.

Tools that you would require:

Setting things up

Once you have all three of the above components, the first step is to set up Firmware Analysis Toolkit.

Firmware Analysis Toolkit is simply a wrapper around the actual project Firmadyne and automates the process of emulating a new firmware.

To download and install FAT, simply clone the git repository recursively as shown below:

git clone --recursive https://github.com/attify/firmware-analysis-toolkit.git

Cloning-Firmware-Analysis-Toolkit

Next, we will need to setup the individual tools such as Binwalk, Firmadyne and Firmware-Mod-Kit.

Set up Binwalk

To Set Up Binwalk, simply install the dependencies as below and then go ahead and install the tool :

cd firmware-analysis-toolkit/binwalk
sudo ./deps.sh
sudo python setup.py install 

If everything went well, you would be able to run binwalk and receive an output as shown below.

Binwalk

Set up Firmadyne

To setup Firmadyne, navigate to the Firmadyne folder and open up firmadyne.config. It should look as shown in the picture below.

firmadyne-configuration

Uncomment the line saying FIRMWARE_DIR=/home/vagrant/firmadyne/ and modify the address to the current path of Firmadyne. The updated line in my case looks like as shown below.

new-firmadyne-config

Once you have updated the path, the next step is to download the additional binaries required for Firmadyne to work. This might take a while (1-2 mins on a good internet connection) - so have a coffee (or beer) at this point of time.

firmadyne-downloading-additional-binaries

Once it is done, the next step is to install the remaining depencies for Firmadyne to function properly:

sudo -H pip install git+https://github.com/ahupp/python-magic
sudo -H pip install git+https://github.com/sviehb/jefferson
sudo apt-get install qemu-system-arm qemu-system-mips qemu-system-x86 qemu-utils

Also set up a PostgreSQL database at this point following the instructions from the official Firmadyne wiki:

sudo apt-get install postgresql
sudo -u postgres createuser -P firmadyne
sudo -u postgres createdb -O firmadyne firmware
sudo -u postgres psql -d firmware < ./firmadyne/database/schema

The password for the database when prompted should be firmadyne (to avoid any later issues).

That is all for the setup of Firmadyne.

Set up Firmware Analysis Toolkit

The first thing that we will do is move the fat.py and reset.py to inside firmadyne folder.

Once that is done, open up fat.py and modify the root password (so that it won't ask you for password while running the script) and specify the path of firmadyne as shown below.

firmware-analysis-toolkit

That's all for the setup. Make sure that your postgresql database is up and running

postgresql-running

.. and we are good to go.

Emulating a firmware image

All you need to do in order to now emulate a firmware is run ./fat.py and specify the firmware name. In this case, we are running the WNAP320.zip firmware, so we will specify that.

For the Brand, you can specify any brand, as that is used for purely database purposes.

Your output should be as shown below:

running-firmware-analysis-toolkit

Once it has completed the initial setup process for the firmware, it will provide you with an IP address. In case the firmware runs a web server, you should be able to access the web interface, as well as interact with the firmware over SSH and perform additional network based exploitation.

network-config

Let's now open up Firefox and see if we are able to access the web interface.

web-interface-of-the-firmware

Congratulations!!! - we have successfully emulated a firmware (which was originally meant for MIPS Big Endian architecture) and even have the web server from within the firmware accessible!

That is all for this blog post. For any further queries, feel free to reach out to us using our contact page .

IoT Penetration Testing and Exploitation training

Redesign_grande-1

You can also now sign up for one of our public training bootcamps where you can learn all about IoT Exploitation (Embedded, Firmware, Radio, BLE, ZigBee, Binary etc.) - https://www.attify-store.com/collections/real-world-training/products/offensive-iot-exploitation-live-training



Get IoT Security Training

IoT Pentesting Exploitation Training

Tags

analog modulation Android android application security android hands on security and exploitation training android security Apktool application auditing application security auditing appsec usa appwatch arduino nano arm ARM binaries ARM course ARM exploitation book ARM exploitation video training ARM gadgets ARM Training attify attify badge attify training best security practices biggest iot attacks of all time binwalk blackberry pentesting blackhat ble BLE attacks BLE dangers BLE hacking and exploitation BLE security issues BLE sniffing BLE vulnerabilities bleah bluetooth technology box brut Exception BtleJuice capture radio traffic career in cybersecurity CCTV cameras challenges in iot retail chroot cloud based mobile application security scanner consulting CTF cyber attacks cybersecurity Damn Vulnerable iOS App dangers of iot DDoS attacks devops digital modulation dumping memory embedded hacking expert Exploit ARM devices exploitation exploiting ble exploiting smart devices firmadyne firmware analysis toolkit firmware emulation Firmware hacking firmware reverse engineering Flare-on frida getting started with firmware hacking GSMA guide to ARM exploitation hacked security IP cameras hacked smart devices hackers hackfest hacking smart devices healthcare business protection against iot threats healthcare cyber security how can healthcare fight iot threats How Mirai botnet infects your device How Mirai works how retail can prevent cyber attacks how to exploit ble how to hack radio waves how to protect iot devices how to secure iot device IDA internet of things Internet of Things Security internet security ios application security ios security iot iot attacks iot bots, malwares iot device IoT Devices IoT Exploitation iot hacking iot hacks IoT hacks on ARM devices iot penetration testing iot pentest iot pentesting iot security IoT security guidelines iot security training iot threats iot threats to healthcare industry iotsecurity IP cameras jtag jtag debugging latest iot attacks learn ARM exploitation measures to prevent cyber attacks on healthcare organisations Mirai Botnet mirai history mobile app mobile application security mobile application security testing mobile security monitor iot devices Mozilla network security in retail ninja recon technique NIST offensive iot exploitation ola cabs owasp owasp appsec penetration testers penetration testing pentesting pentesting mobile apps phishing attacks powerofcommunity PrinterSecurity privacy protection profession professional qemu quizup radio communication protocol radio coomunication radio waves hacking recent ARM attacks recent cyber attacks recent iot attacks recent security camera attacks retail iot Reversing safety measures to protect privacy sdr secure coding guidelines security security cameras security challenges in retail IoT security in healthcare iot security issue security issues faced by e-retailers security services security training security vulnerability setup smart devices smart user security social networking spi steps to prevent iot attacks on healthcare surveillance cameras hijacked threat modeling tools to exploit ble training uart Understanding Mirai Botnet virus vulnerabilities discovered in popular IoT IP cameras vulnerabilities in internet connected cameras vulnerability vulnerable ARM devices What is mirai botnet? why choose career in cybersecurity writeups xposed hooking zigbee zigbee exploitation zigbee security zwave

Instagram