|
2 | 2 | // script by cyclone to check plaintexts against Umbraco HMACSHA256 hashes
|
3 | 3 | // while slow, script supports multi-gigabyte wordlists
|
4 | 4 | // 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) |
7 | 7 | // tested with php7.4 & php8.2
|
8 |
| -// version 2022-12-10.1500 |
| 8 | +// version 2022-12-14.1200 |
9 | 9 |
|
10 | 10 | echo "\e[H\e[J"; // clear screen
|
11 | 11 | $t=time(); // define time
|
@@ -49,27 +49,31 @@ function getLines($file) {
|
49 | 49 | $line_pass_utf16le = mb_convert_encoding($line, "UTF-16LE"); // convert $line to UTF-16LE
|
50 | 50 | $count_lines++; // count lines processed
|
51 | 51 | 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 | + } |
73 | 77 | }
|
74 | 78 | }
|
75 | 79 | }
|
|
0 commit comments