@@ -2,6 +2,9 @@ module Msf
2
2
module Util
3
3
module WindowsCryptoHelpers
4
4
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
+
5
8
#class Error < RuntimeError; end
6
9
#class Unknown < Error; end
7
10
@@ -200,28 +203,26 @@ def decrypt_user_hash(rid, hboot_key, enc_hash, pass, default)
200
203
def decrypt_user_key ( hboot_key , user_v , rid )
201
204
sam_lmpass = "LMPASSWORD\x00 "
202
205
sam_ntpass = "NTPASSWORD\x00 "
203
- sam_empty_lm = [ 'aad3b435b51404eeaad3b435b51404ee' ] . pack ( 'H*' )
204
- sam_empty_nt = [ '31d6cfe0d16ae931b73c59d7e0c089c0' ] . pack ( 'H*' )
205
206
206
207
# TODO: use a proper structure for V data, instead of unpacking directly
207
208
hashlm_off = user_v [ 0x9c , 4 ] &.unpack ( 'V' ) &.first
208
209
hashlm_len = user_v [ 0xa0 , 4 ] &.unpack ( 'V' ) &.first
209
210
if hashlm_off && hashlm_len
210
211
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 )
212
213
else
213
214
elog ( 'decrypt_user_key: Unable to extract LM hash, using empty LM hash instead' )
214
- hashlm = sam_empty_lm
215
+ hashlm = EMPTY_LM
215
216
end
216
217
217
218
hashnt_off = user_v [ 0xa8 , 4 ] &.unpack ( 'V' ) &.first
218
219
hashnt_len = user_v [ 0xac , 4 ] &.unpack ( 'V' ) &.first
219
220
if hashnt_off && hashnt_len
220
221
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 )
222
223
else
223
224
elog ( 'decrypt_user_key: Unable to extract NT hash, using empty NT hash instead' )
224
- hashnt = sam_empty_nt
225
+ hashnt = EMPTY_NT
225
226
end
226
227
227
228
[ hashnt , hashlm ]
0 commit comments