IPMI Scanner Bug Fixes#21526
Open
zeroSteiner wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness and output correctness across the IPMI scanner modules by hardening parsing against malformed UDP replies, shortening unresponsive-target behavior in ipmi_dumphashes, and standardizing host:port formatting via Rex::Socket.to_authority (IPv6-safe).
Changes:
- Add RSpec coverage for malformed-reply handling (
ipmi_cipher_zero) and early-abort behavior on silent targets (ipmi_dumphashes). - Prevent
ipmi_cipher_zerofrom aborting when a malformed Open Session reply is received. - Use
Rex::Socket.to_authority(host, port)in IPMI scanners so IPv6 addresses are bracketed correctly in output.
Impact Analysis:
- Blast radius: medium — affects runtime behavior/output of IPMI auxiliary scanner modules (
ipmi_cipher_zero,ipmi_dumphashes,ipmi_version) and adds new spec coverage for those scanners. - Data and contract effects: low — no schema/payload changes; scanner output strings change (authority formatting) and
ipmi_dumphashesmay abort enumeration sooner on targets deemed non-IPMI. - Rollback and test focus: rollback is straightforward (module-only changes); focus testing on (1) malformed-then-valid reply sequences for
ipmi_cipher_zero, and (2) targets that respond with IPMI “refusal”/short Open Session replies and then go silent (to avoid false-negative early abort).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/modules/auxiliary/scanner/ipmi/ipmi_dumphashes_spec.rb | Adds regression coverage to ensure enumeration stops quickly when the target never answers the initial Open Session probe. |
| spec/modules/auxiliary/scanner/ipmi/ipmi_cipher_zero_spec.rb | Adds regression coverage to ensure malformed replies don’t raise/abort and a later valid reply is still reported. |
| modules/auxiliary/scanner/ipmi/ipmi_version.rb | Switches output to Rex::Socket.to_authority for IPv6-safe host:port formatting. |
| modules/auxiliary/scanner/ipmi/ipmi_dumphashes.rb | Adds early-abort logic when there’s no evidence the target is IPMI, and updates output to to_authority. |
| modules/auxiliary/scanner/ipmi/ipmi_cipher_zero.rb | Wraps reply parsing to ignore malformed packets safely and updates output to to_authority. |
Comment on lines
+122
to
+126
| if seen_valid_open_session | ||
| ipmi_status("No response to IPMI open session request for username #{username}") | ||
| else | ||
| ipmi_error("No response to IPMI open session request; stopping username enumeration") | ||
| stop_username_enumeration = true |
79720e8 to
1d8f78e
Compare
Comment on lines
149
to
+150
| session_succeeded = true | ||
| seen_valid_open_session = true |
Comment on lines
48
to
50
| unless info.ipmi_command == 56 | ||
| vprint_error "#{shost}:#{rport} - IPMI - Invalid response" | ||
| vprint_error "#{Rex::Socket.to_authority(shost, rport)} - IPMI - Invalid response" | ||
| return |
Contributor
Author
There was a problem hiding this comment.
Pretty sure in this context the 's' in shost is for scan-host. It's confusing but the original module printed shost:rport not rhost:rport so either way this is not a regression.
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.
This makes a few improvements to the IPMI scanner modules as described below.
auxiliary/scanner/ipmi/ipmi_cipher_zeroThis module had an issue where if a malformed reply was received it would abort the operation meaning that if a legitimate reply was received afterwards that it would not be processed.
ipmi_udp_harness.pyscript,python tools/dev/ipmi_udp_harness.py --mode cipher_zero --profile malformed_then_valid --listen 127.0.0.1 --port 623ipmi_cipher_zeromodule and target the local harnessauxiliary/scanner/ipmi/ipmi_dumphashesThis module would run against a target that is not an IPMI service. In that case, it can appear hung due to how long it takes to run as it makes repeated requests to a target it can't communicate with. The update here aborts the operation more quickly when there isn't evidence that the target is IPMI.
ipmi_udp_harness.pyscript,python tools/dev/ipmi_udp_harness.py --mode dumphashes --profile silent --listen 127.0.0.1 --port 623auxiliary/scanner/ipmi/ipmi_dumphashesmodule and target the local harnessMultiple
Addresses use
Rex::Socket.to_authorityto report the host and port combination so when there is an IPv6 address, it's correctly encapsulated in brackets.Verification
List the steps needed to make sure this thing works
msfconsoleipmi_udp_harness.py
Demo
Ran through both tests, new on the left, old on the right.