Firstly, here's the C code for the program that makes the different combinations:
Code:
#include <string.h>
#include <stdio.h>
#include <assert.h>
char const *const bank[] =
{
"dog",
"cat",
"monkey",
"fish",
"cow",
"zebra",
"lion",
"tiger",
"pig",
"rat"
};
#define RADIX (sizeof bank / sizeof *bank)
#define MAX_DIGIT (RADIX - 1)
#define STR_SEPARATOR ("")
char const *GetCombo(unsigned const a,unsigned const b,unsigned const c)
{
assert(a <= MAX_DIGIT);
assert(b <= MAX_DIGIT);
assert(c <= MAX_DIGIT);
static char combo_str[126];
strcpy(combo_str,bank[a]);
strcat(combo_str,STR_SEPARATOR);
strcat(combo_str,bank[b]);
strcat(combo_str,STR_SEPARATOR);
strcat(combo_str,bank[c]);
}
int main(void)
{
unsigned words[3] = { 0,0,0 };
for (;;)
{
if ( words[0] != words[1]
&& words[1] != words[2]
&& words[0] != words[2] )
{
puts(GetCombo(words[0],words[1],words[2]));
}
if (++words[0] <= MAX_DIGIT)
continue;
words[0] = 0;
if (++words[1] <= MAX_DIGIT)
continue;
words[1] = 0;
if (++words[2] <= MAX_DIGIT)
continue;
break;
}
}
You need to create a file called "bank.c", and copy the above into that file and save it.
Next, here's the C code for the program that does all the uppercase-lowercase combinations:
Code:
#include <stdint.h>
#include <ctype.h> /* tolower, toupper, isalpha */
#include <stdio.h> /* puts */
#include <string.h> /* strlen */
#include <stddef.h> /* size_t */
#include <stdlib.h> /* exit */
void PrintCombos(char *const str)
{
size_t const lenSizeT = strlen(str);
if (lenSizeT >= 32)
{
puts("String too long, bailing out.");
exit(0);
}
uint_fast8_t const len = lenSizeT;
uint_fast8_t amount_letters;
uint_fast32_t cases, letters;
/* For example:
"tEsT74kT"
cases = 01010001
letters = 11110011
*/
uint_fast32_t mask;
uint_fast8_t char_index;
for (letters = 0, amount_letters = 0, mask = 1, char_index = 0;
len != char_index;
mask <<= 1, ++char_index)
{
if (isalpha(str[char_index]))
{
++amount_letters;
letters |= mask;
}
}
uint_fast32_t const one_past_max_count = (uint_fast32_t)1 << amount_letters;
for (cases = 0; one_past_max_count != cases; ++cases)
{
uint_fast32_t mask_letters;
for (mask = 1, mask_letters = 1, char_index = 0; one_past_max_count != mask; mask <<= 1,
mask_letters <<= 1,
++char_index)
{
while(!(letters & mask_letters))
{
mask_letters <<= 1;
++char_index;
if (char_index >= len) return;
}
if (cases & mask) str[char_index] = toupper((char unsigned)str[char_index]);
else str[char_index] = tolower((char unsigned)str[char_index]);
}
puts(str);
}
}
int main(int argc, char **argv)
{
if (1 == argc)
{
puts("Uppercase-lowercase Combinator\n"
"------------------------------\n\n"
"Usage:\n"
" cases [word]\n\n"
"Put the word between inverted commas if it contains spaces, e.g.:\n"
" cases \"monkey dog\"\n\n"
"To create a dictionary file, do:\n"
" cases \"monkey dog\" > whatever.txt\n\n");
return 0;
}
if (2 != argc)
{
puts("Bad commandline arguments, bailing out.");
return 0;
}
PrintCombos(argv[1]);
return 0;
}
You need to create a file called "uplow.c", and copy the above into that file and save it.
Next, you must compile both programs separately:
Code:
gcc bank.c -o bank
gcc uplow.c -o uplow
Next you want to take every password that gets outputted from "bank", and pass this password as an argument to the program "uplow". You use the Linux program called "xargs" to do this. Something like:
Code:
./bank | xargs ./uplow
I've been playing around with xargs but I can get this to work... I dunno what's wrong with it.
Anyhow, once you get xargs to play friendly, you pipe the output to a password file:
Code:
./bank | xargs ./uplow > mylist.txt