PHP Dangerous Functions Explained_PHP Tutorial
Source: Dongzhi’s BLOG
When compiling PHP, if there is no special need, it must be prohibited to compile and generate PHP parsing support in CLI command line mode.
Can be compiled using --disable-cli. Once PHP in CLI mode is compiled and generated, an intruder may
use this program to establish a WEB Shell backdoor process or execute arbitrary code through PHP!
phpinfo()
Function description: Output PHP environment information and related module, WEB environment and other information.
Danger level: Medium
passthru()
Function description: Allows to execute an external program and echo the output, similar to exec().
Danger Level: High
exec()
Function description: Allows the execution of an external program (such as UNIX Shell or CMD command, etc.).
Danger Level: High
system()
Function description: Allows executing an external program and echoing the output, similar to passthru().
Danger Level: High
chroot()
Function description: It can change the working root directory of the current PHP process. It can only work when the system supports CLI mode
PHP, and this function is not applicable to Windows systems.
Danger Level: High
scandir()
Function description: List files and directories in the specified path.
Danger level: Medium
chgrp()
Function description: Change the user group to which a file or directory belongs.
Danger Level: High
chown()
Function description: Change the owner of a file or directory.
Danger Level: High
shell_exec()
Function description: Execute the command through Shell and return the execution result as a string.
Danger Level: High
proc_open()
Function description: Execute a command and open the file pointer for reading and writing.
Danger Level: High
proc_get_status()
Function description: Get information about the process opened using proc_open().
Danger Level: High
error_log()
Function description: Send error information to the specified location (file).
Safety Note: In some versions of PHP, error_log() can be used to bypass PHP safe mode and
execute arbitrary commands.
Danger Level: Low
ini_alter()
Function description: It is an alias function of the ini_set() function and has the same function as ini_set().
See ini_set() for details.
Danger Level: High
ini_set()
Function description: Can be used to modify and set PHP environment configuration parameters.
Danger Level: High
ini_restore()
Function description: Can be used to restore PHP environment configuration parameters to their initial values.
Danger Level: High
dl()
Function description: Load a PHP external module while PHP is running (not when it is started).
Danger Level: High
pfsockopen()
Function description: Establish a socket persistent connection in the Internet or UNIX domain.
Danger Level: High
syslog()
Function description: The system layer syslog() function of the UNIX system can be called.
Danger level: Medium
readlink()
Function description: Returns the content of the target file pointed to by the symbolic link.
Danger level: Medium
symlink()
Function description: Create a symbolic link in UNIX system.
Danger Level: High
popen()
Function description: You can pass a command through the parameters of popen() and execute it on the file opened by popen().
Danger Level: High
stream_socket_server()
Function description: Establish an Internet or UNIX server connection.
Danger level: Medium
putenv()
Function description: Used to change the system character set environment when PHP is running. In PHP versions earlier than 5.2.6, you can use this function
to modify the system character set environment, and then use the sendmail command to send special parameters to execute the system SHELL command.
Danger Level: High

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita

ToretrievedatafromaPHPsession,startthesessionwithsession_start()andaccessvariablesinthe$_SESSIONarray.Forexample:1)Startthesession:session_start().2)Retrievedata:$username=$_SESSION['username'];echo"Welcome,".$username;.Sessionsareserver-si

The steps to build an efficient shopping cart system using sessions include: 1) Understand the definition and function of the session. The session is a server-side storage mechanism used to maintain user status across requests; 2) Implement basic session management, such as adding products to the shopping cart; 3) Expand to advanced usage, supporting product quantity management and deletion; 4) Optimize performance and security, by persisting session data and using secure session identifiers.

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
