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, Metasploit::Framework::Telnet::Client, Rex::Proto::MSSQL::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.
202 203 204 |
# File 'lib/metasploit/framework/tcp/client.rb', line 202 def sock @sock end |
Instance Method Details
#chost ⇒ Object
Returns the local host for outgoing connections
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
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 |
#cport ⇒ Object
Returns the local port for outgoing connections
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 |
#proxies ⇒ Object
Returns the proxy configuration
198 199 200 |
# File 'lib/metasploit/framework/tcp/client.rb', line 198 def proxies raise NotImplementedError end |
#rhost ⇒ Object
Returns the target host
156 157 158 |
# File 'lib/metasploit/framework/tcp/client.rb', line 156 def rhost raise NotImplementedError end |
#rport ⇒ Object
Returns the remote port
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 |
#ssl ⇒ Object
Returns the boolean indicating SSL
184 185 186 |
# File 'lib/metasploit/framework/tcp/client.rb', line 184 def ssl raise NotImplementedError end |
#ssl_version ⇒ Object
Returns the string indicating SSLVersion
191 192 193 |
# File 'lib/metasploit/framework/tcp/client.rb', line 191 def ssl_version raise NotImplementedError end |