rapid7/metasploit-framework — pull request #3302 by TomSellers (2014-04-27 03:06:40+00:00)
Title: Add support for upgrading Linux shells to Meterpreter

These changes to spawn_meterpreter.rb add support for upgrading Linux shells to Meterpreter.

The change to bourne.rb supports this by allowing the stager to be launched, backgrounded, and then the cleanup commands still run. This was needed during the shell upgrade process. If the stager isn't backgrounded then it continues to run and tie up the original session while the new Meterpreter session is still open. This isn't obvious when trying to use the original 'vanilla' linux shell, it just appears unresponsive until the Meterpreter session is exited. Future attempts to launch Meterpreter from this shell will fail without providing information as to why.

The added side benefit is that the on disk stager files (on linux) are deleted 5 seconds after execution instead of after the Meterpreter session is closed.