File Inclusion Vulnerability Analysis for DVWA Series 14

Source: Internet
Author: User

File Inclusion Vulnerability Analysis for DVWA Series 14

Program developers usually write reusable functions into a single file. When using some functions, they call this file directly without writing it again, this process of calling a file is generally called inclusion. Developers all want code to be more flexible, so they usually set the contained files as variables for dynamic calls. However, this flexibility is precisely because of this, as a result, the client can call a malicious file, resulting in a File Inclusion Vulnerability.
PHP provides four file-contained functions, including include (), include_once (), require (), and require_once (). Their differences are as follows:
When require cannot find the contained file, a fatal error occurs and the script is stopped.
When the include file cannot be found, only warnings are generated and the script continues to run.
Include_once is similar to include. The only difference is that if the code in the file has been included, it will not be included again.
Require_once is similar to require. The only difference is that if the code in the file has been included, it will not be included again.
For example, in this example, 01.txt is a normal text file, but the file content is a code that conforms to the PHP syntax:

The 01.txt file is included in the 02.php file. The Code is as follows:

Put the two files in the D: \ AppServ \ wwwdirectory, and then upload 02.php in the browser. You can see that the code in 01.txt is correctly executed. The extension of the 02.txt file is changed to jpg, rar, doc, and xxx for testing. The phpinfo information can be correctly displayed. As long as the file content complies with PHP syntax specifications, any extension name can be parsed by PHP.

Create another test file 03.txt with the content "Hello, world !", It does not conform to the PHP syntax specification and can be found that such a file can directly display its content.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.