@@ -2,6 +2,9 @@ module Msf
22module Util
33module WindowsCryptoHelpers
44
5+ EMPTY_LM = "\xaa \xd3 \xb4 \x35 \xb5 \x14 \x04 \xee \xaa \xd3 \xb4 \x35 \xb5 \x14 \x04 \xee " . b
6+ EMPTY_NT = "\x31 \xd6 \xcf \xe0 \xd1 \x6a \xe9 \x31 \xb7 \x3c \x59 \xd7 \xe0 \xc0 \x89 \xc0 " . b
7+
58 #class Error < RuntimeError; end
69 #class Unknown < Error; end
710
@@ -200,28 +203,26 @@ def decrypt_user_hash(rid, hboot_key, enc_hash, pass, default)
200203 def decrypt_user_key ( hboot_key , user_v , rid )
201204 sam_lmpass = "LMPASSWORD\x00 "
202205 sam_ntpass = "NTPASSWORD\x00 "
203- sam_empty_lm = [ 'aad3b435b51404eeaad3b435b51404ee' ] . pack ( 'H*' )
204- sam_empty_nt = [ '31d6cfe0d16ae931b73c59d7e0c089c0' ] . pack ( 'H*' )
205206
206207 # TODO: use a proper structure for V data, instead of unpacking directly
207208 hashlm_off = user_v [ 0x9c , 4 ] &.unpack ( 'V' ) &.first
208209 hashlm_len = user_v [ 0xa0 , 4 ] &.unpack ( 'V' ) &.first
209210 if hashlm_off && hashlm_len
210211 hashlm_enc = user_v [ hashlm_off + 0xcc , hashlm_len ]
211- hashlm = decrypt_user_hash ( rid , hboot_key , hashlm_enc , sam_lmpass , sam_empty_lm )
212+ hashlm = decrypt_user_hash ( rid , hboot_key , hashlm_enc , sam_lmpass , EMPTY_LM )
212213 else
213214 elog ( 'decrypt_user_key: Unable to extract LM hash, using empty LM hash instead' )
214- hashlm = sam_empty_lm
215+ hashlm = EMPTY_LM
215216 end
216217
217218 hashnt_off = user_v [ 0xa8 , 4 ] &.unpack ( 'V' ) &.first
218219 hashnt_len = user_v [ 0xac , 4 ] &.unpack ( 'V' ) &.first
219220 if hashnt_off && hashnt_len
220221 hashnt_enc = user_v [ hashnt_off + 0xcc , hashnt_len ]
221- hashnt = decrypt_user_hash ( rid , hboot_key , hashnt_enc , sam_ntpass , sam_empty_nt )
222+ hashnt = decrypt_user_hash ( rid , hboot_key , hashnt_enc , sam_ntpass , EMPTY_NT )
222223 else
223224 elog ( 'decrypt_user_key: Unable to extract NT hash, using empty NT hash instead' )
224- hashnt = sam_empty_nt
225+ hashnt = EMPTY_NT
225226 end
226227
227228 [ hashnt , hashlm ]
0 commit comments