Metasploit-framework: Replace session/channel signal handlers in msfconsole with detach & kill commands

Created on 8 Jan 2015  Â·  8Comments  Â·  Source: rapid7/metasploit-framework

This was originally reported here:
https://github.com/rapid7/meterpreter/issues/113

But I was instructed to also file a ticket under framework, because it appears to be related to Ruby 2.x, although at this point we're still trying to understand the problem.

Basically, if you are on Ruby 2.x and you try to background your shell repeatedly, you can cause a backtrace and then meterpreter will go bad (as in you won't be able to interact with it anymore). If you're on Ruby 1.9 you won't get the same thing.

bug library msfconsole

All 8 comments

Signal handling across multiple threads has been buggy in Ruby for a long time (broken on OS X on multiple occasions). Hijacking this ticket to work on a replacement for the ^C and ^Z handlers.

The proposed changes:

  • Change the ^C and ^Z handlers to print out a message indicating what the replacement command names are:
C:\> ^C
[*] Type ~kill to terminate the channel or session or ~background to detach
  • Modify the session & channel interaction loop to look for the prefix + command as the beginning of user input and handle the command appropriately

Anyone have a preference on the magic command prefix character(s)? I like ~ because its unlikely to conflict with Unix shell sessions (~kill/~background) compared to something like !.
cc @jlee-r7 @trosen-r7 @limhoff-r7

How about: ≈ ;-) (it's just Option-X on OSX)

Great idea! Any time the console receives ≈, it will download the Ubuntu ISO and fix the issue =)

Tilde isn't great and ^[ is likely to have similar issues. Any thoughts on a double sequence like !!quit?

Is #6864 and adequate solution here? Seems we got a little sidetracked on some details.

I honestly did not know enough when https://github.com/rapid7/meterpreter/issues/113 was filed to address it, but I think this should do the trick.

6864 doesn't solve this, still need an escape sequence, since it also applies to shell sessions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sunlewuyou picture sunlewuyou  Â·  48Comments

ortholinux picture ortholinux  Â·  55Comments

TheBrokenWasp picture TheBrokenWasp  Â·  28Comments

apollyonfirstcome picture apollyonfirstcome  Â·  42Comments

monomaki2035 picture monomaki2035  Â·  31Comments