Skip to content

Commit db5d83a

Browse files
committed
Move namespaces
1 parent 5e39814 commit db5d83a

File tree

11 files changed

+807
-823
lines changed

11 files changed

+807
-823
lines changed

lib/msf/core.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ module Msf
7272
require 'msf/http/typo3'
7373
require 'msf/http/jboss'
7474

75-
# Kerberos Support
76-
require 'msf/kerberos/client'
77-
7875
# Drivers
7976
require 'msf/core/exploit_driver'
8077

Lines changed: 120 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,137 @@
11
# -*- coding: binary -*-
22
require 'rex/proto/kerberos'
33

4-
module Msf
5-
module Kerberos
6-
module Client
7-
require 'msf/kerberos/client/base'
8-
require 'msf/kerberos/client/as_request'
9-
require 'msf/kerberos/client/as_response'
10-
require 'msf/kerberos/client/tgs_request'
11-
require 'msf/kerberos/client/tgs_response'
12-
require 'msf/kerberos/client/pac'
13-
require 'msf/kerberos/client/cache_credential'
14-
15-
include Msf::Kerberos::Client::Base
16-
include Msf::Kerberos::Client::AsRequest
17-
include Msf::Kerberos::Client::AsResponse
18-
include Msf::Kerberos::Client::TgsRequest
19-
include Msf::Kerberos::Client::TgsResponse
20-
include Msf::Kerberos::Client::Pac
21-
include Msf::Kerberos::Client::CacheCredential
22-
23-
# @!attribute client
24-
# @return [Rex::Proto::Kerberos::Client] The kerberos client
25-
attr_accessor :client
26-
27-
def initialize(info = {})
28-
super
29-
30-
register_options(
31-
[
32-
Opt::RHOST,
33-
Opt::RPORT(88),
34-
OptInt.new('Timeout', [true, 'The TCP timeout to establish connection and read data', 10])
35-
], self.class
36-
)
37-
end
4+
module Msf::Exploit::Remote::Kerberos
5+
module Client
6+
require 'msf/core/exploit/kerberos/client/base'
7+
require 'msf/core/exploit/kerberos/client/as_request'
8+
require 'msf/core/exploit/kerberos/client/as_response'
9+
require 'msf/core/exploit/kerberos/client/tgs_request'
10+
require 'msf/core/exploit/kerberos/client/tgs_response'
11+
require 'msf/core/exploit/kerberos/client/pac'
12+
require 'msf/core/exploit/kerberos/client/cache_credential'
13+
14+
include Msf::Exploit::Remote::Kerberos::Client::Base
15+
include Msf::Exploit::Remote::Kerberos::Client::AsRequest
16+
include Msf::Exploit::Remote::Kerberos::Client::AsResponse
17+
include Msf::Exploit::Remote::Kerberos::Client::TgsRequest
18+
include Msf::Exploit::Remote::Kerberos::Client::TgsResponse
19+
include Msf::Exploit::Remote::Kerberos::Client::Pac
20+
include Msf::Exploit::Remote::Kerberos::Client::CacheCredential
21+
22+
# @!attribute client
23+
# @return [Rex::Proto::Kerberos::Client] The kerberos client
24+
attr_accessor :client
25+
26+
def initialize(info = {})
27+
super
28+
29+
register_options(
30+
[
31+
Opt::RHOST,
32+
Opt::RPORT(88),
33+
OptInt.new('Timeout', [true, 'The TCP timeout to establish connection and read data', 10])
34+
], self.class
35+
)
36+
end
3837

39-
# Returns the target host
40-
#
41-
# @return [String]
42-
def rhost
43-
datastore['RHOST']
44-
end
38+
# Returns the target host
39+
#
40+
# @return [String]
41+
def rhost
42+
datastore['RHOST']
43+
end
4544

46-
# Returns the remote port
47-
#
48-
# @return [Fixnum]
49-
def rport
50-
datastore['RPORT']
51-
end
45+
# Returns the remote port
46+
#
47+
# @return [Fixnum]
48+
def rport
49+
datastore['RPORT']
50+
end
5251

53-
# Returns the TCP timeout
54-
#
55-
# @return [Fixnum]
56-
def timeout
57-
datastore['Timeout']
58-
end
52+
# Returns the TCP timeout
53+
#
54+
# @return [Fixnum]
55+
def timeout
56+
datastore['Timeout']
57+
end
5958

60-
# Returns the kdc peer
61-
#
62-
# @return [String]
63-
def peer
64-
"#{rhost}:#{rport}"
65-
end
59+
# Returns the kdc peer
60+
#
61+
# @return [String]
62+
def peer
63+
"#{rhost}:#{rport}"
64+
end
6665

