Skip to content

Commit 4c54101

Browse files
v2022-12-14.1200
added hash sanity check
1 parent c333330 commit 4c54101

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

crack_umbraco_hmacsha256.php

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// script by cyclone to check plaintexts against Umbraco HMACSHA256 hashes
33
// while slow, script supports multi-gigabyte wordlists
44
// coding this in php was an experiment, so don't cry about how slow it runs
5-
// $hash_file must be formatted as: "salt==:hash=" (without quotes)
6-
// requires php & php-mbstring to be installed (sudo apt install php8.2 php8.2-php-mbstring -y)
5+
// $hash_file must be formatted as: "salt==:hash=" (without quotes), sanity check will skip hashes which don't contain ":"
6+
// requires php & php-mbstring to be installed (ex: sudo apt install php8.2 php8.2-php-mbstring -y)
77
// tested with php7.4 & php8.2
8-
// version 2022-12-10.1500
8+
// version 2022-12-14.1200
99

1010
echo "\e[H\e[J"; // clear screen
1111
$t=time(); // define time
@@ -49,27 +49,31 @@ function getLines($file) {
4949
$line_pass_utf16le = mb_convert_encoding($line, "UTF-16LE"); // convert $line to UTF-16LE
5050
$count_lines++; // count lines processed
5151
foreach($hash_file as $hash_line) {
52-
$hash_array = preg_split("/\:/", $hash_line); // split $hash_file into salt / hash arrays
53-
$salt_split = trim($hash_array[0]); // salt array
54-
$hash_split = trim($hash_array[1]); // hash array
55-
$input = $salt_split . $hash_split; // $input salt/hash for comparison with $output
56-
$salt_proper = base64_decode($salt_split) . base64_decode($salt_split) . base64_decode($salt_split) . base64_decode($salt_split); // process salt
57-
$dgst = hash_hmac("sha256", $line_pass_utf16le, $salt_proper, true); // hmac256
58-
$output = $salt_split . base64_encode($dgst); // compare $output with $imput to see if we've cracked the hash with $line (password)
59-
if (time()-$time >= 60) { // show words / percentage searched every 60 seconds
60-
$percent = ($count_lines / $lines) * 100;
61-
echo "\nProgress: " . $count_lines . " of " . $lines . ", " . number_format((float)$percent, 2, '.', '') . "%" . ", Hashes found: " . $count;
62-
$time = time();
63-
}
64-
if ($output == $input){ // display cracked hashes
65-
echo "\n##################################################################################\n";
66-
echo "Password: $line\n";
67-
echo "salt==hash: ";
68-
echo $salt_split . ":" . base64_encode($dgst);
69-
echo "\n";
70-
$count++; // count +1 hashes found
71-
echo "\nHashes found: " . $count;
72-
echo "\n##################################################################################\n";
52+
if (strpos($hash_line, ':') === false) {
53+
continue 1;
54+
} else {
55+
$hash_array = preg_split("/\:/", $hash_line); // split $hash_file into salt / hash arrays
56+
$salt_split = trim($hash_array[0]); // salt array
57+
$hash_split = trim($hash_array[1]); // hash array
58+
$input = $salt_split . $hash_split; // $input salt/hash for comparison with $output
59+
$salt_proper = base64_decode($salt_split) . base64_decode($salt_split) . base64_decode($salt_split) . base64_decode($salt_split); // process salt
60+
$dgst = hash_hmac("sha256", $line_pass_utf16le, $salt_proper, true); // hmac256
61+
$output = $salt_split . base64_encode($dgst); // compare $output with $input to see if we've cracked the hash with $line (password)
62+
if (time()-$time >= 60) { // show words / percentage searched every 60 seconds
63+
$percent = ($count_lines / $lines) * 100;
64+
echo "\nProgress: " . $count_lines . " of " . $lines . ", " . number_format((float)$percent, 2, '.', '') . "%" . ", Hashes found: " . $count;
65+
$time = time();
66+
}
67+
if ($output == $input){ // display cracked hashes
68+
echo "\n##################################################################################\n";
69+
echo "Password: $line\n";
70+
echo "salt==hash: ";
71+
echo $salt_split . ":" . base64_encode($dgst);
72+
echo "\n";
73+
$count++; // count +1 hashes found
74+
echo "\nHashes found: " . $count;
75+
echo "\n##################################################################################\n";
76+
}
7377
}
7478
}
7579
}

0 commit comments

Comments
 (0)