Experimental environment: Ubuntu-14.04.1 X86LINUX-2.6.32.1BUSYBOX-1.27.2QEMU
0x00 Installing QEMU
sudo apt-get install qemu qemu-system
0X01 Linux Kernel compilation
$ wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.gz$ tar zxvf linux-2.6.32.tar.gz$ CD linux-2.6.32$ sudo apt-get install libncurses5-dev$ make menuconfig$ make$ make all$ make modules
Compile-time problems encountered:
Error 1:
/usr/src/linux-2.6.32/arch/x86/include/asm/ptrace.h:146:13:note:previous declaration of ' Syscall_trace_leave ' was HEREMAKE[2]: * * * [ARCH/X86/KERNEL/PTRACE.O] Error 1make[1]: * * * [Arch/x86/kernel] Error 2make: * * * [arch/x86] Error 2
Workaround:
Patch ---linux-2.6.32.59/arch/x86/include/asm/ptrace.h+++ fix_ptrace.o_compile_error/arch/x86/include/ asm/ptrace.h@@ -130,6 +130,7 @@ zzfcthotfixz __kernel__ #include <linux/init.h>+ #include <linux/linkage.h > struct cpuinfo_x86; struct task_struct;@@ -142,8 +143,8 @@ int error_code, int si_code); void Signal_fault (S Truct pt_regs *regs, void __user *frame, char *where); -extern long Syscall_trace_enter (struct pt_regs *);-extern void Syscall_trace_leave (struct pt_regs *); +extern Asmregparm long Syscall_trace_enter (struct pt_regs *); +extern asmregparm void Syscall_trace_leave (struct pt_regs *); Static inline unsigned long regs_return_value (struct Pt_regs *regs) {
Error 2:
Gcc:error:elf_i386:No such file or directory objcopy arch/x86/vdso/vdso32-int80.so objcopy: ' arch/x86/vdso/ Vdso32-int80.so.dbg ': No such file make[2]: * * [arch/x86/vdso/vdso32-int80.so] Error 1 make[1]: * * * [arch/x86/ VDSO] Error 2 make : * * * [arch/x86] Error 2
Workaround:
The reason is that GCC 4.6 no longer supports the Linker-style architecture. In Arch/x86/vdso/makefile, replace "-M elf_x86_64" with "-m64" at the beginning of the vdso_ldflags_vdso.lds. Replace "-M elf_x86" with "-m32" at the beginning of Vdso_ldflags_vdso32.lds.
Error 3:
DRIVERS/NET/IGBVF/IGBVF.H:128:15: Error: Duplicate member ' page ' make[4]: * * [DRIVERS/NET/IGBVF/ETHTOOL.O] Error 1 make[3]: * * * [DRIVERS/NET/IGBVF] Error 2 make[2]: * * [drivers/net] Error 2 make[1]: * * * [Drivers] Error 2
Workaround:
1. As recommended by the Linux community, this error is due to a conflict between the GCC version and the kernel version. Their advice is to replace the new version of the kernel, but under certain special conditions, we cannot replace the kernel version, so we modify the kernel code to adapt to the current compiler. 2. According to the wrong instructions, the error code is on line 128th of the drivers/net/igbvf/igbvf.h file. 3. Open the file, look at line 128, the code is: struct page *page; look up, line 123th, there is a struct page *page this line of code, this structure is defined in a structure inside the body. is his name and 128 lines of repetition, and 4.6.3 compiler does not support the definition of this way, we modify 128 lines of code for the struct page *pagep; save exit;
0x02 compiling BusyBox
$ wget https://busybox.net/downloads/busybox-1.27.2.tar.bz2$ tar-jxvf busybox-1.27.2.tar.bz2$ cd busybox-1.27.2$ make Menuconfig # Busybox Settings-Build Options-build Busybox as a static binary$ make install
0X03 all compiled successfully, do the following configuration
#进入busybox的_install目录 $ cd _install$ mkdir proc SYS Dev etc etc/init.d$ vim etc/init.d/rcs#!/bin/shmount-t proc None/proc Mount-t Sysfs none/sys/sbin/mdev-s$ chmod +x etc/init.d/rcs$ find. | Cpio-o--FORMAT=NEWC >. /rootfs.img# into the Linux kernel directory $ cd linux-2.6.32$ Qemu-system-i386-kernel ARCH/I386/BOOT/BZIMAGE-INITRD. /busybox-1.19.4/rootfs.img-append "Root=/dev/ram Rdinit=/sbin/init"
0x04 Successful
Linux kernel Exploit-environment configuration (RPM)