PostgreSQL
PostgreSQL injection
PostgreSQL Comments
--
/**/ PostgreSQL Version
SELECT version()PostgreSQL Current User
SELECT user;
SELECT current_user;
SELECT session_user;
SELECT usename FROM pg_user;
SELECT getpgusername();PostgreSQL List Users
PostgreSQL List Password Hashes
PostgreSQL List Database Administrator Accounts
PostgreSQL List Privileges
PostgreSQL Check if Current User is Superuser
PostgreSQL Database Name
PostgreSQL List Database
PostgreSQL List Tables
PostgreSQL List Columns
PostgreSQL Error Based
PostgreSQL XML helpers
The query_to_xml above returns all the results of the specified query as a single result. Chain this with the PostgreSQL Error Based technique to exfiltrate data without having to worry about LIMITing your query to one result.
Note, with the above queries, the output needs to be assembled in memory. For larger databases, this might cause a slow down or denial of service condition.
PostgreSQL Blind
PostgreSQL Time Based
PostgreSQL Stacked Query
Use a semi-colon ";" to add another query
PostgreSQL File Read
NOTE: Earlier versions of Postgres did not accept absolute paths in pg_read_file or pg_ls_dir. Newer versions (as of this commit) will allow reading any file/filepath for super users or users in the default_role_read_server_files group.
PostgreSQL File Write
Or as one line:
PostgreSQL Command execution
CVE-2019–9193
Can be used from Metasploit if you have a direct access to the database, otherwise you need to execute manually the following SQL queries.
Using libc.so.6
Bypass Filter
Quotes
Using CHR
Using Dollar-signs ( >= version 8 PostgreSQL)
References
Last updated
Was this helpful?