首页
社区
课程
招聘
[原创]IoT安全:调试环境搭建教程(MIPS篇)
2018-7-4 14:55 5993

[原创]IoT安全:调试环境搭建教程(MIPS篇)

2018-7-4 14:55
5993
不多说,继续MIPS篇。

0x004 MIPS


主机:Ubuntu 16.04 LST

虚拟机版本: qemu 2.8.0

Linux内核版本:3.2.0

交叉编译工具链:gcc-mips-linux-gnu

gdb版本:7.11.1


安装交叉编译链
sudo apt-get install linux-libc-dev-mips-cross 
sudo apt-get install libc6-mips-cross libc6-dev-mips-cross 
sudo apt-get install binutils-mips-linux-gnu gcc-mips-linux-gnu 
sudo apt-get install g++-mips-linux-gnu

下载vmlinux-3.2.0-4-4kc-malta、debian_wheezy_mips_standard.qcow2

启动qemu
sudo qemu-system-mips \
    -M malta \
    -kernel vmlinux-3.2.0-4-4kc-malta \
    -hda debian_wheezy_mips_standard.qcow2 \
    -nographic \
    -append "root=/dev/sda1 rw console=tty0 init=/linuxrc ignore_loglevel" \
    -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
    -redir tcp:2333::2333

设置ip
$ ifconfig eth0 192.168.1.20

挂载共享文件
$ mkdir /nfsroot
$ mount -t nfs -o nolock 192.168.1.156:/nfsroot /nfsroot

编译gdbserver
$ CC="mips-linux-gnu-gcc" CXX="mips-linux-gnu-g++" ./configure --target=mips-linux-gnu --host="mips-linux-gnu" --prefix="/root/toolchain/gdb/build"

$ nano Makefile
# LDFLAGS is specifically reserved for setting from the command line
# when running make.
LDFLAGS = -static
INTERNAL_LDFLAGS = $(LDFLAGS) -Wl,--dynamic-list=$(srcdir)/proc-service.list

$ make install

编译测试程序
$ mips-linux-gnu-gcc -g hello.c -o hello_mips -static

guest机启动调试
$ ./gdbserver_aarch32 0.0.0.0:2333 ./hello_mips

执行gdb-multiarch
$ gdb-multiarch
gef➤ set architecture mips
The target architecture is assumed to be mips
gef➤ gef-remote -q 192.168.1.20:2333

0x005 MIPSEL


主机:Ubuntu 16.04 LST

虚拟机版本: qemu 2.8.0

Linux内核版本:3.2.0

交叉编译工具链:gcc-mipsel-linux-gnu

gdb版本:7.11.1


安装交叉编译链

sudo apt-get install linux-libc-dev-mipsel-cross
sudo apt-get install libc6-mipsel-cross libc6-dev-mipsel-cross
sudo apt-get install binutils-mipsel-linux-gnu gcc-mipsel-linux-gnu
sudo apt-get install g++-mipsel-linux-gnu

下载vmlinux-3.2.0-4-4kc-malta、debian_wheezy_mipsel_standard.qcow2

启动qemu
sudo qemu-system-mipsel \
    -M malta \
    -kernel vmlinux-3.2.0-4-4kc-malta \
    -hda debian_wheezy_mipsel_standard.qcow2 \
    -nographic \
    -append "root=/dev/sda1 rw console=tty0 init=/linuxrc ignore_loglevel" \
    -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
    -redir tcp:2333::2333

设置ip
$ ifconfig eth0 192.168.1.20

挂载共享文件
$ mkdir /nfsroot
$ mount -t nfs -o nolock 192.168.1.156:/nfsroot /nfsroot

编译gdbserver
$ CC="mipsel-linux-gnu-gcc" CXX="mipsel-linux-gnu-g++" ./configure --target=mipsel-linux-gnu --host="mipsel-linux-gnu" --prefix="/root/toolchain/gdb/build"

$ nano Makefile
# LDFLAGS is specifically reserved for setting from the command line
# when running make.
LDFLAGS = -static
INTERNAL_LDFLAGS = $(LDFLAGS) -Wl,--dynamic-list=$(srcdir)/proc-service.list

$ make install
```

编译测试程序
$ mipsel-linux-gnu-gcc -g hello.c -o hello_mipsel -static

guest机启动调试
$ ./gdbserver_aarch32 0.0.0.0:2333 ./hello_mipsel

执行gdb-multiarch
$ gdb-multiarch
gef➤ set architecture mips
The target architecture is assumed to be mips
gef➤ gef-remote -q 192.168.1.20:2333


[CTF入门培训]顶尖高校博士及硕士团队亲授《30小时教你玩转CTF》,视频+靶场+题目!助力进入CTF世界

最后于 2018-7-4 17:09 被m0nshaw编辑 ,原因:
收藏
点赞0
打赏
分享
打赏 + 2.00雪花
打赏次数 1 雪花 + 2.00
 
赞赏  junkboy   +2.00 2018/07/04
最新回复 (0)
游客
登录 | 注册 方可回帖
返回