Land #10374, Net::SSH::CommandStream fixes

GSoC/Meterpreter_Web_Console
Brent Cook 2018-07-25 18:21:39 -05:00
commit e78337d59a
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
13 changed files with 28 additions and 11 deletions

View File

@ -271,7 +271,7 @@ GEM
metasm
rex-core
rex-text
rex-socket (0.1.14)
rex-socket (0.1.15)
rex-core
rex-sslscan (0.1.5)
rex-core

View File

@ -20,15 +20,11 @@ class CommandStream
channel[:data] = ''
channel.on_eof do
self.rsock.close rescue nil
self.ssh.close rescue nil
self.thread.kill
cleanup
end
channel.on_close do
self.rsock.close rescue nil
self.ssh.close rescue nil
self.thread.kill
cleanup
end
channel.on_data do |ch,data|
@ -42,7 +38,7 @@ class CommandStream
self.channel = channel
end
def initialize(ssh, cmd = nil, cleanup = true)
def initialize(ssh, cmd = nil, cleanup = false)
self.lsock, self.rsock = Rex::Socket.tcp_socket_pair()
self.lsock.extend(Rex::IO::Stream)
@ -60,10 +56,10 @@ class CommandStream
self.lsock.localinfo = "#{info[1]}:#{info[2]}"
rssh.open_channel do |rch|
if cmd.nil?
if rcmd.nil?
rch.send_channel_request("shell", &method(:shell_requested))
else
rch.exec(rsh, &method(:shell_requested))
rch.exec(rcmd, &method(:shell_requested))
end
end
@ -90,7 +86,7 @@ class CommandStream
end
# Shut down the SSH session if requested
if rcleanup
if !rcmd.nil? && rcleanup
rssh.close
end
end
@ -106,6 +102,14 @@ class CommandStream
end
end
def cleanup
self.monitor.kill
self.lsock.close rescue nil
self.rsock.close rescue nil
self.ssh.close rescue nil
self.thread.kill
end
end
end
end

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
include Msf::Auxiliary::Report

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -3,6 +3,9 @@
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
# See note about overwritten files

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

View File

@ -4,6 +4,7 @@
##
require 'net/ssh'
require 'net/ssh/command_stream'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking