The PHPInfo () function is mainly used to test whether the PHP environment set up during Website construction is correct. many websites are not deleted in time after the test is completed. Therefore, when accessing these test pages, the key information of the server will be output, and the leakage of such information will lead to the risk of server penetration. Next let's take a look at the detailed introduction. The PHPInfo () function is mainly used to test whether the PHP environment set up during Website construction is correct. many websites are not deleted in time after the test is completed. Therefore, when accessing these test pages, the key information of the server will be output, and the leakage of such information will lead to the risk of server penetration. Next let's take a look at the detailed introduction.
Phpinfo function
Phpinfo function PHP provides the PHPInfo () function, which returns all PHP information, including PHP compilation options and expansion configuration, PHP version, server information and environment variables, PHP environment variables, operating system version information, path and environment variable configuration, HTTP header, and copyright notice.
The function is defined as follows:
Syntax: int phpinfo (void );
Return value: integer
Function types: PHP system functions
For example, to create a php file, enter the following content:
Sophpinfo()I'm sure I am most familiar with everyone. after setting up the environment, I will writephpinfo()To test whether the environment is normal. after testing, many people forget to delete the environment and start to deploy the environment. This results in leakage of some sensitive information. Then we canphpinfo()Which sensitive information is obtained in?
Let alone the php version. let's take a look at the sensitive information leaked.
1. absolute path (_ SERVER ["script_FILENAME"])
This is the most common and most effective method.phpinfo()The absolute path of the website can be directly found on the page, which is essential for writing shell and collecting information.
2. supported programs
You can usephpinfo()Check some special program services, such as redis, memcache, mysql, SMTP, curl, etc. if the server is installed with redis or memcache, you can use ssrf to getshell, which has encountered such problems in discuz. If you are sure you have installed redis or memcache, you can focus on ssrf if you have no idea.
3. leakage of real ip addresses (_ SERVER ["SERVER_ADDR"] or SERVER_ADDR)
Sometimesphpinfo()For leaked ip addresses, you can check the site and CIDR block, and ignore cdn directly.
IV. GOPHER
This is part of ssrf, or it is mainly used by ssrf. if gopher is supported, ssrf will not be under pressure.
V. fastcgi
Check whether fastcgi and fastcgi versions are enabled, which may cause parsing vulnerabilities, remote command execution, arbitrary file reading, and other problems.
6. leakage of the cache file address (_ FILES ["file1"])
To post a shell to phpinfo (), you can_FILES[“file1”]To see the uploaded temporary file, if there is an lfi, you can directly getshell.
7. some sensitive configurations
Allow_url_include, allow_url_fopen, disable_functions, open_basedir, short_open_tag, etc.
For example, allow_url_include can be used for remote file inclusion, disable_functions is used to view disabled functions, bypass execution, and check whether open_basedir is enabled. the method of bypassing open_basedir by p may be able to read directories with no permissions.
In addition, you can obtain some Environment information, such as path and log in Environment.
Summary
The above describes the details of valuable information that can be obtained from phpinfo. For more information, see other related articles in the first PHP community!