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

Add AutoVerifySessionTimeout Meterpreter advanced option #5547

Merged
merged 1 commit into from
Jun 19, 2015

Conversation

OJ
Copy link
Contributor

@OJ OJ commented Jun 16, 2015

With the addition of the AutoVerifySession setting in MSF users can control whether they want session validation to be enabled or not. This means that MSF will make sure the shell is responsive within a "reasonable" period of time, and if not, shut down the session. This prevents users from having "dead shells" and not knowing what to do with them.

This PR adds another setting called AutoVerifySessionTimeout, which allows the user to control the period of time that those validation messages have before the session is marked as invalid, and then closed. The original value, hidden behind the scenes in code, was 10 seconds. This is left as the default value. Users can modify this value in environments where latency is higher, forcing the framework to give the shell a better opportunity to get established before marking it as invalid.

This PR should fix #5534.

Verification

  • use multi/handler
  • set payload to any Meterpreter payload
  • Make sure that the AutoVerifySessionTimeout value is present in the advanced options
  • Create a Meterpreter session using the default value
  • Modify the value, and create a new session

It'd be nice to simulate a high latency environment somewhere prior to landing this so you can see it fail in one case, modify the timeout, and see it work in the second case. @sweetsoftware it'd be nice if you could also have a look at this branch to see if it helps your situation. Thanks!

@OJ OJ added the enhancement label Jun 16, 2015
@sweetsoftware
Copy link

This patch works as expected, with the default value I get the "invalid session" error, then I set it to 180 and created a new session, which was handled properly. Cheers !

@bcook-r7 bcook-r7 self-assigned this Jun 19, 2015
@bcook-r7
Copy link
Contributor

I setup a 1 second delay per-packet environment and this works great:

$ ./msfconsole -qx 'loadpath test/modules; use auxiliary/test/netem_proxy; set PacketDelayMs 1000; set VagrantCleanup destroy; set srvhost 192.168.56.1; set lhost 192.168.56.1; run'
Loaded 0 modules:
PacketDelayMs => 1000
VagrantCleanup => destroy
srvhost => 192.168.56.1
lhost => 192.168.56.1
[*] Writing Vagrant config to /var/folders/7q/jwhmljqn6nx8lnqft8nf5w2myy7k2k/T/metasploit_netem_router/Vagrantfile
[*] Starting Vagrant image metasploit_netem_router (ubuntu/trusty64)
[*] Vagrant router image started
[*] Auxiliary module execution completed
$ ./msfconsole -qx 'use exploit/multi/handler; set payload windows/meterpreter/reverse_tcp; set lhost 192.168.56.1; set AutoVerifySessionTimeout 1; run'
payload => windows/meterpreter/reverse_tcp
lhost => 192.168.56.1
AutoVerifySessionTimeout => 1
[*] Started reverse handler on 192.168.56.1:4444
[*] Starting the payload handler...
[*] Sending stage (884270 bytes) to 192.168.56.1
[*] Meterpreter session 1 opened (192.168.56.1:4444 -> 192.168.56.1:50789) at 2015-06-19 15:22:18 -0500

meterpreter >
[-] Meterpreter session 1 is not valid and will be closed

[*] 192.168.56.1 - Meterpreter session 1 closed.

msf exploit(handler) > exit
$ ./msfconsole -qx 'use exploit/multi/handler; set payload windows/meterpreter/reverse_tcp; set lhost 192.168.56.1; set AutoVerifySessionTimeout 180; run'
payload => windows/meterpreter/reverse_tcp
lhost => 192.168.56.1
AutoVerifySessionTimeout => 180
[*] Started reverse handler on 192.168.56.1:4444
[*] Starting the payload handler...
[*] Sending stage (884270 bytes) to 192.168.56.1
[*] Meterpreter session 1 opened (192.168.56.1:4444 -> 192.168.56.1:50802) at 2015-06-19 15:23:33 -0500

meterpreter >

@bcook-r7 bcook-r7 merged commit 9dbdaf1 into rapid7:master Jun 19, 2015
bcook-r7 pushed a commit that referenced this pull request Jun 19, 2015
@OJ
Copy link
Contributor Author

OJ commented Jun 19, 2015 via email

@OJ OJ deleted the auto-verify-session-timeout branch June 16, 2017 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Meterpreter session flagged invalid when using SSH tunnel
4 participants