9200 - Pentesting Elasticsearch

Support HackTricks

Basic information

Elasticsearch एक वितरित, ओपन सोर्स खोज और विश्लेषण इंजन है जो सभी प्रकार के डेटा के लिए है। यह अपनी गति, स्केलेबिलिटी, और सरल REST APIs के लिए जाना जाता है। इसे Apache Lucene पर बनाया गया था, और इसे पहली बार 2010 में Elasticsearch N.V. (अब Elastic के रूप में जाना जाता है) द्वारा जारी किया गया था। Elasticsearch Elastic Stack का मुख्य घटक है, जो डेटा इनजेशन, समृद्धि, भंडारण, विश्लेषण, और दृश्यता के लिए ओपन सोर्स टूल्स का एक संग्रह है। इस स्टैक को सामान्यतः ELK स्टैक के रूप में जाना जाता है, जिसमें Logstash और Kibana भी शामिल हैं, और अब इसमें हल्के डेटा शिपिंग एजेंट्स होते हैं जिन्हें Beats कहा जाता है।

What is an Elasticsearch index?

Elasticsearch का इंडेक्स संबंधित दस्तावेजों का एक संग्रह है जो JSON के रूप में संग्रहीत होता है। प्रत्येक दस्तावेज में कुंजी और उनके संबंधित मान (स्ट्रिंग, नंबर, बूलियन, तिथियाँ, एरे, भू-स्थान, आदि) होते हैं।

Elasticsearch तेज पूर्ण-पाठ खोजों को सुविधाजनक बनाने के लिए एक कुशल डेटा संरचना का उपयोग करता है जिसे इनवर्टेड इंडेक्स कहा जाता है। यह इंडेक्स दस्तावेजों में प्रत्येक अद्वितीय शब्द को सूचीबद्ध करता है और उन दस्तावेजों की पहचान करता है जिनमें प्रत्येक शब्द प्रकट होता है।

इंडेक्सिंग प्रक्रिया के दौरान, Elasticsearch दस्तावेजों को संग्रहीत करता है और इनवर्टेड इंडेक्स का निर्माण करता है, जिससे लगभग वास्तविक समय में खोज करना संभव होता है। इंडेक्स API का उपयोग एक विशिष्ट इंडेक्स के भीतर JSON दस्तावेज़ जोड़ने या अपडेट करने के लिए किया जाता है।

डिफ़ॉल्ट पोर्ट: 9200/tcp

Manual Enumeration

Elasticsearch तक पहुँचने के लिए उपयोग किया जाने वाला प्रोटोकॉल HTTP है। जब आप HTTP के माध्यम से इसे एक्सेस करते हैं, तो आपको कुछ दिलचस्प जानकारी मिलेगी: http://10.10.10.115:9200/

यदि आप / तक पहुँचने पर वह प्रतिक्रिया नहीं देखते हैं, तो निम्नलिखित अनुभाग देखें।

Authentication

डिफ़ॉल्ट रूप से Elasticsearch में प्रमाणीकरण सक्षम नहीं है, इसलिए डिफ़ॉल्ट रूप से आप किसी भी क्रेडेंशियल का उपयोग किए बिना डेटाबेस के अंदर सब कुछ एक्सेस कर सकते हैं।

आप एक अनुरोध के साथ सत्यापित कर सकते हैं कि प्रमाणीकरण अक्षम है:

curl -X GET "ELASTICSEARCH-SERVER:9200/_xpack/security/user"
{"error":{"root_cause":[{"type":"exception","reason":"Security must be explicitly enabled when using a [basic] license. Enable security by setting [xpack.security.enabled] to [true] in the elasticsearch.yml file and restart the node."}],"type":"exception","reason":"Security must be explicitly enabled when using a [basic] license. Enable security by setting [xpack.security.enabled] to [true] in the elasticsearch.yml file and restart the node."},"status":500}

हालांकि, यदि आप / पर एक अनुरोध भेजते हैं और निम्नलिखित प्रतिक्रिया प्राप्त करते हैं:

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}

यह मतलब है कि प्रमाणीकरण कॉन्फ़िगर किया गया है और आपको कोई भी जानकारी प्राप्त करने के लिए मान्य क्रेडेंशियल्स की आवश्यकता है। फिर, आप इसे ब्रूटफोर्स करने की कोशिश कर सकते हैं (यह HTTP बेसिक ऑथ का उपयोग करता है, इसलिए BF HTTP बेसिक ऑथ का उपयोग किया जा सकता है)। यहाँ आपके पास डिफ़ॉल्ट उपयोगकर्ता नामों की सूची है: elastic (सुपरयूजर), remote_monitoring_user, beats_system, logstash_system, kibana, kibana_system, apm_system, _anonymous_._ Elasticsearch के पुराने संस्करणों में इस उपयोगकर्ता के लिए डिफ़ॉल्ट पासवर्ड changeme है।

curl -X GET http://user:password@IP:9200/

बेसिक यूजर एन्यूमरेशन

#List all roles on the system:
curl -X GET "ELASTICSEARCH-SERVER:9200/_security/role"

#List all users on the system:
curl -X GET "ELASTICSEARCH-SERVER:9200/_security/user"

#Get more information about the rights of an user:
curl -X GET "ELASTICSEARCH-SERVER:9200/_security/user/<USERNAME>"

Elastic Info

यहाँ कुछ endpoints हैं जिन्हें आप GET के माध्यम से जानकारी प्राप्त करने के लिए एक्सेस कर सकते हैं elasticsearch के बारे में:

