They can be used to combine of output of two SELECT statements This method only works if the number of columns in both the statements are the same
In place of numbers we can use SQL functions
Finding Number of Columns
Brute Force Approach
We can try different number of columns till we find the result that works union select 1# (Error) union select 1,2# (Error)
ORBER BY Clause
We cause the query ORBER BY 20#
and see if we get error if so there are less an 20 columns
Then we try 10. If no error which means there are either exactly 10 or more than 10 columns
No we can try values between 10 and 20 till be find the no. of columns
NOTE
Not all columns from the DB are going to be present in output. Only the fields that are fetched from the DB can be used for fetching information
Finding Tables Names and Column Values
View DB Names
The “schema_name” column consist of the DB names
So we can used “schema_name” to find all the DB
View Table Names in DB
The “table_name” column consist of the table name
Now we can view all the tables in the DB using the following
The group_concat()
function will show all the results as an single string
Table Column Names
The “column_name” filed consist of the column names of the table
The columns of the table can be viewed as follows
View Data from Columns
Reading and Writing Files to Server
Reading Data from File
Load File can be used to load files on Server
Writing Data to File
Outfile command can be used to write data to a file on the server
For reading and writing to the server we need to have the right permissions so only works if the permissions are miss configured