|
Extremists must be
executed! |
|
Programming time
What's is your favorite time to program?
View poll results
|
|
|
Welcome, dear visiotor, and greetings to United Kingdom
(According to your IP: 23.22.212.158)
|

|
UP Home
MD5 Cracker
Rate the article
Comment the article
Disclaimer:
- A renunciation of any claim to or connection with
- Disavowal
- A statement made to save one's ass
(Definition found at movie "Dogma" )
I am not responsible of any bad usage of this tutorial; I just show it for informational purpose. By reading the text below you agree to assume the entire responsibility of your usage, tests and applications.
Use this tutorial at your own risk.
MD5 (RSA Data Security, Inc. MD5 Message-Digest Algorithm) returns any string to a hash which is a 32-character hexadecimal number. MD5 is a one-way-only encryption algorithm, this means, no encrypted password can be decrypted by anyway. However, there's a little chance to crack an MD5 password.
Let's suppose you are a MySQL databases administrator for example, all the users' passwords you store are encrypted with MD5. A user told you s/he lost her/his password and wants to retrieve it (means s/he gives you the permission, and s/he wants to retrieve one's password, not to replace it [I'm fed up with these warnings, I just want to prove my good intentions ] ). The only method to find this password is to use words from dictionary. You write (or get) some common words that could be qualified to be "passwords", these words are separated by a break line (\n) and make sure the dictionary file is in Unix mode (well, I didn't tested this program on Windows yet) and readable ($ dos2unix dict.txt && chmod 0444 dict.txt).
Let's start:
<?php
$password_to_be_cracked = "098f6bcd4621d373cade4e832627b4f6"; //This is the MD5 result of 'test'
$lines = file('dict.txt');
print "<table width=70%>";
print "<tr>\n
<td>Passwords to test</td>\n
</td>\n
<td>MD5</td>\n
</td>\n
<td>Result</td>\n
</td>\n
</tr>\n
";
for ($i = 0; $i <count($lines); $i++)
{ $lines[$i] = trim($lines[$i]); //To avoid problems when the file is in DOS mode
if (MD5($lines[$i]) ==$password_to_be_cracked) {
echo("<tr>\n
\t<td>\n
Trying ".$lines[$i]."n
\t</td>\n\t
<td>\n
".MD5($lines[$i])."\n
\t</td>nt<td>npassword found! =>t".$lines[$i]."\n\t</td>\n
</tr>");
break;}
else{
print "<tr>\n";
print "\t<td>\n";
print "Trying ".$lines[$i]."\n";
print "\t</td>\n\t<td>\n";
print MD5($lines[$i])."\n";
print "\t</td>\n\t<td>\n";
print "Failedn";
print "\t</td>\n</tr>\n";
}
}
print "</table>";
?>
I strongly recommend you don't use a web browser to execute this program, neither a web server (Apache) in order to optimize memory, the best solution is using php in text mode (for those who don't know it: yes, it is possible!). Type the following in the shell (or dos):
$ php -q cracker.php > result.txt
or
C:phpphp.exe -q > result.txt
This will made an output called result.txt; the -q option is for quiet mode, to not to display header such as "Content-type: text/html".
Or, why not, writing such program with Perl; guess I'm learning this language, and discovering it's not less interesting than PHP.
#!/usr/bin/perl
use Digest::MD5 qw(md5_hex);
$password_to_be_cracked = "098f6bcd4621d373cade4e832627b4f6";#MD5 of 'test'
unless (open(DICT,"dict.txt"))
{
die("Can't open file!");
}
@data = <DICT>;
chop(@data);#To delete the "\n" at the end of each value
$lines = @data;
for ($i = 0; $i<$lines ; $i++)
{
$crypted_data = md5_hex($data[$i]);
print "Trying ".$data[$i];
print "=> ".$crypted_data."\n";
if ($crypted_data eq $password_to_be_cracked)
{
print "Password found: ".$data[$i];
last;
}
print "Failed\n";
}
Nevertheless, it's possible that the word you are looking for doesn't exist in the dictionary; then it's the time to use another method; not optimized at all, but leads to a result. It's based on retrieving the password by combining characters.
For example, to pick out with PHP an alpha-numeric password - 4 characters:
(Remember, use it in text mode)
<?php $password_to_be_cracked = "test";
$crypted_password = MD5($password_to_be_cracked);
$data = array("a","b","c","d","e","f","g","h","i","j","k","l","m",
"n","o","p","q","r","s","t","u","v","w","x","y","z",
"A","B","C","D","E","F","G","H","I","J","K","L",
"M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
1,2,3,4,5,6,7,8,9,0);
$count = count($data);
for ($i =0; $i<$count; $i++)
{
for($j=0;$j<$count;$j++)
{
for ($k = 0;$k<$count;$k++)
{
for ($l = 0; $l<$count; $l++)
{
$result = $data[$i].$data[$j].$data[$k].$data[$l];
//For verbose mode, uncomment the lines after, you'll get an output of (at least) 700 MB
/* echo "Trying ".$result."n";
echo "=>t".MD5($result)."n";
*/ if (MD5($result) == $crypted_password)
die("Password found: ".$result."n");
}
}
}
} ?>
In Perl, the program is the following:
#!/usr/bin/perl
use Digest::MD5 qw(md5_hex);
$password_to_be_cracked = "test";
$crypted_password = md5_hex($password_to_be_cracked);
@data = ("a","b","c","d","e","f","g","h","i","j","k","l","m"
,"n","o","p","q","r","s","t","u","v","w","x","y","z",
"A","B","C","D","E","F","G","H","I","J","K","L","M"
,"N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
,1,2,3,4,5,6,7,8,9,0);
$count = @data;
for ($i = 0; $i<$count; $i++)
{
for ($j = 0; $j<$count; $j++)
{
for ($k = 0;$k<$count;$k++)
{
for ($l =0; $l<$count;$l++)
{
$res = $data[$i].$data[$j].$data[$k].$data[$l];
#for verbose mode, uncomment the line after, it makes some 40 MB (at least) of output
#print $res."\n";
#print "=>t".md5_hex($res)."\n";
if (md5_hex($res) eq $crypted_password)
{
print "Password found: ".$res."\n";
exit();
}
}
}
}
}
UP Home
|
| |
|
| |
|
No comments yet; be the first to post
|
| |
|
| |
 |
|
Global note :: 2.47/5 |
Total votes :: 15 |
|
Rate this article
|
|