FTP mixin: Report if host is up but service doesn't match#21575
Open
g0tmi1k wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the shared FTP remote mixin so that when an FTP module connects to an open TCP port but the initial greeting does not look like an FTP banner, Metasploit still reports the host/service to the workspace (instead of silently closing without recording anything).
Changes:
- Add a fallback
report_service()path inFtp#connectwhen the greeting does not match an FTP RFC-959 style banner. - Record the service as
unknownwith a TCP parent, and store a short info string intended to capture the banner (or a fallback message).
Impact Analysis:
- Blast radius: medium/high (all modules/mixins calling
Msf::Exploit::Remote::Ftp#connect, including scanners likeauxiliary/scanner/ftp/ftp_version; downstream effect is limited to DB/workspace reporting). - Data and contract effects: introduces additional service rows for
(host, port)when the port is open but not FTP (or when no FTP banner is received), potentially increasing “services” counts and persisting “unknown” service entries. - Rollback and test focus: easy rollback (single mixin change); validate against (1) real FTP services (still reports
ftpand note), (2) non-FTP banner services (records banner/info as intended), and (3) no-banner/timeouts (does not mislead or spam).
Comment on lines
+94
to
+106
| report_service( | ||
| host: rhost, | ||
| port: rport, | ||
| proto: 'tcp', | ||
| name: 'unknown', | ||
| info: Rex::Text.to_hex_ascii(banner.to_s.strip).presence || 'Non-FTP service', | ||
| parents: { | ||
| host: rhost, | ||
| port: rport, | ||
| proto: 'tcp', | ||
| name: 'tcp' | ||
| } | ||
| ) |
Contributor
|
Tested and seems to work as expected: We have some merged conflicts and I believe that copilot comment may be worth looking into. Once those are resolved I can get this merged for you 👍 |
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 has come from: #21416
When
ftp_version(or any module using the FTP mixin) connects to an open port that responds with a non-FTP banner, the greeting fails to match/^(120|220)[\s-]/.Currently, the connection simply closes with nothing added to the workspace.
This uses
report_service()to update the workspace with the unknown service (and also host).Demo
Before
After