OSWA · Module 8
SQL Injection
Exploit SQL injection via UNION, error-based, blind, and stacked queries; automate with sqlmap; escalate to file read and RCE; plus NoSQL injection.
~3 h 9 resources Last updated September 26, 2026
With an injectable parameter confirmed, exploitation extracts data, escalates to code execution, and ultimately reaches the admin session and proof the OSWA exam requires. The technique you choose depends on how the application responds: UNION when results are reflected, error-based when the database leaks errors, and blind (boolean or time-based) when there is no visible output at all. Beyond data theft, stacked queries and database-specific features turn SQL injection into remote command execution.
Manual Exploitation Techniques
UNION-based injection appends attacker-controlled rows to the result set to dump metadata, tables, and credentials. Error-based extraction abuses functions that leak data inside error messages. Blind injection extracts data one bit at a time through boolean or time-based inference. Stacked queries run entirely separate statements, enabling data modification and, on some engines, command execution. Second-order injection fires when stored input is later used unsafely in a different query.
Automation, Exfiltration, and RCE
sqlmap (permitted on the OSWA exam) automates detection, extraction, file operations, and OS shells, especially when driven from a saved Burp request with tamper scripts. Beyond dumping credentials and hashes, SQL injection can read files (LOAD_FILE, pg_read_file, OPENROWSET) and escalate to RCE: MySQL FILE web shells, MSSQL xp_cmdshell, and PostgreSQL COPY TO PROGRAM.
NoSQL Injection
Applications backed by MongoDB and similar stores are vulnerable to NoSQL injection: operator injection for authentication bypass, boolean and time-based extraction, and $where JavaScript injection. JSON APIs are a common entry point, with their own WAF bypass and encoding considerations.
Read
The core material for this module. Where a guide goes deeper than needed, the relevant sections are highlighted.
-
Guide 3 min readSQL Injection Exploitation
-
Guide 7 min readUnion-Based SQL Injection Exploitation
-
Guide 5 min readStacked Queries SQLi
Practice
Apply the module hands-on.
- PortSwigger Web Security Academy - NoSQL injection PortSwigger Mixed
- PortSwigger Web Security Academy - SQL injection PortSwigger Mixed
- Hawat Proving Grounds Easy
- Kioptrix Level 2 Vulnhub Easy
- NodeBlog HackTheBox Easy
- Pentester Lab: From SQL injection to Shell Vulnhub Easy
- Shoppy HackTheBox Easy
- Soccer HackTheBox Easy
- Stocker HackTheBox Easy
- Trick HackTheBox Easy
- Usage HackTheBox Easy
- Validation HackTheBox Easy
- Writeup HackTheBox Easy
- Cockpit Proving Grounds Intermediate
- DC-9 Vulnhub Intermediate
- PC Proving Grounds Intermediate
- Jarvis HackTheBox Medium
- Mango HackTheBox Medium
- Union HackTheBox Medium
- Writer HackTheBox Medium
- Zipping HackTheBox Medium
- Falafel HackTheBox Hard
- Intentions HackTheBox Hard