Class: Rex::Proto::Kerberos::Client
- Inherits:
-
Object
- Object
- Rex::Proto::Kerberos::Client
- Defined in:
- lib/rex/proto/kerberos/client.rb
Overview
This class is a representation of a kerberos client.
Instance Attribute Summary collapse
-
#connection ⇒ IO
The connection established through Rex sockets.
-
#context ⇒ Hash
The Msf context where the connection belongs to.
-
#host ⇒ String
The kerberos server host.
-
#port ⇒ Integer
The kerberos server port.
-
#protocol ⇒ String
The transport protocol used (tcp/udp).
-
#proxies ⇒ String?
The proxy directive to use for the socket.
-
#timeout ⇒ Integer
The connect / read timeout.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the connection.
-
#connect ⇒ Rex::Socket::Tcp
Creates a connection through a Rex socket.
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
-
#recv_response ⇒ <Rex::Proto::Kerberos::Model::KrbError, Rex::Proto::Kerberos::Model::KdcResponse>
Receives a kerberos response through the connection.
-
#send_recv(req) ⇒ <Rex::Proto::Kerberos::Model::KrbError, Rex::Proto::Kerberos::Model::KdcResponse>
Sends a kerberos request, and reads the response through the connection.
-
#send_request(req) ⇒ Integer
Sends a kerberos request through the connection.
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
33 34 35 36 37 38 39 40 |
# File 'lib/rex/proto/kerberos/client.rb', line 33 def initialize(opts = {}) self.host = opts[:host] self.port = (opts[:port] || 88).to_i self.proxies = opts[:proxies] self.timeout = (opts[:timeout] || 10).to_i self.protocol = opts[:protocol] || 'tcp' self.context = opts[:context] || {} end |
Instance Attribute Details
#connection ⇒ IO
Returns The connection established through Rex sockets.
28 29 30 |
# File 'lib/rex/proto/kerberos/client.rb', line 28 def connection @connection end |
#context ⇒ Hash
Returns The Msf context where the connection belongs to.
31 32 33 |
# File 'lib/rex/proto/kerberos/client.rb', line 31 def context @context end |
#host ⇒ String
Returns The kerberos server host.
12 13 14 |
# File 'lib/rex/proto/kerberos/client.rb', line 12 def host @host end |
#port ⇒ Integer
Returns The kerberos server port.
15 16 17 |
# File 'lib/rex/proto/kerberos/client.rb', line 15 def port @port end |
#protocol ⇒ String
Returns The transport protocol used (tcp/udp).
25 26 27 |
# File 'lib/rex/proto/kerberos/client.rb', line 25 def protocol @protocol end |
#proxies ⇒ String?
Returns The proxy directive to use for the socket.
18 19 20 |
# File 'lib/rex/proto/kerberos/client.rb', line 18 def proxies @proxies end |
#timeout ⇒ Integer
Returns The connect / read timeout.
21 22 23 |
# File 'lib/rex/proto/kerberos/client.rb', line 21 def timeout @timeout end |
Instance Method Details
#close ⇒ Object
Closes the connection
62 63 64 65 66 67 68 69 |
# File 'lib/rex/proto/kerberos/client.rb', line 62 def close if connection connection.shutdown connection.close unless connection.closed? end self.connection = nil end |
#connect ⇒ Rex::Socket::Tcp
Creates a connection through a Rex socket
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rex/proto/kerberos/client.rb', line 46 def connect return connection if connection raise ArgumentError, 'Missing remote address' unless self.host && self.port case protocol when 'tcp' self.connection = create_tcp_connection when 'udp' raise ::NotImplementedError, 'Kerberos Client: UDP not supported' else raise ::RuntimeError, 'Kerberos Client: unknown transport protocol' end connection end |
#recv_response ⇒ <Rex::Proto::Kerberos::Model::KrbError, Rex::Proto::Kerberos::Model::KdcResponse>
Receives a kerberos response through the connection
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/rex/proto/kerberos/client.rb', line 100 def recv_response if connection.nil? raise ::RuntimeError, 'Kerberos Client: connection not established' end res = nil case protocol when 'tcp' res = recv_response_tcp when 'udp' res = recv_response_udp else raise ::RuntimeError, 'Kerberos Client: unknown transport protocol' end res end |
#send_recv(req) ⇒ <Rex::Proto::Kerberos::Model::KrbError, Rex::Proto::Kerberos::Model::KdcResponse>
Sends a kerberos request, and reads the response through the connection
124 125 126 127 128 129 |
# File 'lib/rex/proto/kerberos/client.rb', line 124 def send_recv(req) send_request(req) res = recv_response res end |
#send_request(req) ⇒ Integer
Sends a kerberos request through the connection
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rex/proto/kerberos/client.rb', line 77 def send_request(req) connect sent = 0 case protocol when 'tcp' sent = send_request_tcp(req) when 'udp' sent = send_request_udp(req) else raise ::RuntimeError, 'Kerberos Client: unknown transport protocol' end sent end |