--- jumbo-bleeding2/src/rawSHA1_LinkedIn_fmt_plug.c 2012-06-08 13:05:24.468750000 +0000 +++ jumbo-bleeding/src/rawSHA1_LinkedIn_fmt_plug.c 2012-06-08 15:28:08.187500000 +0000 @@ -83,11 +83,11 @@ static struct fmt_tests rawsha1_tests[] #define crypt_key rawSHA1_crypt_key_LI #ifdef MMX_COEF #if defined (_MSC_VER) -__declspec(align(16)) unsigned int saved_key[SHA_BUF_SIZ*NBKEYS]; -__declspec(align(16)) unsigned int crypt_key[BINARY_SIZE/4*NBKEYS]; +__declspec(align(16)) ARCH_WORD_32 saved_key[SHA_BUF_SIZ*NBKEYS]; +__declspec(align(16)) ARCH_WORD_32 crypt_key[BINARY_SIZE/4*NBKEYS]; #else -unsigned int saved_key[SHA_BUF_SIZ*NBKEYS] __attribute__ ((aligned(16))); -unsigned int crypt_key[BINARY_SIZE/4*NBKEYS] __attribute__ ((aligned(16))); +ARCH_WORD_32 saved_key[SHA_BUF_SIZ*NBKEYS] __attribute__ ((aligned(16))); +ARCH_WORD_32 crypt_key[BINARY_SIZE/4*NBKEYS] __attribute__ ((aligned(16))); #endif static unsigned char out[PLAINTEXT_LENGTH + 1]; #else @@ -95,6 +95,7 @@ static char saved_key[PLAINTEXT_LENGTH + static ARCH_WORD_32 crypt_key[BINARY_SIZE / 4]; static SHA_CTX ctx; #endif +static int key_count; static int valid(char *ciphertext, struct fmt_main *pFmt) { @@ -127,6 +128,10 @@ static char *rawsha1_split(char *ciphert memcpy(&out[TAG_LENGTH], ciphertext, HASH_LENGTH); out[CIPHERTEXT_LENGTH] = 0; + // 'normalize' these hashes to all 'appear' to be 00000xxxxxx hashes. + // on the get_source() function, we later 'fix' these up. + memcpy(&out[TAG_LENGTH], "00000", 5); + strlwr(&out[TAG_LENGTH]); return out; @@ -141,6 +146,7 @@ static void rawsha1_set_key(char *key, i ARCH_WORD_32 temp; len = 0; + key_count = index; while((unsigned char)(temp = *wkey++)) { if (!(temp & 0xff00)) { @@ -201,12 +207,12 @@ static int rawsha1_cmp_all(void *binary, #endif for(x=0;x>2)*MMX_COEF*5) -static int get_hash_0(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0xf; } -static int get_hash_1(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0xff; } -static int get_hash_2(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0xfff; } -static int get_hash_3(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0xffff; } -static int get_hash_4(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0xfffff; } -static int get_hash_5(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0xffffff; } -static int get_hash_6(int index) { return ((unsigned int *)crypt_key)[INDEX+MMX_COEF] & 0x7ffffff; } +static int get_hash_0(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0xf; } +static int get_hash_1(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0xff; } +static int get_hash_2(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0xfff; } +static int get_hash_3(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0xffff; } +static int get_hash_4(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0xfffff; } +static int get_hash_5(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0xffffff; } +static int get_hash_6(int index) { return ((ARCH_WORD_32*)crypt_key)[INDEX+MMX_COEF] & 0x7ffffff; } #undef INDEX #else -static int get_hash_0(int index) { return ((unsigned int *)crypt_key)[1] & 0xf; } -static int get_hash_1(int index) { return ((unsigned int *)crypt_key)[1] & 0xff; } -static int get_hash_2(int index) { return ((unsigned int *)crypt_key)[1] & 0xfff; } -static int get_hash_3(int index) { return ((unsigned int *)crypt_key)[1] & 0xffff; } -static int get_hash_4(int index) { return ((unsigned int *)crypt_key)[1] & 0xfffff; } -static int get_hash_5(int index) { return ((unsigned int *)crypt_key)[1] & 0xffffff; } -static int get_hash_6(int index) { return ((unsigned int *)crypt_key)[1] & 0x7ffffff; } +static int get_hash_0(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0xf; } +static int get_hash_1(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0xff; } +static int get_hash_2(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0xfff; } +static int get_hash_3(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0xffff; } +static int get_hash_4(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0xfffff; } +static int get_hash_5(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0xffffff; } +static int get_hash_6(int index) { return ((ARCH_WORD_32*)crypt_key)[1] & 0x7ffffff; } #endif static char *get_source(struct db_password *pw, char Buf[LINE_BUFFER_SIZE] ) @@ -307,6 +321,23 @@ static char *get_source(struct db_passwo char *cpo; int i; +#ifdef MMX_COEF + for (i = 0; i <= key_count; ++i) { + if (rawSHA1_crypt_key_LI[(i/4)*20+4+(i%4)] == ((ARCH_WORD_32*)(*pw).binary)[1]) { + // Ok, we may have found it. Check the next 3 DWORDS + if (rawSHA1_crypt_key_LI[(i/4)*20+8+(i%4)] == ((ARCH_WORD_32*)(*pw).binary)[2] && + rawSHA1_crypt_key_LI[(i/4)*20+12+(i%4)] == ((ARCH_WORD_32*)(*pw).binary)[3] && + rawSHA1_crypt_key_LI[(i/4)*20+16+(i%4)] == ((ARCH_WORD_32*)(*pw).binary)[4]) + ((ARCH_WORD_32*)(*pw).binary)[0] = rawSHA1_crypt_key_LI[(i/4)*20+(i%4)]; + } + } +#else + if (rawSHA1_crypt_key_LI[1] == ((ARCH_WORD_32*)(*pw).binary)[1] && + rawSHA1_crypt_key_LI[2] == ((ARCH_WORD_32*)(*pw).binary)[2] && + rawSHA1_crypt_key_LI[3] == ((ARCH_WORD_32*)(*pw).binary)[3] && + rawSHA1_crypt_key_LI[4] == ((ARCH_WORD_32*)(*pw).binary)[4]) + ((ARCH_WORD_32*)(*pw).binary)[0] = rawSHA1_crypt_key_LI[0]; +#endif memcpy(realcipher, pw->binary, BINARY_SIZE); #ifdef MMX_COEF alter_endianity(realcipher, BINARY_SIZE);