Hacking - The Art of Exploitation, 2nd Edition

(Romina) #1

428 0x700


charval = (k-32)95 + (l-32); // Last 2 plaintext bytes
data[(val
WIDTH)+(charval/8)] |= (1<<(charval%8));


val = (3 HEIGHT) + enum_hashtriplet(code[8], code[9], code[10]); // bytes 8-10
charval = (i-32)
95 + (j-32); // First 2 plaintext chars
data[(valWIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT
4);
charval = (k-32)95 + (l-32); // Last 2 plaintext bytes
data[(val
WIDTH)+(charval/8)] |= (1<<(charval%8));
}
}
}
}
printf("finished.. saving..\n");
fwrite(data, SIZE, 1, handle);
free(data);
fclose(handle);
}


The first piece of code, ppm_gen.c, can be used to generate a four-
character password probability matrix, as shown in the output below. The
-O3option passed to GCC tells it to optimize the code for speed when it
compiles.

reader@hacking:~/booksrc $ gcc -O3 -o ppm_gen ppm_gen.c -lcrypt
reader@hacking:~/booksrc $ ./ppm_gen
Adding ** to 4char.ppm..
Adding !** to 4char.ppm..
Adding "** to 4char.ppm..

.:[ output trimmed ]:.

Adding ~|** to 4char.ppm..
Adding ~}** to 4char.ppm..
Adding ~~** to 4char.ppm..
finished.. saving..
@hacking:~ $ ls -lh 4char.ppm
-rw-r--r-- 1 142M 2007-09-30 13:56 4char.ppm
reader@hacking:~/booksrc $

The 142MB 4char.ppm file contains loose associations between the
plaintext and hash data for every possible four-character password. This data
can then be used by this next program to quickly crack four-character pass-
words that would foil a dictionary attack.

ppm_crack.c


/*****\



  • Password Probability Matrix File: ppm_crack.c








  • Author: Jon Erickson [email protected] *

  • Organization: Phiral Research Laboratories *







Free download pdf