SQL Injection: practice machines and key commands
By Daniel Dayan ยท Updated
SQL injection happens when user input is concatenated into a query, letting you change its logic. Test every parameter, header and cookie with a single quote, a comment sequence and boolean conditions, and watch for errors, timing differences or changed content. Depending on the result you can use UNION queries to read other tables, boolean or time based blind techniques, or stacked queries on some engines. Authentication bypasses and credential dumps are the common wins, and on MSSQL or MySQL with the right privileges you may reach file writes or command execution. sqlmap automates the work, but understand the manual payload first so you can fix it when filters or WAFs get in the way. Save the HTTP request to a file and let sqlmap reuse it. NoSQL variants use operators like $ne instead of quotes. The machines below feature injection as the foothold.
Key commands
Placeholders in braces, such as {TARGET_IP}, are values you fill in for your target.
SQLmap Automated Injection & Database Dump
Batch automated SQL injection extraction with risk and level escalation.
sqlmap -u "http://{TARGET_IP}/item.php?id=1" --batch --random-agent --level=3 --risk=2 --dbsSQLmap Target Saved HTTP Request File
Pass raw saved Burp Suite POST request file to extract DB tables.
sqlmap -r request.txt -p username --batch --current-db --dumpSQLmap Heavy Injection Probe (Risk 3 / Level 5)
High-potency SQL injection test checking all HTTP headers, cookies, and injection boundaries.
sqlmap -u "http://{TARGET_IP}/page?id=1" --batch --risk=3 --level=5 --threads=4 --dbs
Keep going
- Methodology: Phase 04: Foothold Execution & Initial Access
- Cheatsheet: Web & Directory Fuzzing
- Cheatsheet: Exploitation & Payloads
SQL Injection machines (27)
3 of these are machines I solved myself and are listed first within each difficulty. 22 Linux, 5 Windows.
Listed when a machine has a catalog tag that is one of: sql, sqli, sql injection, basic sql injection, nosql injection, sqlmap; or a tag that contains the word sqli. Capital letters, hyphens and underscores are ignored, and the tags that matched come first in each row.
SQL Injection at a glance
- By platform: 22 Hack The Box, 5 TryHackMe.
- On these practice lists: CWEE (16), OSCP (10), CPTS (7), Unofficial IppSec CPTS (6), OSEP (3), HTB Active Directory (2).
- Tags that most often appear alongside it: Command-Injection (3), SUID (3), Buffer-Overflow (2), GTFOBins (2), Password-Cracking (2).
- Solved by me, with a page here: Appointment (Linux Very Easy), Vaccine (Linux Very Easy), Simple CTF (Linux Easy).
Very Easy (2)
| Machine | Platform | OS |
|---|---|---|
| Appointment | HTB | Linux |
| Vaccine | HTB | Linux |
Easy (6)
| Machine | Platform | OS |
|---|---|---|
| Simple CTF | THM | Linux |
| PC IppSec | HTB | Linux |
| Shoppy IppSec | HTB | Linux |
| Soccer IppSec | HTB | Linux |
| Stocker IppSec | HTB | Linux |
| Usage IppSec | HTB | Linux |
Medium (9)
| Machine | Platform | OS |
|---|---|---|
| Cache IppSec | HTB | Linux |
| Clicker IppSec | HTB | Linux |
| Cronos IppSec | HTB | Linux |
| Game Zone | THM | Linux |
| Magic IppSec | HTB | Linux |
| Mango IppSec | HTB | Linux |
| Monitored IppSec | HTB | Linux |
| Sneaky IppSec | HTB | Linux |
| Zipping | HTB | Linux |
Hard (7)
| Machine | Platform | OS |
|---|---|---|
| Breadcrumbs IppSec | HTB | Windows |
| Control IppSec | HTB | Windows |
| Daily Bugle | THM | Linux |
| Enterprise | THM | Windows |
| OverGraph | HTB | Linux |
| Scavenger IppSec | HTB | Linux |
| Year of the Dog | THM | Linux |
Insane (3)
| Machine | Platform | OS |
|---|---|---|
| Bankrobber IppSec | HTB | Windows |
| Fatty IppSec | HTB | Linux |
| Multimaster IppSec | HTB | Windows |
Related techniques
Related guides: TJ Null OSCP list, OSCP exam scoring and time budget, OSCP vs CPTS, OSCP report template.
Practise it, then track it.
Log every box and the commands you used in ZeroBox.