A simple SQL Injection Attack

Source: Internet
Author: User

In the previous blog: http://blog.csdn.net/suwei19870312/article/details/7579667. This section describes the interaction between client code and server code.

The client code passes a parameter q to the server code user. php through the get method,

In the user. PHP code, use the parameter q to construct an SQL statement for accessing the database:

  1. $ SQL = "select * from user where id = '". $ Q ."'";
  2. $ Result = mysql_query ($ SQL );


If the parameter q = "'or '1' = '1" passed by the client at this time ",

In this case, the SQL statement becomes "select * from user where id ='' or '1' = '1 '"

In this case, all data in the User table is returned.

This is an example of a simple SQL injection attack.


Http://zh.wikipedia.org/wiki/ SQL %E8%B3%87%E6%96%99%E9%9A%B1%E7%A2%BC%E6%94%BB%E6%93%8A

Http://baike.baidu.com/view/983303.htm










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.