Volver al ranking

attify/firmware-analysis-toolkit

Python

Toolkit to emulate firmware and analyse it for security vulnerabilities

binary-analysisfirmwarefirmware-analysisfirmware-securityfirmware-toolsiotiot-securityiot-security-toolsreverse-engineeringsecurityvulnerability-scanner
Crecimiento de estrellas
Estrellas
1.6k
Forks
283
Crecimiento semanal
Issues
47
5001k1.5k
oct 2016ene 2020abr 2023jul 2026
ArtefactosPyPIpip install firmware-analysis-toolkit
README

Firmware Analysis Toolkit

FAT is a toolkit built in order to help security researchers analyze and identify vulnerabilities in IoT and embedded device firmware. This is also used in the "Offensive IoT Exploitation" training conducted by Attify.

Note:

  • As of now, it is simply a script to automate Firmadyne which is a tool used for firmware emulation. In case of any issues with the actual emulation, please post your issues in the firmadyne issues.  

  • In case you are facing issues, you can try AttifyOS which has Firmware analysis toolkit and other tools pre-installed and ready to use.


Firmware Analysis Toolkit (FAT henceforth) is based on Firmadyne with some changes. Firmadyne uses a PostgreSQL database to store information about the emulated images. However just for the core functionality i.e. emulating firmware, PostgreSQL is not really needed. Hence FAT doesn't use it.

Setup instructions

FAT is developed in Python 3. However you need to have both Python 3 and Python 2 installed since parts of Firmadyne and its dependencies use Python 2. It's highly recommended to install FAT inside a Virtual Machine.

To install just clone the repository and run the script ./setup.sh.

git clone https://github.com/attify/firmware-analysis-toolkit
cd firmware-analysis-toolkit
./setup.sh

After installation is completed, edit the file fat.config and provide the sudo password as shown below. Firmadyne requires sudo privileges for some of its operations. The sudo password is provided to automate the process.

[DEFAULT]
sudo_password=attify123
firmadyne_path=/home/attify/firmadyne

Running FAT

$ ./fat.py <firmware file>
  • Provide the firmware filename as an argument to the script.

  • The script would display the IP addresses assigned to the created network interfaces. Note it down.

  • Finally, it will say that running the firmware. Hit ENTER and wait until the firmware boots up. Ping the IP which was shown in the previous step, or open in the browser.

Congrats! The firmware is finally emulated.

To remove all analyzed firmware images, run

$ ./reset.py

Example 1

