/*********************************************************\ * Password Probability Matrix * File: ppm_gen.c * *********************************************************** * * * Author: Jon Erickson * * Organization: Phiral Research Laboratories * * * * This is the generate program for the PPM proof of * * concept. It generates a file called 4char.ppm, which * * contains information regarding all possible 4 * * character passwords salted with 'je'. This file can * * used to quickly crack passwords found within this * * keyspace with the corresponding ppm_crack.c program. * * * \*********************************************************/ #define _XOPEN_SOURCE #include #include #include #define HEIGHT 16384 #define WIDTH 1129 #define DEPTH 8 #define SIZE HEIGHT * WIDTH * DEPTH int singleval(char a) { int i, j; i = (int)a; if((i >= 46) && (i <= 57)) j = i - 46; else if ((i >= 65) && (i <= 90)) j = i - 53; else if ((i >= 97) && (i <= 122)) j = i - 59; return j; } int tripleval(char a, char b, char c) { return (((singleval(c)%4)*4096)+(singleval(a)*64)+singleval(b)); } main() { char *plain; char *code; char *data; int i, j, k, l; unsigned int charval, val; FILE *handle; if (!(handle = fopen("4char.ppm", "w"))) { printf("Error: Couldn't open file '4char.ppm' for writing.\n"); exit(1); } data = (char *) malloc(SIZE+19); if (!(data)) { printf("Error: Couldn't allocate memory.\n"); exit(1); } plain = data+SIZE; code = plain+5; for(i=32; i<127; i++) { for(j=32; j<127; j++) { printf("Adding %c%c** to 4char.ppm..\n", i, j); for(k=32; k<127; k++) { for(l=32; l<127; l++) { plain[0] = (char)i; plain[1] = (char)j; plain[2] = (char)k; plain[3] = (char)l; plain[4] = 0; code = crypt(plain, "je"); val = tripleval(code[2], code[3], code[4]); charval = (i-32)*95 + (j-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val += (HEIGHT * 4); charval = (k-32)*95 + (l-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val = HEIGHT + tripleval(code[4], code[5], code[6]); charval = (i-32)*95 + (j-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val += (HEIGHT * 4); charval = (k-32)*95 + (l-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val = (2 * HEIGHT) + tripleval(code[6], code[7], code[8]); charval = (i-32)*95 + (j-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val += (HEIGHT * 4); charval = (k-32)*95 + (l-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val = (3 * HEIGHT) + tripleval(code[8], code[9], code[10]); charval = (i-32)*95 + (j-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); val += (HEIGHT * 4); charval = (k-32)*95 + (l-32); data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8)); } } } } printf("finished.. saving..\n"); fwrite(data, SIZE, 1, handle); free(data); fclose(handle); }