Skip to content

Commit 1d0a3aa

Browse files
committed
[FixRM rapid7#8525] undefined method `+' for nil:NilClass in enum_ie
Looks like for some reason if CryptUnprotectData fails, the decrypt_reg() method will return "". And when you unpack "", you produce an array of nils. Since you cannot add something to nil, this should cause an "undefined method `+' for nil:NilClass" error. This will check if we get an array of nils, we jump to the next iteration.
1 parent 36165cb commit 1d0a3aa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/post/windows/gather/enum_ie.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ def run
321321
dec = decrypt_reg(url, data)
322322
#decode data and add to creds array
323323
header = dec.unpack("VVVVVV")
324+
325+
# If CryptUnprotectData fails, decrypt_reg() will return "", and unpack() will end up
326+
# returning an array of nils. If this happens, we can cause an "undefined method
327+
# `+' for NilClass." when we try to calculate the offset, and this causes the module to die.
328+
next if header == [nil, nil, nil, nil, nil, nil]
329+
324330
offset = header[0] + header[1] #offset to start of data
325331
cnt = header[5]/2 # of username/password combinations
326332
secrets = dec[offset,dec.length-(offset + 1)].split("\x00\x00")

0 commit comments

Comments
 (0)