Module: Metasploit::Framework::Tcp::Client
- Extended by:
- ActiveSupport::Concern
- Included in:
- Ftp::Client, LoginScanner::ACPP, LoginScanner::AFP, LoginScanner::DB2, LoginScanner::FreeswitchEventSocket, LoginScanner::MQTT, LoginScanner::MySQL, LoginScanner::POP3, LoginScanner::Redis, LoginScanner::SMB, LoginScanner::VMAUTHD, LoginScanner::VNC, LoginScanner::VarnishCLI, LoginScanner::X3, MSSQL::Client, Metasploit::Framework::Telnet::Client
- Defined in:
- lib/metasploit/framework/tcp/client.rb
Instance Attribute Summary collapse
-
#max_send_size ⇒ Integer
The max size of the data to encapsulate in a single packet.
-
#send_delay ⇒ Integer
The delay between sending packets.
-
#sock ⇒ Object
Returns the value of attribute sock.
Instance Method Summary collapse
-
#chost ⇒ Object
Returns the local host for outgoing connections.
-
#connect(global = true, opts = {}) ⇒ Object
Establishes a TCP connection to the specified RHOST/RPORT.
-
#cport ⇒ Object
Returns the local port for outgoing connections.
-
#disconnect(nsock = self.sock) ⇒ Object
Closes the TCP connection.
-
#proxies ⇒ Object
Returns the proxy configuration.
-
#rhost ⇒ Object
Returns the target host.
-
#rport ⇒ Object
Returns the remote port.
-
#set_tcp_evasions(socket) ⇒ Object
Enable evasions on a given client.
-
#ssl ⇒ Object
Returns the boolean indicating SSL.
-
#ssl_version ⇒ Object
Returns the string indicating SSLVersion.
Instance Attribute Details
#max_send_size ⇒ Integer
Returns 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_delay ⇒ Integer
Returns The delay between sending packets.
50 51 52 |
# File 'lib/metasploit/framework/tcp/client.rb', line 50 def send_delay @send_delay end |
#sock ⇒ Object
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
#chost ⇒ Object
Returns the local host for outgoing connections
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
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, '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 |
#cport ⇒ Object
Returns the local port for outgoing connections
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
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 |
#proxies ⇒ Object
Returns the proxy configuration
199 200 201 |
# File 'lib/metasploit/framework/tcp/client.rb', line 199 def proxies raise NotImplementedError end |
#rhost ⇒ Object
Returns the target host
157 158 159 |
# File 'lib/metasploit/framework/tcp/client.rb', line 157 def rhost raise NotImplementedError end |
#rport ⇒ Object
Returns the remote port
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
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 |
#ssl ⇒ Object
Returns the boolean indicating SSL
185 186 187 |
# File 'lib/metasploit/framework/tcp/client.rb', line 185 def ssl raise NotImplementedError end |
#ssl_version ⇒ Object
Returns the string indicating SSLVersion
192 193 194 |
# File 'lib/metasploit/framework/tcp/client.rb', line 192 def ssl_version raise NotImplementedError end |