物联网设备固件模拟流程

Iot安全之漏洞挖掘。为了对智能设备进行渗透测试,固件模拟可以在没有设备的情况下对固件进行分析。
\color{#D2691E}{1. 环境}
\color{#D2691E}{2. 工具安装}
-\color{#5F9EA0}{1. firmadyne}
-\color{#5F9EA0}{2. Extractor}
-\color{#5F9EA0}{3. Database}
\color{#D2691E}{3. 模拟测试}


环境

  1. 操作系统:Ubuntu14.04.6,其他基于Debian的系统也可以。
  2. 安装Linux常用命令及软件
sudo apt-get install busybox-static fakeroot git dmsetup kpartx netcat-openbsd nmap python-psycopg2 python3-psycopg2 snmp uml-utilities util-linux vlan

工具安装

  • \color{#5F9EA0}{1. firmadyne}

FIRMADYNE is an automated and scalable system for performing emulation and dynamic analysis of Linux-based embedded firmware. It includes the following components:

  • modified kernels (MIPS: v2.6.32, ARM: v4.1, v3.10) for instrumentation of firmware execution;
  • a userspace NVRAM library to emulate a hardware NVRAM peripheral;
  • an extractor to extract a filesystem and kernel from downloaded firmware;
  • a small console application to spawn an additional shell for debugging;
  • and a scraper to download firmware from 42+ different vendors.

Git上下载

$ git clone --recursive https://github.com/firmadyne/firmadyne.git

并下载所需的额外二进制文件

$ cd ./firmadyne
$ ./download.sh

安装其余依赖项

    1. sudo -H pip install git+https://github.com/ahupp/python-magic
    1. sudo -H pip install git+https://github.com/sviehb/jefferson
    1. sudo apt-get install qemu-system-arm qemu-system-mips qemu-system-x86 qemu-utils
      设置firmadyne
      打开config文件,将firmadyne路径设置为正确路径
      image.png
  • \color{#5F9EA0}{2. Extractor}
    使用Extractor提取固件的文件系统(filesystem),Extractor依赖binwalk工具

Binwalk是一个固件分析工具,用于协助研究人员对固件进行分析,文件提取等。

    1. git clone https://github.com/devttys0/binwalk.git
    1. cd binwalk
    1. sudo python setup.py install
  • \color{#5F9EA0}{3. Database}
    安装配置数据库,注意数据库密码设为firmadyne
$ sudo apt-get install postgresql
$ sudo -u postgres createuser -P firmadyne, with password firmadyne
$ sudo -u postgres createdb -O firmadyne firmware
$ sudo -u postgres psql -d firmware < ./firmadyne/database/schema

模拟测试

  1. 下载你需要模拟的固件
wget http://www.downloads.netgear.com/files/GDC/WNAP320/WNAP320%20Firmware%20Version%202.0.3.zip
  1. 用extractor 提取filesystem
    ./sources/extractor/extractor.py -b Netgear -sql 127.0.0.1 -np -nk "WNAP320 Firmware Version 2.0.3.zip" images

  2. 识别固件架构
    ./scripts/getArch.sh ./images/1.tar.gz
    可知为mips架构

    image.png

  3. 将固件系统内容存储到数据库的image表中
    ./scripts/tar2db.py -i 1 -f ./images/1.tar.gz

  4. 为固件创建qemu磁盘镜像
    sudo ./scripts/makeImage.sh 1

  5. 指定固件的网络配置
    ./scripts/inferNetwork.sh 1

    image.png

  6. 使用指定的网络配置模拟运行固件
    ./scratch/1/run.sh

    image.png

    系统运行成功,主机可以访问,日志记录到./scratch/1/qemu.final.serial.log
    image.png

接下里就可以使用snmp脚本探测固件信息,测试web接口;使用nmap扫描firmadyne虚拟环境运行的固件,使用nmap vuln脚本探测固件漏洞;并且使用msf对固件进行渗透等操作。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容