In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "what is the common command execution function of PHP". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "what is the common command execution function of PHP" can help you solve the problem.
PHP command execution functions are often used in conjunction with code execution vulnerabilities to launch attacks by using command execution functions to execute operating system commands, and then simply share a few commonly used PHP command execution functions
System ()
The system () function can execute the system command and output the result of the command execution directly to the interface. When you use it, you can directly pass in the command to be executed in the parameters.
System ('ls')
Exec ()
The exec () function can execute system commands, but it does not output the results directly, but saves the results to an array
Exec ('ls', $result)
Parameter 1: string type, system command to be executed
Parameter 2: array type, saving the execution results of system commands
Print_r ($result); / / output the execution result
Shell_exec ()
The shell_exec () function can execute system commands, but it does not directly output the results of execution. Instead, it returns a variable of string type to store the results of system commands, passing the system commands that need to be executed in the parameters.
Echo shell_exec ('ls')
Passthru ()
The passthru () function can execute the system command and output the execution result to the page. Unlike the system () function, it supports binary data and is more used for files, pictures and other operations. When in use, it can directly pass the system command of the string type in the parameter.
Passthru ('ls')
Popen ()
The popen () function can execute the system command, but does not output the execution result. Instead, it returns a variable of resource type to store the execution result of the system command. It needs to cooperate with the fread () function to read the execution result of the command.
$result = popen ('ls',' r')
Parameter 1: string type, command to be executed
Parameter 2: string type, pattern
Return value: resource type, result of command execution
Echo fread ($result, 100)
Parameter 1: resource type, file pointer to be read
Parameter 2:int type, read n bytes
Return value: string type, contents of the file read
Echo fread (popen ('ls','r'), 100)
Back quotation mark ``
The backquote can execute the system command, but it does not output the result, but returns a variable of string type, which is used to store the execution result of the system command, which can be used alone or in conjunction with other command execution functions to bypass the filtering conditions in the parameter.
Echo `ls`
This is the end of the content about "what is the common command execution function of PHP". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.