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 ⇒ Fixnum
The kerberos server port.
-
#protocol ⇒ String
The transport protocol used (tcp/udp).
-
#timeout ⇒ Fixnum
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) ⇒ Fixnum
Sends a kerberos request through the connection.
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 |
# File 'lib/rex/proto/kerberos/client.rb', line 28 def initialize(opts = {}) self.host = opts[:host] self.port = (opts[:port] || 88).to_i 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.
23 24 25 |
# File 'lib/rex/proto/kerberos/client.rb', line 23 def connection @connection end |
#context ⇒ Hash
Returns The Msf context where the connection belongs to.
26 27 28 |
# File 'lib/rex/proto/kerberos/client.rb', line 26 def context @context end |
#host ⇒ String
Returns The kerberos server host.
10 11 12 |
# File 'lib/rex/proto/kerberos/client.rb', line 10 def host @host end |
#port ⇒ Fixnum
Returns The kerberos server port.
13 14 15 |
# File 'lib/rex/proto/kerberos/client.rb', line 13 def port @port end |
#protocol ⇒ String
Returns The transport protocol used (tcp/udp).
20 21 22 |
# File 'lib/rex/proto/kerberos/client.rb', line 20 def protocol @protocol end |
#timeout ⇒ Fixnum
Returns The connect / read timeout.
16 17 18 |
# File 'lib/rex/proto/kerberos/client.rb', line 16 def timeout @timeout end |
Instance Method Details
#close ⇒ Object
Closes the connection
56 57 58 59 60 61 62 63 |
# File 'lib/rex/proto/kerberos/client.rb', line 56 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rex/proto/kerberos/client.rb', line 40 def connect return connection if connection 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
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rex/proto/kerberos/client.rb', line 94 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
118 119 120 121 122 123 |
# File 'lib/rex/proto/kerberos/client.rb', line 118 def send_recv(req) send_request(req) res = recv_response res end |
#send_request(req) ⇒ Fixnum
Sends a kerberos request through the connection
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rex/proto/kerberos/client.rb', line 71 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 |