mirror of
https://github.com/hashcat/hashcat.git
synced 2025-05-08 09:58:49 +00:00
Fixed verify mechanism + cosmetic changes in global test.pl
This commit is contained in:
parent
7ff09c6710
commit
80927f6f66
@ -2671,8 +2671,7 @@ sub verify
|
|||||||
|
|
||||||
$salt = substr ($hash_in, length ('$DPAPImk$'));
|
$salt = substr ($hash_in, length ('$DPAPImk$'));
|
||||||
|
|
||||||
$param = $iv;
|
$param = $cipher;
|
||||||
$param2 = $cipher;
|
|
||||||
|
|
||||||
next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in})));
|
next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in})));
|
||||||
}
|
}
|
||||||
@ -3053,7 +3052,7 @@ sub verify
|
|||||||
}
|
}
|
||||||
elsif ($mode == 15300)
|
elsif ($mode == 15300)
|
||||||
{
|
{
|
||||||
$hash_out = gen_hash ($mode, $word, $salt, $iter, $param, $param2);
|
$hash_out = gen_hash ($mode, $word, $salt, $iter, $param);
|
||||||
|
|
||||||
$len = length $hash_out;
|
$len = length $hash_out;
|
||||||
|
|
||||||
@ -8246,32 +8245,15 @@ END_CODE
|
|||||||
|
|
||||||
my $SID = $salt_arr[2];
|
my $SID = $salt_arr[2];
|
||||||
|
|
||||||
my $cipher_algorithm;
|
my $cipher_algorithm = $salt_arr[3];
|
||||||
|
|
||||||
my $hash_algorithm;
|
my $hash_algorithm = $salt_arr[4];
|
||||||
|
|
||||||
my $iterations = $salt_arr[3];
|
my $iterations = $salt_arr[5];
|
||||||
|
|
||||||
my $salt = pack ("H*", $salt_arr[4]);
|
my $salt = pack ("H*", $salt_arr[6]);
|
||||||
|
|
||||||
my $cipher_len;
|
my $cipher_len = $salt_arr[7];
|
||||||
|
|
||||||
if ($version == 1)
|
|
||||||
{
|
|
||||||
$cipher_algorithm = "des3";
|
|
||||||
|
|
||||||
$hash_algorithm = "sha1";
|
|
||||||
|
|
||||||
$cipher_len = 208;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$cipher_algorithm = "aes256";
|
|
||||||
|
|
||||||
$hash_algorithm = "sha512";
|
|
||||||
|
|
||||||
$cipher_len = 288;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $cipher;
|
my $cipher;
|
||||||
|
|
||||||
@ -8330,12 +8312,8 @@ END_CODE
|
|||||||
|
|
||||||
if (defined $additional_param)
|
if (defined $additional_param)
|
||||||
{
|
{
|
||||||
$salt = pack ("H*", $additional_param);
|
$cipher = pack ("H*", $additional_param);
|
||||||
}
|
my $computed_hmac = "";
|
||||||
|
|
||||||
if (defined $additional_param2)
|
|
||||||
{
|
|
||||||
$cipher = $additional_param2;
|
|
||||||
|
|
||||||
if ($version == 1)
|
if ($version == 1)
|
||||||
{
|
{
|
||||||
@ -8370,7 +8348,6 @@ END_CODE
|
|||||||
});
|
});
|
||||||
|
|
||||||
# let's compute a 3DES-EDE-CBC decryption
|
# let's compute a 3DES-EDE-CBC decryption
|
||||||
$iv = substr ($cipher, 0, 8);
|
|
||||||
|
|
||||||
my $out1;
|
my $out1;
|
||||||
my $out2;
|
my $out2;
|
||||||
@ -8389,7 +8366,16 @@ END_CODE
|
|||||||
$iv = substr ($cipher, $k * 8, 8);
|
$iv = substr ($cipher, $k * 8, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($expected_cleartext != $cleartext)
|
$last_key = substr ($expected_cleartext, length ($expected_cleartext) - 64, 64);
|
||||||
|
$hmacSalt = substr ($expected_cleartext, 0, 16);
|
||||||
|
$expected_hmac = substr ($expected_cleartext, 16, 20);
|
||||||
|
|
||||||
|
$encKey = hmac_sha1 ($hmacSalt, $user_derivationKey);
|
||||||
|
$computed_hmac = hmac_sha1 ($last_key, $encKey);
|
||||||
|
|
||||||
|
$cleartext = $expected_cleartext;
|
||||||
|
|
||||||
|
if (unpack ("H*", $expected_hmac) ne unpack ("H*", $computed_hmac))
|
||||||
{
|
{
|
||||||
$cleartext = "0" x 104;
|
$cleartext = "0" x 104;
|
||||||
}
|
}
|
||||||
@ -8409,9 +8395,18 @@ END_CODE
|
|||||||
padding => "null",
|
padding => "null",
|
||||||
});
|
});
|
||||||
|
|
||||||
my $expected_cleartext = $aes->decrypt(pack ("H*", $cipher));
|
my $expected_cleartext = $aes->decrypt ($cipher);
|
||||||
|
|
||||||
if ($expected_cleartext != $cleartext)
|
$last_key = substr ($expected_cleartext, length ($expected_cleartext) - 64, 64);
|
||||||
|
$hmacSalt = substr ($expected_cleartext, 0, 16);
|
||||||
|
$expected_hmac = substr ($expected_cleartext, 16, 64);
|
||||||
|
|
||||||
|
$encKey = hmac_sha512 ($hmacSalt, $user_derivationKey);
|
||||||
|
$computed_hmac = hmac_sha512 ($last_key, $encKey);
|
||||||
|
|
||||||
|
$cleartext = $expected_cleartext;
|
||||||
|
|
||||||
|
if (unpack ("H*", $expected_hmac) ne unpack ("H*", $computed_hmac))
|
||||||
{
|
{
|
||||||
$cleartext = "0" x 144;
|
$cleartext = "0" x 144;
|
||||||
}
|
}
|
||||||
@ -10090,6 +10085,10 @@ sub get_random_dpapimk_salt
|
|||||||
|
|
||||||
my $context = get_random_num (1, 3);
|
my $context = get_random_num (1, 3);
|
||||||
|
|
||||||
|
my $cipher_algo = "";
|
||||||
|
|
||||||
|
my $hash_algo = "";
|
||||||
|
|
||||||
my $iterations;
|
my $iterations;
|
||||||
|
|
||||||
my $SID = sprintf ('S-15-21-%d-%d-%d-%d',
|
my $SID = sprintf ('S-15-21-%d-%d-%d-%d',
|
||||||
@ -10098,13 +10097,27 @@ sub get_random_dpapimk_salt
|
|||||||
get_random_num (400000000,490000000),
|
get_random_num (400000000,490000000),
|
||||||
get_random_num (1000,1999));
|
get_random_num (1000,1999));
|
||||||
|
|
||||||
|
my $cipher_len = 0;
|
||||||
|
|
||||||
if ($version == 1)
|
if ($version == 1)
|
||||||
{
|
{
|
||||||
$iterations = get_random_num (4000, 24000);
|
$iterations = get_random_num (4000, 24000);
|
||||||
|
|
||||||
|
$cipher_algo = "des3";
|
||||||
|
|
||||||
|
$hash_algo = "sha1";
|
||||||
|
|
||||||
|
$cipher_len = 208;
|
||||||
}
|
}
|
||||||
elsif ($version == 2)
|
elsif ($version == 2)
|
||||||
{
|
{
|
||||||
$iterations = get_random_num (8000, 17000);
|
$iterations = get_random_num (8000, 17000);
|
||||||
|
|
||||||
|
$cipher_algo = "aes256";
|
||||||
|
|
||||||
|
$hash_algo = "sha512";
|
||||||
|
|
||||||
|
$cipher_len = 288;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $iv = randbytes (16);
|
my $iv = randbytes (16);
|
||||||
@ -10113,8 +10126,11 @@ sub get_random_dpapimk_salt
|
|||||||
$salt_buf = $version . '*' .
|
$salt_buf = $version . '*' .
|
||||||
$context . '*' .
|
$context . '*' .
|
||||||
$SID . '*' .
|
$SID . '*' .
|
||||||
|
$cipher_algo . '*' .
|
||||||
|
$hash_algo . '*' .
|
||||||
$iterations . '*' .
|
$iterations . '*' .
|
||||||
$iv . '*';
|
$iv . '*' .
|
||||||
|
$cipher_len . '*';
|
||||||
|
|
||||||
return $salt_buf;
|
return $salt_buf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user