PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : kann mir einer erklären wie das funktioniert ? :-)



Gribbler
12.01.2012, 05:06
<?php
/*
* Thanks to Robert Green for this script he wrote in python
* http://www.rbgrn.net/blog/2007/09/how-to-write-a-brute-force-password-cracker.html
* I took what we wrote and ported this to PHP
*
* This script was written for PHP 5, but should work with
* PHP 4 if the hash() function is replaced with md5() or something else
*/

################################################## #######
/* 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', 4);


// available characters to try for password
// uncomment additional charsets for more complex passwords
$charset = 'abcdefghijklmnopqrstuvwxyz';
//$charset .= '0123456789';
//$charset .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
//$charset .= '~`!@#$%^&*()-_\/\'";:,.+=<>? ';
################################################## #######
$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";


?>




ist ein brute-force-pass-cracker-md5-hash php script

Freak1936
12.01.2012, 06:49
Ich hab es mal probiert nen bissen mit Worten auszudrücken was da passiert, bin ich kein PHP Ass aber ich interpretiere den source so (config ist ja selbst erklärend):

<?php
/*
* Thanks to Robert Green for this script he wrote in python
* http://www.rbgrn.net/blog/2007/09/ho...d-cracker.html (http://www.rbgrn.net/blog/2007/09/how-to-write-a-brute-force-password-cracker.html)
* I took what we wrote and ported this to PHP
*
* This script was written for PHP 5, but should work with
* PHP 4 if the hash() function is replaced with md5() or something else
*/

################################################## #######
/* 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', 4);


// available characters to try for password
// uncomment additional charsets for more complex passwords
$charset = 'abcdefghijklmnopqrstuvwxyz';
//$charset .= '0123456789';
//$charset .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
//$charset .= '~`!@#$%^&*()-_\/\'";:,.+=<>? ';
################################################## #######
$charset_length = strlen($charset);

/*
Hier wird wird der $password string gehashed und mit dem gesuchten HASH verglichen, wenn gleich kommt das echo, wenn ungleich wird die funktion ohne ergebinss geschlossen
*/
function check($password)
{
if (hash(HASH_ALGO, $password) == HASH) {
echo 'FOUND MATCH, password: '.$password."\r\n";
exit;
}
}

/*
Hier werden die $password strings erstellt, abhängig von $charset(oben #bei Config kannst du wählen aus groß/klein, Zahlen und Sonderzeichen).
Die Schleife geht jetzt die ganzen gewählten $charsets[$i] durch und #ersetzt sie im $base_string. Abhängig von $position und $width wird die #neue $position und/oder ein andererer $charset[x] errechnet.
Das ganze wird jetzt mit check() auf übereinstimmung geprüft und die Schleife geht weiter bis $i < $charset_length nicht mehr erfüllt wird
*/
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";


?>

sn0w
12.01.2012, 10:10
Warum packt ihr das nicht in code tags oder schmeißt das ganze auf eine nopaste seite?

Es werden verschiedene Passwörter generiert die dann gehashed werden und dann wird überprüft ob der hash dem gesuchten entspricht.