Databases — Hub

OSCP Database Ports at a Glance

PortServicePrimary ToolNote
1433MSSQLMSSQL (impacket-mssqlclient)xp_cmdshell → RCE
1521OracleOracle (sqlplus, odat)SID brute first
3306MySQL / MariaDBMySQL (mysql)Blank root common
5432PostgreSQLPostgreSQL (psql)COPY FROM PROGRAM → RCE
6379RedisRedis (redis-cli)Often no auth
27017MongoDBMongoDB (mongosh)Often no auth (old installs)
(file)SQLiteSQLite (sqlite3).db / .sqlite files — no network port

OSCP workflow: See open DB port → try default/blank creds → enumerate with client tool → look for file read/write or OS command execution paths.

Install all DB clients: Installation - Kali Setup > 📌 Databases · mysqldumpMySQL > 📌 10) mysqldump — backup / exfiltrate databases


📌 Quick Enumeration Flow

1. Nmap version + scripts
   nmap -p PORT -sV --script *-info,*-brute,*-empty-password TARGET

2. Try default credentials
   root / blank, sa / blank, postgres / postgres, redis / no auth

3. Connect with native client
   mysql, psql, impacket-mssqlclient, redis-cli, mongosh

4. Enumerate
   - List databases / schemas
   - List tables / collections
   - Dump credential tables (users, admin, config)
   - Check privileges (FILE, sysadmin, superuser)

5. Escalate
   - MySQL: LOAD_FILE / INTO OUTFILE
   - MSSQL: xp_cmdshell
   - PostgreSQL: COPY FROM PROGRAM
   - Redis: SSH key / cron write
   - MongoDB: dump creds, check for admin users
   - SQLite: find `.db` files → sqlite3 → dump tables (no network port)

📌 Default Credentials to Try

Full list + lab log → Default Credentials

DatabaseUsernamePassword
MySQLroot(blank), root, password, mysql
MSSQLsa(blank), Password123, sa
PostgreSQLpostgrespostgres, (blank)
Redis(no auth — very common)
MongoDB(no auth on old versions)
OracleSCOTTTIGER
OracleSYSCHANGE_ON_INSTALL

📌 Brute Force (All DBs)

# MySQL
hydra -l root -P /usr/share/wordlists/rockyou.txt TARGET mysql
 
# MSSQL
hydra -L users.txt -P passwords.txt TARGET mssql
medusa -h TARGET -U users.txt -P passwords.txt -M mssql
 
# Connect — domain user needs -windows-auth
impacket-mssqlclient DOMAIN/user:pass@TARGET -windows-auth
impacket-mssqlclient oscp.exam/sql_svc:Dolphin1@TARGET -windows-auth
 
# PostgreSQL
hydra -l postgres -P /usr/share/wordlists/rockyou.txt TARGET postgres
 
# CrackMapExec (MSSQL)
crackmapexec mssql TARGET -u sa -p passwords.txt --local-auth
crackmapexec mssql TARGET -d corp.local -u svc_sql -p 'CrackedPassword'

📌 Sub-Notes (This Folder)

NoteCovers
MySQLmysql client — connect, flags, enumeration, LOAD_FILE, INTO OUTFILE
MSSQLimpacket-mssqlclient, sqsh — connect, xp_cmdshell, linked servers
mysqldump - Windows XAMPP Database ExfiltrationWindows/XAMPP mysqldump.exe — dump DB to .sql, grep creds
PowerUpSQLPowerShell MSSQL discovery + Invoke-SQLOSCmd (Windows shell)
PostgreSQLpsql — connect, enumeration, COPY FROM PROGRAM RCE
Redisredis-cli — connect, enumeration, SSH key / cron RCE
MongoDBmongosh — connect, dump collections, no-auth enumeration
Oraclesqlplus, odat — SID brute, default creds, OS command execution
SQLitesqlite3 — file-based .db enum, dump tables, SQLMap --dbms=sqlite

📌 SQL Injection → Database Access

If you find SQLi on a web app, the database type often maps to these ports:

SQLi fingerprintLikely DBSee
@@version, SLEEP()MySQLMySQL, SQL Injection
@@SERVERNAME, WAITFOR DELAYMSSQLMSSQL, SQL Injection
pg_sleep(), version()PostgreSQLPostgreSQL, SQL Injection
FROM dualOracleOracle, SQL Injection
sqlite_version()SQLiteSQLite, SQL Injection