尽管 firmware-analysis-toolkit 还在不断更新,然而其中包含的诸多 bug,加上国内网络不通畅,导致此工具在现实场景中很难真正安装起来。为此,笔者查看了firmware-analysis-toolkit 的部分源码,修改了其中存在的 bug,在此基础上重写脚本,改成了一个新的项目,即
firmware-analysis-plus
- 项目说明:本项目依赖于 firmadyne 以及 firmware-analysis-toolkit,修复了其中的大量bug,可直接运行固件。
- 项目地址:https://github.com/liyansong2018/firmware-analysis-plus
- 项目依赖:要求系统中,已经安装 python2 python3 以及 binwalk。Kali 自带 binwalk,但是仍然需要用源码安装的方式安装 binwalk,因其自带 binwalk 缺少很多依赖。
安装 binwalk
设置 python 源,加快 python 模块下载速度
找到
1 2 3 4 5 6 7 8 | [global] timeout = 10 index-url = http://mirrors.aliyun.com/pypi/simple/ extra-index-url= http://pypi.douban.com/simple/ [install] trusted-host= mirrors.aliyun.com pypi.douban.com |
安装 binwalk
1 2 3 4 | $ git clone https://github.com/ReFirmLabs/binwalk.git $ cd binwalk $ sudo ./deps.sh $ sudo python setup.py install |
遇到此类问题,删除
如果报错,先进行下面的步骤,安装
安装
运行 ./setup.sh ,如果报错,请使用备用文件 ./setup2kali.sh,国内网路不通畅,如果更新卡住,终止程序,多试几次就好了
1 2 3 4 5 6 7 8 9 10 11 | DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Looking in indexes: https://mirrors.aliyun.com/pypi/simple/ Collecting python-magic Downloading https://mirrors.aliyun.com/pypi/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl (5.5 kB) Installing collected packages: python-magic Successfully installed python-magic-0.4.15 Setting up firmware analysis plus ===================================================== Firmware Analysis Plus installed successfully! Before running fat.py for the first time, please edit fat.config and provide your sudo password |
配置
修改 fat.config 文件中的密码,改为 root 系统用户的密码
运行
1 | python3 fat.py -q /root/Documents/firmware-analysis-toolkit/qemu-builds/2.5.0/ /root/Documents/test/WNAP320_V3.7.11.4.zip |
运行成功!
可登录路由器网页管理界面
终端输入回车键,可进入 shell,账号 root,密码 password
总结
模拟固件的方式有多种,很难有一种工具可以完成对所有固件的模拟,如果是 CTF 中的一些固件,或者国外路由器的固件,其定制化程度往往较低,很容易使用我们的工具运行起来。但是,对于国内的主流厂商,想使用单一的工具搭建环境,模拟固件,还是较为困难的。因此,最好的方式,还是分析固件的各个组成部分,提取内核和文件系统,这才是最为关键的部分。