Ejemplo n.º 1
0
hash_stat hash_plugin_check_hash(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    char *saltpass[VECTORSIZE];
    char *saltpass2[VECTORSIZE];
    char *saltpass3[VECTORSIZE];

    int a;
    int saltlen,templen;
    int lens[VECTORSIZE];
    char dash='-';

    saltlen = strlen(salt);

    /* Type A hash */
    if (saltlen==0)
    {
	for (a=0;a<vectorsize;a++) 
	{
	    lens[a]=strlen(password[a]);
	    saltpass[a]=alloca(64);
	    bzero(saltpass[a],64);
	    memcpy(saltpass[a],password[a],strlen(password[a]));
	}
	(void)hash_md5_unicode((const char **)saltpass, salt2, lens);
	for (a=0;a<vectorsize;a++) if (fastcompare((const char *)salt2[a],hash,16)==0) {*num=a;return hash_ok;}
	return hash_err;
    }

    /* Type B hash */
    for (a=0;a<vectorsize;a++) 
    {
	saltpass[a]=alloca(64);
	saltpass2[a] = alloca(16);
	saltpass3[a] = alloca(32);
	bzero(saltpass[a],64);
	memcpy(saltpass[a],password[a],strlen(password[a]));
	lens[a]=strlen(password[a]);
    }
    (void)hash_md5_unicode((const char **)saltpass, saltpass2, lens);
    hash_md5_hex((const char **)saltpass2,  saltpass3);

    for (a=0;a<vectorsize;a++) 
    {
	templen=saltlen;
	memcpy(saltpass[a],salt,templen);
	memcpy(saltpass[a]+templen, &dash, 1);
	templen++;
	memcpy(saltpass[a]+templen, saltpass3[a], 32);
	templen+=32;
	lens[a] = templen;
    }
    (void)hash_md5_unicode((const char **)saltpass, salt2, lens);
    
    for (a=0;a<vectorsize;a++) if (fastcompare((const char *)salt2[a],hash,16)==0) {*num=a;return hash_ok;}
    return hash_err;
}
Ejemplo n.º 2
0
hash_stat hash_plugin_check_hash_dictionary(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    char *dest[VECTORSIZE];
    int a;
    char *salted[VECTORSIZE];
    int lens[VECTORSIZE];
    
    for (a=0;a<vectorsize;a++) 
    {
	salted[a]=alloca(128);
	bzero(salted[a],40);
	memcpy(salted[a],password[a], strlen(password[a]));
	memcpy(salted[a]+strlen(password[a]), salt,strlen(salt));
	dest[a] = alloca(128);
	lens[a] = strlen(password[a])+strlen(salt);
    }
    
    (void)hash_sha1_unicode((const char **)salted, dest, lens);
    for (a=0;a<vectorsize;a++) 
    {
	memcpy(dest[a]+20,salt,8);
	memcpy(salt2[a],"{SSHA}",6);
	b64_ntop((const unsigned char *)dest[a], 28, salt2[a]+6, 128);
    }
    for (a=0;a<vectorsize;a++) 
    {
	if (fastcompare((const char *)salt2[a],hash,strlen(hash)-1)==0) {*num=a;return hash_ok;}
    }
    return hash_err;
}
Ejemplo n.º 3
0
struct PictureNode *get_picturenode( List *list, const char *path )
{
	struct PictureNode *pn;
	if( !path || !list || !list->head ) return NULL;
	for( pn=(struct PictureNode *)(list->head); pn; pn=(struct PictureNode *)(pn->node.next) )
	{
		if( fastcompare( path, pn->pn_original.p_path ) ) return pn;
	}
	return NULL;
}
Ejemplo n.º 4
0
hash_stat hash_plugin_check_hash_dictionary(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    int cnt;
    char *newpass[VECTORSIZE];
    int intsalt;
    unsigned int t;
    unsigned char x;
    int a;
    int lens[VECTORSIZE];


    for (a=0;a<vectorsize;a++) newpass[a] = alloca(128);

    for (a=0;a<vectorsize;a++)
    {
	newpass[a] = alloca(128);
	for (cnt=0;cnt<strlen(password[a]);cnt++)
	{
	    newpass[a][cnt*2] = password[a][cnt];
	    newpass[a][(cnt*2)+1] = 0;
	}
	cnt *= 2;

	// add salt
	intsalt = strtol(salt, NULL, 16);
	t = intsalt >> 24;
	x = (unsigned char) t;
	newpass[a][cnt]=x;
	cnt++;
	t = intsalt << 8;
	t = t >> 24;
	x = (unsigned char) t;
	newpass[a][cnt]=x;
	cnt++;
	t = intsalt << 16;
	t = t >> 24;
	x = (unsigned char) t;
	newpass[a][cnt]=x;
	cnt++;
	t = intsalt << 24;
	t = t >> 24;
	x = (unsigned char) t;
	newpass[a][cnt]=x;
	cnt++;
	lens[a] = cnt;
    }
    (void)hash_sha512_unicode((const char **)newpass, salt2, lens);

    for (a=0;a<vectorsize;a++) if (fastcompare((const char *)salt2[a],hash,64)==0) {*num=a;return hash_ok;}

    return hash_err;
}
Ejemplo n.º 5
0
hash_stat hash_plugin_check_hash(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    char dest[32];
    int a;
    char mysalt[512];
    char myuser[512];
    char *tok;
    char *save;
    char *verifier="lastpass rocks\x02\x02";
    int iterations;
    int len;
    AES_KEY key;
    unsigned char result[16];
    unsigned char iv[16];

    strcpy(mysalt,salt);
    tok = strtok_r(mysalt,":",&save);
    tok = strtok_r(NULL,":",&save);
    if (!tok) return hash_err;
    strcpy(myuser,tok);
    tok = strtok_r(NULL,":",&save);
    if (!tok) return hash_err;
    tok = strtok_r(NULL,":",&save);
    if (!tok) return hash_err;
    iterations = atoi(tok);
    len = strlen(myuser);

    for (a=0;a<vectorsize;a++) 
    {
	hash_pbkdf2_256_len(password[a], strlen(password[a]), (unsigned char *)myuser, len, iterations, 32, (unsigned char *)dest);
	memset(iv,0,16);
	hash_aes_set_encrypt_key((unsigned char *)dest, 256, &key);
	hash_aes_cbc_encrypt((unsigned char *)verifier, (unsigned char *)result, 16, &key, iv, AES_ENCRYPT);
	if (fastcompare((const char *)result,(const char *)hash,16)==0) 
	{
	    *num=a;
	    return hash_ok;
	}
    }
    return hash_err;
}
Ejemplo n.º 6
0
hash_stat hash_plugin_check_hash_dictionary(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    char *dest[VECTORSIZE];
    int a;
    char myhash[64];
    char mysalt[12];
    int rounds,len;

    strcpy(myhash,hash+33);
    rounds=atoi(salt);
    memcpy(mysalt,salt+12,12);
    len=strlen(myhash)-1;

    for (a=0;a<vectorsize;a++) 
    {
	dest[a] = alloca(128);
	hash_pbkdf2_256_len(password[a], strlen(password[a]), (unsigned char *)mysalt, 12, rounds, 32, (unsigned char *)dest[a]);
	b64_ntop((const unsigned char *)dest[a], 32, salt2[a], 128);
	if (fastcompare((const char *)salt2[a],myhash,len)==0) {*num=a;return hash_ok;}
    }
    return hash_err;
}
Ejemplo n.º 7
0
hash_stat hash_plugin_check_hash_dictionary(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    char *saltpass[VECTORSIZE];
    int a;
    int lens[VECTORSIZE];

    for (a=0; a<vectorsize; a++) saltpass[a] = alloca(64);
    for (a=0; a<vectorsize; a++)
    {
        strcpy(saltpass[a],salt);
        strcat(saltpass[a],password[a]);
        lens[a] = strlen(salt)+strlen(password[a]);
    }
    (void)hash_md5_unicode_slow((const char **)saltpass, salt2, lens);


    for (a=0; a<vectorsize; a++) if (fastcompare((const char *)salt2[a],hash,16)==0) {
            *num=a;
            return hash_ok;
        }
    return hash_err;
}
Ejemplo n.º 8
0
hash_stat hash_plugin_check_hash(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    int a;

/*
    char *password1[VECTORSIZE];
    for (a=0;a<vectorsize;a++)
    {
	password1[a] = alloca(64);
	bzero(password1[a],64);
	memcpy(password1[a],password[a], strlen(password[a]));
    }
*/
    __apr1_crypt_r((const char **)password, salt, salt2, 64, vectorsize);

    for (a=0;a<vectorsize;a++) if (fastcompare((const char *)salt2[a]+15,hash,16)==0) 
    {
	*num=a;
	return hash_ok;
    }
    
    return hash_err;
}
Ejemplo n.º 9
0
hash_stat hash_plugin_check_hash(const char *hash, const char *password[VECTORSIZE], const char *salt,  char *salt2[VECTORSIZE], const char *username, int *num, int threadid)
{
    char *hash1[VECTORSIZE];
    char *hash2[VECTORSIZE];
    char *hash3[VECTORSIZE];
    char *hash4[VECTORSIZE];
    char *hash5[VECTORSIZE];
    int a,i,j;
    unsigned char sapgarray[160]=
    {0x91, 0xAC, 0x51, 0x14, 0x9F, 0x67, 0x54, 0x43, 0x24, 0xE7, 0x3B, 0xE0, 0x28, 0x74, 
    0x7B, 0xC2,  0x86, 0x33, 0x13, 0xEB, 0x5A, 0x4F, 0xCB, 0x5C, 0x08, 0x0A, 0x73, 0x37, 
    0x0E, 0x5D, 0x1C, 0x2F,  0x33, 0x8F, 0xE6, 0xE5, 0xF8, 0x9B, 0xAE, 0xDD, 0x16, 0xF2, 
    0x4B, 0x8D, 0x2C, 0xE1, 0xD4, 0xDC,  0xB0, 0xCB, 0xDF, 0x9D, 0xD4, 0x70, 0x6D, 0x17, 
    0xF9, 0x4D, 0x42, 0x3F, 0x9B, 0x1B, 0x11, 0x94,  0x9F, 0x5B, 0xC1, 0x9B, 0x06, 0x05, 
    0x9D, 0x03, 0x9D, 0x5E, 0x13, 0x8A, 0x1E, 0x9A, 0x6A, 0xE8,  0xD9, 0x7C, 0x14, 0x17, 
    0x58, 0xC7, 0x2A, 0xF6, 0xA1, 0x99, 0x63, 0x0A, 0xD7, 0xFD, 0x70, 0xC3,  0xF6, 0x5E, 
    0x74, 0x13, 0x03, 0xC9, 0x0B, 0x04, 0x26, 0x98, 0xF7, 0x26, 0x8A, 0x92, 0x93, 0x25,  
    0xB0, 0xA2, 0x0D, 0x23, 0xED, 0x63, 0x79, 0x6D, 0x13, 0x32, 0xFA, 0x3C, 0x35, 0x02, 
    0x9A, 0xA3,  0xB3, 0xDD, 0x8E, 0x0A, 0x24, 0xBF, 0x51, 0xC3, 0x7C, 0xCD, 0x55, 0x9F, 
    0x37, 0xAF, 0x94, 0x4C,  0x29, 0x08, 0x52, 0x82, 0xB2, 0x3B, 0x4E, 0x37, 0x9F, 0x17, 
    0x07, 0x91, 0x11, 0x3B, 0xFD, 0xCD };
    int lens[VECTORSIZE];


    for (a=0;a<vectorsize;a++)
    {
	hash1[a]=alloca(64);
	hash2[a]=alloca(64);
	hash3[a]=alloca(128);
	hash4[a]=alloca(64);
	hash5[a]=alloca(128);

	hash1[a][0] = 0;
	bzero(hash2[a], 64);

	// Perform translation
	j=0;
	for (i=0; i<strlen(password[a]); i++) 
	{
	    if (password[a][i] & 0x80) 
	    {
		switch ((unsigned char)password[a][i]) 
		{
		    case 0xFC:
			hash2[a][j]=0xC3; hash2[a][j+1]=0xBC; j+=2; break;
		    case 0xF6:
			hash2[a][j]=0xC3; hash2[a][j+1]=0xB6; j+=2; break;
		    case 0xE4:
			hash2[a][j]=0xC3; hash2[a][j+1]=0xA4; j+=2; break;
		    case 0xDC:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x9C; j+=2; break;
		    case 0xD6:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x96; j+=2; break;
		    case 0xC4:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x84; j+=2; break;
		    case 0xDF:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x9F; j+=2; break;
		    case 0xBA:
			hash2[a][j]=0xC2; hash2[a][j+1]=0xB0; j+=2; break;
		    case 0xB4:
			hash2[a][j]=0xC2; hash2[a][j+1]=0xB4; j+=2; break;
		    case 0xE9:
			hash2[a][j]=0xC3; hash2[a][j+1]=0xA9; j+=2; break;
		    case 0xEA:
			hash2[a][j]=0xC3; hash2[a][j+1]=0xAA; j+=2; break;
		    case 0xE8:
			hash2[a][j]=0xC3; hash2[a][j+1]=0xA8; j+=2; break;
		    case 0xC9:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x89; j+=2; break;
		    case 0xCA:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x8A; j+=2; break;
		    case 0xC8:
			hash2[a][j]=0xC3; hash2[a][j+1]=0x88; j+=2; break;
		    case 0xA7:
			hash2[a][j]=0xC2; hash2[a][j+1]=0xA7; j+=2; break;
		    default:
			hash2[a][j]=password[a][i]; j++;
			break;
		} 
	    }
	    else hash2[a][j++]=password[a][i];
	}
	hash2[a][j]='\0';
	memcpy(hash3[a],hash2[a],j);
	memcpy(hash3[a]+j,username,strlen(username));
	lens[a] = j+strlen(username);
    }
    (void)hash_sha1_unicode((const char **)hash3, hash4, lens);
    for (a=0;a<vectorsize;a++)
    {
	unsigned int len,offset;
	len=offset=0;
	for (i=0; i<=9; i++) len+=(hash4[a][i]&255)%6;
	len+=0x20;
	for (i=19; i>=10; i--) offset+= ((hash4[a][i]&255)%8);
	memcpy(hash5[a],hash2[a],strlen(hash2[a]));
	memcpy(hash5[a]+strlen(hash2[a]), &sapgarray[offset],len); 
	memcpy(hash5[a]+strlen(hash2[a])+len, username, strlen(username));
	lens[a] = strlen(hash2[a]) + len + strlen(username);
    }
    (void)hash_sha1_slow((const char **)hash5,salt2,lens);
    for (a=0;a<vectorsize;a++) if (fastcompare(salt2[a], hash,20)==0) {*num=a;return hash_ok;}
    
    return hash_err;
}
Ejemplo n.º 10
0
// Create a buffer containing the differences between the two arguments.
// The new buffer must be deleted by the user.
// The first 4 bytes of the buffer are the size of the new buffer, in case it's
// shorter than the previous buffer.
static unsigned char* get_difference(unsigned char *before, 
		int before_len,
		unsigned char *after,
		int after_len,
		int *result_len,
		int verbose)
{
	unsigned char *result = new unsigned char[4];
	*result_len = 4;

// Store size of new buffer
	*(int32_t*)result = after_len;

	unsigned char *before_end = before + before_len;
	unsigned char *after_end = after + after_len;
	unsigned char *before_ptr = before;
	unsigned char *after_ptr = after;
	int done = 0;

// Scan forward for first difference
	while(!done)
	{
		if(before_ptr < before_end && 
			after_ptr < after_end)
		{
// Both characters equal
			if(*before_ptr == *after_ptr)
			{
				before_ptr++;
				after_ptr++;			
			}
			else
// Characters differ
			{
// Get length of difference by calculating the similarity of every possible
// transposition after it.
				int size = 0;
				unsigned char *before_difference_start = before_ptr;
				unsigned char *after_difference_start = after_ptr;
// Start of most similar transpositions
				unsigned char *before_difference_end = before_end;
				unsigned char *after_difference_end = after_end;
				int done2 = 0;

				int most_similar = 0;

// Assume after_ptr is the start of a transposed block.
				for( ;
					after_ptr < after_end - MIN_TRANS &&
					after_end - after_ptr > most_similar; )
				{
// Scan for transposed after text in remaining before text
					for(before_ptr = before_difference_start;
						before_ptr < before_end - MIN_TRANS &&
						before_end - before_ptr > most_similar; )
					{
// Got a match.
// The start of the match is the end of the difference.
						int comparison;
						if((comparison = fastcompare(before_ptr, 
							after_ptr, 
							before_end, 
							after_end)) > most_similar)
						{
							most_similar = comparison;
							before_difference_end = before_ptr;
							after_difference_end = after_ptr;
// printf("after_ptr=%d before_ptr=%d comparison=%d\n",
// after_ptr - after_difference_start,
// before_ptr - before_difference_start,
// comparison);
						}

// Test only lines
						before_ptr++;
						while(before_ptr < before_end - MIN_TRANS &&
							before_end - before_ptr > most_similar &&
							*before_ptr != '\n')
							before_ptr++;
					}

// Test only lines
					after_ptr++;
					while(after_ptr < after_end - MIN_TRANS &&
						after_end - after_ptr > most_similar &&
						*after_ptr != '\n')
						after_ptr++;
				}




// Test every offset in current lines for closest match.
				unsigned char *new_before_difference_end = before_difference_end;
				unsigned char *new_after_difference_end = after_difference_end;
				for(after_ptr = after_difference_start;
					after_ptr < after_difference_end && 
					after_end - after_ptr > most_similar;
					after_ptr++)
				{
					for(before_ptr = before_difference_start;
						before_ptr < before_difference_end &&
						before_end - before_ptr > most_similar; 
						before_ptr++)
					{
						int comparison;
						if((comparison = fastcompare(before_ptr,
							after_ptr,
							before_end,
							after_end)) > most_similar)
						{
							most_similar = comparison;
							new_before_difference_end = before_ptr;
							new_after_difference_end = after_ptr;
						}
					}
				}

				
				after_difference_end = new_after_difference_end;
				before_difference_end = new_before_difference_end;





				int after_start = after_difference_start - after;
				int before_start = before_difference_start - before;
				int after_len = after_difference_end - after_difference_start;
				int before_len = before_difference_end - before_difference_start;

				if(verbose)
				{
					char string[1024];
					memcpy(string, after_difference_start, MIN(after_len, 40));
					string[MIN(after_len, 40)] = 0;
					printf("after_offset=0x%x before_offset=0x%x after_size=%d before_size=%d\n", 
					after_start, 
					before_start,
					after_len,
					before_len);
				}


// Create difference record
				append_record(&result,
					result_len,
					after_difference_start,
					after_start,
					after_len,
					before_len);
				before_ptr = before_difference_end;
				after_ptr = after_difference_end;
			}
		}
		else
		if(after_ptr < after_end)
		{
// All data after this point is different
			append_record(&result, 
				result_len, 
				after_ptr,
				after_ptr - after,
				after_end - after_ptr,
				before_end - before_ptr);
			done = 1;
		}
		else
		{
			done = 1;
		}
	}
	return result;
}