PHP File Inclusion Vulnerability Solution

Source: Internet
Author: User

Nowadays, the program code is getting more and more strange. You can write two types of code in one file: require include.
 
First, use require to terminate the output if an error occurs, and use include to continue execution if an error occurs.
 
If the administrator of a website is written in auth. php and auth. php is maliciously deleted, there is no vulnerability if require is used.
 
If include is used, the vulnerability is generated. Why? This is because the Include operation will continue when an error occurs, so that the user password is blank and the system enters the background.
 
If a website returns a link-based index. php? Act = view & file = gonggao. php
 
The code is
If ($ act = "view "){

$ File = $ _ GET ["file"];

Include $ file;

}
 
At first glance, there was no problem. After a closer look, the problem came out.
 
$ File has a Inclusion Vulnerability
 
If this Website Supports portrait upload or file upload
 
Cooperate with this vulnerability
 
You can obtain the WEBSHELL of the website.
 
 
 
 
 
Solution:


1. The most fundamental thing is that you do not need to pass the include parameter, and the configuration file can be require as much as possible.
 

Related Article

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.