_cat/_cluster/_security

/_cat/segments

/_cluster/allocation/explain

/_security/user

/_cat/shards

/_cluster/settings

/_security/privilege

/_cat/repositories

/_cluster/health

/_security/role_mapping

/_cat/recovery

/_cluster/state

/_security/role

/_cat/plugins

/_cluster/stats

/_security/api_key

/_cat/pending_tasks

/_cluster/pending_tasks

/_cat/nodes

/_nodes

/_cat/tasks

/_nodes/usage

/_cat/templates

/_nodes/hot_threads

/_cat/thread_pool

/_nodes/stats

/_cat/ml/trained_models

/_tasks

/_cat/transforms/_all

/_remote/info

/_cat/aliases

/_cat/allocation

/_cat/ml/anomaly_detectors

/_cat/count

/_cat/ml/data_frame/analytics

/_cat/ml/datafeeds

/_cat/fielddata

/_cat/health

/_cat/indices

/_cat/master

/_cat/nodeattrs

/_cat/nodes

ये endpoints दस्तावेज़ीकरण से लिए गए हैं जहाँ आप और अधिक पा सकते हैं। इसके अलावा, यदि आप /_cat एक्सेस करते हैं तो प्रतिक्रिया में /_cat/* endpoints शामिल होंगे जो इंस्टेंस द्वारा समर्थित हैं।

/_security/user में (यदि प्रमाणीकरण सक्षम है) आप देख सकते हैं कि कौन सा उपयोगकर्ता superuser भूमिका रखता है।

Indices

आप सभी इंडेक्स को एक्सेस करके इकट्ठा कर सकते हैं http://10.10.10.115:9200/_cat/indices?v

health status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .kibana 6tjAYZrgQ5CwwR0g6VOoRg   1   0          1            0        4kb            4kb
yellow open   quotes  ZG2D1IqkQNiNZmi2HRImnQ   5   1        253            0    262.7kb        262.7kb
yellow open   bank    eSVpNfCfREyYoVigNWcrMw   5   1       1000            0    483.2kb        483.2kb

To obtain information about which kind of data is saved inside an index you can access: http://host:9200/<index> from example in this case http://10.10.10.115:9200/bank

Dump index

If you want to dump all the contents of an index you can access: http://host:9200/<index>/_search?pretty=true like http://10.10.10.115:9200/bank/_search?pretty=true

थोड़ा समय निकालें और बैंक इंडेक्स के प्रत्येक दस्तावेज़ (एंट्री) की सामग्री की तुलना करें और इस इंडेक्स के फ़ील्ड की जो हमने पिछले अनुभाग में देखी थी।

So, at this point you may notice that there is a field called "total" inside "hits" that indicates that 1000 documents were found inside this index but only 10 were retried. This is because by default there is a limit of 10 documents. But, now that you know that this index contains 1000 documents, you can dump all of them indicating the number of entries you want to dump in the size parameter: http://10.10.10.115:9200/quotes/_search?pretty=true&size=1000asd नोट: यदि आप बड़ा संख्या निर्दिष्ट करते हैं तो सभी एंट्रीज़ वैसे भी डंप हो जाएंगी, उदाहरण के लिए आप size=9999 निर्दिष्ट कर सकते हैं और यह अजीब होगा यदि अधिक एंट्रीज़ हों (लेकिन आपको जांचना चाहिए)।

Dump all

In order to dump all you can just go to the same path as before but without indicating any indexhttp://host:9200/_search?pretty=true like http://10.10.10.115:9200/_search?pretty=true याद रखें कि इस मामले में डिफ़ॉल्ट सीमा 10 परिणामों की लागू होगी। आप size पैरामीटर का उपयोग करके परिणामों की बड़ी मात्रा को डंप कर सकते हैं। अधिक जानकारी के लिए पिछले अनुभाग को पढ़ें।

If you are looking for some information you can do a raw search on all the indices going to http://host:9200/_search?pretty=true&q=<search_term> like in http://10.10.10.115:9200/_search?pretty=true&q=Rockwell

If you want just to search on an index you can just specify it on the path: http://host:9200/<index>/_search?pretty=true&q=<search_term>

नोट करें कि सामग्री को खोजने के लिए उपयोग किया जाने वाला q पैरामीटर नियमित अभिव्यक्तियों का समर्थन करता है

You can also use something like https://github.com/misalabs/horuz to fuzz an elasticsearch service.

Write permissions

You can check your write permissions trying to create a new document inside a new index running something like the following:

curl -X POST '10.10.10.115:9200/bookindex/books' -H 'Content-Type: application/json' -d'
{
"bookId" : "A00-3",
"author" : "Sankaran",
"publisher" : "Mcgrahill",
"name" : "how to get a job"
}'

उस cmd से एक नया इंडेक्स bookindex नाम से बनेगा जिसमें books प्रकार का एक दस्तावेज़ होगा जिसमें "bookId", "author", "publisher" और "name" विशेषताएँ होंगी।

ध्यान दें कि नया इंडेक्स अब सूची में दिखाई दे रहा है:

और ध्यान दें कि स्वतः निर्मित गुण:

स्वचालित गणना

कुछ उपकरण पहले प्रस्तुत किए गए डेटा में से कुछ डेटा प्राप्त करेंगे:

msf > use auxiliary/scanner/elasticsearch/indices_enum

Shodan

  • port:9200 elasticsearch

HackTricks का समर्थन करें

Last updated