Php injection prevention

Source: Internet
Author: User
Tags define function

The submitted parameters are not filtered or the filtering is not rigorous. The Hacker defense line has always been attacked. Here, let's take a rough look at the preventive methods.

First of all, I personally think the most important thing is to set magic_quotes_gpc to ON. It is used to convert single quotes, double quotation marks, backslash, and empty characters into characters containing backslash, for example, In the select * from admin where username = '$ username' and password =' $ password' statement, an attacker wants to skip verification with either 1 or 1 = '1. However, the strings will be converted into the following: select * from admin where username = 'A' and password = '1 \ 'or 1 = \ '1' to prevent injection, the fact is that the addslashes () operation is automatically performed. if not, define function processing. now it seems that the PHP injection users are also quite depressed, because mysql versions earlier than myslq4 do not support substatements, and the new version of mysql will enable the magic_quotes_gpc option by default.

The solution to the file inclusion vulnerability is to require programmers to avoid using variables for parameters in the file. If variables are used, they must strictly check the file name to be included, it cannot be specified by any user. We recommend that you set global_variables to off. For example, it is necessary to restrict the PHP operation path in the preceding file. In addition, you must disable the PHP Remote File opening function unless otherwise required. Modify the php. ini file: allow_url_fopen = Off (Note: See ).

Another point I think many websites will have this problem, that is, there is no error display. there may be nothing to look at, but some people who have been staring for a long time (the words are a bit wrong) can get information such as database information and the physical path of web files through error prompts.

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.