Skip to main content
Database services are common targets during pentests. Each DBMS has unique features that can be abused for privilege escalation and code execution.

MySQL (Port 3306)

Connection

Enumeration

MySQL Permissions

MySQL INTO OUTFILE → Python .pth RCE

MySQL UDF (User Defined Function) RCE

Rogue MySQL Server Attack

When JDBC clients connect to attacker-controlled MySQL server with allowLoadLocalInfile=true:

Extracting Credentials


Microsoft SQL Server (Port 1433)

Connection

Enumeration

OS Command Execution via xp_cmdshell

Steal NetNTLM Hash

Privilege Escalation: db_owner to sysadmin

User Impersonation

Write Files

User Enumeration via RID Brute Force


PostgreSQL (Port 5432)

Connection

Enumeration

File Read

COPY TO PROGRAM (RCE)

File Write

Privilege Escalation: CREATEROLE

PostgreSQL Configuration File RCE

Dumping Hashes and Credentials

Privilege Escalation: Overwrite pg_authid

If you can read and write files, overwrite the pg_authid table filenode to become superuser:

Quick Reference: Nmap Commands