static void md5_50_bench(void) { uint8_t *buf; unsigned int nrprocessed = 0; clock_t startTime, endTime; int i; buf = calloc(16, sizeof(uint8_t)); md5_50_init(16); alarm(BENCHINTERVAL); startTime = clock(); while(!finished) { md5_50(buf, 16); buf[0]++; nrprocessed++; } endTime = clock(); print_and_clean("MD5_50 (fast):\t", nrprocessed, &startTime, &endTime); buf[0] = 0; nrprocessed = 0; alarm(BENCHINTERVAL); startTime = clock(); while(!finished) { for(i=0; i<50; i++) { md5(buf, 16, buf); } buf[0]++; nrprocessed++; } endTime = clock(); print_and_clean("MD5_50 (slow):\t", nrprocessed, &startTime, &endTime); free(buf); }
bool runCrackRev3(struct custom_salt *cs, unsigned char *currPW) { uint8_t test[16], enckey[16], tmpkey[16]; unsigned int j, length; int i; unsigned int currPWLen; length = cs->e.length / 8; currPWLen = strlen((const char *)currPW); if(currPWLen > 32) currPWLen = 32; memcpy(currPW + currPWLen, pad, 32 - currPWLen); md5(currPW, cs->ekwlen, enckey); md5_50(enckey); memcpy(test, cs->e.u_string, 16); /** Algorithm 3.5 reversed */ RC4_DECRYPT_REV3(PARTIAL_TEST_SIZE); /** if partial test succeeds we make a full check to be sure */ if (unlikely(memcmp(test, cs->rev3TestKey, PARTIAL_TEST_SIZE) == 0)) { memcpy(test, cs->e.u_string, 16); RC4_DECRYPT_REV3(16); if (memcmp(test, cs->rev3TestKey, 16) == 0) { return true; } } return false; }
bool runCrackRev3_o(struct custom_salt *cs, unsigned char *currPW) { uint8_t test[32], enckey[16], tmpkey[16]; unsigned int j, length; int i; unsigned int currPWLen; unsigned char buf[128]; length = cs->e.length / 8; currPWLen = strlen((const char *)currPW); if(currPWLen > 32) currPWLen = 32; memcpy(currPW + currPWLen, pad, 32 - currPWLen); md5(currPW, 32, enckey); md5_50(enckey); memcpy(test, cs->e.o_string, 32); RC4_DECRYPT_REV3(32); // memcpy(cs->encKeyWorkSpace, test, 32); memcpy(buf, cs->encKeyWorkSpace, 128); memcpy(buf, test, 32); if (isUserPasswordRev3(cs, buf)) { memcpy(cs->password_user, cs->encKeyWorkSpace, 32); return true; } return false; }
bool runCrackRev3_of(struct custom_salt *cs, unsigned char *currPW) { uint8_t test[32], enckey[16], tmpkey[16]; unsigned int j, length; int i; unsigned int currPWLen; length = cs->e.length / 8; currPWLen = strlen((const char *)currPW); if(currPWLen > 32) currPWLen = 32; memcpy(currPW + currPWLen, pad, 32 - currPWLen); md5(currPW, 32, enckey); md5_50(enckey); memcpy(test, cs->e.o_string, 32); RC4_DECRYPT_REV3(PARTIAL_TEST_SIZE); /** if partial test succeeds we make a full check to be sure */ if (unlikely(memcmp(test, cs->password_user, PARTIAL_TEST_SIZE) == 0)) { memcpy(test, cs->e.o_string, 32); RC4_DECRYPT_REV3(32); if (memcmp(test, cs->password_user, 32) == 0) return true; } return false; }
/** Checks if the rev3-password set up in encKeyWorkSpace is the correct one and return true if it is and false otherwise. */ static bool isUserPasswordRev3(struct custom_salt *cs, unsigned char *buf) { uint8_t test[16], enckey[16], tmpkey[16]; int i; unsigned int length, j; length = cs->e.length / 8; md5(buf, cs->ekwlen, enckey); md5_50(enckey); memcpy(test, cs->e.u_string, 16); RC4_DECRYPT_REV3(PARTIAL_TEST_SIZE); /** if partial test succeeds we make a full check to be sure */ if (unlikely(memcmp(test, cs->rev3TestKey, PARTIAL_TEST_SIZE) == 0)) { memcpy(test, cs->e.u_string, 16); RC4_DECRYPT_REV3(16); if (memcmp(test, cs->rev3TestKey, 16) == 0) { return true; } } return false; }