SQLi
SQLi Methodology
SQL Injection Cheat Sheet
MySQL/MariaDB
1. Error-Based Tests
' OR 1=1-- -
' AND 1=2 UNION SELECT NULL-- -2. Sort Columns (Find Maximum Column Count)
' ORDER BY 1-- -
' ORDER BY 2-- -
' ORDER BY 3-- -' UNION SELECT NULL-- -
' UNION SELECT NULL,NULL-- -
' UNION SELECT NULL,NULL,NULL-- -3. Find Version
4. Find Database Name
5. Find Current User
6. Find Databases
7. Find Tables from Database
8. Find Columns from Table
9. Dump Data
PostgreSQL
1. Error-Based Tests
2. Sort Columns (Find Maximum Column Count)
3. Find Version
4. Find Database Name
5. Find Current User
6. Find Databases
7. Find Tables from Database
8. Find Columns from Table
9. Dump Data
Microsoft SQL Server (MSSQL)
1. Error-Based Tests
2. Sort Columns (Find Maximum Column Count)
3. Find Version
4. Find Database Name
5. Find Current User
6. Find Databases
7. Find Tables from Database
8. Find Columns from Table
9. Dump Data
Oracle
1. Error-Based Tests
2. Sort Columns (Find Maximum Column Count)
3. Find Version
4. Find Database Name
5. Find Current User
6. Find Databases/Schemas
7. Find Tables from Schema
8. Find Columns from Table
9. Dump Data
SQLite
1. Error-Based Tests
2. Sort Columns (Find Maximum Column Count)
3. Find Version
4. Find Database Name
5. Find Current User
6. Find Databases
7. Find Tables
8. Find Columns from Table
9. Dump Data
Quick Reference Guide
Comment Styles by Database
Database
Comment Syntax
String Concatenation by Database
Database
Concatenation Operator
Important Notes
1) Confirmation of a potential SQLi
2) Find the number of columns in the table
3) Find DB Version
4) Find Databases
5) Find tables names (DB=Users)
6) Find the columns name of a table (Table=User)
7) Dump data (group_concat(username,β | β,password))
8) Create wordlists for credential stuffing attacks
1) File write
2) Execute payload on webserver
Various triggers for SQLi
1) Single Quote
2) Double Quote
Blind SQLi
Login Bypass
SQL Truncation
Stored Procedures
1) Open SQL Server Management Studio, connect to the database, then go to:
2) Find interesting stored procedures and press:
3) If you find anything interesting, open Visual Studio and load the entire solution of the web app.
4) Try to find where the Stored Procedure is called within the code.
5) Check which function is located, check variables, and where it is called by clicking on:
6) Try to reproduce the vulnerability.
Blind SQL Injection Payloads
1) Manual Exploitation
2) Python Code Snippets
Automated
1) SQLmap
Last updated