exploits now pass context when creating sockets
git-svn-id: file:///home/svn/incoming/trunk@3034 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
dbdb15e8f5
commit
fc42fef941
|
@ -32,7 +32,12 @@ module Exploit::Remote::Tcp
|
|||
'PeerPort' => datastore['RPORT'].to_i,
|
||||
'LocalHost' => datastore['CHOST'] || "0.0.0.0",
|
||||
'LocalPort' => datastore['CPORT'] ? datastore['CPORT'].to_i : 0,
|
||||
'SSL' => datastore['SSL'])
|
||||
'SSL' => datastore['SSL'],
|
||||
'Context' =>
|
||||
{
|
||||
'Msf' => framework,
|
||||
'MsfExploit' => self
|
||||
})
|
||||
|
||||
# Set this socket to the global socket as necessary
|
||||
self.sock = nsock if (global)
|
||||
|
|
|
@ -82,6 +82,9 @@ class ExploitDriver
|
|||
"Incompatible payload", caller
|
||||
end
|
||||
|
||||
# Associate the payload instance with the exploit
|
||||
payload.assoc_exploit = exploit
|
||||
|
||||
# Finally, validate options on the exploit module to ensure that things
|
||||
# are ready to operate as they should.
|
||||
exploit.options.validate(exploit.datastore)
|
||||
|
|
|
@ -83,7 +83,13 @@ module BindTcp
|
|||
client = Rex::Socket::Tcp.create(
|
||||
'PeerHost' => datastore['RHOST'],
|
||||
'PeerPort' => datastore['LPORT'].to_i,
|
||||
'Comm' => comm)
|
||||
'Comm' => comm,
|
||||
'Context' =>
|
||||
{
|
||||
'Msf' => framework,
|
||||
'MsfPayload' => self,
|
||||
'MsfExploit' => assoc_exploit
|
||||
})
|
||||
rescue Rex::ConnectionRefused
|
||||
# Connection refused is a-okay
|
||||
rescue
|
||||
|
|
|
@ -56,7 +56,13 @@ module ReverseTcp
|
|||
self.listener_sock = Rex::Socket::TcpServer.create(
|
||||
'LocalHost' => datastore['LHOST'],
|
||||
'LocalPort' => datastore['LPORT'].to_i,
|
||||
'Comm' => comm)
|
||||
'Comm' => comm,
|
||||
'Context' =>
|
||||
{
|
||||
'Msf' => framework,
|
||||
'MsfPayload' => self,
|
||||
'MsfExploit' => assoc_exploit
|
||||
})
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -318,6 +318,12 @@ class Payload < Msf::Module
|
|||
#
|
||||
attr_accessor :prepend_encoder
|
||||
|
||||
#
|
||||
# If this payload is associated with an exploit, the assoc_exploit
|
||||
# attribute will point to that exploit instance.
|
||||
#
|
||||
attr_accessor :assoc_exploit
|
||||
|
||||
protected
|
||||
|
||||
##
|
||||
|
|
|
@ -28,7 +28,50 @@ class Rex::Socket::Parameters
|
|||
##
|
||||
|
||||
#
|
||||
# Initializes the attributes from the supplied hash.
|
||||
# Initializes the attributes from the supplied hash. The following hash
|
||||
# keys can be specified.
|
||||
#
|
||||
# PeerHost / PeerAddr
|
||||
#
|
||||
# The remote host to connect to.
|
||||
#
|
||||
# PeerPort
|
||||
#
|
||||
# The remote port to connect to.
|
||||
#
|
||||
# LocalHost / LocalAddr
|
||||
#
|
||||
# The local host to communicate from, if any.
|
||||
#
|
||||
# LocalPort
|
||||
#
|
||||
# The local port to communicate from, if any.
|
||||
#
|
||||
# Bare
|
||||
#
|
||||
# Create a bare socket.
|
||||
#
|
||||
# Server
|
||||
#
|
||||
# Whether or not this should be a server.
|
||||
#
|
||||
# SSL
|
||||
#
|
||||
# Whether or not SSL should be used.
|
||||
#
|
||||
# Comm
|
||||
#
|
||||
# The underlying Comm class to use to create the socket for this parameter
|
||||
# set.
|
||||
#
|
||||
# Context
|
||||
#
|
||||
# A context hash that can allow users of this parameter class instance to
|
||||
# determine who is responsible for requesting that a socket be created.
|
||||
#
|
||||
# Retries
|
||||
#
|
||||
# The number of times a connection should be retryed.
|
||||
#
|
||||
def initialize(hash)
|
||||
if (hash['PeerHost'])
|
||||
|
@ -84,6 +127,9 @@ class Rex::Socket::Parameters
|
|||
# The communication subsystem to use to create the socket
|
||||
self.comm = hash['Comm']
|
||||
|
||||
# The context that was passed in, if any.
|
||||
self.context = hash['Context'] || {}
|
||||
|
||||
# If no comm was supplied, try to use the comm that is best fit to
|
||||
# handle the provided host based on the current routing table.
|
||||
if (self.comm == nil and hash['PeerHost'])
|
||||
|
@ -184,6 +230,10 @@ class Rex::Socket::Parameters
|
|||
#
|
||||
attr_accessor :comm
|
||||
#
|
||||
# The context hash that was passed in to the structure.
|
||||
#
|
||||
attr_accessor :context
|
||||
#
|
||||
# The number of attempts that should be made.
|
||||
#
|
||||
attr_accessor :retries
|
||||
|
|
Loading…
Reference in New Issue