Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Security 返回到libc漏洞:在哪里为system()调用提供参数?_Security_Unix_Calling Convention_Shellcode - Fatal编程技术网

Security 返回到libc漏洞:在哪里为system()调用提供参数?

Security 返回到libc漏洞:在哪里为system()调用提供参数?,security,unix,calling-convention,shellcode,Security,Unix,Calling Convention,Shellcode,我正在尝试编写一个返回libc漏洞,但无法确定我应该将system()调用的参数放在堆栈中的什么位置 易受攻击的功能是 void func(char *str) { char buffer[12]; strcpy(buffer,str); } 此函数的堆栈将如下所示: ----------- str ----------- return address ----------- previous frame pointer ----------- buffer

我正在尝试编写一个返回libc漏洞,但无法确定我应该将
system()
调用的参数放在堆栈中的什么位置

易受攻击的功能是

void func(char *str)
{
     char buffer[12];
     strcpy(buffer,str);
}
此函数的堆栈将如下所示:

 -----------
 str
 -----------
 return address
 -----------
 previous frame pointer
 -----------
 buffer
 -----------
-----------
shellcode: /bin/whatever ...
...
...
...
\0
-----------
&shellcode    <-- str is here
-----------
&system       <-- return address is here
-----------
previous frame pointer <--- don't corrupt this
-----------
padding       <-- buffer
我知道我必须用
system()
调用的地址覆盖返回地址,但是我应该将其参数的地址放在哪里,为什么


谢谢。

应该在返回地址的正上方找到指向该参数的指针。也就是说,覆盖之后,堆栈应该如下所示:

 -----------
 str
 -----------
 return address
 -----------
 previous frame pointer
 -----------
 buffer
 -----------
-----------
shellcode: /bin/whatever ...
...
...
...
\0
-----------
&shellcode    <-- str is here
-----------
&system       <-- return address is here
-----------
previous frame pointer <--- don't corrupt this
-----------
padding       <-- buffer
-----------
外壳代码:/bin/随便什么。。。
...
...
...
\0
-----------
&外壳代码