Mongodb Aux Modules - #21785
Conversation
|
incorporated the changes from #21788 and credited @prithvee07 . Retested and looking good. |
|
meterp acceptance build fail is unrelated. |
|
Not to be greedy or anything, but is there any chance for some rspecs for that library? 🤣 |
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR expands Metasploit’s MongoDB auxiliary scanner capabilities by adding new MongoDB scanners (version, schema dump, hash dump) and updating the existing MongoDB login module to support SCRAM authentication via a new shared wire-protocol mixin.
Changes:
- Added new MongoDB auxiliary scanner modules for version detection, schema enumeration, and hash extraction.
- Updated
mongodb_loginto support SCRAM-SHA-1 (MongoDB 3.0+) with a MONGODB-CR fallback. - Introduced a shared
Msf::Exploit::Remote::Mongodbmixin for OP_QUERY packet construction and BSON reply parsing.
Impact Analysis:
- Blast radius: medium — affects all MongoDB scanner modules in this PR plus any future modules that include
Msf::Exploit::Remote::Mongodb; downstream impact beyond MongoDB tooling is low. - Data and contract effects: adds new credential/hash entries to the Metasploit database via
create_credential; no schema migrations or external API contracts changed. - Rollback and test focus: rollback is straightforward (remove new modules/mixin), but test focus should include auth detection behavior (
mongodb_have_auth_error?), SCRAM login success/failure paths, and hash/schema dump completeness.
File summaries
| File | Description |
|---|---|
| modules/auxiliary/scanner/mongodb/mongodb_version.rb | New scanner to query buildInfo and report MongoDB version. |
| modules/auxiliary/scanner/mongodb/mongodb_schemadump.rb | New schema enumerator that lists DBs/collections and samples documents into JSON loot. |
| modules/auxiliary/scanner/mongodb/mongodb_login.rb | Adds SCRAM-SHA-1 login support with legacy fallback; uses new wire-protocol mixin. |
| modules/auxiliary/scanner/mongodb/mongodb_hashdump.rb | New hash extraction module for system/app user hashes with credential storage. |
| lib/msf/core/exploit/remote/mongodb.rb | New shared wire-protocol helper mixin for MongoDB OP_QUERY + BSON parsing. |
| documentation/modules/auxiliary/scanner/mongodb/mongodb_version.md | Documentation for the new version scanner module. |
| documentation/modules/auxiliary/scanner/mongodb/mongodb_schemadump.md | Documentation for the new schema dump module (including scenarios). |
| documentation/modules/auxiliary/scanner/mongodb/mongodb_login.md | Documentation for updated login behavior (SCRAM + fallback). |
| documentation/modules/auxiliary/scanner/mongodb/mongodb_hashdump.md | Documentation for the new hash dump module and hashcat usage. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Brendan <bwatters@rapid7.com>
Co-authored-by: Brendan <bwatters@rapid7.com>
|
#21785 (comment) |
|
yup, i'll get to it later, wanted it bound in though to test against later |
|
Pulled auth out of the modules and put it in the centralized lib. That's where it should be and helped standardized some options, pull duplicated code out of modules, and such. I didn't know mongo allowed you to login to a db and not just the system in general. so i've now tested that, and also fixed a bug in schemadump where you can't list the databases, but you provide a database name |
|
diff --git a/spec/lib/msf/core/exploit/remote/mongodb_spec.rb b/spec/lib/msf/core/exploit/remote/mongodb_spec.rb
|
|
@prithvee07 can you mark blocks of code with triple ticks so its readable? Also, as previously noted, you should put that in a PR to my repo's mongodb_schemadump so I can look over the diff easily and you get credit. You should be able to ask claude how to do it, or have it do it for you. Just point it to this comment. |
|
@prithvee07, github makes collaboration easy, but you need to use it correctly. @h00die's already spent time copying over code that would have been trivial to add if you had PR'd to his branch, and now you have left a huge comment that should be a PR to h00die's branch. |
|
@bwatters-r7 and @h00die i'm new to git and this my first project i am contributing |
We understand, we've all been there. However, we're trying to give you clear instructions on how to do things the right way, and offering additional help in slack to guide you w/o having these long public discussions that end up in people's email boxes. |
| [*] 127.0.0.1:27017 - DB 'intranet' Collections: users, config | ||
| [*] 127.0.0.1:27017 - DB 'local' Collections: startup_log | ||
| [+] 127.0.0.1:27017 - Schema dumped to loot: /home/h00die/.msf4/loot/20260814091146_default_127.0.0.1_mongodb.schema_850455.json | ||
| [*] 127.0.0.1:27017 - Scanned 1 of 1 hosts (100% complete) |
There was a problem hiding this comment.
MongoDB 3.6 with NO Authentication
Description
MongoDB is sorely missing capabilities. mysql/mssql/postgres have hash dumpers, login, version, schema dumping, lots of fun stuff. However, nobody seems to want to give Mongo some <3 except Gregory Man, who is the man.
This PR adds:
Notably this is not a full new hash capability since thats a long and arduous process, this just adds the dumping capabilities for the time being (theyre in hashcat format)
Reviewer Notes
There are several modules in this PR, and while thats not typical and can be a bit of a pain, the version portion is part of login, the login portion is part of schema and hash dump, so it felt all similar.
Verification Steps
See module docs for each module
AI Usage Disclosure
Gemini assisted in making schemadump, and updating login. GLM-4.7 assisted wtih version and hashdump. I did the verification, removed extraneous things, made them work more how MSF users would think they work, and wrote all the docs (therefore, theyre poorer quality than AI would make, but at least the Scenarios sections are legit)