我有以下shellcode:
xor eax, eax ; eax = 0
push eax ; 0 (end of the string)
push 0x68732f2f ; //sh
push 0x6e69622f ; /bin
mov ebx, esp ; ebx = &(/bin//sh)
xor ecx, ecx ; ecx = 0
mov al, 0xb ; execve
int 0x80
其中,转换为十六进制用于以下 C 程序:
const char shellcode[] =
"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x31\xc9\xb0\x0b\xcd\x80";
int main(){
(*(void(*)()) shellcode)();
return 0;
}
这工作得很好,但是当我单步执行有效负载时,gdb我看到在 shellcode 中添加了一条额外的指令:
$ gdb shellcode
(gdb) disass main
Dump of assembler code for function main:
0x080483ed <+0>: push %ebp
0x080483ee <+1>: mov %esp,%ebp
0x080483f0 <+3>: and $0xfffffff0,%esp
0x080483f3 <+6>: mov $0x80484a0,%eax
0x080483f8 <+11>: call *%eax
0x080483fa <+13>: mov $0x0,%eax
0x080483ff <+18>: leave
0x08048400 <+19>: ret
End of assembler dump.
(gdb) x/14i 0x80484a0
0x80484a0 <shellcode>: xor %eax,%eax
0x80484a2 <shellcode+2>: push %eax
0x80484a3 <shellcode+3>: push $0x68732f2f
0x80484a8 <shellcode+8>: push $0x6e69622f
0x80484ad <shellcode+13>: mov %esp,%ebx
0x80484af <shellcode+15>: xor %ecx,%ecx
0x80484b1 <shellcode+17>: mov $0xb,%al
0x80484b3 <shellcode+19>: int $0x80
0x80484b7 <shellcode+21>: add %al,(%ecx)
... (gibberish)
你可以看到shellcode+23是一个额外的行,添加到 shellcode 中。在这里寻找答案时,我发现它使 shellcode 崩溃,我不得不ecx在调用中断之前清除寄存器。
你知道这个额外的命令是什么吗?