27017,27018 - Pentesting MongoDB

Support HackTricks

Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking Insights Engage with content that delves into the thrill and challenges of hacking

Real-Time Hack News Keep up-to-date with fast-paced hacking world through real-time news and insights

Latest Announcements Stay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

Basic Information

MongoDB एक ओपन सोर्स डेटाबेस प्रबंधन प्रणाली है जो विभिन्न प्रकार के डेटा को संभालने के लिए डॉक्यूमेंट-ओरिएंटेड डेटाबेस मॉडल का उपयोग करती है। यह बड़े डेटा एनालिटिक्स और सामग्री प्रबंधन जैसे अनुप्रयोगों में असंरचित या अर्ध-संरचित डेटा प्रबंधित करने के लिए लचीलापन और स्केलेबिलिटी प्रदान करती है। डिफ़ॉल्ट पोर्ट: 27017, 27018

PORT      STATE SERVICE VERSION
27017/tcp open  mongodb MongoDB 2.6.9 2.6.9

Enumeration

Manual

from pymongo import MongoClient
client = MongoClient(host, port, username=username, password=password)
client.server_info() #Basic info
#If you have admin access you can obtain more info
admin = client.admin
admin_info = admin.command("serverStatus")
cursor = client.list_databases()
for db in cursor:
print(db)
print(client[db["name"]].list_collection_names())
#If admin access, you could dump the database also

कुछ MongoDB कमांड:

show dbs
use <db>
show collections
db.<collection>.find()  #Dump the collection
db.<collection>.count() #Number of records of the collection
db.current.find({"username":"admin"})  #Find in current db the username admin

स्वचालित

nmap -sV --script "mongo* and default" -p 27017 <IP> #By default all the nmap mongo enumerate scripts are used

Shodan

  • सभी mongodb: "mongodb server information"

  • पूर्ण रूप से खुले mongodb सर्वरों के लिए खोजें: "mongodb server information" -"partially enabled"

  • केवल आंशिक रूप से प्रमाणीकरण सक्षम करें: "mongodb server information" "partially enabled"

लॉगिन

डिफ़ॉल्ट रूप से mongo पासवर्ड की आवश्यकता नहीं है। Admin एक सामान्य mongo डेटाबेस है।

mongo <HOST>
mongo <HOST>:<PORT>
mongo <HOST>:<PORT>/<DB>
mongo <database> -u <username> -p '<password>'

nmap स्क्रिप्ट: mongodb-brute यह जांचेगा कि क्या क्रेडेंशियल्स की आवश्यकता है।

nmap -n -sV --script mongodb-brute -p 27017 <ip>

_/opt/bitnami/mongodb/mongodb.conf के अंदर देखें कि क्या क्रेडेंशियल्स की आवश्यकता है:

grep "noauth.*true" /opt/bitnami/mongodb/mongodb.conf | grep -v "^#" #Not needed
grep "auth.*true" /opt/bitnami/mongodb/mongodb.conf | grep -v "^#\|noauth" #Not needed

Mongo Objectid Predict

Example from here.

Mongo Object IDs 12-बाइट हेक्साडेसिमल स्ट्रिंग हैं:

उदाहरण के लिए, यहाँ एक वास्तविक Object ID है जो एक एप्लिकेशन द्वारा लौटाई गई है: 5f2459ac9fa6dc2500314019

  1. 5f2459ac: 1596217772 दशमलव में = शुक्रवार, 31 जुलाई 2020 17:49:32

  2. 9fa6dc: मशीन पहचानकर्ता

  3. 2500: प्रक्रिया ID

  4. 314019: एक वृद्धि काउंटर

उपरोक्त तत्वों में, मशीन पहचानकर्ता तब तक समान रहेगा जब तक डेटाबेस उसी भौतिक/वर्चुअल मशीन पर चल रहा है। प्रक्रिया ID केवल तभी बदलेगी जब MongoDB प्रक्रिया को पुनः प्रारंभ किया जाएगा। टाइमस्टैम्प हर सेकंड अपडेट होगा। केवल चुनौती Object IDs का अनुमान लगाने में काउंटर और टाइमस्टैम्प मानों को सरलता से बढ़ाना है, यह तथ्य है कि Mongo DB सिस्टम स्तर पर Object IDs उत्पन्न करता है और असाइन करता है।

उपकरण https://github.com/andresriancho/mongo-objectid-predict, एक प्रारंभिक Object ID (आप एक खाता बना सकते हैं और एक प्रारंभिक ID प्राप्त कर सकते हैं) दिया गया, यह लगभग 1000 संभावित Object IDs वापस भेजता है जो संभवतः अगले ऑब्जेक्ट्स को असाइन किए जा सकते थे, इसलिए आपको बस उन्हें ब्रूटफोर्स करना है।

Post

यदि आप रूट हैं तो आप mongodb.conf फ़ाइल को संशोधित कर सकते हैं ताकि कोई क्रेडेंशियल की आवश्यकता न हो (noauth = true) और क्रेडेंशियल के बिना लॉगिन करें


Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking Insights Engage with content that delves into the thrill and challenges of hacking

Real-Time Hack News Keep up-to-date with fast-paced hacking world through real-time news and insights

Latest Announcements Stay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

Support HackTricks

Last updated