Linux execve函数

在介绍execve函数之前,我们先介绍exec函数。

exec

exec用被执行的程序完全替换调用它的程序的影像。fork创建一个新的进程就产生了一个新的PID,
exec启动一个新程序,替换原有的进程,因此这个新的被exec执行的进程的PID不会改变,
和调用exec函数的进程一样。

execve

execve(参数1,参数2,参数3),头文件在unistd.h

参数1:命令所在路径

参数2:命令的集合

参数3:传递给执行文件的环境变量集

经典shellcode实例:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
int main(int argc, char const *argv[])
{
char * name[2];
name[0] = "/bin/sh";
name[1] = NULL;
execve(name[0], name, NULL);
return 0;
}
音频算法中的声学基础 Linux系统静态库与共享库

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×