An example of an MD5 source string in Openmp brute-force speculation

Source: Internet
Author: User

// Gcc-fopenmp-O2-static-s omp_pwd_md5.c md5.c-o omp_pwd_md5.exe
# Include <stdio. h>
# Include "md5.h"
# Include <omp. h>
 
# Define PASSWD_MAXLEN 32
# Define PASSWD_SET_SIZE 36
Const char * passwd_words = "0123456789abcdefghijklmnopqrstuvwxyz _-.,";
Const char * real_pass_digest = "\ x5d \ x41 \ x40 \ x2a \ xbc \ x4b \ x2a \ x76 \ xb9 \ x71 \ x9d \ x91 \ x10 \ x17 \ xc5 \ x92 ";
Int compare_pass (int passwd_len, char * passwd)
{
Int I;
Int match = 0;
Unsigned int * p1, * p2;
P2 = (unsigned int *) real_pass_digest;
// Printf ("Guess Password: % s", passwd );
Md5_state_t MS;
Md5_byte_t digest [16];
Md5_init (& ms );
Md5_append (& ms, passwd, passwd_len );
Md5_finish (& ms, digest );
P1 = (unsigned int *) digest;
For (I = 0; I <4; I ++)
{
If (p1 [I] = p2 [I]) match ++;
}
I = 0;
If (match = 4)
{
I = 1;
Printf ("String: % s -- Matched! ", Passwd );
}
Return I;
}
 
Void passwd_gen ()
{
Int core_nums = omp_get_num_procs ();
Printf ("Core Number: % d \ n", core_nums );
Int I, finded = 0;
Int len = 0, passwd_count = 0;
Int PP [PASSWD_MAXLEN];
Int * passlen = (int *) malloc (sizeof (int) * core_nums );
Char * passwd = (char *) malloc (PASSWD_MAXLEN * core_nums );
For (I = 0; I <PASSWD_MAXLEN; I ++)
{
PP [I] = 0;
Passwd [I] = 0;
}
Int pos = 0;
While (1)
{
PP [pos] ++;
If (PP [pos] = PASSWD_SET_SIZE)
{
PP [pos] = 0; pos ++;
Continue;
}
Else
{
Len = pos> len? Pos: len;
Pos = 0;
For (I = 0; I <len + 1; I ++) passwd [PASSWD_MAXLEN * passwd_count + I] = passwd_words [PP [I];
Passlen [passwd_count] = len + 1;
Passwd_count ++;
If (passwd_count = core_nums)
{
Passwd_count = 0;
# Pragma omp parallel
For (I = 0; I <core_nums; I ++)
{
Finded + = compare_pass (passlen [I], passwd + PASSWD_MAXLEN * I );
}
If (finded) break;
}
}
}
Free (passwd );
Free (passlen );
}
 
Int main (int argc, char * argv [])
{
Passwd_gen ();
}

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.