feat: capture and log attacker payload metadata from MQTT sessions#18
Open
Uday9909 wants to merge 1 commit intohoneynet:mainfrom
Open
feat: capture and log attacker payload metadata from MQTT sessions#18Uday9909 wants to merge 1 commit intohoneynet:mainfrom
Uday9909 wants to merge 1 commit intohoneynet:mainfrom
Conversation
Add mqtt_pit_payload_captured Prometheus metric that records attacker-supplied data from three MQTT packet types: - CONNECT: client_id, username, protocol version (password never captured) - PUBLISH: topic name and payload - SUBSCRIBE: topic filter Follows the same sendMetric() unixgram IPC pattern as PR honeynet#15. Safety: - Passwords skipped entirely, never passed to any metric - Binary payloads sanitized to printable ASCII - All fields truncated at 256 bytes - Malformed packets handled without crash - NULL guards on all capture functions Also removes password from existing credentials metric emission. Old code sent username and password. New code sends username only. Adds uint16_t port to struct mqttClient for source port labeling.
|
Nice work on the payload capture. One thing worth considering would Might be worth doing the same here, keep packet_type and ip as Also the credentials metric change dropping password is a breaking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds real-time attacker payload capture to the MQTT tarpit, recording
what attackers send during sessions as a new Prometheus metric.
Follows the same pattern as PR #15 (Telnet input capture).
Changes
servers/mqtt_pit.c
and truncate to 256 bytes, matching the Telnet sanitization approach
readPublish() so they can emit captures with source IP and port
sent username and password, new code sends username only
shared/structs.h
prometheus/main.go
packet_type, payload
New Metric
mqtt_pit_payload_captured with labels:
Why
The MQTT tarpit previously discarded all semantic data sent by
attackers beyond version and topic metadata. This change captures
client identifiers, publish payloads, and subscription patterns
in real time, giving researchers visibility into attacker tooling,
credential stuffing scripts, and topic reconnaissance behavior
without requiring log parsing.
Safety
entirely with offset += passwordLength and never passed to any
metric or log function
emitMqttPayloadMetric before any processing
the socket is unavailable the tarpit continues normally
Testing
Tested by connecting an MQTT client via mosquitto_pub and
mosquitto_sub and confirming mqtt_pit_payload_captured appears
in the /metrics endpoint output with correct labels.
Go build passes: cd prometheus && go build ./...