使用 firmware-analysis-plus 一键模拟固件

Firmadyne 是一个自动化和可扩展的系统,用于对基于 Linux 的嵌入式固件执行仿真和动态分析。详细说明见:基于Firmadyne的固件模拟环境搭建。奈何该工具实际配置较为复杂,后来 attify 制作了开源工具 firmware-analysis-toolkit 整合相关流程,进一步降低了该工具的使用难度。


2021-01-32 重要说明:
本篇博客首发于 2020-06-14,以下所示的方法仅仅适用于 firmware-analysis-plus v0.1
更多详情请移步
项目地址:https://github.com/liyansong2018/firmware-analysis-plus

尽管 firmware-analysis-toolkit 还在不断更新,然而其中包含的诸多 bug,加上国内网络不通畅,导致此工具在现实场景中很难真正安装起来。为此,笔者查看了firmware-analysis-toolkit 的部分源码,修改了其中存在的 bug,在此基础上重写脚本,改成了一个新的项目,即 firmware-analysis-plus

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 模块下载速度

找到 ~/.pip/pip.conf,如果不存在就创建,这一步是为了加快下载 binwalk 依赖,添加以下内容

[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

$ git clone https://github.com/ReFirmLabs/binwalk.git
$ cd binwalk
$ sudo ./deps.sh
$ sudo python setup.py install

./deps.sh 命令,不能出错,某些依赖没有安装可能会导致解包失败
在这里插入图片描述
遇到此类问题,删除 ./deps.sh 中的上述几个包,继续安装。
在这里插入图片描述

如果报错,先进行下面的步骤,安装 firmware-analysis-plus ,在这个过程中,会自从安装 python-pip 包,安装完成之后,再回来安装 binwalk。

如果不想忽略这些依赖,按照如下方式按照

安装

git clone https://github.com/liyansong2018/firmware-analysis-plus.git
cd firmware-analysis-plus

运行 ./setup.sh ,如果报错,请使用备用文件 ./setup2kali.sh,国内网路不通畅,如果更新卡住,终止程序,多试几次就好了

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 系统用户的密码;修改相关路径。

运行

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 中的一些固件,或者国外路由器的固件,其定制化程度往往较低,很容易使用我们的工具运行起来。但是,对于国内的主流厂商,想使用单一的工具搭建环境,模拟固件,还是较为困难的。因此,最好的方式,还是分析固件的各个组成部分,提取内核和文件系统,这才是最为关键的部分。

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 20
    评论
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

江下枫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值