$ ./fat.py DIR-601_REVB_FIRMWARE_2.01.BIN 

                               __           _   
                              / _|         | |  
                             | |_    __ _  | |_ 
                             |  _|  / _` | | __|
                             | |   | (_| | | |_ 
                             |_|    \__,_|  \__|                    
                    
                Welcome to the Firmware Analysis Toolkit - v0.3
    Offensive IoT Exploitation Training http://bit.do/offensiveiotexploitation
                  By Attify - https://attify.com  | @attifyme
    
[+] Firmware: DIR-601_REVB_FIRMWARE_2.01.BIN
[+] Extracting the firmware...
[+] Image ID: 1
[+] Identifying architecture...
[+] Architecture: mipseb
[+] Building QEMU disk image...
[+] Setting up the network connection, please standby...
[+] Network interfaces: [('br0', '192.168.0.1')]
[+] All set! Press ENTER to run the firmware...
[+] When running, press Ctrl + A X to terminate qemu

Asciicast

asciicast

Example 2

$ ./fat.py DIR890A1_FW103b07.bin --qemu 2.5.0

                               __           _
                              / _|         | |
                             | |_    __ _  | |_
                             |  _|  / _` | | __|
                             | |   | (_| | | |_
                             |_|    \__,_|  \__|

                Welcome to the Firmware Analysis Toolkit - v0.3
    Offensive IoT Exploitation Training http://bit.do/offensiveiotexploitation
                  By Attify - https://attify.com  | @attifyme

[+] Firmware: DIR890A1_FW103b07.bin
[+] Extracting the firmware...
[+] Image ID: 2
[+] Identifying architecture...
[+] Architecture: armel
[+] Building QEMU disk image...
[+] Setting up the network connection, please standby...
[+] Network interfaces: [('br0', '192.168.0.1'), ('br1', '192.168.7.1')]
[+] Using qemu-system-arm from /home/attify/firmware-analysis-toolkit/qemu-builds/2.5.0
[+] All set! Press ENTER to run the firmware...
[+] When running, press Ctrl + A X to terminate qemu

Additional Notes

  • As of now, the ARM firmadyne kernel doesn't work with the latest version of Qemu (2.11.1) available on the Ubuntu 18.04 official repository. However, Qemu (2.5.0) on Ubuntu 16.04 does work. Alternatively you can also use the bundled Qemu (2.5.0) provided with firmadyne as shown in example 2.

  • If no network interfaces are detected, try increasing the timeout value from 60 in scripts/inferNetwork.sh as shown below

    echo "Running firmware ${IID}: terminating after 60 secs..."
    timeout --preserve-status --signal SIGINT 60 "${SCRIPT_DIR}/run.${ARCH}.sh" "${IID}"
    

Known Issues

  • FAT does not work on Ubuntu 20.04. The main reason behind this is some dependencies of Firmadyne (especially binwalk) require Python 2. Unless this is fixed upstream, stick to Ubuntu 18.04 or lower. Ubuntu 20.04 is now supported. The current version of FAT patches the binwalk installation script to workaround the issue.

Building static Qemu

The repository already includes a static builds of qemu 2.0.0, 2.5.0 & 3.0.0 (in releases) but if you want to build your own follow the steps below.

On a clean Ubuntu 16.04 VM run. (It's important to use 16.04, later versions have issues with static compilation).

Qemu 2.0.0

sudo apt update && sudo apt build-dep qemu -y
wget https://download.qemu.org/qemu-2.0.0.tar.bz2
tar xf qemu-2.0.0.tar.bz2
mkdir qemu-2.0.0-build
cd qemu-2.0.0
./configure --prefix=$(realpath ../qemu-2.0.0-build) --static --target-list=arm-softmmu,mips-softmmu,mipsel-softmmu --disable-smartcard-nss --disable-spice --disable-libusb --disable-usb-redir
make
make install

The compiled binaries can be found in qemu-2.0.0-build directory.

Qemu 2.5.0

sudo apt update && sudo apt build-dep qemu -y
wget https://download.qemu.org/qemu-2.5.0.tar.bz2
tar xf qemu-2.5.0.tar.bz2
mkdir qemu-2.5.0-build
cd qemu-2.5.0
./configure --prefix=$(realpath ../qemu-2.5.0-build) --static --target-list=arm-softmmu,mips-softmmu,mipsel-softmmu --disable-smartcard --disable-libusb --disable-usb-redir
make 
make install

The compiled binaries can be found in qemu-2.5.0-build directory.

Qemu 3.0.0

sudo apt update && sudo apt build-dep qemu -y
wget https://download.qemu.org/qemu-3.0.0.tar.bz2
tar xf qemu-3.0.0.tar.bz2
mkdir qemu-3.0.0-build
cd qemu-3.0.0
./configure --prefix=$(realpath ../qemu-3.0.0-build) --static --target-list=arm-softmmu,mips-softmmu,mipsel-softmmu --disable-smartcard --disable-libusb --disable-usb-redir
make 
make install

The compiled binaries can be found in qemu-3.0.0-build directory.

Note: It should also be possible to compile qemu statically on an alpine system but this hasn't been tested. In general compiling on alpine is preferred to Ubuntu as the former comes with musl libc which is better at static linkage than glibc on Ubuntu.

Repositorios relacionados
WerWolv/ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.

C++GNU General Public License v2.0hex-editorreverse-engineering
imhex.werwolv.net
54.3k2.4k
x64dbg/x64dbg

An open-source user mode debugger for Windows. Optimized for reverse engineering and malware analysis.

C++Otherdebuggerwindows
x64dbg.com
49k2.8k
radareorg/radare2

UNIX-like reverse engineering framework and command-line toolset

COtherradare2c
radare.org
24.4k3.3k
horsicq/Detect-It-Easy

Program for determining types of files for Windows, Linux and MacOS.

JavaScriptnpmMIT Licensedebuggerdetect
ntinfo.biz
11.2k932
mrexodia/ida-pro-mcp

AI-powered reverse engineering assistant that bridges IDA Pro with language models through MCP.

PythonPyPIMIT Licenseida-pluginida-pro
plugins.hex-rays.com/mrexodia/ida-pro-mcp
10.7k1.3k
We5ter/Scanners-Box

A powerful and open-source toolkit for hackers and security automation - 安全行业从业者自研开源扫描器合辑

pentesting-toolshacker-tools
9k2.4k
mandiant/capa

The FLARE team's open-source tool to identify capabilities in executable files.

PythonPyPIApache License 2.0malware-analysisreverse-engineering
mandiant.github.io/capa/
6.1k710
lief-project/LIEF

LIEF - Library to Instrument Executable Formats (C++, Python, Rust)

C++Apache License 2.0reverse-engineeringmalware-analysis
lief.re
5.5k741
JonathanSalwan/Triton

Triton is a dynamic binary analysis library. Build your own program analysis tools, automate your reverse engineering, perform software verification or just emulate code.

C++Apache License 2.0reverse-engineeringsymbolic-execution
triton-library.github.io
4.2k592
HyperDbg/HyperDbg

State-of-the-art native debugging tools

CGNU General Public License v3.0hypervisorhyperdbg
hyperdbg.org
3.9k491
trailofbits/manticore

Symbolic execution tool

PythonPyPIGNU Affero General Public License v3.0symbolic-executionz3
blog.trailofbits.com/2017/04/27/manticore-symbolic-execution-for-humans/
3.9k499
e-m-b-a/emba

EMBA - The firmware security analyzer

ShellGNU General Public License v3.0firmwarelinux
securefirmware.de
3.6k314