Пример #1
0
int main (int argc, char *argv[])
{

    int n = atoi(argv[1]);
    int s = atoi(argv[2]);
    unsigned char buffer[16];
    int i, j;

    if (argc != 4)
         error("Usage:  crack n s hash");

    if ((strlen(argv[3]) != 34) | (argv[3][0] != '0') || (argv[3][1] != 'x'))
        error("Hash value should be of the form 0x... and exactly 16 bytes long");
    for (i=2, j=0; j<16; i += 2, j++)
        buffer[j] = (asciitohex(argv[3][i])<<4) | (asciitohex(argv[3][i+1]));
    int* aesP = (int *)malloc(sizeof(int));

    *aesP = 0;
    unsigned char* passHead = calloc(round_div(n, BYTE), sizeof(char));
    // int zero = malloc(sizeof(int));
    // zero = 0;
    //aesP = zero;
    doCompareAndHash(buffer, n, s, passHead, aesP);
    //haveCorrectChain(buffer, n, s, passHead);
    free(passHead);
    free(aesP);
    return 0;
}
Пример #2
0
void main(int argc, char *argv[]) {
    int n = atoi(argv[1]);
    int s = atoi(argv[2]);
    unsigned char *hash = argv[3];
    unsigned char hex_hash[16];
    int i, j;
    int count;

    /* Converts ascii char array to hex. Provided by Tygar */
    for (i=2, j=0; j<16; i += 2, j++)
        hex_hash[j] = (asciitohex(hash[i])<<4) | (asciitohex(hash[i+1]));

    aes_context ctx;
    unsigned char buffer[24] = {};
    unsigned char pass[8] = {};
    unsigned char last[16] = {};
    unsigned char ciphertext[16] = {};
    unsigned char plaintext[16] = {};

    FILE *rainbow = fopen("rainbow", "r");

    fread(buffer, 24*sizeof(char), 1, rainbow);
    memcpy(pass, buffer, 8*sizeof(char));
    memcpy(last, &buffer[8], 16*sizeof(char));

    /* Same reduce function as from gentable.c */
    void reduce(unsigned char *pass, int bits, int num) {
        int i;
        if (bits < 0 || bits > 128) {
            fprintf(stderr, "Error: invalid value in reduce:  %d\n", bits);
            exit (-1);
        }

        for (i=15; i >= 0; i--, bits -= 8)
            if (bits <= 0)
                pass[i] = 0;
            else if (bits < 8)
                pass[i] &= (0xFF >> (8-bits));
        pass[15] = (char) num;
    }
Пример #3
0
INT32 BurnLoadPicROM(UINT8 *src, INT32 offset, INT32 len)
{
	UINT8 *PICROM_HEX = (UINT8*)BurnMalloc(len);
	UINT16 *PICROM = (UINT16*)src;
	INT32   offs, data;
	UINT16  src_pos = 0;
	UINT16  dst_pos = 0;
	UINT8   data_hi, data_lo;

	if (BurnLoadRom(PICROM_HEX, offset, 1)) return 1;

	// Convert the PIC16C57 ASCII HEX dump to pure HEX
	do
	{
		if ((PICROM_HEX[src_pos + 0] == ':') &&
			(PICROM_HEX[src_pos + 1] == '1') &&
			(PICROM_HEX[src_pos + 2] == '0'))
			{
			src_pos += 9;

			for (offs = 0; offs < 32; offs += 4)
			{
				data_hi = asciitohex((PICROM_HEX[src_pos + offs + 0]));
				data_lo = asciitohex((PICROM_HEX[src_pos + offs + 1]));
				if ((data_hi <= 0x0f) && (data_lo <= 0x0f)) {
					data =  (data_hi <<  4) | (data_lo << 0);
					data_hi = asciitohex((PICROM_HEX[src_pos + offs + 2]));
					data_lo = asciitohex((PICROM_HEX[src_pos + offs + 3]));

					if ((data_hi <= 0x0f) && (data_lo <= 0x0f)) {
						data |= (data_hi << 12) | (data_lo << 8);
						PICROM[dst_pos] = data;
						dst_pos += 1;
					}
				}
			}
			src_pos += 32;
		}

		/* Get the PIC16C57 Config register data */

		if ((PICROM_HEX[src_pos + 0] == ':') &&
			(PICROM_HEX[src_pos + 1] == '0') &&
			(PICROM_HEX[src_pos + 2] == '2') &&
			(PICROM_HEX[src_pos + 3] == '1'))
			{
				src_pos += 9;

				data_hi = asciitohex((PICROM_HEX[src_pos + 0]));
				data_lo = asciitohex((PICROM_HEX[src_pos + 1]));
				data =  (data_hi <<  4) | (data_lo << 0);
				data_hi = asciitohex((PICROM_HEX[src_pos + 2]));
				data_lo = asciitohex((PICROM_HEX[src_pos + 3]));
				data |= (data_hi << 12) | (data_lo << 8);

				pic16c5x_config(data);
				src_pos = 0x7fff;		/* Force Exit */
		}
		src_pos += 1;
	} while (src_pos < len);		/* 0x2d4c is the size of the HEX rom loaded */

	BurnFree (PICROM_HEX);

	return 0;
}