Penetration test_ SQL Injection

Source: Internet
Author: User

1. SQL Injection Detection
(1) The tester needs to list the input fields for SQL query, including the hidden fields in the POST request. Test them one by one and try to use the query to interfere with them and generate errors.
(2) A single quotation mark (') or a semicolon (;) is usually added to the test field (;). Single quotes are used as a string terminator in SQL. If the application does not filter it, it will cause incorrect queries. A semicolon is used to terminate an SQL statement. If it is not filtered out, it can also produce errors.

2. Conventional SQL injection testing
(1) For the query statement select * from users where username = '$ username' and Password =' $ password', use
$ Username = 1 'or '1' = '1
$ Password = 1 'or '1' = '1
(2) For the following query: Select * from users where (username = '$ username') and (Password = MD5 (' $ password'), use
$ Username = 1 'or '1' = '1 '))/*
$ Password = foo

3. Union Query
For the query statement select name, phone, address from users where id = $ id, Set ID: $ id = 1 Union all select creditcardnumber, 1, 1 from creditcartable.
This will be added to the original query results with all credit card users. Keyword all is required for queries that use distinct keywords. To avoid syntax errors, Union queries must have the same number of parameters as the preceding query.

4. SQL blind Injection
(1) confirm the correct and wrong response page for the query (error query: Select field1, field2, field3 from users where id = '1' and '1' = '2 ')
(2) sequential inference query (select field1, field2, field3 from users where id = '1' and ASCII (substring (username, 1, 1 )) = 97 and '1' = '1 ')
(3) If true is returned after comparison with ASCII code 0, execute the query: Select field1, field2, field3 from users where id = 'name' and length (username) = N and '1' = '1' (name is the string previously deduced). If true is returned, the query is completed. Otherwise, the string to be queried contains null characters, continue to launch until the next null character.

5. Stored Procedure Injection
(1) If improperly handled, dynamic SQL statements in storage programs can be as vulnerable to attacks as dynamic SQL statements on webpages.
(2) If you cannot bypass logon or return query results, you can inject update and delete operations to modify the database.

Reference: OWASP test Guide

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.