Fixes #3625 by replacing with proper calls to create Rex sockets.
git-svn-id: file:///home/svn/framework3/trunk@11686 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
8f4a16cba0
commit
9bfdcfece1
|
@ -20,7 +20,7 @@ module Net; module SSH
|
|||
# available for write, and then call #enqueue and #read_available during
|
||||
# the idle times.
|
||||
#
|
||||
# socket = Rex::Socket::Tcp.connect(address, port)
|
||||
# socket = Rex::Socket::Tcp.create( ... address, ... port ... )
|
||||
# socket.extend(Net::SSH::BufferedIo)
|
||||
#
|
||||
# ssh.listen_to(socket)
|
||||
|
|
|
@ -386,7 +386,7 @@ module Net; module SSH; module Connection
|
|||
# ch.exec "/some/process/that/wants/input" do |ch, success|
|
||||
# abort "can't execute!" unless success
|
||||
#
|
||||
# io = Rex::Socket::Tcp.connect(somewhere, port)
|
||||
# io = Rex::Socket::Tcp.create( ... somewhere, ... port ... )
|
||||
# io.extend(Net::SSH::BufferedIo)
|
||||
# ssh.listen_to(io)
|
||||
#
|
||||
|
|
|
@ -49,7 +49,18 @@ module Net; module SSH; module Proxy
|
|||
# Return a new socket connected to the given host and port via the
|
||||
# proxy that was requested when the socket factory was instantiated.
|
||||
def open(host, port)
|
||||
socket = Rex::Socket::Tcp.connect(proxy_host, proxy_port)
|
||||
socket = Rex::Socket::Tcp.create(
|
||||
'PeerHost' => proxy_host,
|
||||
'PeerPort' => proxy_port,
|
||||
'Context' => {
|
||||
'Msf' => options[:msframework],
|
||||
'MsfExploit' => options[:msfmodule]
|
||||
}
|
||||
)
|
||||
# Tell MSF to automatically close this socket on error or completion...
|
||||
# This prevents resource leaks.
|
||||
options[:msfmodule].add_socket(@socket) if options[:msfmodule]
|
||||
|
||||
socket.write "CONNECT #{host}:#{port} HTTP/1.0\r\n"
|
||||
|
||||
if options[:user]
|
||||
|
|
|
@ -48,7 +48,18 @@ module Net
|
|||
# Return a new socket connected to the given host and port via the
|
||||
# proxy that was requested when the socket factory was instantiated.
|
||||
def open(host, port)
|
||||
socket = Rex::Socket::Tcp.connect(proxy_host, proxy_port)
|
||||
socket = Rex::Socket::Tcp.create(
|
||||
'PeerHost' => proxy_host,
|
||||
'PeerPort' => proxy_port,
|
||||
'Context' => {
|
||||
'Msf' => options[:msframework],
|
||||
'MsfExploit' => options[:msfmodule]
|
||||
}
|
||||
)
|
||||
# Tell MSF to automatically close this socket on error or completion...
|
||||
# This prevents resource leaks.
|
||||
options[:msfmodule].add_socket(@socket) if options[:msfmodule]
|
||||
|
||||
ip_addr = IPAddr.new(Resolv.getaddress(host))
|
||||
|
||||
packet = [VERSION, CONNECT, port.to_i, ip_addr.to_i, options[:user]].pack("CCnNZ*")
|
||||
|
|
|
@ -63,7 +63,17 @@ module Net
|
|||
# Return a new socket connected to the given host and port via the
|
||||
# proxy that was requested when the socket factory was instantiated.
|
||||
def open(host, port)
|
||||
socket = Rex::Socket::Tcp.connect(proxy_host, proxy_port)
|
||||
socket = Rex::Socket::Tcp.create(
|
||||
'PeerHost' => proxy_host,
|
||||
'PeerPort' => proxy_port,
|
||||
'Context' => {
|
||||
'Msf' => options[:msframework],
|
||||
'MsfExploit' => options[:msfmodule]
|
||||
}
|
||||
)
|
||||
# Tell MSF to automatically close this socket on error or completion...
|
||||
# This prevents resource leaks.
|
||||
options[:msfmodule].add_socket(@socket) if options[:msfmodule]
|
||||
|
||||
methods = [METHOD_NO_AUTH]
|
||||
methods << METHOD_PASSWD if options[:user]
|
||||
|
|
|
@ -241,7 +241,16 @@ module Net; module SSH; module Service
|
|||
raise Net::SSH::ChannelOpenFailed.new(1, "unknown request from remote forwarded connection on #{connected_address}:#{connected_port}")
|
||||
end
|
||||
|
||||
client = Rex::Socket::Tcp.connect(remote.host, remote.port)
|
||||
client = Rex::Socket::Tcp.create(
|
||||
'PeerHost' => remote.host,
|
||||
'PeerPort' => remote.port,
|
||||
'Context' => {
|
||||
'Msf' => options[:msframework],
|
||||
'MsfExploit' => options[:msfmodule]
|
||||
}
|
||||
)
|
||||
options[:msfmodule].add_socket(client) if options[:msfmodule]
|
||||
|
||||
info { "connected #{connected_address}:#{connected_port} originator #{originator_address}:#{originator_port}" }
|
||||
|
||||
prepare_client(client, channel, :remote)
|
||||
|
|
|
@ -67,7 +67,7 @@ module Net; module SSH; module Transport
|
|||
factory = options[:proxy]
|
||||
|
||||
if (factory)
|
||||
@socket = timeout(options[:timeout] || 0) { factory.connect(@host, @port) }
|
||||
@socket = timeout(options[:timeout] || 0) { factory.open(@host, @port) }
|
||||
else
|
||||
@socket = timeout(options[:timeout] || 0) {
|
||||
Rex::Socket::Tcp.create(
|
||||
|
@ -81,7 +81,7 @@ module Net; module SSH; module Transport
|
|||
}
|
||||
# Tell MSF to automatically close this socket on error or completion...
|
||||
# This prevents resource leaks.
|
||||
options[:msfmodule].add_socket(@socket)
|
||||
options[:msfmodule].add_socket(@socket) if options[:msfmodule]
|
||||
end
|
||||
|
||||
@socket.extend(PacketStream)
|
||||
|
|
Loading…
Reference in New Issue