πŸ—ƒοΈDatabase Enumeration

MySQL Fingerprinting

We can try to find what database is been used with a couple of commands

SELECT @@version - Returns MySQL version if MySQL, error out if other DMBS

SELECT POW(1,1) - Returns 1 if MySQL, errors with other DBMS

SELECT SLEEP(5)- Delays page response by 5 seconds if MySQL, will not delay with other DBMS

INFORMATION_SCHEMA

Contains information about the DB and the tables present

SCHEMATA

We can find out the available databases on the DBMS using the INFORMATION_SCHEMA in our query, by selecting the SCHEMA_NAME column we can see all the database names present.

SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA;

Working UNION SQL Injection Example

cn' UNION select 1,schema_name,3,4 from INFORMATION_SCHEMA.SCHEMATA-- -

Let's say we found two other than the default DB's; dev and customers.

We can then find out which database the web app is currently running

TABLES

We can get a list of all the tables within the database with the below query.

COLUMNS

We can find the columns names of a particular table with the below query

Data

Once we have all the information we can form our UNION query to data, in this case, username and password in the dev database.

Last updated