Today I will discuss with you a very important issue about password security.

Source: Internet
Author: User
PHP code: coding $ sRandabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789; $ lengthstrlen ($ sRand); if (! ($ Dir @ opendir (dic) {mkdir (dic, 0777);} for ($ PHP code :--------------------------------------------------------------------------------
$ SRand = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 ';
$ Length = strlen ($ sRand );

If (! ($ Dir = @ opendir ("/dic "))){
Mkdir ("dic", 0777 );
}

For ($ q = 0; $ q <$ length; $ q ++ ){
If ($ q> 25 & $ 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 is worth noting that this is just an example. for the sake of simplicity, we lock the password character into 26 lower-case letters, 26 upper-case letters, and 10 digits (I believe it should be appropriate for most passwords, I don't know which BT friend has punctuation marks? Haha ......), However, we only test the password with four or less digits. The principle is the same when the number of digits increases, but the possibility of cracking is greatly reduced. let's talk about it later.

In this way, a series of dictionary files are generated under the dic Directory.
Now, let's create an 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, 32) ==$ md5_pwd ){
Echo "password:". $ adics [0]."
";
$ Mtime = explode ('', microtime ());
$ Endtime = $ mtime [1] + $ mtime [0];
Echo "total time consumed:". round ($ endtime-$ starttime, 6). "seconds

";
Echo "continue test ";
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) ==$ md5_pwd ){
Echo "password:". $ sdics;
Exit ();
}
}
}

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


In the program, you can add the code to check the running time to know how long it takes to crack an MD5 password with 62 characters and four characters...
Before the test, what should we do first?


Also, the default value is about 537M ~~
It takes about 15 minutes to generate a dictionary (on my PIII733 256 M memory)
Related Article

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.