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.



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

def sock
  @sock
end

Instance Method Details

#chostObject

Returns the local host for outgoing connections

Raises:

  • (NotImplementedError)


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

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


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
# 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,
      '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)


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

def cport
  raise NotImplementedError
end

#disconnect(nsock = self.sock) ⇒ Object

Closes the TCP connection



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

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)


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

def proxies
  raise NotImplementedError
end

#rhostObject

Returns the target host

Raises:

  • (NotImplementedError)


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

def rhost
  raise NotImplementedError
end

#rportObject

Returns the remote port

Raises:

  • (NotImplementedError)


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

def rport
  raise NotImplementedError
end

#set_tcp_evasions(socket) ⇒ Object

Enable evasions on a given client



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

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)


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

def ssl
  raise NotImplementedError
end

#ssl_versionObject

Returns the string indicating SSLVersion

Raises:

  • (NotImplementedError)


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

def ssl_version
  raise NotImplementedError
end