5432 - PostgreSQL
Usage
PostgreSQL stores metadata in tables beggining with pg_.
SELECT version();SELECT current_user;SELECT datname FROM pg_database;// Query only user-created tables (excluding `pg_` tables)
SELECT table_name FROM <database>.information_schema.tables WHERE table_schema='public';SELECT column_name, data_type FROM <database>.information_schema.columns WHERE table_name='<table>'We can connect via CLI with psql.
psql -h 127.0.0.1 -U postgres# Listing dbs
postgres=# \l
# Connecting to a db
postgres=# \c cozyhosting
# Listing tables
cozyhosting=# \dt
# Dumping data
cozyhosting=# select * from users;SQLi
Read/Write
COPY FROM-> insert data into a table from a file (the PostgreSQL process must havereadaccess to the file and the user making the query permissions to create a new table).
COPY TO-> copy data to a file from a table (the PostgreSQL process must havewritepermissions to the directory where the file will be created).
pg_read_file()-> instead of inserting the results into a table, it just returns a single field containing all the data (useful if the PostgreSQL process hasreadaccess on the file, but the user querying don't have permissions to create a new table).
RCE
PostgreSQL 9.3-11.7 has an authenticated RCE vulnerability (CVE-2019-9193) with an available PoC.
Last updated
Was this helpful?