Lab9 SQL Injection - SQL Injection UNION Attacks
Lab9 SQL Injection - SQL Injection UNION Attacks
Objective:
- This lab focuses on exploring and understanding Union-Based SQL Injection attacks.
Participants will engage with a simulated web application that is vulnerable to SQL injection,
specifically through the misuse of the UNION SQL operator. The objective is to learn how to
identify, exploit, and subsequently defend against Union-Based SQL Injection vulnerabilities.
Union-Based SQLi: Uses to fetch data from different tables and display results in the
application's response.UNION SELECT
Error-Based SQLi: Extracts data by causing intentional database errors that reveal useful
information.
Boolean-Based SQLi: Uses true/false conditions to infer database structure without
directly seeing data.
Time-Based SQLi: Uses SQL functions like to measure response time, inferring data from
delays.SLEEP()
Blind SQLi: The attacker receives no direct output but determines data through indirect
responses.
o Explain the role of the UNION SQL operator in this type of attack and how it can be used
to extract data from a database that is not typically accessible through the intended use
of a web application.
Role of the UNION SQL Operator in Union-Based SQL Injection
The SQL operator is used in Union-Based SQL Injection to combine the results of
multiple queries into a single result set. Attackers exploit this feature to retrieve
unauthorized data from a database by injecting malicious SQL queries.UNIONSELECT
How UNION SQL Operator Works in SQL Injection`
1. Combining Two SELECT Statements:
The operator merges the output of two or more statements if they have the same
number of columns and compatible data types.UNIONSELECT
2. Bypassing Application Restrictions:
Many applications only allow certain data to be queried (e.g., customer details).
Using , an attacker can extract hidden tables like , , etc.UNIONusersadmin_credentials
Extracting Hidden Data with UNION-Based SQL Injection
1. Finding the Number of Columns
2. Identifying Data Types
3. Extracting Sensitive Data
Perform challenge:
o SQL injection UNION attack, determining the number of columns returned by the query
Explain and capture all steps (full windows screen capture).