新手玩转Linux Kernel漏洞Null Pointer Dereference之环境搭建

新手玩转Linux Kernel漏洞Null Pointer Dereference之环境搭建

条件

System: Ubuntu 12.04 i386(虚拟机即可)
Disk Space: 50G(编译内核很耗资源)
BusyBox: 1.19.4(将常见的Unix 命令集成在了一个可执行文件)
Qemu(一个模拟器, 非常强悍)
Source Code: Linux Kernel 2.6.32

Linux Kernel 2.6.32下载链接
BusyBox 1.19.4 下载链接

编译工具

sudo apt-get install build-essential libncurses5-dev
sudo apt-get install qemu qemu-system

编译内核

make menuconfig
make
make modules
make modules_install(可选)

编译BusyBox

# BusyBox Settings --> Build Options --> Build BusyBox as a static ....
# 取消Linux System Utilities -->  Support mounting NFS file system
# 取消Networking Utilities --> inetd
$ make menuconfig
$ make
$ make install #在busybox源码目录中生一个一个_install的目录
$ cd _install
$ mkdir proc sys dev etc etc/init.d
$ vim etc/init.d/rcS
#!/bin/sh
mount -t proc none /proc #挂在proc虚拟文件系统
mount -t sysfs none /sys #挂在sysfs虚拟文件系统
/sbin/mdev -s
$ chmod +x etc/init.d/rcS
$ find . | cpio -o -H newc > ../rootfs.img #生成一个rootfs,这个文件系统很关键

常见问题

  1. error: duplicate member ‘page’

    filename: drivers/net/igbvf/igbvf.h
    将第128行代码注释掉

  2. elf_i386: No such file or directory


    filename: arch/x86/vdso/Makefile
    28 - VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1
    28 + VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1
    72 - VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
    72 + VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1

结果

将下面保存为./boot.sh

#!/bin/sh
qemu-system-i386 -m 128M -kernel linux-2.6.32/arch/x86/boot/bzImage -initrd busybox-1.19.4/rootfs.img -append "console=ttyS0 root=/dev/ram rdinit=/sbin/init" --nographic

启动./boot.sh
result01

忠告

    我曾经尝试通过在Linux Kernel 2.6.32内核源码中打KGDB调试的补丁, 但是Google了好久, 没找到对应的文件. 搜索到的结果中, 关于KGDB补丁的链接均失效了。所以奉劝大家, 实在不行就找内核源码已打好KGDB补丁的源码, 这里给大家一个版本Linux Kernel 3.10

参考链接

pwn4

猜你喜欢

转载自blog.csdn.net/qq_33528164/article/details/80461504
今日推荐