Database Service Attack Methodology
Databases are the core pivot of internal network penetration — almost every application has a database backend, and databases usually have operating-system-level capabilities.
⛔ Further Reading (Must Read)
- Redis attacks (unauthorized access/file write/master-slave replication RCE) → references/redis-attack.md
- MSSQL attacks (xp_cmdshell/CLR/privilege escalation) → references/mssql-attack.md
- PostgreSQL attacks (command execution/file read-write/privilege escalation) → references/postgresql-attack.md
Phase 1: Database Identification
| Port |
Service |
Attack priority |
| 6379 |
Redis |
⭐⭐⭐ High probability of unauthorized access |
| 1433 |
MSSQL |
⭐⭐⭐ xp_cmdshell gives direct RCE |
| 5432 |
PostgreSQL |
⭐⭐ Strong command execution capability |
| 3306 |
MySQL |
⭐⭐ UDF privilege escalation |
| 27017 |
MongoDB |
⭐⭐ High probability of unauthorized access |
| 1521 |
Oracle |
⭐ Complex to exploit |
Phase 2: Generic Attack Workflow
Database port discovered?
├─ 1. Try unauthorized access (empty password/anonymous)
├─ 2. Weak credential brute-force (default accounts + top100)
├─ 3. Known vulnerability exploitation
├─ 4. Once inside the database:
│ ├─ Search for sensitive data (user tables/config tables/flag)
│ ├─ Try command execution
│ └─ Try file read/write
└─ 5. Operating system privilege escalation
Phase 3: Quick Unauthorized Access Detection
# Redis
redis-cli -h TARGET ping
# Returns PONG → unauthorized access
# MSSQL (default sa account)
netexec mssql TARGET -u sa -p '' --local-auth
netexec mssql TARGET -u sa -p 'sa' --local-auth
# PostgreSQL
psql -h TARGET -U postgres -w
# Empty password test
# MySQL
mysql -h TARGET -u root --skip-password
# MongoDB
mongosh --host TARGET --eval "db.adminCommand('listDatabases')"
Phase 4: Weak Credential Brute-Force
# Generic brute-force (netexec supports multiple protocols)
netexec mssql TARGET -u userlist.txt -p passlist.txt --local-auth
netexec ssh TARGET -u userlist.txt -p passlist.txt
# Common default accounts
# Redis: no authentication / requirepass is often a weak password
# MSSQL: sa / sa, sa / empty, sa / 123456
# PostgreSQL: postgres / postgres, postgres / empty
# MySQL: root / root, root / empty, root / 123456
# MongoDB: admin / admin, no authentication
Redis Quick Reference (most common)
# Unauthorized connection
redis-cli -h TARGET
# Information gathering
INFO server
CONFIG GET dir
CONFIG GET dbfilename
Redis key exploitation paths:
- Write a webshell / SSH key / Crontab
- Master-slave replication RCE
- Lua sandbox escape
→ Details on password brute-forcing / Cluster / Sentinel → references/redis-attack.md
MSSQL Quick Reference
# Connection
impacket-mssqlclient DOMAIN/sa:PASSWORD@TARGET -windows-auth
MSSQL key exploitation paths:
- xp_cmdshell / OLE / Agent Job RCE
- CLR assembly attacks
- File read/write
- NTLM hash theft
→ Information gathering / privilege escalation methodology → references/mssql-attack.md
MySQL Quick Reference
MySQL key exploitation paths:
- UDF privilege escalation / file read-write
1---2name: database-tactics3description: "Attacking database services methodology. Use when database ports such as Redis(6379), MSSQL(1433), PostgreSQL(5432), MySQL(3306), or MongoDB(27017) are discovered. Covers unauthorized access, weak credential brute-forcing, command execution, file read/write, and privilege escalation. Should be used for any scenario involving database attacks, database privilege escalation, or database exploitation"4zh-signals: "面向数据库服务的攻击方法论,覆盖 Redis、MSSQL、PostgreSQL、MySQL、MongoDB 的未授权、爆破与提权。信号:数据库攻击,Redis,MSSQL,PostgreSQL,提权"5when-to-use: "Use when database ports such as 6379, 1433, 5432, 3306, or 27017 are discovered and you need to test unauthorized access, weak credentials, command execution, file read/write, or privilege escalation."6metadata:7 source: https://skillmd.com/skills/dangeroussong/database-tactics8 tags: "database,redis,mssql,postgresql,mysql,mongodb,unauthorized-access,command-execution,privilege-escalation,6379,1433,5432,3306"9 category: "postexploit"10---1112# Database Service Attack Methodology13- 攻击大类:C09 Web应用漏洞利用1415Databases are the core pivot of internal network penetration — almost every application has a database backend, and databases usually have operating-system-level capabilities.1617## ⛔ Further Reading (Must Read)1819- Redis attacks (unauthorized access/file write/master-slave replication RCE) → [references/redis-attack.md](references/redis-attack.md)20- MSSQL attacks (xp_cmdshell/CLR/privilege escalation) → [references/mssql-attack.md](references/mssql-attack.md)21- PostgreSQL attacks (command execution/file read-write/privilege escalation) → [references/postgresql-attack.md](references/postgresql-attack.md)2223---2425## Phase 1: Database Identification2627| Port | Service | Attack priority |28|------|------|-----------|29| 6379 | Redis | ⭐⭐⭐ High probability of unauthorized access |30| 1433 | MSSQL | ⭐⭐⭐ xp_cmdshell gives direct RCE |31| 5432 | PostgreSQL | ⭐⭐ Strong command execution capability |32| 3306 | MySQL | ⭐⭐ UDF privilege escalation |33| 27017 | MongoDB | ⭐⭐ High probability of unauthorized access |34| 1521 | Oracle | ⭐ Complex to exploit |3536## Phase 2: Generic Attack Workflow3738```39Database port discovered?40├─ 1. Try unauthorized access (empty password/anonymous)41├─ 2. Weak credential brute-force (default accounts + top100)42├─ 3. Known vulnerability exploitation43├─ 4. Once inside the database:44│ ├─ Search for sensitive data (user tables/config tables/flag)45│ ├─ Try command execution46│ └─ Try file read/write47└─ 5. Operating system privilege escalation48```4950## Phase 3: Quick Unauthorized Access Detection5152```bash53# Redis54redis-cli -h TARGET ping55# Returns PONG → unauthorized access5657# MSSQL (default sa account)58netexec mssql TARGET -u sa -p '' --local-auth59netexec mssql TARGET -u sa -p 'sa' --local-auth6061# PostgreSQL62psql -h TARGET -U postgres -w63# Empty password test6465# MySQL66mysql -h TARGET -u root --skip-password6768# MongoDB69mongosh --host TARGET --eval "db.adminCommand('listDatabases')"70```7172## Phase 4: Weak Credential Brute-Force7374```bash75# Generic brute-force (netexec supports multiple protocols)76netexec mssql TARGET -u userlist.txt -p passlist.txt --local-auth77netexec ssh TARGET -u userlist.txt -p passlist.txt7879# Common default accounts80# Redis: no authentication / requirepass is often a weak password81# MSSQL: sa / sa, sa / empty, sa / 12345682# PostgreSQL: postgres / postgres, postgres / empty83# MySQL: root / root, root / empty, root / 12345684# MongoDB: admin / admin, no authentication85```8687## Redis Quick Reference (most common)8889```bash90# Unauthorized connection91redis-cli -h TARGET9293# Information gathering94INFO server95CONFIG GET dir96CONFIG GET dbfilename97```9899**Redis key exploitation paths:**100- Write a webshell / SSH key / Crontab101- Master-slave replication RCE102- Lua sandbox escape103104→ Details on password brute-forcing / Cluster / Sentinel → [references/redis-attack.md](references/redis-attack.md)105106## MSSQL Quick Reference107108```bash109# Connection110impacket-mssqlclient DOMAIN/sa:PASSWORD@TARGET -windows-auth111```112113**MSSQL key exploitation paths:**114- xp_cmdshell / OLE / Agent Job RCE115- CLR assembly attacks116- File read/write117- NTLM hash theft118119→ Information gathering / privilege escalation methodology → [references/mssql-attack.md](references/mssql-attack.md)120121## MySQL Quick Reference122123**MySQL key exploitation paths:**124- UDF privilege escalation / file read-write