#include<stdio.h>
#include<unistd.h>
int main()
{
char *filename[]={"./BP",NULL};//BP是c文件编译链接后产生的可执行文件,目的是打印一条语句
char *envp[]={0,NULL};//如果依赖于新环境变量,这里才需要改
execve("/root/BP",filename,envp);//字符串是文件的路径需要具体到该运行文件名,直到文件夹貌似识别不了,或者命令的路径
/*注意,把下面的三个注释遇到去掉,后面的ls命令也无法执行,因为*execve执行后,相当于结束了当前的程序,切换到execve里面的那个程序*去了*/
// char *filename1[]={"ls","-al","/root",NULL};//命令和参数,记得要加NULL
// char *envp1[]={0,NULL};
// execve("/bin/ls",filename1,envp1);
return 0;
} //BP.c
#include<stdio.h>
int main()
{
printf("this is c process\n");
return 0;
}

运行结果如下

没修改前的运行结果

[22:41:10] gcc execvetest.c -o execvetest

[22:41:18] gcc BP.c -o BP

[22:41:24] ./execvetest

this is c process

注释掉前三行,并且去掉后面的注释,运行结果如下

[22:45:05] gcc execvetest.c -o execvetest

[22:45:11] gcc BP.c -o BP

[22:45:23] ./execvetest

total 64

dr-xr-x—. 15 root root 4096 May 10 21:06 .

dr-xr-xr-x. 17 root root 224 Apr 30 02:52 ..

-rw——-. 1 root root 314 Apr 30 07:08 .ICEauthority

-rw——-. 1 root root 3769 May 10 18:33 .bash_history

-rw-r–r–. 1 root root 18 Dec 28 2013 .bash_logout

-rw-r–r–. 1 root root 176 Dec 28 2013 .bash_profile

-rw-r–r–. 1 root root 208 May 10 18:19 .bashrc

drwx——. 10 root root 194 Apr 30 07:09 .cache

drwx——. 15 root root 276 Apr 30 07:09 .config

-rw-r–r–. 1 root root 100 Dec 28 2013 .cshrc

drwx——. 3 root root 25 Apr 30 06:53 .dbus

-rw——-. 1 root root 16 Apr 30 07:08 .esd_auth

drwx——. 3 root root 19 Apr 30 07:08 .local

-rw-r–r–. 1 root root 129 Dec 28 2013 .tcshrc

-rwxr-xr-x. 1 root root 8512 May 10 20:55 BP

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Desktop

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Documents

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Downloads

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Music

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Pictures

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Public

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Templates

drwxr-xr-x. 2 root root 6 Apr 30 07:08 Videos

-rw——-. 1 root root 2742 Apr 30 02:52 anaconda-ks.cfg

drwxr-xr-x. 2 root root 4096 May 10 22:45 bp

-rw-r–r–. 1 root root 2750 Apr 30 06:55 initial-setup-ks.cfg

-rw——-. 1 root root 2033 Apr 30 02:52 original-ks.cfg

execve函数的介绍与使用的更多相关文章

  1. php常用Stream函数集介绍

    php常用Stream函数集介绍 作者: 字体:[增加 减小] 类型:转载 时间:2013-06-24   本篇文章是对php中的常用Stream函数集进行了详细的分析介绍,需要的朋友参考下     ...

  2. Signal ()函数详细介绍 Linux函数

    http://blog.csdn.net/ta893115871/article/details/7475095 Signal ()函数详细介绍 Linux函数 signal()函数理解 在<s ...

  3. JavaScript function函数种类介绍

    JavaScript function函数种类介绍 本篇主要介绍普通函数.匿名函数.闭包函数 1.普通函数介绍 1.1 示例 ? 1 2 3 function ShowName(name) {     ...

  4. C语言之函数的介绍

    函数的介绍 遇到的问题: 1.代码看起来特别多,不简洁 2.修改起来非常麻烦,需要所有用到的地方都修改 函数就可以解决上述这两个问题 函数可以理解为一个打包带,就是把一段代码打包起来,用到的时候只要写 ...

  5. ConnectString ()函数的介绍

    ConnectString ()函数的介绍: connectstring 函数主要负责数据库的连接工作 Public Function ConnectString() As String       ...

  6. Signal ()函数详细介绍 Linux函数(转)

    Signal ()函数详细介绍 Linux函数 收藏人:紫火神兵     2012-09-27 | 阅:5659  转:22    |   来源   |  分享               signa ...

  7. Python入门之函数的介绍/定义/定义类型/函数调用/Return

    本篇目录: 一. 函数的介绍 二. 函数的定义 三. 定义函数的三种类型 四. 函数调用的阶段 五. Return返回值 ======================================= ...

  8. Oracle自我补充之trunc()函数使用介绍

    oracle trunc函数使用介绍 核心提示:oracle trunc函数使用介绍 1.TRUNC(for dates) TRUNC函数为指定元素而截去的日期值. 其具体的语法格式如下: TRUNC ...

  9. loadrunner 脚本开发-web_custom_request函数详细介绍

    脚本开发-web_custom_request函数详细介绍 by:授客 QQ:1033553122 c语言版本: int web_custom_request(const char *RequestN ...

随机推荐

  1. sql语句最后一行显示统计。

    SELECT id, username, id_Num FROM users UNION ALL SELECT '合计', count(*), null FROM users ORDER BY id_ ...

  2. 每天CSS学习之text-overflow

    text-overflow是CSS3的一个属性,其作用是当文本溢出包含它的元素时,应该裁剪还是将多余的字符用省略号来表示. 该属性一般和overflow:hidden属性一起使用. text-over ...

  3. Python 基础day4

    整体大纲关于占位符 tpl = "i am %s" % "alex"   tpl = "i am %s age %d" % ("a ...

  4. ob_get_contents 获取输出缓存内容

    function _require($filename){ ob_start(); include $filename; $content = ob_get_contents(); ob_end_cl ...

  5. dynamic programming:find max subarray

    public static mark dynway( ) //put or pop the books into the basket,mark the highest recorder { int ...

  6. 使用solr报错

    2017-11-15  20:15:18 错误介绍: 错误原因:url错误 错误解决:换成正确

  7. PAP认证(单向、双向)

    实验要求:掌握PAP单向.双向认证 拓扑如下: 单向验证 R1(认证方)enable 进入特权模式configure terminal 进入全局模式hostname R1 设置主机名interface ...

  8. RESTful Service API 常见问题解决方案

    REST 风格的优秀设计应该像下面这些: - GET /users 获取所有用户 - GET /users/1234 获取ID为1234的用户 - POST /users 创建一个新用户 - PUT ...

  9. sql,按照时间排序,取前N条

    mysql: SELECT * from  (SELECT H_TEMPERATURE,TH_TIME FROM wenshidu  WHERE TH_TIME <= STR_TO_DATE(' ...

  10. Spring Boot 揭秘与实战(二) 数据缓存篇 - EhCache

    文章目录 1. EhCache 集成 2. 源代码 本文,讲解 Spring Boot 如何集成 EhCache,实现缓存. 在阅读「Spring Boot 揭秘与实战(二) 数据缓存篇 - 快速入门 ...