示例#1
0
static hash_stat check_kwallet(char *key)
{
    BlowFish _bf;
    int sz;
    unsigned char buffer[0x10000];
    const char *t;
    long fsize;
    CipherBlockChain bf;
    unsigned char testhash[20];
    SHA_CTX ctx;
    int i;

    CipherBlockChain_constructor(&bf, &_bf);
    CipherBlockChainSetKey(&bf, (void *) key, 20 * 8);
    memcpy(buffer, cs.ct, cs.ctlen);
    CipherBlockChain_decrypt(&bf, buffer, cs.ctlen);

    t = (char *) buffer;

    t += 8;

    fsize = 0;
    fsize |= ((long) (*t) << 24) & 0xff000000;
    t++;
    fsize |= ((long) (*t) << 16) & 0x00ff0000;
    t++;
    fsize |= ((long) (*t) << 8) & 0x0000ff00;
    t++;
    fsize |= (long) (*t) & 0x000000ff;
    t++;
    if (fsize < 0 || fsize > (long) (cs.ctlen) - 8 - 4) 
    {
        return hash_err;
    }
    SHA1_Init(&ctx);
    SHA1_Update(&ctx, t, fsize);
    SHA1_Final(testhash, &ctx);

    sz = cs.ctlen;
    for (i = 0; i < 20; i++) 
    {
        if (testhash[i] != buffer[sz - 20 + i]) 
        {
            return hash_err;
        }
    }

    return hash_ok;
}
示例#2
0
文件: kwallet.c 项目: 6e6f36/hashkill
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;
	unsigned char *buf[VECTORSIZE];
	unsigned char *buf2[VECTORSIZE];
	int lens[VECTORSIZE];
	int lens2[VECTORSIZE];
	BlowFish _bf;
	int sz;
	unsigned char buffer[0x10000];
	const char *t;
	long fsize;
        CipherBlockChain bf;

	for (a = 0; a < vectorsize; a++) 
	{
	    buf[a]=alloca(256);
	    buf2[a]=alloca(64);
	    memset(buf[a],0,256);
	    lens[a]=MIN(strlen(password[a]), 16);
	    memcpy(buf[a],password[a],lens[a]);
	    lens2[a]=20;
	}
	
	hash_sha1_slow((const char **)buf,(char **)buf,lens);
	for (a = 0; a < 1999; a++) 
	{
	    hash_sha1_unicode((const char **)buf,(char **)buf,lens2);
	}

	for (a = 0; a < vectorsize; a++) 
	{
	    CipherBlockChain_constructor(&bf, &_bf);
	    CipherBlockChain_setKey(&bf, (void *) buf[a], 20 * 8);
	    memcpy(buffer, cs.ct, cs.ctlen);
	    CipherBlockChain_decrypt(&bf, buffer, cs.ctlen);
    	    t = (char *) buffer;
	    // strip the leading data
	    t += 8; 
	    // strip the file size off
	    fsize = 0;
	    fsize |= ((long) (*t) << 24) & 0xff000000;
	    t++;
	    fsize |= ((long) (*t) << 16) & 0x00ff0000;
	    t++;
	    fsize |= ((long) (*t) << 8) & 0x0000ff00;
	    t++;
	    fsize |= (long) (*t) & 0x000000ff;
	    t++;
	    if (fsize < 0 || fsize > (long) (cs.ctlen) - 8 - 4) 
	    {
		// file structure error
		lens[a]=1;
		buf2[a][0]='_';
		continue;
	    }
	    lens[a]=fsize;
	    memcpy(buf[a],t,fsize);
	    sz = cs.ctlen;
	    memcpy(buf2[a],buffer+(sz-20),20);
	}

	hash_sha1_slow((const char **)buf,(char **)buf,lens);
	
	for (a = 0; a < vectorsize; a++) 
	{
	    sz = cs.ctlen;
	    if (memcmp(buf2[a],buf[a],20)==0)
	    {
		*num = a;
		return hash_ok;
	    }
	}
	return hash_err;
}