Skip to content

Commit 3e2d721

Browse files
Update to v0.3
1 parent 7c23ed6 commit 3e2d721

File tree

5 files changed

+206
-212
lines changed

5 files changed

+206
-212
lines changed

README.md

Lines changed: 37 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -14,124 +14,52 @@ _**Download AttifyOS**_
1414

1515
---
1616

17-
Firmware Analysis Toolkit is build on top of the following existing tools and projects :
18-
19-
1. [Firmadyne](https://github.com/firmadyne/firmadyne)
20-
2. [Binwalk](https://github.com/devttys0/binwalk)
21-
3. [Firmware-Mod-Kit](https://github.com/mirror/firmware-mod-kit)
22-
4. [MITMproxy](https://mitmproxy.org/)
23-
5. [Firmwalker](https://github.com/craigz28/firmwalker)
17+
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.
2418

2519
## Setup instructions
2620

27-
If you are a training student and setting this as a pre-requirement for the training, it is recommended to install the tools in the /root/tools folder, and individual tools in there.
28-
29-
### Install Binwalk
30-
31-
```
32-
git clone https://github.com/devttys0/binwalk.git
33-
cd binwalk
34-
sudo ./deps.sh
35-
sudo python ./setup.py install
36-
sudo apt-get install python-lzma :: (for Python 2.x)
37-
sudo -H pip install git+https://github.com/ahupp/python-magic
38-
```
39-
40-
Note: Alternatively, you could also do a `sudo apt-get install binwalk`
41-
42-
43-
### Setting up firmadyne
44-
45-
`sudo apt-get install busybox-static fakeroot git kpartx netcat-openbsd nmap python-psycopg2 python3-psycopg2 snmp uml-utilities util-linux vlan qemu-system-arm qemu-system-mips qemu-system-x86 qemu-utils`
21+
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.
4622

47-
`git clone --recursive https://github.com/firmadyne/firmadyne.git`
23+
To install just clone the repository and run the script `./setup.sh`.
4824

49-
`cd ./firmadyne; ./download.sh`
50-
51-
Edit `firmadyne.config` and make the `FIRMWARE_DIR` point to the current location of Firmadyne folder.
52-
53-
### Setting up the database
54-
55-
1. `sudo apt-get install postgresql`
56-
2. `sudo -u postgres createuser -P firmadyne`, with password `firmadyne`
57-
3. `sudo -u postgres createdb -O firmadyne firmware`
58-
4. `sudo -u postgres psql -d firmware < ./firmadyne/database/schema`
59-
60-
### Setting up Firmware Analysis Toolkit (FAT)
61-
62-
First install [`pexpect`](https://github.com/pexpect/pexpect).
63-
64-
```
65-
pip install pexpect
66-
```
67-
Now clone the repo to your system.
6825
```
6926
git clone https://github.com/attify/firmware-analysis-toolkit
70-
mv firmware-analysis-toolkit/fat.py .
71-
mv firmware-analysis-toolkit/reset.py .
72-
chmod +x fat.py
73-
chmod +x reset.py
27+
cd firmware-analysis-toolkit
28+
./setup.sh
7429
```
7530

76-
Adjust the paths to firmadyne and binwalk in `fat.py` and `reset.py`. Additionally, provide the root password. Firmadyne requires root privileges for some of its operations. The root password is provided in the script itself to automate the process.
31+
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.
7732

78-
```python
79-
# Configurations - change this according to your system
80-
firmadyne_path = "/home/ec/firmadyne"
81-
binwalk_path = "/usr/local/bin/binwalk"
82-
root_pass = "root"
83-
firmadyne_pass = "firmadyne"
8433
```
85-
86-
### Setting up Firmware-mod-Kit
87-
34+
[DEFAULT]
35+
sudo_password=attify123
36+
firmadyne_path=/home/attify/firmadyne
8837
```
89-
sudo apt-get install git build-essential zlib1g-dev liblzma-dev python-magic
90-
git clone https://github.com/brianpow/firmware-mod-kit.git
91-
```
92-
93-
Find the location of binwalk using `which binwalk` . Modify the file `shared-ng.inc` to change the value of variable `BINWALK` to the value of `/usr/local/bin/binwalk` (if that is where your binwalk is installed). .
94-
95-
### Setting up MITMProxy
96-
97-
`pip install mitmproxy`
98-
or
99-
`apt-get install mitmproxy`
100-
101-
### Setting up Firmwalker
102-
103-
`git clone https://github.com/craigz28/firmwalker.git`
104-
105-
That is all the setup needed in order to run FAT.
10638

10739
## Running FAT
10840

109-
Once you have completed the above steps you can run can fat. The syntax for running fat is
110-
111-
11241
```
113-
$ python fat.py <firmware file>
42+
$ ./fat.py <firmware file>
11443
```
11544

116-
+ Provide the firmware filename as an argument to the script. If not provided, the script would prompt for it at runtime.
117-
118-
+ The script will then ask you to enter the brand name. Enter the brand which the firmware belongs to. This is for pure database storage and categorisational purposes.
45+
+ Provide the firmware filename as an argument to the script.
11946

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

12249
+ 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.
12350

124-
***Congrats! The firmware is finally emulated. The next step will be to setup the proxy in Firefox and run mitmproxy.***
51+
***Congrats! The firmware is finally emulated.***
12552

12653
To remove all analyzed firmware images, run
12754

12855
```
129-
$ python reset.py
56+
$ ./reset.py
13057
```
131-
### Example Run
58+
59+
## Example
13260

13361
```
134-
$ python fat.py DIR850LB1_FW210WWb03.bin
62+
$ ./fat.py DIR-601_REVB_FIRMWARE_2.01.BIN
13563
13664
__ _
13765
/ _| | |
@@ -140,24 +68,28 @@ $ python fat.py DIR850LB1_FW210WWb03.bin
14068
| | | (_| | | |_
14169
|_| \__,_| \__|
14270
143-
Welcome to the Firmware Analysis Toolkit - v0.2
71+
Welcome to the Firmware Analysis Toolkit - v0.3
14472
Offensive IoT Exploitation Training - http://offensiveiotexploitation.com
14573
By Attify - https://attify.com | @attifyme
14674
147-
[?] Enter the name or absolute path of the firmware you want to analyse : DIR850LB1_FW210WWb03.bin
148-
[?] Enter the brand of the firmware : dlink
149-
[+] Now going to extract the firmware. Hold on..
150-
[+] Firmware : DIR850LB1_FW210WWb03.bin
151-
[+] Brand : dlink
152-
[+] Database image ID : 1
153-
[+] Identifying architecture
154-
[+] Architecture : mipseb
155-
[+] Storing filesystem in database
156-
[!] Filesystem already exists
157-
[+] Building QEMU disk image
158-
[+] Setting up the network connection, please standby
159-
[+] Network interfaces : [('br0', '192.168.0.1'), ('br1', '192.168.7.1')]
160-
[+] Running the firmware finally
161-
[+] command line : sudo /home/ec/firmadyne/scratch/1/run.sh
162-
[*] Press ENTER to run the firmware...
75+
[+] Firmware: DIR-601_REVB_FIRMWARE_2.01.BIN
76+
[+] Extracting the firmware...
77+
[+] Image ID: 1
78+
[+] Identifying architecture...
79+
[+] Architecture: mipseb
80+
[+] Building QEMU disk image...
81+
[+] Setting up the network connection, please standby...
82+
[+] Network interfaces: [('br0', '192.168.0.1')]
83+
[+] All set! Press ENTER to run the firmware...
84+
[+] When running, press Ctrl + A X to terminate qemu
16385
```
86+
87+
## Additional Notes
88+
89+
- As of now, the [ARM firmadyne kernel](https://github.com/firmadyne/kernel-v4.1) doesn't work with the latest version of Qemu (2.11.1) available on the Ubuntu 18.04 official repositiory. However, Qemu (2.5.0) on Ubuntu 16.04 does work.
90+
91+
- If no network interfaces are detected, try increasing the timeout value from 60 in `scripts/inferNetwork.sh` as shown below
92+
```
93+
echo "Running firmware ${IID}: terminating after 60 secs..."
94+
timeout --preserve-status --signal SIGINT 60 "${SCRIPT_DIR}/run.${ARCH}.sh" "${IID}"
95+
```

fat.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[DEFAULT]
2+
sudo_password=attify123
3+
firmadyne_path=/home/attify/firmware-analysis-toolkit/firmadyne

0 commit comments

Comments
 (0)