FAT是一種工具包,以幫助安全研究人員分析和識別物聯網和嵌入式設備固件中的漏洞。這也用於Athifity進行的“進攻性IoT剝削”培訓。
筆記:
到目前為止,這只是一個自動化Firmadyne的腳本,這是用於固件仿真的工具。如果有實際仿真的任何問題,請在Firmadyne問題中發布您的問題。
如果您面臨問題,則可以嘗試使用固件分析工具包和其他已預裝並準備使用的工具的Athifyos。
固件分析工具包(脂肪之後)是基於Firmadyne的,並且有一些更改。 Firmadyne使用PostgreSQL數據庫存儲有關模擬圖像的信息。但是,僅對於核心功能即模擬固件,實際上並不需要PostgreSQL。因此,脂肪不使用它。
脂肪是在Python 3中開發的。但是,由於Firmadyne及其依賴關係使用Python 2,因此您需要同時安裝Python 3和Python 2。強烈建議在虛擬機中安裝脂肪。
要安裝一個克隆存儲庫並運行腳本./setup.sh 。
git clone https://github.com/attify/firmware-analysis-toolkit
cd firmware-analysis-toolkit
./setup.sh
安裝完成後,編輯file fat.config並提供SUDO密碼,如下所示。 Firmadyne需要其某些運營的Sudo特權。提供SUDO密碼以自動化該過程。
[DEFAULT]
sudo_password=attify123
firmadyne_path=/home/attify/firmadyne
$ ./fat.py <firmware file>
提供固件文件名作為腳本的參數。
腳本將顯示分配給創建的網絡接口的IP地址。請注意。
最後,它將說運行固件。點擊輸入並等到固件啟動。 ping在上一步中顯示的IP或在瀏覽器中打開。
恭喜!固件最終被模擬。
要刪除所有分析的固件圖像,請運行
$ ./reset.py
$ ./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
$ ./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
截至目前,ARM Firmadyne內核無法與Ubuntu 18.04官方存儲庫中最新版本的Qemu(2.11.1)一起使用。但是,Ubuntu上的Qemu(2.5.0)確實有效。另外,您還可以使用firmadyne提供的捆綁的Qemu(2.5.0),如示例2所示。
如果未檢測到網絡接口,請嘗試將超時值從scripts/inferNetwork.sh中的60增加如下所示
echo "Running firmware ${IID}: terminating after 60 secs..."
timeout --preserve-status --signal SIGINT 60 "${SCRIPT_DIR}/run.${ARCH}.sh" "${IID}"
存儲庫已經包含QEMU 2.0.0、2.5.0&3.0.0(發行)的靜態構建,但是如果您想構建自己的靜態構建,請按照以下步驟操作。
在乾淨的Ubuntu 16.04 VM運行中。 (使用16.04,以後的版本具有靜態彙編問題很重要)。
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可以在qemu-2.0.0-build目錄中找到編譯的二進製文件。
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可以在qemu-2.5.0-build目錄中找到編譯的二進製文件。
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可以在qemu-3.0.0-build目錄中找到編譯的二進製文件。
注意:還應該可以在高山系統上靜態編譯QEMU,但尚未進行測試。通常,在高山上彙編比Ubuntu更喜歡,因為前者帶有Musl Libc,它在靜態連鎖上比Ubuntu上的Glibc更好。