Face-to-Face SQL injection attacks

Source: Internet
Author: User

SQL injection attacksAn attacker inserts SQL commands into the input field of a web form or the query string requested by the page, deceiving the server to execute malicious SQL commands. In some forms, the content entered by users is directly used to construct (or affect) dynamic SQL commands or as input parameters of stored procedures. Such forms are particularly vulnerable to SQL injection attacks.

This is Baidu encyclopedia's explanation. How can this problem be solved? But it doesn't matter. Let me try. Can you wake up.

As the name implies: SQL injection attacks must be a matter of SQL statements. So let's look at an SQL statement:

Select * From tabel1 where user_name = '"& txtuser_name.text &"'

This is a commonly used SQL statement. Some people may think, what is the problem with such a simple sentence? Don't worry, and listen to me carefully.

Your intention is to let some people with the corresponding permissions to operate the program, they will know the login user name, to verify. However, have you ever wondered if I entered in the txtuser_name input box"
"&" 'Or' "&" 1 = 1"

Look, the originalSQL statement:

Select * From tabel1 where user_name = '"& txtuser_name.text &"'

Now it becomes:

Select * From tabel1 where user_name = '"&" "&"' or '"&" 1 = 1 "&"'


At this time, I believe all the discerning people can see it,The following part or proposition:
Or 1 = 1 is inevitable
So, the login program is successful!

Yes, this is an SQL injection attack.Attackers try to input some special SQL strings to tamper with the query and change its original functions, deceiving the system to grant access permissions.

So far, do you feel that hackers are actually doing this...

So, since SQL injection has such a big hazard, how can we prevent SQL injection?

This document briefly introduces these methods, which can be selected by the user.

  1. Never trust users' input. Validate user input. You can use regular expressions or limit the length. Convert single quotes and double.

2. Never use dynamic assembled SQL statements. You can use parameterized SQL statements or directly use stored procedures for data query and access.

3. Never use a database connection with administrator permissions. Use a database connection with limited permissions for each application.

4. Do not store confidential information directly, encrypt or hash passwords and sensitive information.

5. The application exception information should be given as few prompts as possible. It is best to use custom error information to wrap the original error information.

6. the SQL Injection detection method generally uses auxiliary software or website platform for testing. The software generally uses the SQL Injection detection tool jsky, and the website platform has the Yis website security platform detection tool. Mdcsoft
Scan. Using MDCSOFT-IPS can effectively defend against SQL injection, XSS attacks, etc.

Face-to-Face SQL injection attacks make your programs safer and users feel more comfortable using them!

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.