Today, we're going to discuss a very important issue--password security

Source: Internet
Author: User
Security | Problem PHP code:--------------------------------------------------------------------------------
$sRand = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ';
$length = strlen ($sRand);

if (!) ( $dir = @opendir ("/dic"))) {
mkdir ("dic", 0777);
}

for ($q =0; $q < $length; $q + +) {
if ($q > && $q < 52) {
$op = ' cap ';
} else {
$op = ';
}
$fp = fopen ("./dic/". $op. $sRand [$q]. ". TXT "," w ");
$crack = $sRand [$q];
Fputs ($FP, $crack. "|" MD5 ($crack). " \ n ");
for ($m =0; $m < $length; $m + +) {
$crack = $sRand [$q]. $sRand [$m];
Fputs ($FP, $crack. "|" MD5 ($crack). " \ n ");
for ($l =0; $l < $length; $l + +) {
$crack = $sRand [$q]. $sRand [$m]. $sRand [$l];
Fputs ($FP, $crack. "|" MD5 ($crack). " \ n ");
for ($o =0; $o < $length; $o + +) {
$crack = $sRand [$q]. $sRand [$m]. $sRand [$l]. $sRand [$o];
Fputs ($FP, $crack. "|" MD5 ($crack). " \ n ");
}
}
}
Fclose ($FP);
}

--------------------------------------------------------------------------------


It should be noted that this is just an example, for the simple period, we lock the cipher character to 26 lowercase letters, 26 uppercase letters, 10 digits (believe should be suitable for most passwords, I do not know which BT friend with punctuation?) Oh...... , and we only test the four-bit password, the number of password digits increase the same principle, but the possibility of cracking is greatly reduced, this moment to speak again.

In this way, a series of dictionary files are produced in the DIC directory.
Now, let's do a MD5 random password:

PHP Code:--------------------------------------------------------------------------------
$afcontent = File ("./dic/". $op. $sRand [$s]. ". TXT "," R ");
foreach ($afcontent as $sdics) {
$adics = Explode ("|", $sdics);
if (substr ($adics [1], 0,) = = $md 5_pwd) {
echo "Cracked the password:". $adics [0]. " <br> ";
$mtime = Explode (', microtime ());
$endtime = $mtime [1] + $mtime [0];
echo "Total time consuming:". Round ($endtime-$starttime, 6). " SEC <br><br> ";
echo "<a href=\" md5.php\ "> Continue test </a>";
Exit ();
}
}

for ($s =0; $s < $length; $s + +) {
if ($s >25 && $s < 52) {
$op = ' cap ';
} else {
$op = ';
}
$afcontent = File ("./dic/". $op. $sRand [$s]. ". TXT "," R ");
foreach ($afcontent as $sdics) {
if (MD5 ($sdics) = = $md 5_pwd) {
echo "Cracked the password:". $sdics;
Exit ();
}
}
}

--------------------------------------------------------------------------------


In the program, you add the test run time code, you can know how to crack a 62-character four-bit length of the MD5 password will take a long time ...
Before the test, we first estimate it?


And now the default is to produce probably 537m~~
And it takes about 15 minutes to generate the dictionary (on my PIII733 256M memory)





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.