PHP executes the root command-general Linux technology-Linux programming and kernel information. The following is a detailed description. Author: mq110
When PHP was used to run the root command before playing C for a period of time, it never worked until the super plug-in was found one day.
With the increasing days of playing C, I found that the external commands to be run can be wrapped in C. I tried it and succeeded.
You can use PHP to execute the root command without any external tools.
I will release the method to you below. If you need to use php to run the root command, you don't have to worry about it.
Platform: Linux. The current directory of the experiment command iptables is/var/www/html/http
Use the root user to write the program.
We all know that iptables cannot be run by non-root users.
First write a C program
The name is
CODE:
# Include # Include # Include # Include Int main () { Uid_t uid, euid; Char cmd [1024]; Uid = getuid (); Euid = geteuid (); Printf ("my uid: % u \ n", getuid (); // The current uid can be commented out. Printf ("my euid: % u \ n", geteuid (); // The current euid is displayed here If (setreuid (euid, uid) // exchange the two IDs Perror ("setreuid "); Printf ("after setreuid uid: % u \ n", getuid ()); Printf ("afer sertreuid euid: % u \ n", geteuid ()); System ("/sbin/iptables-L"); // execute the iptables-L command Return 0; } |