运行环境:vmware + Ubuntu16.04+qemu

一、搭建qemu模拟环境

1.安装qemu

sudo vim /etc/apt/sources.list

-----sources.list内容换成如下-----

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

——然后按esc,输入:wq  保存并退出——————————————

接着输入命令:

sudo apt-get update

sudo apt install qemu-system-arm

查看qemu是否安装成功,

qemu-system-arm --version

2.从站点https://people.debian.org/~aurel32/qemu/mips/下载debianmips qemu镜像,

下载debian_squeeze_mips_standard.qcow2和vmlinux-2.6.32-5-4kc-malta即可,然后保存在新建文件夹/home/test/mips中

 

3.MIPS系统网络配置

sudo apt-get install bridge-utils uml-utilities

sudo gedit /etc/network/interfaces

----/etc/network/interfaces修改后内容如下----

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet dhcp

#auto br0
iface br0 inet dhcp
  bridge_ports ens33
  bridge_maxwait 0

接着命令:

sudo gedit /etc/qemu-ifup

---- /etc/qemu-ifup增加后的内容如下---

########################################################
#!/bin/sh
echo "Executing /etc/qemu-ifup"
echo "Bringing $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."

接着重启网络,命令如下:

sudo chmod a+x /etc/qemu-ifup

sudo /etc/init.d/networking restart

4.QEMU启动配置

sudo ifdown ens33

sudo ifup br0

(此处忘记截图,图片选用其他博客的,效果是一样的,参考博客:https://www.freebuf.com/vuls/228726.html

5.QEMU MIPS虚拟机启动

进入步骤2中下载的镜像的目录,并启动,QEMU用户名密码均为root

cd test/mips
sudo qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/sda1 console=tty0" -net nic -net tap,ifname=tap0

启动效果如下:

新开一个终端,方便连接控制qemu,其中IP地址为上图中qemu中eth0的地址,且qemu不要关闭。

ssh root@192.168.51.232

6.固件模拟运行

新开终端,下载固件(需换成mips格式的固件):

cd test
wget ftp://ftp.dlink.de/dap/dap-2020/driver_software/DAP-2020_fw_reva_102rc002_ALL_en_20200322.zip

使用binwalk提取

sudo apt install binwalk
binwalk -e DAP-2020_RevA_Firmware_102rc002.bin

使用scp命令将squashfs-root目录上传到qemu mips虚拟机

scp -r squashfs-root/ root@192.168.51.232:/root/

然后输入命令:

chroot /root/squashfs-root sh

效果如下,

二、远程调试(需要IDA)

1.安装qemu-user-static

sudo apt install qemu-user-static

2.搜索qemu-mips0-static,将其复制到squashfs-root目录下,输入如下指令

//webproc为需要调试的程序
chroot . ./qemu-mips-static -g 1235 ./usr/www/cgi-bin/webproc

3.在物理机中打开IDA,进行如下操作

继续点击红框

成功进行远程调试

参考博客:https://www.freebuf.com/vuls/228726.html

 

 

 

Logo

更多推荐