使用Buffer-Overflow执行一些简单的说明失败 - (Segfaults)
我正在尝试缓冲溢出并使使系统执行mmap
分配的地址,这将是某些简单说明的函数,即
mov $0x1, %rax
ret
opCode数组的\ x48 \ xc7 \ xc7 \ xc0 \ x01 \ x00 \ x00 \ x00 \ xc3
。
我编写的以下代码
char shellcode[] = "\x48\xc7\xc0\x01\x00\x00\x00\xc3";
int main() {
#define page 400
char buff[page];
void* m = mmap(NULL,
sizeof(shellcode),
PROT_WRITE | PROT_EXEC,
MAP_ANONYMOUS | MAP_PRIVATE,
-1,
0);
for(int i=0;i<page;i++) strcat(buff, "\x90");
strcat(buff, shellcode);
strcpy(m,buff);
int(*f)() = m;
return f();
}
(我的实际代码更长,所以这是关于在那里正在执行的操作的摘要),
但是当我运行它时,我会得到segfault
-> 0x7ffff7ffa193: addl %eax, (%rax)
0x7ffff7ffa195: addb %al, (%rax)
0x7ffff7ffa197: addb %al, (%rax)
0x7ffff7ffa199: addb %al, (%rax)
0x7ffff7ffa19b: addb %al, (%rax)
0x7ffff7ffa19d: addb %al, (%rax)
0x7ffff7ffa19f: addb %al, (%rax)
0x7ffff7ffa1a1: addb %al, (%rax)
0x7ffff7ffa1a3: addb %al, (%rax)
0x7ffff7ffa1a5: addb %al, (%rax)
0x7ffff7ffa1a7: addb %al, (%rax)
0x7ffff7ffa1a9: addb %al, (%rax)
0x7ffff7ffa1ab: addb %al, (%rax)
0x7ffff7ffa1ad: addb %al, (%rax)
0x7ffff7ffa1af: addb %al, (%rax)
0x7ffff7ffa1b1: addb %al, (%rax)
,但是如果我执行follwing shellCode,“ \ x32 \ xc0 \ xc0 \ x48 \ x48 \ x48 \ xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\x2b\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05\ x05“
它可以按预期工作。
请帮助我如何制作“ \ x48 \ xc7 \ xc0 \ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ xc3”
exeute。
I'm trying to buffer overflow and make the make the system execute mmap
allocated address which would be a function of some simple instructions, namely
mov $0x1, %rax
ret
the opcode array for this is \x48\xc7\xc0\x01\x00\x00\x00\xc3
.
The following code I wrote
char shellcode[] = "\x48\xc7\xc0\x01\x00\x00\x00\xc3";
int main() {
#define page 400
char buff[page];
void* m = mmap(NULL,
sizeof(shellcode),
PROT_WRITE | PROT_EXEC,
MAP_ANONYMOUS | MAP_PRIVATE,
-1,
0);
for(int i=0;i<page;i++) strcat(buff, "\x90");
strcat(buff, shellcode);
strcpy(m,buff);
int(*f)() = m;
return f();
}
(my actual code is longer, so this is summary of what's being done there)
but when I run it, I get segfault
-> 0x7ffff7ffa193: addl %eax, (%rax)
0x7ffff7ffa195: addb %al, (%rax)
0x7ffff7ffa197: addb %al, (%rax)
0x7ffff7ffa199: addb %al, (%rax)
0x7ffff7ffa19b: addb %al, (%rax)
0x7ffff7ffa19d: addb %al, (%rax)
0x7ffff7ffa19f: addb %al, (%rax)
0x7ffff7ffa1a1: addb %al, (%rax)
0x7ffff7ffa1a3: addb %al, (%rax)
0x7ffff7ffa1a5: addb %al, (%rax)
0x7ffff7ffa1a7: addb %al, (%rax)
0x7ffff7ffa1a9: addb %al, (%rax)
0x7ffff7ffa1ab: addb %al, (%rax)
0x7ffff7ffa1ad: addb %al, (%rax)
0x7ffff7ffa1af: addb %al, (%rax)
0x7ffff7ffa1b1: addb %al, (%rax)
but if I execute the follwing shellcode, "\x32\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\x2b\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05\x05"
it works as expected.
Please help me with how to make "\x48\xc7\xc0\x01\x00\x00\x00\xc3"
exeute.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论