firmadyne环境搭建

老版本安装成功

Ubuntu16.04 86位
Linux pwn 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:19 UTC 2019 i686 i686 i686 GNU/Linux
python2.7

先把老版本的拉下来

git clone --recursive https://github.com/liyansong2018/Old-Firmware-Analysis-Toolkit
//我拉的时候,由于网速问题经常会拉一半断开
可以选择下载压缩包下来,解压就可以使用了
https://github.com/liyansong2018/Old-Firmware-Analysis-Toolkit/releases/tag/1.1 //压缩包地址

下载的压缩包没有binaries目录,从github仓库拉下来的有

安装pip

sudo apt-get install python-pip

安装Firmadyne

安装依赖

sudo apt-get install busybox-static fakeroot git dmsetup kpartx netcat-openbsd nmap python-psycopg2 python3-psycopg2 snmp uml-utilities util-linux vlan

因为firmadyne里的download.sh下载源在国外,需要翻墙,这里直接用被人已经下载好的binaries即可。

git clone https://github.com/liyansong2018/Firmadyne-binaries.git
git后替换Firmadyne目录内的binaries即可。

下载好之后替换掉Firmadyne目录内的binaries。使用复制方式

再安装其他依赖

sudo -H pip install git+https://github.com/ahupp/python-magic //如果安装不了,就重启系统,再安装即可
sudo -H pip install git+https://github.com/sviehb/jefferson //如果安装不了,就重启系统,再安装即可
sudo apt-get install qemu-system-arm qemu-system-mips qemu-system-x86 qemu-utils

得安装pexpect
访问https://pypi.python.org/pypi/pexpect //下载压缩包,拉到ubuntu解压
tar -xzvf 压缩包名称
进入解压文件夹,执行安装目录
sudo python ./setup.py install
安装ptyprocess
访问https://pypi.python.org/pypi/ptyprocess#downloads //下载压缩包,拉到ubuntu解压
tar -xzvf 压缩包名称
进入解压文件夹,执行安装目录
sudo python ./setup.py install

安装 sasquatch

sudo apt-get install build-essential liblzma-dev liblzo2-dev zlib1g-dev
git clone https://github.com/debug601/sasquatch
cd sasquatch
./build.sh

安装binwalk

sudo apt-get update
sudo apt-get install build-essential autoconf git //执行完上面两条命令再执行下面的

将Old-Firmware-Analysis-Toolkit文件夹的binwalk替换为binwalk2.2版本并将binwalk文件夹下面的deps.sh文件某部分进行修改
修改如下:
搜索function install_sasquatch
将git链接替换为: git clone https://github.com/debug601/sasquatch
----------------------------------------------------------

sudo apt-get remove python-pip //删除pip,但是安装的库还会存在,应对长洪报错使用
sudo apt-get install python-pip
sudo python -m pip install --upgrade pip==19.0 //把pip升级到19.0版本

git clone https://github.com/devttys0/binwalk.git //执行改文件夹的deps.sh文件看看补丁
//以下的包全部得安装
sudo apt-get install python-lzma python-crypto
sudo apt-get install libqt4-opengl python-opengl python-qt4 python-qt4-gl python-numpy python-scipy python-pip

sudo apt-get install git build-essential libqt4-opengl mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop srecord cpio python-crypto python-lzo python-lzma python-pip python-tk

sudo pip install pyqtgraph = sudo apt-get install python-pyqtgraph
sudo apt-get install python-pip
sudo apt-get install python-capstone
sudo pip install capstone
sudo apt-get install python-pyqtgraph
sudo apt-get install python-matplotlib
sudo pip install PyQt5
sudo apt-get install mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsprogs cramfsswap squashfs-tools cramfsprogs
sudo apt-get install python3-crypto python3-pip python3-tk

sudo python setup.py install
sudo ./deps.sh //安装完上面的包,执行这个sh文件

//使用python2安装哦

安装postgresql

sudo apt-get install postgresql
sudo -u postgres createuser -P firmadyne //回车会要求你输入两次密码,输入firmadyne即可
sudo -u postgres createdb -O firmadyne firmware
sudo -u postgres psql -d firmware < ./firmadyne/database/schema (schema具体路径可以在文件内pwd查找)

创建时会提示输密码,就使用firmadyne作为密码方便使用。

修改配置

修改firmadyne文件夹的firmadyne.config文件,修改成绝对路径。

//这块本来是注释掉的
'''
# uncomment and specify full path to FIRMADYNE repository
#FIRMWARE_DIR=/home/vagrant/firmadyne/
'''
//我们强调#号注释,把FIRMWARE_DIR的路径替换成我们真实的firmadyne路径即可
# uncomment and specify full path to FIRMADYNE repository
FIRMWARE_DIR=/home/f5/Old-Firmware-Analysis-Toolkit/firmadyne //将这块修改成你真实的firmadyne路径

将firmware-analysis-toolkit根目录下的两个脚本文件fat.py和reset.py ,拷贝到 firmadyne 目录下。并修改 。主要修改如下,root-pass 修改成你当前系统用户的密码,firmadyne_pass 是其在 postgresql 数据库中的账号密码(修改成firmadyne)。

//修改fat.py文件
#Configurations - change this according to your system
firmadyne_path = "/home/f5/Old-Firmware-Analysis-Toolkit/firmadyne" //修改成你firmadyne的真实目录
binwalk_path = "/usr/local/bin/binwalk" //保留
root_pass = "123com" //修改成你目前系统的root密码
firmadyne_pass = "firmadyne" //修改成firmadyne

//修改reset.py文件
# Change the root password according to your system
root_pass = "123.com" //修改成你目前系统的root密码
firm_pass = "firmadyne" //修改成firmadyne

使用FAT

进入firmadyne路径,执行以下命令
python fat.py 固件的绝对路径 //开启FAT
python fat.py 固件名称即可 //或者也可以把固件防止firmadyne的目录,开启FAT
python reset.py //清除掉之前模拟固件留下的缓存,建议每此开启之前都执行一次