<?php
#########################################################
/* Configuration */
// this is the hash we are trying to crack
define('HASH', '098f6bcd4621d373cade4e832627b4f6');
// algorithm of hash
// see
http://php.net/hash_algos for available algorithms
define('HASH_ALGO', 'md5');
// max length of password to try
define('PASSWORD_MAX_LENGTH', 6);
// available characters to try for password
// uncomment additional charsets for more complex passwords
$charset = 'abcdef';
//$charset .= '0123456789';
#########################################################
$charset_length = strlen($charset);
function check($password)
{
if (hash(HASH_ALGO, $password) == HASH) {
echo 'FOUND MATCH, password: '.$password."\r\n";
exit;
}
}
function recurse($width, $position, $base_string)
{
global $charset, $charset_length;
for ($i = 0; $i < $charset_length; ++$i) {
if ($position < $width - 1) {
recurse($width, $position + 1, $base_string . $charset[$i]);
}
check($base_string . $charset[$i]);
}
}
echo 'target hash: '.HASH."\r\n";
recurse(PASSWORD_MAX_LENGTH, 0, '');
echo "Execution complete, no password found\r\n";
?>
Something like this?