Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling in tcp channels #7770

Merged
merged 2 commits into from Dec 30, 2016

Conversation

bcook-r7
Copy link
Contributor

@bcook-r7 bcook-r7 commented Dec 30, 2016

This makes some minor idiomatic changes to channel handling code, but also fixes some areas where Meterpreter payloads actually send failure responses to opening sockets, but Metasploit does not handle these as expected. Rather than raising an exception or returning a nil socket, often a nil object is instead dereferenced, throwing an entirely different exception, and as a result, a lot of things sort of work only by luck.

Verification

Run various exploits and modules that use TCP sockets through a pivot. For example, I have been running this RC script for testing mettle's network channel support:

use exploit/multi/handler
set payload linux/x86/mettle_reverse_tcp
set lhost 127.0.0.1
run -j
sleep 4
route add 192.168.1.0 255.255.255.0 1
use auxiliary/scanner/portscan/tcp
set RHOSTS 192.168.1.0/24
set SESSION -1
run

Your mileage may vary. This is certainly up for discussion, and I suspect I may have gotten intent vs what the code was actually doing mixed up. It does seem to help a bit with handling sudden unexpected socket closes.

@acammack-r7 acammack-r7 self-assigned this Dec 30, 2016
@acammack-r7 acammack-r7 merged commit fdca963 into rapid7:master Dec 30, 2016
acammack-r7 added a commit that referenced this pull request Dec 30, 2016
@bcook-r7
Copy link
Contributor Author

bcook-r7 commented Jan 2, 2017

Thanks @acammack-r7 !

@acammack-r7
Copy link
Contributor

acammack-r7 commented Jan 3, 2017

Release Notes

Previously, Metasploit TCP channels would crash in certain race conditions, and cause the whole subsystem to hang. This fix improves the reliability of TCP channels.

@tdoan-r7 tdoan-r7 added the rn-enhancement release notes enhancement label Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants