Skip to main content

Firmware analysis Basic Approach

OWASP IoT I9: Insecure Software/Firmware, But here Our main concern is Firmware.


Testing Methodology:

• Get the firmware• Reconnaissance• Unpacking• Localize point of interest• Decompile/pentest/fun!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.

Requirements:


1.Binwalk
2.Strings
3.Hexeditor
4.Linux OS - Ubuntu or Any other
5.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.

Installation:

1.Binwalk:


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

https://github.com/ReFirmLabs/binwalk/blob/master/INSTALL.md
  
$sudo apt-get install binwalk





2.Strings:


After installation in the Binwalk in my Linux operating OS so next strings already default many Linux systems if it’s not there then install strings and Hexeditor

Strings using for 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, initialised data sections. If the file type in unrecognisable, or if strings is reading from "stdin" then it will always display all of the printable sequences that it can find.



3.hexedit tool:


hexedit tool - view and edit files in hexadecimal or in ASCII.


4.Linux OS:


Here coming for the firmware analysis many Linux OS having some problems while doing the testing, so i am choosing Ubuntu 
You can choose other Linux as well but issues found many


5. Vulnerable 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 files to test 


Here i am showing the a simple firmware of “openwrt” for testing purpose you can download with help of Google dorks also for example: “index of firmware”


Before going to start the "firmware analysis"


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 :


1. CD/DVD from vendor 
2. Device Vendor websites 
3.   Dump with the help of hardware debuggers from the devices.
4. Capture when updating firmware 
5. Reversing APPS

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/stack/heap 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 vulnerabilities like are zero days in firmware , that 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 first,


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.

1. File information
2. Printable characters analysis
3. Identify the Build of firmware
4. Reverse engineering with the Binwalk
5. 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”there are two main types of architecture MIPS and ARM ,

MIPS(Million Instructions Per Second):  

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 command not only architecture information, will get more than that like passwords or any other sensitive information 


Identify the Build of firmware:


For finding the firmware build information we are going to use Hexdump

# hexdump -C -n 512 xyz.bin






Analysis with Binwalk:


With help of binwalk we can find more information from the firmware files so lets begin
Here we go for the testing firmware file

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 ,
LZMA compressed data , squashfs file system , and some other information for video actually what are they.




The Lempel–Ziv–Markov chain algorithm (LZMA) is an algorithm used to perform lossless data compression. 


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 , certificates , running services , architecture information, api's , fimrware upgrade url's and many other sensitive information that we need to check manually or automated way 


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

Command:


$cat etc/banner



For finding the Confidential information form the extracted files
Some interesting information is available like passwords , root information and certificated , hardcoded url’s 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$cat /etc/shadow




To check additional information about

Firmware like release and version information



$cat openwrt_release
$cat openwrt_version 





Comments

Popular posts from this blog

Dumping the Firmware from the device Using buspirate

One of the best way to get the firmware from the hardware


While doing penetration testing there are scenarios in which we need to dump the firmware from the devices.This method is typically used when there are no firmware’s available from vendor site. Today we are going to show you how to dump the firmware from an Wireless router Binatone DT 850W Software and hardware Requirements:
BuspirateUbuntu 16.04 or any other Linux machineFlashrom toolSOIC cable pin 8Buspirate connectors


This is a Wireless router from Binatone DT 850W which will be used as an example for dumping the firmware.
Let’s us Analyze the Inside Device.You can see IC chips like EEPROM, UART pins and Ralink CPU and also some OtherIC chips Let us focus mainly on the EEPROM chip (winbond W25Q16). What is EEPROM: EEPROM (also written E2PROM and pronounced “e-e-prom”, “double-e-prom” or “e-squared-prom”) stands for electrically erasable programmable read-only memory and is a type of non-volatile memory used in computers and other e…

Software Defined Radio

Software Defined Radio Part 1
SDR is Software defined Radio is used for the to Capturing and analyzing the various radio frequency signals , we can monitor and transmit the signals also , according to security reasons i am not showing transmission of open source signals but soon i will update how to pentest the replay attacks of key fobs and smart door lock systems.
what we going to discuss
1. Introduction about Radio And Software Defined Radio 2. Various types of devices 3. Antennas 4. Radio waves 5. Capturing the FM Signals And Analyzing

Requirements:
1. Software Defined Radio (SDR) 2. Antenna 3. GQRX software for Linux , windows - SDR software 4. Gnu Radio Companion 5. Computer

Radio:
Radio is the technology of using radio waves to carry information, such as sound, by systematically modulating some property of electromagnetic energy waves transmitted through space, such as their amplitude, frequency, phase, or pulse width.(Wikipedia)