如果碰到智能设备的程序,我们应该怎样动态逆向分析呢?
一、环境准备
首先,需要搭建嵌入式开发环境。并不一定需要硬件平台,可以使用ubuntu进行模拟。在unbuntu主机上安装一个arm操作系统。系统采用nfs方式挂载文件系统。
安装qemu-system-arm
apt-get install qemu-system-arm
假设手头上已有基于arm的linux内核、设备、根文件系统,则运行qemu-system-arm启动。引导命令类似于:
qemu-system-arm -M vexpress-a9 -m 128M -dtb vexpress-v2p-ca9.dtb
-kernel zImage -append "root=/dev/mmcblk0 rw" -sd a9rootfs
上述启动命令面向于vexpress-a9目标板,需要逆向的是a9rootfs
启动后会出现如下的界面

用Explore2fs提取文件系统中的文件,找出需要分析的ELF文件,并从文件系统中提取出来。
为了调试程序,需要安装qemu-user。
apt install qemu-user
二、远程调试
qemu的远程调试比较简单,采用-g参数绑定本地端口即可。假设此时我们需要分析的程序为./sh,则在ubuntu中运行下述命令
qemu-arm -g 12345 ./sh
在IDA中,选择Remote GDB debugger来attach

填写远程主机IP和端口。本示例中填写12345端口。

同时,点击“Debug options”按钮,配置调试选项。勾选Suspend on debugging start, Suspend on process entry point。

点击“Set specific options”,执行目标进程的架构,本示例中选择ARM Little-endian。

如何选择架构呢?这些信息使用readelf –h file就能查看到。

设置完毕后,如果前面的配置都正确则会弹出如下对话框。

之后就出现熟悉的IDA调试界面,可以设置断点,浏览和调试该可执行程序的运行过程以及内存情况。

网友评论