int FireMasterInit(char *dirProfile)
{
    SECItem saltItem;

	if( CrackKeyData(dirProfile, &keyCrackData) == false)
	{
		exit(0);
	}

	// Initialize the pkcs5 structure...
	saltItem.type = (SECItemType) 0;
	saltItem.len  = keyCrackData.saltLen;
	saltItem.data = keyCrackData.salt;
	paramPKCS5 = nsspkcs5_NewParam(0, &saltItem, 1);

	if( paramPKCS5 == NULL)
	{
		printf("\n Failed to initialize NSSPKCS5 structure");
		exit(0);
   	}

	// Current algorithm is
	// SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC

	// Setup the encrypted password-check string
    memcpy(encString, keyCrackData.encData, keyCrackData.encDataLen );

	if( CheckMasterPassword("") == true )
	{
		printf("\n Master password is not set ...exiting FireMaster \n\n");
		exit(0);
	}

	// Calculate partial sha1 data for password hashing...
    SHA1_Init(&pctx);
	SHA1_Update(&pctx, keyCrackData.globalSalt, keyCrackData.globalSaltLen);

	return true;
}
Beispiel #2
0
static void process_path(char *path)
{
    int i;
    struct stat sb;
    if(stat(path, &sb) == 0) {
        if(S_ISDIR(sb.st_mode)) {
            fprintf (stderr, "%s : is a directory, expecting key3.db file!\n", path);
            return;
        }
    }
    if(CrackKeyData(path, &keyCrackData) == false) {
        return;
    }
    // initialize the pkcs5 structure
    saltItem.type = (SECItemType) 0;
    saltItem.len  = keyCrackData.saltLen;
    assert(keyCrackData.saltLen < 32);
    assert(keyCrackData.oidLen < 32);
    saltItem.data = keyCrackData.salt;
    struct NSSPKCS5PBEParameter gpbe_param;
    unsigned char salt_data[4096];

    paramPKCS5 = nsspkcs5_NewParam(0, &saltItem, 1, &gpbe_param, salt_data);
    if(paramPKCS5 == NULL) {
        fprintf(stderr, "Failed to initialize NSSPKCS5 structure\n");
        return;
    }
    // Current algorithm is
    // SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC
    // Setup the encrypted password-check string
    memcpy(encString, keyCrackData.encData, keyCrackData.encDataLen);
    // Calculate partial sha1 data for password hashing
    SHA1_Init(&pctx);
    SHA1_Update(&pctx, keyCrackData.globalSalt, keyCrackData.globalSaltLen);
    unsigned char data1[256];
    unsigned char data2[512];
    SECItem secPreHash;
    secPreHash.data = data1;
    memcpy(secPreHash.data + SHA1_LENGTH, saltItem.data, saltItem.len);
    secPreHash.len = saltItem.len + SHA1_LENGTH;
    SECItem pkcs5_pfxpbe;
    pkcs5_pfxpbe.data = data2;
    if(CheckMasterPassword("", &pkcs5_pfxpbe, &secPreHash)) {
        fprintf (stderr, "%s : no Master Password set!\n", path);
        return;
    }
    printf("%s:$mozilla$*%d*%d*%d*",path, keyCrackData.version, keyCrackData.saltLen, keyCrackData.nnLen);
    for (i = 0; i < keyCrackData.saltLen; i++)
        printf("%c%c", itoa16[ARCH_INDEX(keyCrackData.salt[i] >> 4)],
               itoa16[ARCH_INDEX(keyCrackData.salt[i] & 0x0f)]);
    printf("*%d*", keyCrackData.oidLen);
    for (i = 0; i < keyCrackData.oidLen; i++)
        printf("%c%c", itoa16[ARCH_INDEX(keyCrackData.oidData[i] >> 4)],
               itoa16[ARCH_INDEX(keyCrackData.oidData[i] & 0x0f)]);

    printf("*%d*", keyCrackData.encDataLen);
    for (i = 0; i < keyCrackData.encDataLen; i++)
        printf("%c%c", itoa16[ARCH_INDEX(keyCrackData.encData[i] >> 4)],
               itoa16[ARCH_INDEX(keyCrackData.encData[i] & 0x0f)]);
    printf("*%d*", keyCrackData.globalSaltLen);
    for (i = 0; i < keyCrackData.globalSaltLen; i++)
        printf("%c%c", itoa16[ARCH_INDEX(keyCrackData.globalSalt[i] >> 4)],
               itoa16[ARCH_INDEX(keyCrackData.globalSalt[i] & 0x0f)]);
    printf("\n");
}