67-
# Creates a kerberos connection
68-
#
69-
# @param opts [Hash{Symbol => <String, Fixnum>}]
70-
# @option opts [String] :rhost
71-
# @option opts [<String, Fixnum>] :rport
72-
# @return [Rex::Proto::Kerberos::Client]
73-
def connect(opts={})
74-
kerb_client = Rex::Proto::Kerberos::Client.new(
75-
host: opts[:rhost] || rhost,
76-
port: (opts[:rport] || rport).to_i,
77-
timeout: (opts[:timeout] || timeout).to_i,
78-
context:
79-
{
80-
'Msf' => framework,
81-
'MsfExploit' => self,
82-
},
83-
protocol: 'tcp'
84-
)
85-
86-
disconnect if client
87-
self.client = kerb_client
88-
89-
kerb_client
90-
end
66+
# Creates a kerberos connection
67+
#
68+
# @param opts [Hash{Symbol => <String, Fixnum>}]
69+
# @option opts [String] :rhost
70+
# @option opts [<String, Fixnum>] :rport
71+
# @return [Rex::Proto::Kerberos::Client]
72+
def connect(opts={})
73+
kerb_client = Rex::Proto::Kerberos::Client.new(
74+
host: opts[:rhost] || rhost,
75+
port: (opts[:rport] || rport).to_i,
76+
timeout: (opts[:timeout] || timeout).to_i,
77+
context:
78+
{
79+
'Msf' => framework,
80+
'MsfExploit' => self,
81+
},
82+
protocol: 'tcp'
83+
)
84+
85+
disconnect if client
86+
self.client = kerb_client
87+
88+
kerb_client
89+
end
9190

92-
# Disconnects the Kerberos client
93-
#
94-
# @param kerb_client [Rex::Proto::Kerberos::Client] the client to disconnect
95-
def disconnect(kerb_client = client)
96-
kerb_client.close if kerb_client
91+
# Disconnects the Kerberos client
92+
#
93+
# @param kerb_client [Rex::Proto::Kerberos::Client] the client to disconnect
94+
def disconnect(kerb_client = client)
95+
kerb_client.close if kerb_client
9796

98-
if kerb_client == client
99-
self.client = nil
100-
end
97+
if kerb_client == client
98+
self.client = nil
10199
end
100+
end
102101

103-
# Performs cleanup as necessary, disconnecting the Kerberos client
104-
# if it's still established.
105-
def cleanup
106-
super
107-
disconnect
108-
end
102+
# Performs cleanup as necessary, disconnecting the Kerberos client
103+
# if it's still established.
104+
def cleanup
105+
super
106+
disconnect
107+
end
109108

110-
# Sends a kerberos AS request and reads the response
111-
#
112-
# @param opts [Hash]
113-
# @return [Rex::Proto::Kerberos::Model::KdcResponse]
114-
# @see Msf::Kerberos::Client::AsRequest#build_as_request
115-
# @see Rex::Proto::Kerberos::Model::KdcResponse
116-
def send_request_as(opts = {})
117-
connect(opts)
118-
req = build_as_request(opts)
119-
res = client.send_recv(req)
120-
disconnect
121-
res
122-
end
109+
# Sends a kerberos AS request and reads the response
110+
#
111+
# @param opts [Hash]
112+
# @return [Rex::Proto::Kerberos::Model::KdcResponse]
113+
# @see Msf::Kerberos::Client::AsRequest#build_as_request
114+
# @see Rex::Proto::Kerberos::Model::KdcResponse
115+
def send_request_as(opts = {})
116+
connect(opts)
117+
req = build_as_request(opts)
118+
res = client.send_recv(req)
119+
disconnect
120+
res
121+
end
123122

124-
# Sends a kerberos AS request and reads the response
125-
#
126-
# @param opts [Hash]
127-
# @return [Rex::Proto::Kerberos::Model::KdcResponse]
128-
# @see Msf::Kerberos::Client::TgsRequest#build_tgs_request
129-
# @see Rex::Proto::Kerberos::Model::KdcResponse
130-
def send_request_tgs(opts = {})
131-
connect(opts)
132-
req = build_tgs_request(opts)
133-
res = client.send_recv(req)
134-
disconnect
135-
res
136-
end
123+
# Sends a kerberos AS request and reads the response
124+
#
125+
# @param opts [Hash]
126+
# @return [Rex::Proto::Kerberos::Model::KdcResponse]
127+
# @see Msf::Kerberos::Client::TgsRequest#build_tgs_request
128+
# @see Rex::Proto::Kerberos::Model::KdcResponse
129+
def send_request_tgs(opts = {})
130+
connect(opts)
131+
req = build_tgs_request(opts)
132+
res = client.send_recv(req)
133+
disconnect
134+
res
137135
end
138136
end
139137
end

0 commit comments

Comments
 (0)