Php Basics, common vulnerabilities, and simple prevention.

Source: Internet
Author: User
Tags php basics
Php Basics, common vulnerabilities, and simple prevention. Common php attacks and security defense:

1. Xss + SQL injection:

Xss protection for input:

$ _ REQUEST = filter_xss ($ _ REQUEST); $ _ GET = filter_xss ($ _ GET); $ _ POST, $ _ COOKIE,

SQL injection:

Filter_ SQL ();

The simplest xss function is htmlspecialchars;

The simplest SQL function is mysql_real_escape_string ();

2. command execution

Php code execution, if eval

Execute the shell command exec

File processing, fopen, fwirte, etc.

3. Upload vulnerability

The most secure method is random naming and the filename suffix whitelist. generally, do not grant execution permissions.

4. file inclusion functions

For example, include_once, require (), require_once (), and some vulnerabilities such as down. php? File =/.../. etc/passwd, directly download the server configuration file.

5. permission bypass

A. unauthorized access to background files. The most common is the session verification code.

B. for user isolation, for example, mail. php? Id = 23 shows your letter, so id = 24 can view others' letters.

6. information leakage

Such vulnerabilities are relatively low, such as file path exposure and source code exposure.

Generally, the error message "error_reporting (0);" is disabled and stored in a public configuration file.

Of course, there are also many vulnerabilities, such as cookie forgery and cross-origin.

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.