Skip to content

Commit f6cdbb6

Browse files
committed
Land rapid7#5706, Kiwi creds_* -o write to file
2 parents ea4a7d9 + 4fc258e commit f6cdbb6

File tree

2 files changed

+131
-94
lines changed
  • lib/rex/post/meterpreter

2 files changed

+131
-94
lines changed

lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rex/post/meterpreter/extensions/kiwi/tlv'
44
require 'rexml/document'
5+
require 'set'
56

67
module Rex
78
module Post
@@ -283,9 +284,12 @@ def scrape_passwords(pwd_id)
283284
request.add_tlv(TLV_TYPE_KIWI_PWD_ID, pwd_id)
284285
response = client.send_request(request)
285286

287+
# keep track of unique entries
288+
uniques = Set.new
289+
286290
results = []
287291
response.each(TLV_TYPE_KIWI_PWD_RESULT) do |r|
288-
results << {
292+
result = {
289293
:username => r.get_tlv_value(TLV_TYPE_KIWI_PWD_USERNAME),
290294
:domain => r.get_tlv_value(TLV_TYPE_KIWI_PWD_DOMAIN),
291295
:password => r.get_tlv_value(TLV_TYPE_KIWI_PWD_PASSWORD),
@@ -294,6 +298,17 @@ def scrape_passwords(pwd_id)
294298
:lm => r.get_tlv_value(TLV_TYPE_KIWI_PWD_LMHASH),
295299
:ntlm => r.get_tlv_value(TLV_TYPE_KIWI_PWD_NTLMHASH)
296300
}
301+
302+
# generate a "unique" set identifier based on the domain/user/pass. We
303+
# don't use the whole object because the auth hi/low might be different
304+
# but everything else might be the same. Join with non-printable, as this
305+
# can't appear in passwords anyway.
306+
set_id = [result[:domain], result[:username], result[:password]].join("\x01")
307+
308+
# only add to the result list if we don't already have it
309+
if uniques.add?(set_id)
310+
results << result
311+
end
297312
end
298313

299314
return results

0 commit comments

Comments
 (0)