-2

I am looking for solution in c# to generate combinations on given list of characters or word to perform dictionary attack on zip files. because we lost passwords file for those zip. Advantage is that we know possible words on it. Dictionary should contain all the combos of words that I choose. And all characters/words are small case only.

Example: Let say we have a set of chars:

Set A = {A,B,C}

A,B,C   =3

AA,AB,AC

BA,BB,BC

CA,CB,CC    =9


AAA,AAB,AAC,ABA,ABB,ABC,ACA,ACB,ACC

BAA,BAB,BAC,BBA,BBB,BBC,BCA,BCB,BCC

CAA,CAB,CAC,CBA,CBB,CBC,CCA,CCB,CCA    = 27


TOTAL POSIBLE COMBINATION 39

from the list of words a single word/character may repeat maximum of 4 times. If any such alogrithm/logic available please suggest.

bommina
  • 307
  • 4
  • 16
  • 1
    Since that other question seems to have a working solution, why don't you rewrite that in C#? – Chris Aug 15 '15 at 17:45
  • I'm voting to close this question as off-topic because the asker didn't consider the volume of data this would generate. – Joshua Aug 16 '15 at 02:31
  • I am not sure why this question is voted -1, but when a programmer want to achieve his solution he should not consider about the volume of data. simple example if you are asked to perform dictionary attack on zip file with known passwords list what we do? If you can remove -1 vote that wold be good.. Thanks. – bommina Aug 16 '15 at 17:06

1 Answers1

2

Here is a C# implementation using recursion:

static char[] A={'a','b','c'};
static int N = 3;
static void foo(string s)
{
    if (s.Length == N)
    {
        Console.WriteLine(s);
        return;
    }
    for (int i = 0; i < A.Length; i++)
    {
        string t = s;
        t += A[i];
        foo(t);
    }
}

Demo

If you want to retrieve the values later, store the strings in a global array before returning from function foo().

xashru
  • 3,400
  • 2
  • 17
  • 30