Java: Send the channel address info back to Metasploit - #781
Merged
jheysel-r7 merged 1 commit intoNov 13, 2025
Merged
Conversation
jheysel-r7
approved these changes
Nov 13, 2025
Contributor
There was a problem hiding this comment.
Changes look good and are working as expected 👍
Testing
msf post(test/socket_channels) > run
[*] Running against session -1
[*] Session type is meterpreter and platform is linux
[*] Running TCP client channel tests...
[+] [TCP-Client] Has the correct peer information
[+] [TCP-Client] Receives data from the peer
[+] [TCP-Client] Sends data to the peer
[+] [TCP-Client] Propagates close events to the peer
[+] [TCP-Client] Propagates close events from the peer
[*] Running UDP channel tests...
[-] FAILED: [UDP] Has the correct peer information
[+] [UDP] Receives data from the peer
[+] [UDP] Sends data to the peer
[*] Running TCP server channel tests...
[+] [TCP-Server] Accepts a connection
[+] [TCP-Server] Has the correct peer information
[+] [TCP-Server] Receives data from the peer
[+] [TCP-Server] Sends data to the peer
[+] [TCP-Server] Propagates close events to the server
[+] [TCP-Server] Propagates close events to the peer
[+] [TCP-Server] Propagates close events from the peer
[-] Passed: 14; Failed: 1; Skipped: 0
[*] Post module execution completed
zeroSteiner
added a commit
to zeroSteiner/metasploit-framework
that referenced
this pull request
Nov 13, 2025
Includes changes from: * rapid7/metasploit-payloads#782 * rapid7/metasploit-payloads#781
smcintyre-r7
pushed a commit
that referenced
this pull request
Jul 6, 2026
…tests Java: Send the channel address info back to Metasploit
smcintyre-r7
pushed a commit
that referenced
this pull request
Jul 7, 2026
…tests Java: Send the channel address info back to Metasploit
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.
The Java Meterpreter has inconsistent behavior in how the socket channels are handled in that it does not send the local address and local port information back to Metasploit. This becomes an issue when Metasploit requests that the OS environment on which the Java Meterpreter is running allocate the port by specifying port 0. When bound to port 0 in any of the three configurations (UDP, TCP client and TCP server), the port should be fetched from the socket and sent back to Metasploit. Metasploit can then use this information for socket communications. At least the Python, Windows and Mettle Meterpreter implementations do this already. I'll test PHP shortly and get a PR to fix it as well if it has the same issue.
Testing
The easiest way to test this is to use the module from rapid7/metasploit-framework#20689
post/test/socket_channelstest suite[-] FAILED: [UDP] Has the correct peer informationis a separate issue requiring a different fix, ignore it for nowDemo