Skip to content

Commit 2ae9e39

Browse files
committed
Land rapid7#5376, Report ipmi_dumphashes credentials with create_credential_login
2 parents f81c08e + e1f1077 commit 2ae9e39

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed

modules/auxiliary/scanner/ipmi/ipmi_dumphashes.rb

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def run_host(ip)
7171
passwords << ""
7272
passwords = passwords.uniq
7373

74-
7574
self.udp_sock = Rex::Socket::Udp.create({'Context' => {'Msf' => framework, 'MsfExploit' => self}})
7675
add_socket(self.udp_sock)
7776

@@ -180,18 +179,8 @@ def run_host(ip)
180179
write_output_files(rhost, username, sha1_salt, sha1_hash)
181180

182181
# Write the rakp hash to the database
183-
report_auth_info(
184-
:host => rhost,
185-
:port => rport,
186-
:proto => 'udp',
187-
:sname => 'ipmi',
188-
:user => username,
189-
:pass => "#{sha1_salt}:#{sha1_hash}",
190-
:source_type => "captured",
191-
:active => true,
192-
:type => 'rakp_hmac_sha1_hash'
193-
)
194-
182+
hash = "#{rhost} #{username}:$rakp$#{sha1_salt}$#{sha1_hash}"
183+
core_id = report_hash(username, hash)
195184
# Write the vulnerability to the database
196185
unless reported_vuln
197186
report_vuln(
@@ -216,17 +205,7 @@ def run_host(ip)
216205
print_good("#{rhost}:#{rport} - IPMI - Hash for user '#{username}' matches password '#{pass}'")
217206

218207
# Report the clear-text credential to the database
219-
report_auth_info(
220-
:host => rhost,
221-
:port => rport,
222-
:proto => 'udp',
223-
:sname => 'ipmi',
224-
:user => username,
225-
:pass => pass,
226-
:source_type => "cracked",
227-
:active => true,
228-
:type => 'password'
229-
)
208+
report_cracked_cred(username, pass, core_id)
230209
break
231210
end
232211
end
@@ -265,6 +244,45 @@ def write_output_files(rhost, username, sha1_salt, sha1_hash)
265244
end
266245
end
267246

247+
def service_data
248+
{
249+
address: rhost,
250+
port: rport,
251+
service_name: 'ipmi',
252+
protocol: 'udp',
253+
workspace_id: myworkspace_id
254+
}
255+
end
256+
257+
def report_hash(user, hash)
258+
credential_data = {
259+
module_fullname: self.fullname,
260+
origin_type: :service,
261+
private_data: hash,
262+
private_type: :nonreplayable_hash,
263+
jtr_format: 'rakp',
264+
username: user,
265+
}.merge(service_data)
266+
267+
login_data = {
268+
core: create_credential(credential_data),
269+
status: Metasploit::Model::Login::Status::UNTRIED
270+
}.merge(service_data)
271+
272+
cl = create_credential_login(login_data)
273+
cl.core_id
274+
end
275+
276+
def report_cracked_cred(user, password, core_id)
277+
cred_data = {
278+
core_id: core_id,
279+
username: user,
280+
password: password
281+
}
282+
283+
create_cracked_credential(cred_data)
284+
end
285+
268286
#
269287
# Helper methods (these didn't quite fit with existing mixins)
270288
#
@@ -292,5 +310,4 @@ def rhost
292310
def rport
293311
datastore['RPORT']
294312
end
295-
296313
end

0 commit comments

Comments
 (0)