Land #7788, Add ability to interact with a manually backgrouned session

bug/bundler_fix
bwatters_r7 2017-01-10 08:55:00 -06:00
commit b3e8c3376d
No known key found for this signature in database
GPG Key ID: ECC0F0A52E65F268
2 changed files with 18 additions and 3 deletions

View File

@ -277,8 +277,23 @@ class Meterpreter < Rex::Post::Meterpreter::Client
#
# Explicitly runs a command in the meterpreter console.
#
def run_cmd(cmd)
console.run_single(cmd)
def run_cmd(cmd,output_object=nil)
stored_output_state = nil
# If the user supplied an Output IO object, then we tell
# the console to use that, while saving it's previous output/
if output_object
stored_output_state = console.output
console.send(:output=, output_object)
end
success = console.run_single(cmd)
# If we stored the previous output object of the channel
# we restore it here to put everything back the way we found it
# We re-use the conditional above, because we expect in many cases for
# the stored state to actually be nil here.
if output_object
console.send(:output=,stored_output_state)
end
success
end
#

View File

@ -1236,7 +1236,7 @@ class Core
session.response_timeout = response_timeout
end
output = session.run_cmd cmd
output = session.run_cmd(cmd, driver.output)
end
end
when 'kill'