Skip to content

Commit d9876e8

Browse files
authored
Land #15994, fix console.read does not return command output
2 parents 6a28765 + e0d0514 commit d9876e8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/msf/ui/console/driver.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,9 @@ def unknown_command(method, line)
474474
[method, method+".exe"].each do |cmd|
475475
if command_passthru && Rex::FileUtils.find_full_path(cmd)
476476

477-
print_status("exec: #{line}")
478-
print_line('')
479-
480477
self.busy = true
481478
begin
482-
system(line)
479+
run_unknown_command(line)
483480
rescue ::Errno::EACCES, ::Errno::ENOENT
484481
print_error("Permission denied exec: #{line}")
485482
end
@@ -500,6 +497,12 @@ def unknown_command(method, line)
500497
super
501498
end
502499

500+
def run_unknown_command(command)
501+
print_status("exec: #{command}")
502+
print_line('')
503+
system(command)
504+
end
505+
503506
##
504507
#
505508
# Handlers for various global configuration values

lib/msf/ui/web/web_console.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ module WebConsoleShell
3232
def supports_color?
3333
false
3434
end
35+
36+
def run_unknown_command(command)
37+
Open3.popen2e(command) {|stdin,output,thread|
38+
output.each {|outline|
39+
print_line(outline.chomp)
40+
}
41+
}
42+
end
43+
3544
end
3645

3746
def initialize(framework, console_id, opts={})

0 commit comments

Comments
 (0)