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 --dbs

SQLmap 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 --dump

SQLmap 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

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

Very Easy (2)

MachinePlatformOSTags
AppointmentSQLiAuthentication-BypassHTBLinuxSQLi, Authentication-Bypass
VaccineSQLiFTPSudoTar WildcardHTBLinuxSQLi, FTP, Sudo, Tar Wildcard

Easy (6)

MachinePlatformOSTags
Simple CTFSQLiCMS-Made-SimpleCVE-2019-9053Vim-SudoTHMLinuxSQLi, CMS-Made-Simple, CVE-2019-9053, Vim-Sudo
PC IppSecSQLigRPCPivotingPySqliteHTBLinuxSQLi, gRPC, Pivoting, PySqlite
Shoppy IppSecNoSQL-InjectionReverse-EngineeringHTBLinuxNoSQL-Injection, Reverse-Engineering
Soccer IppSecBlind SQLiWebSocketsDstatDoasHTBLinuxBlind SQLi, WebSockets, Dstat, Doas
Stocker IppSecNoSQL-InjectionServer-Side XSSNodeJSSSRFHTBLinuxNoSQL-Injection, Server-Side XSS, NodeJS, SSRF
Usage IppSecBlind SQLi7-Zip SymlinkHTBLinuxBlind SQLi, 7-Zip Symlink

Medium (9)

MachinePlatformOSTags
Cache IppSecSQLiMemcachedHTBLinuxSQLi, Memcached
Clicker IppSecSQLiNFSMass AssignmentCronHTBLinuxSQLi, NFS, Mass Assignment, Cron
Cronos IppSecSQLiCommand-InjectionExploiting-cron-jobsHTBLinuxSQLi, Command-Injection, Exploiting-cron-jobs
Game ZoneSQLiSSH-TunnelingWebminTHMLinuxSQLi, SSH-Tunneling, Webmin
Magic IppSecSQLiPath-HijackingSUIDHTBLinuxSQLi, Path-Hijacking, SUID
Mango IppSecNoSQL-InjectionGTFOBinsHTBLinuxNoSQL-Injection, GTFOBins
Monitored IppSecSQLiNagios-XI-CVE-2023-40931CactiSUIDHTBLinuxSQLi, Nagios-XI-CVE-2023-40931, Cacti, SUID
Sneaky IppSecSQLiBuffer-OverflowSNMPSUIDHTBLinuxSQLi, Buffer-Overflow, SNMP, SUID
ZippingSQLiZip-SymlinkLFIShared-Library-HijackHTBLinuxSQLi, Zip-Symlink, LFI, Shared-Library-Hijack

Hard (7)

MachinePlatformOSTags
Breadcrumbs IppSecSQLiForging-PHP-sessionsHTBWindowsSQLi, Forging-PHP-sessions
Control IppSecSQLiCVE-2019-11043Password-CrackingHTBWindowsSQLi, CVE-2019-11043, Password-Cracking
Daily BugleSQLiJoomlaCVE-2019-8942Yum SudoersTHMLinuxSQLi, Joomla, CVE-2019-8942, Yum Sudoers
EnterpriseSQLiActive DirectoryZeroLogonKerberosTHMWindowsSQLi, Active Directory, ZeroLogon, Kerberos
OverGraphNoSQL-InjectionCSRF-attacksFFmpegXSSHTBLinuxNoSQL-Injection, CSRF-attacks, FFmpeg, XSS
Scavenger IppSecSQLiReversing-RootkitsHTBLinuxSQLi, Reversing-Rootkits
Year of the DogSQLiGiteaCommand-InjectionTHMLinuxSQLi, Gitea, Command-Injection

Insane (3)

MachinePlatformOSTags
Bankrobber IppSecFile-read-through-SQLiBuffer-OverflowCommand-InjectionHTBWindowsFile-read-through-SQLi, Buffer-Overflow, Command-Injection
Fatty IppSecSQLiDeserializationDirectory-TraversalThick-Client-PentestingHTBLinuxSQLi, Deserialization, Directory-Traversal, Thick-Client-Pentesting
Multimaster IppSecSQLiCVE-2020-1472Password-CrackingVS-CodeHTBWindowsSQLi, CVE-2020-1472, Password-Cracking, VS-Code

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.