File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
ui/console/command_dispatcher Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -277,8 +277,23 @@ def queue_cmd(cmd)
277
277
#
278
278
# Explicitly runs a command in the meterpreter console.
279
279
#
280
- def run_cmd ( cmd )
281
- console . run_single ( cmd )
280
+ def run_cmd ( cmd , output_object = nil )
281
+ stored_output_state = nil
282
+ # If the user supplied an Output IO object, then we tell
283
+ # the console to use that, while saving it's previous output/
284
+ if output_object
285
+ stored_output_state = console . output
286
+ console . send ( :output= , output_object )
287
+ end
288
+ success = console . run_single ( cmd )
289
+ # If we stored the previous output object of the channel
290
+ # we restore it here to put everything back the way we found it
291
+ # We re-use the conditional above, because we expect in many cases for
292
+ # the stored state to actually be nil here.
293
+ if output_object
294
+ console . send ( :output= , stored_output_state )
295
+ end
296
+ success
282
297
end
283
298
284
299
#
Original file line number Diff line number Diff line change @@ -1236,7 +1236,7 @@ def cmd_sessions(*args)
1236
1236
session . response_timeout = response_timeout
1237
1237
end
1238
1238
1239
- output = session . run_cmd cmd
1239
+ output = session . run_cmd ( cmd , driver . output )
1240
1240
end
1241
1241
end
1242
1242
when 'kill'
You can’t perform that action at this time.
0 commit comments