PHP执行root权限程序
本文地址:http://tongxinmao.com/Article/Detail/id/293
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> char cmd[256]; int main(int argc,char **argv) { uid_t uid ,euid; uid = getuid() ; euid = geteuid(); printf("my uid :%u\n",getuid()); //这里显示的是当前的uid 可以注释掉. printf("my euid :%u\n",geteuid()); //这里显示的是当前的euid if(setreuid(euid, uid)) //交换这两个id perror("setreuid"); printf("after setreuid uid :%u\n",getuid()); printf("afer sertreuid euid :%u\n",geteuid()); //system("/sbin/iptables -L"); //执行iptables -L命令 sprintf(cmd,"wine /bin/pxxxcmd.exe %s %s",argv[1],argv[2]); printf(cmd); system(cmd); return 0; } gcc cmd.c -o cmd chmod u+s cmd 将cmd放在网站目录下,即可在PHP脚本中通过此C程序调用ROOT才能执行的程序
$cmd = "/home/ftp/s/st/wwwroot/cmd " . $file ." " .APP_ROOT.'/upload/tmp/';
上一篇:微信小程序MQTT支持
下一篇:树莓派USB设备信息获取(含插入检测)