// ************************************************************************** // Word Merger module for 'building' possible passwords. // // This has been designed to work directly with johnripper. It will // end up building a [List.Rules:Wordlist] sections of john.conf, which // properly adds rules for the words to be prepended and appended to // the dictionary (using --rules command line switch) // // Usage: // 2 files are needed (can work with just one of them). These files // are append.lst and prepend.lst They are in the format of a 'valid' // john dictionary file (1 word per line, lines starting with #!comment // are comment lines). // // There are some other 'mangling' rules that can be 'added' that will // allow modifications of the per-word, the post-word, or the word read // from the dictionary file by john, or allow addition of things at any // of the 4 points of insersion (in front of per (or pw), between pre/post // and pw, or after the pw (or post). These 'insersion points' are: // 1PrePw Pre2Pw PrePw3 1PwPost Pw2Post PwPost3 // ************************************************************************** #include #include #include char *sPre[100000], *sPost[100000]; int nPre, nPost; int nRules; void LoadPre(); void LoadPost(); void LoadOpts(int argc, char **argv); void DumpPre(int i); void DumpPost(int i); int main(int argc, char **argv) { int i; fprintf(stderr, "JohnRipper JoinWordMerge tool, v0.01 JimF.\nFree usage rights granted to all\n\n"); LoadOpts(argc, argv); LoadPre(); LoadPost(); if (nPre==0 && nPost==0) return 0-!!printf("JoinWordMerge requires at least one of the files append.lst or prepend.lst\nto be in the current directory\n"); for (i = 0; i < nPre || i < nPost; ++i) { DumpPost(i); DumpPre(i); } fprintf(stderr, "%d rules created (%d pre and %d post)\n", nRules, nPre, nPost); return 0; } void LoadPre() { FILE *in = fopen("prepend.lst", "r"); char Line[16384]; if (!in) return; // Only problem is if line is a comment longer than 16k. // It will ignore the first part of the comment, and then // add the other part(s) of the comment as new words. // Oh well, if people want to give bogus data, they should // expect bogus output. fgets(Line, sizeof(Line), in); Line[sizeof(Line)-1] = 0; while (!feof(in)) { if (strncmp(Line, "#!comment", 9)) { strtok(Line, "\r\n"); sPre[nPre] = malloc(strlen(Line)+1); strcpy(sPre[nPre++], Line); } fgets(Line, sizeof(Line), in); Line[sizeof(Line)-1] = 0; } } void LoadPost() { FILE *in = fopen("append.lst", "r"); char Line[16384]; if (!in) return; fgets(Line, sizeof(Line), in); Line[sizeof(Line)-1] = 0; while (!feof(in)) { if (strncmp(Line, "#!comment", 9)) { strtok(Line, "\r\n"); sPost[nPost] = malloc(strlen(Line)+1); strcpy(sPost[nPost++], Line); } fgets(Line, sizeof(Line), in); Line[sizeof(Line)-1] = 0; } } void LoadOpts(int argc, char **argv) { // do nothing at this time. } void DumpPre(int i) { if (i < nPre) { int j; // Note, the 'pre' words are written in reverse order // (due to how john processes when processing rules, at least at v1.7.3.1-pl.5) for (j = strlen(sPre[i])-1; j >= 0; --j) printf ("^[%c]", sPre[i][j]); printf("\n"); ++nRules; } } void DumpPost(int i) { if (i < nPost) { int j; for (j = 0; j < strlen(sPost[i]); ++j) printf ("$[%c]", sPost[i][j]); printf("\n"); ++nRules; } }