Graphics Programs Reference
In-Depth Information
}
/* Print the plaintext pairs that each ON bit in the vector enumerates. */
void print_vector(char *vector) {
int i, a, b, val;
for(i=0; i < 9025; i++) {
if(get_vector_bit(vector, i) == 1) { // If bit is on,
a = i / 95; // calculate the
b = i - (a * 95); // plaintext pair
printf("%c%c ",a+32, b+32); // and print it.
}
}
printf("\n");
}
/* Barf a message and exit. */
void barf(char *message, char *extra) {
printf(message, extra);
exit(1);
}
/* Crack a 4-character password using generated 4char.ppm file. */
int main(int argc, char *argv[]) {
char *pass, plain[5];
unsigned char bin_vector1[WIDTH], bin_vector2[WIDTH], temp_vector[WIDTH];
char prob_vector1[2][9025];
char prob_vector2[2][9025];
int a, b, i, j, len, pv1_len=0, pv2_len=0;
FILE *fd;
if(argc < 1)
barf("Usage: %s <password hash> (will use the file 4char.ppm)\n", argv[0]);
if(!(fd = fopen("4char.ppm", "r")))
barf("Fatal: Couldn't open PPM file for reading.\n", NULL);
pass = argv[1]; // First argument is password hash
printf("Filtering possible plaintext bytes for the first two characters:\n");
fseek(fd,(DCM*0)+enum_hashtriplet(pass[2], pass[3], pass[4])*WIDTH, SEEK_SET);
fread(bin_vector1, WIDTH, 1, fd); // Read the vector associating bytes 2-4 of hash.
len = count_vector_bits(bin_vector1);
printf("only 1 vector of 4:\t%d plaintext pairs, with %0.2f%% saturation\n", len, len*100.0/
9025.0);
fseek(fd,(DCM*1)+enum_hashtriplet(pass[4], pass[5], pass[6])*WIDTH, SEEK_SET);
fread(temp_vector, WIDTH, 1, fd); // Read the vector associating bytes 4-6 of hash.
merge(bin_vector1, temp_vector); // Merge it with the first vector.
len = count_vector_bits(bin_vector1);
printf("vectors 1 AND 2 merged:\t%d plaintext pairs, with %0.2f%% saturation\n", len,
len*100.0/9025.0);
Search WWH ::




Custom Search