OWASP I9: Insecure Software/Firmware, But here Our main concern is Firmware.
- Dump the firmware
- Localize point of interest
What are the requirements i will explain step by step. Here i am using the Ubuntu Xenial 16.04 you can use which Linux is comfortable with you.
- Hexdump or Hexeditor
- Linux OS – Ubuntu or Any other
- Vulnerable firmware
So here i am not attacking any device directly because for firmware you will get from the vendor site or you can find some firmware in index of some sites.
Installing Required tools for testing :
as shown below And follow the installation steps from the Github location some dependencies need to be install. Some of them i will show how to do and remaining check from here
# sudo apt-get install binwalk
Besides a Python interpreter, there are no installation dependenciesfor Binwalk. All dependencies are optional run-time dependencies, and unless otherwise specified, are available from most Linux package managers.
Although all Binwalk run-time dependencies are optional, the python-lzma module is highly recommended for improving the reliability of signature scans. This module is included by default in Python3, but must be installed separately for Python2.7
# sudo apt-get install python-lzma
Binwalk uses the pycrypto library to decrypt some known encrypted firmware images
# sudo apt-get install python-crypto
After installation in the Binwalk in my Linux operating OS so next strings already default many Linux systems if its not there then install strings and Hexdump
For print the strings of printable characters in files.Depending upon how the strings program was configured it will default to either displaying all the printable sequences that it can find in
each file, or only those sequences that are in loadable, initialized data sections. If the file type in unrecognizable, or if strings is reading from stdin then it will always display all of the printable sequences that it can find.
Hexdump – is a hexadecimal view of computer data, and it is mainly using for the debugging and reverse engineering the file of data , here we are using for firmware analysis
For installing the firmware analysis follow the command
#sudo apt-get install hexdump
Here coming for the firmware analysis many Linux OS having some problems while doing the testing, so i am choosing Ubuntu In your way comfortably choose your friendly other Linux Operating Systems.
1. Dump the firmware:
In firmware testing we required a firmware and why i mentioned vulnerable firmware here , i am not going to target any particular device , the people who are working in this firmware analysis they designed one DVRF – Damn Vulnerable Framework Router , we are going test DVRF you can download from here:
Some other firmware bin files to test
Here i am showing the a simple firmware of “openwrt” for testing purpose , you can download many firmware type files with help of Google dorks also for example: “index of firmware”
Lets start the firmware analysis
Before we go a small understanding inside of firmware testing
What is firmware:
Firmware is a software for hardware, and it is helped for the user running programs on the devices
Where it is available :
CD/DVD from vendor , or FTP/HTTP websites of vendor and devices or you can dump with the help of hardware debuggers from the devices.
What is firmware testing:
Firmware testing is nothing but finding the bug inside of firmware before hackers do ..
In firmware testing main flaw findings are buffer over flows , so some other testing are like functionality test and security test , so we are discuss about the security test.
Why firmware testing:
Firmware is consist of hidden data and it is controller of device which means once find the vulnerability are zero days in firmware , the time firmware related all devices can be hackable , already many hacks exposed like “netusb”related hacking techniques , so before hackers taking advantage of devices hacking will go for test,
Lets get into testing:
Before i am going to test i want to say something to all , this is not only final or advanced method , As a beginner it will give some idea on testing , there many more methods are there i am keep writing for the different types of testing of firmware analysis and IoT hacking also.
- File information
- Printable characters analysis
- Identify the Build of firmware
- Reverse engineering with the Binwalk
- Finding the confidential information
Run “file” command in on testing binary file to get the data information of bin file,
A data contains of the txt files and bin files , when we are running the file command it will showing the data it means bin file containing information.
# file “file.bin”
And check for the printable characters in bin file with help of “strings”
# strings -n 10 “file.bin”
The above image is giving the information of the architecture of “MIPS” , and there are two main types of architecture “MIPS” and “ARM” ,
MIPS(Microprocessor without Interlocked Pipeline): This architecture is mainly in Routers and Play stations , and it is is a reduced instruction set computer (RISC).
ARM(Advanced RISC Machine): This architecture is using for the mainly mobiles , and “SoC (system on chips)” , radios etc.
“MIPS” And “ARM” Exploitation is possible , from strings not only the Architecture information disclosing some other information also disclosing like chksum information , file information
Identify the Build of firmware:
For finding the firmware build information we are going to use Hexdump
# hexdump -C -n 512 xyz.bin
With help of binwalk we can find more information from the firmware files so lets begin
Here we going to check for the signatures and file containing inside of binary file
# binwalk “file.bin”
After that what we got information about the given file containing ,
4.Localize point of interest:
LZMA compressed data , squashfs file system , and some other information for video actually what are they.
SquashFS is a compressed read-only file system for Linux. SquashFS compresses files, inodes and directories, and supports block sizes up to 1 MB for greater compression.
And it is containing information of passwords and many others
Extracting the data form the firmware and analyzing the information what it contains
# binwalk -Me “file.bin”
In binwalk “M” for even recursively scan files as it extracts them , For extracting firmware we choose option “e” after extracting looking like this as shown below
And like that grab the banner information and root information
# cat etc/banner
# cat etc/shadow
For finding the Confidential information form the extracted files
Some interesting information is available like passwords , root etc
Once squashfs folder is extracted we will get more information from it like passwords,
Go to extracted folder as shown below
# cat /etc/passwd
To check additional information about
Firmware like release and version information
# cat openwrt_release
# cat openwrt_version
IDA Pro is best tool to reverse engineering , i will explain about this tool on advance firmware analysis
BH USA 2013: Firmware Reverse Engineering by Jonas Zaddach and Andrei Costin
Reversing Auerswald firmware: https://cweiske.de/tagebuch/auerswald-firmware.htm