Module: Metasploit::Framework::Tcp::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#max_send_sizeInteger

Returns The max size of the data to encapsulate in a single packet.

Returns:

  • (Integer)

    The max size of the data to encapsulate in a single packet


47
48
49
# File 'lib/metasploit/framework/tcp/client.rb', line 47

def max_send_size
  @max_send_size
end

#send_delayInteger

Returns The delay between sending packets.

Returns:

  • (Integer)

    The delay between sending packets


50
51
52
# File 'lib/metasploit/framework/tcp/client.rb', line 50

def send_delay
  @send_delay
end

#sockObject

Returns the value of attribute sock.


203
204
205
# File 'lib/metasploit/framework/tcp/client.rb', line 203

def sock
  @sock
end

Instance Method Details

#chostObject

Returns the local host for outgoing connections

Raises:

  • (NotImplementedError)
[View source]

171
172
173
# File 'lib/metasploit/framework/tcp/client.rb', line 171

def chost
  raise NotImplementedError
end

#connect(global = true, opts = {}) ⇒ Object

Establishes a TCP connection to the specified RHOST/RPORT

See Also:

  • Rex::Socket::Tcp
  • Rex::Socket::Tcp.create
[View source]

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/metasploit/framework/tcp/client.rb', line 75

def connect(global = true, opts={})
  dossl = false
  if(opts.has_key?('SSL'))
    dossl = opts['SSL']
  else
    dossl = ssl
  end

  nsock = Rex::Socket::Tcp.create(
      'PeerHost'      =>  opts['RHOST'] || rhost,
      'PeerHostname'  =>  opts['SSLServerNameIndication'] || opts['RHOSTNAME'],
      'PeerPort'      => (opts['RPORT'] || rport).to_i,
      'LocalHost'     =>  opts['CHOST'] || chost || "0.0.0.0",
      'LocalPort'     => (opts['CPORT'] || cport || 0).to_i,
      'SSL'           =>  dossl,
      'SSLVersion'    =>  opts['SSLVersion'] || ssl_version,
      'SSLVerifyMode' =>  opts['SSLVerifyMode'] || ssl_verify_mode,
      'SSLKeyLogFile' =>  opts['SSLKeyLogFile'] || sslkeylogfile,
      'SSLCipher'     =>  opts['SSLCipher'] || ssl_cipher,
      'Proxies'       => proxies,
      'Timeout'       => (opts['ConnectTimeout'] || connection_timeout || 10).to_i,
      'Context'       => { 'Msf' => framework, 'MsfExploit' => framework_module }
      )
  # enable evasions on this socket
  set_tcp_evasions(nsock)

  # Set this socket to the global socket as necessary
  self.sock = nsock if (global)

  return nsock
end

#cportObject

Returns the local port for outgoing connections

Raises:

  • (NotImplementedError)
[View source]

178
179
180
# File 'lib/metasploit/framework/tcp/client.rb', line 178

def cport
  raise NotImplementedError
end

#disconnect(nsock = self.sock) ⇒ Object

Closes the TCP connection

[View source]

133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/metasploit/framework/tcp/client.rb', line 133

def disconnect(nsock = self.sock)
  begin
    if (nsock)
      nsock.shutdown
      nsock.close
    end
  rescue IOError
  end

  if (nsock == sock)
    self.sock = nil
  end

end

#proxiesObject

Returns the proxy configuration

Raises:

  • (NotImplementedError)
[View source]

199
200
201
# File 'lib/metasploit/framework/tcp/client.rb', line 199

def proxies
  raise NotImplementedError
end

#rhostObject

Returns the target host

Raises:

  • (NotImplementedError)
[View source]

157
158
159
# File 'lib/metasploit/framework/tcp/client.rb', line 157

def rhost
  raise NotImplementedError
end

#rportObject

Returns the remote port

Raises:

  • (NotImplementedError)
[View source]

164
165
166
# File 'lib/metasploit/framework/tcp/client.rb', line 164

def rport
  raise NotImplementedError
end

#set_tcp_evasions(socket) ⇒ Object

Enable evasions on a given client

[View source]

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/metasploit/framework/tcp/client.rb', line 108

def set_tcp_evasions(socket)

  if( max_send_size.to_i == 0 and send_delay.to_i == 0)
    return
  end

  return if socket.respond_to?('evasive')

  socket.extend(EvasiveTCP)

  if ( max_send_size.to_i > 0)
    socket._send_size = max_send_size
    socket.denagle
    socket.evasive = true
  end

  if ( send_delay.to_i > 0)
    socket._send_delay = send_delay
    socket.evasive = true
  end
end

#sslObject

Returns the boolean indicating SSL

Raises:

  • (NotImplementedError)
[View source]

185
186
187
# File 'lib/metasploit/framework/tcp/client.rb', line 185

def ssl
  raise NotImplementedError
end

#ssl_versionObject

Returns the string indicating SSLVersion

Raises:

  • (NotImplementedError)
[View source]

192
193
194
# File 'lib/metasploit/framework/tcp/client.rb', line 192

def ssl_version
  raise NotImplementedError
end