
MQTT 침투 테스트를 위한 Rust CLI: 구독/발행, 브로커 핑거프린팅, ACL 프로빙, 토픽 열거, 자격 증명 무차별 대입, 그리고 TLS/mTLS를 통한 Last Will 주입.
명령줄용 Rust 기반 MQTT 침투 테스트 도구입니다.
$ nix-shell
$ cargo build --release
바이너리는 target/release/mqattack에 생성됩니다.
Rust 1.80+, C 컴파일러, OpenSSL 개발 헤더가 필요합니다.
$ cargo build --release
Nix 또는 NixOS 사용자를 위한 패키지가 제공됩니다. 최신 릴리스는 unstable 채널에만
있을 수 있다는 점을 유의하세요.
$ nix-env -iA nixos.mqattack
모든 명령은 공통된 연결 및 인증 옵션 세트를 공유합니다:
Connection options:
-H, --host <HOST> Broker hostname or IP [default: localhost]
-p, --port <PORT> Broker port [default: 1883]
-u, --username <USER> Username
-P, --password <PASS> Password (mutually exclusive with --jwt)
--jwt <TOKEN> JWT token sent as MQTT password
--client-id <ID> MQTT client identifier [default: mqattack]
--keepalive <SECS> Keep-alive interval [default: 60]
TLS options:
--tls Enable TLS with system root CAs
--cafile <PATH> Custom CA certificate in PEM format (implies --tls)
--cert <PATH> Client certificate for mTLS in PEM format (requires --key)
--key <PATH> Client private key for mTLS in PEM format (requires --cert)
--insecure Disable certificate verification — for testing only
$ mqattack subscribe [OPTIONS] -t <TOPIC>...
-t, --topic <TOPIC> Topic filter, repeatable
-q, --qos <QOS> QoS level 0/1/2 [default: 0]
-C, --count <N> Exit after N messages
--hex Print payload as hexadecimal
# Subscribe to all topics
$ mqattack subscribe -t '#'
# Subscribe to multiple filters, exit after 5 messages
$ mqattack subscribe -t 'home/#' -t 'sensors/#' -C 5
# Plaintext with credentials
$ mqattack subscribe -H 192.168.1.10 -u admin -P secret -t '#'
# TLS using system root CAs (default port 8883)
$ mqattack subscribe --tls -H broker.example.com -p 8883 -t '#'
# TLS with a custom CA
$ mqattack subscribe --cafile ca.crt -H broker.example.com -p 8883 -t '#'
# mTLS with client certificate
$ mqattack subscribe --cert client.crt --key client.key --cafile ca.crt \
-H broker.example.com -p 8883 -t '#'
# JWT authentication over TLS
$ mqattack subscribe --tls --jwt 'eyJhbGci...' -H broker.example.com -p 8883 -t '#'
# Self-signed cert — skip verification
$ mqattack subscribe --insecure -H 192.168.1.10 -p 8883 -t '#'
# Collect for 5 seconds, print a grouped summary
$ mqattack sys-info -H 192.168.1.10
# Longer collection window
$ mqattack sys-info -H broker.example.com --tls -p 8883 -w 15
# Stream values live
$ mqattack sys-info -H 192.168.1.10 --live
$ mqattack publish [OPTIONS] -t <TOPIC> -m <MESSAGE>
-t, --topic <TOPIC> Target topic
-m, --message <MSG> Payload; use '-' to read from stdin
-q, --qos <QOS> QoS level 0/1/2 [default: 0]
-r, --retain Set the retain flag
# Publish a simple message
$ mqattack publish -t test/topic -m 'hello'
# Publish with QoS 1 and retain flag
$ mqattack publish -H 192.168.1.10 -t alerts/door -m 'open' -q 1 -r
# Pipe payload from stdin
$ echo '{"cmd":"reboot"}' | mqattack publish -t device/1/cmd -m -
# Publish over TLS with JWT
$ mqattack publish --tls --jwt 'eyJhbGci...' \
-H broker.example.com -p 8883 -t device/1/cmd -m 'reboot'
# mTLS publish
$ mqattack publish --cert client.crt --key client.key --cafile ca.crt \
-H broker.example.com -p 8883 -t test -m 'hello'
$SYS/#를 구독하고 수집된 메시지를 분석하여 브로커 소프트웨어와 버전을 식별합니다.
표준 SUBSCRIBE 외에는 어떤 패킷도 전송하지 않습니다 — 브로커가 발행하는 내용을 통해
스스로를 드러냅니다.
인식되는 브로커와 탐지 신호:
| 브로커 | 탐지 신호 |
|---|---|
| Mosquitto | $SYS/broker/version 값이 mosquitto version으로 시작 |
| HiveMQ | $SYS/broker/version 값이 HiveMQ로 시작 |
| VerneMQ | $SYS/broker/version 값이 VerneMQ로 시작 |
| EMQX | $SYS/brokers/(복수형) 하위 토픽; 토픽 경로에서 노드 이름 추출 |
| NanoMQ | $SYS/nanomq/ 네임스페이스 하위 토픽 |
| RabbitMQ | $SYS/broker/version 값에 rabbitmq 포함 |
알려진 시그니처가 일치하면 신뢰도가 high로, $SYS/broker/version이 존재하지만
인식되지 않으면 low로, $SYS에 접근 가능하지만 식별 정보가 없으면 unknown으로
보고됩니다.
$ mqattack fingerprint [OPTIONS]
-w, --wait <SECS> Collection window in seconds [default: 5]
--verbose Print all collected $SYS messages after the summary
예시
# Fingerprint a broker on the default port
$ mqattack fingerprint -H 192.168.1.10
# Longer collection window for slow brokers, then dump everything
$ mqattack fingerprint -H 192.168.1.10 -w 10 --verbose
# Fingerprint over TLS with credentials
$ mqattack fingerprint --cafile ca.crt -H broker.example.com -p 8883 \
-u admin -P secret
출력 예시 (Mosquitto):
[+] Broker Fingerprint
Software: Mosquitto
Version: 2.0.18
Confidence: high
Build info: With OpenSSL 3.0.2 15 Mar 2022
Uptime: 12345 seconds
Clients connected: 3
Clients total: 47
Messages received: 1082
Messages sent: 2341
[*] 47 $SYS message(s) collected (use --verbose to see all)
단일 토픽 또는 토픽 목록에 대한 구독 및/또는 발행 권한을 탐지합니다.
각 테스트는 브로커에 새로 연결하고 반환된 SubAck/PubAck을 검사합니다.
결과는 ALLOWED, DENIED, INCONCLUSIVE(응답 미수신), 또는 SKIPPED로
보고됩니다.
참고: 발행 탐지는 브로커 응답을 받기 위해 QoS 1 또는 2(
-q 1또는-q 2)가 필요합니다. QoS 0은 발행에 대해 항상INCONCLUSIVE를 반환합니다.
$ mqattack check-acl [OPTIONS] (-t <TOPIC> | -w <FILE>)
-t, --topic <TOPIC> Single topic to probe (mutually exclusive with --wordlist)
-w, --wordlist <FILE> File with one topic per line (mutually exclusive with --topic)
--no-subscribe Skip subscribe permission tests
--no-publish Skip publish permission tests
--payload <TEXT> Payload used for publish probes [default: mqattack]
-q, --qos <QOS> QoS for publish probes (1 or 2) [default: 1]
--wait <SECS> Seconds to wait for a broker response per test [default: 5]
# Test a single topic (both subscribe and publish)
$ mqattack check-acl -H 192.168.1.10 -u admin -P secret -t 'home/lights/1'
# Test all topics from a wordlist, subscribe only
$ mqattack check-acl -H 192.168.1.10 -w topics.txt --no-publish
# Test publish permissions only with QoS 2
$ mqattack check-acl -H 192.168.1.10 -t 'cmd/device/1' --no-subscribe -q 2
# Check ACL over TLS with a custom CA
$ mqattack check-acl --cafile ca.crt -H broker.example.com -p 8883 -w topics.txt
# Use a custom payload and a longer wait window
$ mqattack check-acl -H 192.168.1.10 -t 'sensor/temp' --payload 'test' --wait 10
# Wordlist enumeration
mqattack enum-topics -H 192.168.1.10 -w mqtt-topics.txt
# Brute-force single-level topics under "home/"
mqattack enum-topics -H 192.168.1.10 --brute --prefix home --max-length 4
# Two-level brute-force (home/word/word) with longer window
mqattack enum-topics -H 192.168.1.10 --brute --prefix home --depth 2 -t 10
브로커에 대해 사용자 이름/비밀번호 조합을 테스트합니다. 네 가지 공격 모드가
지원되며, 모두 브로커의 ConnAck 반환 코드를 사용하여 성공과 실패를 구분합니다
(예: BadUserNamePassword vs. NotAuthorized).
| 모드 | 플래그 | 사용 사례 |
|---|---|---|
| 자격 증명 쌍 | -c FILE | 미리 작성된 username:password 목록 테스트 |
| 단일 사용자 브루트포스 | -u USER -W FILE | 한 계정에 대한 사전 공격 |
| 비밀번호 스프레이 | -U FILE -P PASS | 여러 사용자에 대해 하나의 비밀번호 |
| 교차 곱 | -U FILE -W FILE | 모든 조합 (10,000개로 제한, --force로 재정의) |
--try-anonymous는 워드리스트 시도 전에 자격 증명 없는 연결을 탐지합니다.
$ mqattack brute-auth [OPTIONS]