Understand SQL Injection, a critical web security vulnerability that allows attackers to manipulate databases through malicious queries.
Learn how it works, see real-world examples, and discover effective prevention techniques to secure your website and protect user data.
Introduction to SQL: Definition
Structured Query Language | Management |
Database | Operations |
DBMS | Tables |
Rows | Columns |
Queries/Statement |
SQL Operations: Usage
Insert (Input) | Update (Modify) |
Retrieve (Fetch) | Delete (Remove) |
Filter (Need) | Sort (Arrange) |
Adding (Add) | Creating (New Table) |
Join (Integrate) |
Introduction to Parameters
Values | Store |
Variables | Manipulate |
Functionality | Unauthorized access |
Manipulating Parameters
Check | Fetch |
Interact | Database |
SQL Query |
Identifying Parameters
URL | User input |
?name=value | &name2=value |
Examples |
What is SQL Injection
Code Injection attack | Malicious SQL Query |
Steal | Sensitive Data |
Gain Access | Database |
Types of SQLi
In-Band | Inferential |
Out-of-Band |
In-Band SQLi
Results in the Application’s response
Error-Based: Inject SQL statement to produce |
Error. |
Union-Based: Inject SQL statement to produce |
Multiple results |
Blind Based SQLi or Inferential SQLi
Boolean-based Blind: Conditions |
Time-based Blind: Response time |
Out-of-Band SQLi
Export results | External system |
Mail Address | File |
Remote Server |
SQL Injection Methodology
Finding Parameters | Parameters Status |
Parameters Functions | Error Generation |
Error Resolving | Grabbing Banner and Database |
Practical SQL Injection
1: Open the XAMPP.
2: Start Apache and MySQL.
3: Open the DVWA.
Link: http://localhost/dvwa/
4: Practice the SQL Injection.
5: Open the Vulnweb testing website.
Website: http://testphp.vulnweb.com/login.php
6: Bypass the login and sign in to the website.
Username: admin’ or 1=1#
Password random: wali
7: Website login successful.
How to Hack a Website Using SQL Injection
1: Find the SQL injection-affected websites.
2: Use the Google Dork to find the SQL Injection-affected websites.
Browser: inurl: admin login.aspx
3: Try the SQL Injection syntax.
Syntax: ‘1’OR’1’=’1′
Syntax: 1’OR’1’=’1
4: You can use the Home of Acunetix Art website for testing this website is legal for Penetration testing and other Vulnerabilities.
Website: http://testphp.vulnweb.com/login.php
5: The website has been hacked.
What is SQL injection
1: Injection SQL Query.
2: Most common Web attack.
3: High severity level.
4: Can modify or delete the Database.
Types of SQLi:
1: SQLi:1: In-band SQLi 2: Inferential SQLi
- Error-based SQLi
- Union-based SQLi
1: Error-based SQLi:
1: Relies on error messages.
2: Thrown by the database server.
3: To obtain information.
4: About the structure of the database.
2: Union-based SQLi:
1: Leverages the UNION SQL operator.
2: To combine the results of two/more SELECT statements.
3: Which is returned as part of the HTTP response.
3: Inferential SQLi:
1: Also known as Blink SQLi.
2: Takes more time to take.
3: Boolean-based Blind SQLi.
4: Time-based Blind SQLi.
4: Boolean-based Blind SQLi:
1: Relies on sending an SQL query to the database.
2: Which forces the application to return a different result.
3: Depends on query types (True or False).
5: Time-based Blind SQLi:
1: Forces the database to wait for a specified time.
2: Response time will indicate the result of TRUE? FALASE query.
3: This attack is typically slow.
4: Since enumeration is done character by character.
SQLi Methodology:
1: Understand website works.
2: Search for parameters.
3: Try to generate an error and solve the generated error.
4: Accessing DB using tools.
SQL Injection tools:
1: SQLMAP
2: jSQL injection
3: BBQSQL
4: SQL Ninja