Skip to content

Commit b1b8cba

Browse files
committed
Rescue an IOError on channel double-close.
This was causing output from python meterpreter commands run on OSX to be discarded when the error was raised, making cmd_exec not-so-useful.
1 parent 0380c5e commit b1b8cba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/msf/core/post/common.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ def cmd_exec(cmd, args=nil, time_out=15)
111111
o << d
112112
end
113113
o.chomp! if o
114-
process.channel.close
114+
115+
begin
116+
process.channel.close
117+
rescue IOError => e
118+
# Channel was already closed, but we got the cmd output, so let's soldier on.
119+
end
120+
115121
process.close
116122
when /shell/
117123
o = session.shell_command_token("#{cmd} #{args}", time_out)

0 commit comments

Comments
 (0)