Skip to content

Commit ea77216

Browse files
committed
Land rapid7#7248, CredEnumerateA fix for enum_cred_store
2 parents 43a9b2f + bc6a529 commit ea77216

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

modules/post/windows/gather/credentials/enum_cred_store.rb

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,25 @@ def get_creds
178178
credentials = []
179179
#call credenumerate to get the ptr needed
180180
adv32 = session.railgun.advapi32
181-
ret = adv32.CredEnumerateA(nil,0,4,4)
182-
p_to_arr = ret["Credentials"].unpack("V")
183-
if is_86
184-
count = ret["Count"]
185-
arr_len = count * 4
181+
begin
182+
ret = adv32.CredEnumerateA(nil,0,4,4)
183+
rescue Rex::Post::Meterpreter::RequestError => e
184+
print_error("This module requires WinXP or higher")
185+
print_error("CredEnumerateA() failed: #{e.class} #{e}")
186+
ret = nil
187+
end
188+
if ret.nil?
189+
count = 0
190+
arr_len = 0
186191
else
187-
count = ret["Count"] & 0x00000000ffffffff
188-
arr_len = count * 8
192+
p_to_arr = ret["Credentials"].unpack("V")
193+
if is_86
194+
count = ret["Count"]
195+
arr_len = count * 4
196+
else
197+
count = ret["Count"] & 0x00000000ffffffff
198+
arr_len = count * 8
199+
end
189200
end
190201

191202
#tell user what's going on

0 commit comments

Comments
 (0)