Method: Msf::Sessions::Meterpreter#run_cmd
- Defined in:
- lib/msf/base/sessions/meterpreter.rb
permalink #run_cmd(cmd, output_object = nil) ⇒ Object
:category: Msf::Session::Interactive implementors
Explicitly runs a command in the meterpreter console.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/msf/base/sessions/meterpreter.rb', line 387 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 |