# Generate all possibilities

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
You know them brute force password crackers...  Just give the min/max
passwordlength and the character scope in which they have to search.

min length: 1
max length: 7
scope:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890!@#\$%^&*()_

Can anybody help me with a compact code for generating all possibilities?

## Re: Generate all possibilities

Hans Worst wrote:

You do realize that at the maxlength there are 10,030,613,004,288
combinations, at that a generation and test rate of 1,000,000 per
second, it would take over 100 days to test them all?

There is a more complicated way, which lets max length be a variable,
but this is short and easy:

for(\$i1=0; \$i1<strlen(\$scope); \$i1++) {
\$key = substr(\$scope, \$i1, 1);
print \$key;
for(\$i2=0; \$i2<strlen(\$scope); \$i2++) {
\$key = substr(\$key,0,1) . substr(\$scope, \$i2, 1);
print \$key;
for(\$i3=0; \$i3<strlen(scope); \$i++) {
\$key = substr(\$key,0,2) . substr(\$scope, \$i3, 1);
print \$key;
}
}
}

Make further loops inside the ones already present to increase the key
length beyond 3. Note that each loop increases the run time and output
lines by a factor of 72

## Re: Generate all possibilities

Bob,

Thanks for the example but there is something wrong - I cannot find what
though...

I put  \$scope = "abcdefghijklmnopqrstuvwxyz";
and I put <BR>'s after every print
The script outputs a  aa aaa aaa aaa aaa aaa aaa

## Re: Generate all possibilities

try indexing the keys as well:

for(\$i1=0; \$i1<strlen(\$scope); \$i1++) {
\$key1 = \$scope;
print \$key1;
for(\$i2=0; \$i2<strlen(\$scope); \$i2++) {
\$key2 = \$key1 . \$scope;
print \$key2;
for(\$i3=0; \$i3<strlen(scope); \$i++) {
\$key3 = \$key2 . \$scope;
print \$key3;
}
}
}

--
"Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia  koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pivittyv nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

## Re: Generate all possibilities

I still only get aaaaaaaaaaaaaaaaaaaaaaaa...

## Re: Generate all possibilities

Strange... I just tried this:

\$scope = 'abcdef';
for(\$i1=0; \$i1<strlen(\$scope); \$i1++) {
\$key1 = \$scope;
print \$key1.'<br>';
for(\$i2=0; \$i2<strlen(\$scope); \$i2++) {
\$key2 = \$key1 . \$scope;
print \$key2.'<br>';
for(\$i3=0; \$i3<strlen(\$scope); \$i3++) {
\$key3 = \$key2 . \$scope;
print \$key3.'<br>';
}
}
}

And it prints
a
aa
aaa
aab
aac
aae
aaf
ab
aba
abb
abc
abd
abe
abf
ac
aca
acb
acc
acd
ace
acf
...

and so on...

and so on....-- "Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia
koodiksi" - lpkhttp://outolempi.net/ahdistus/ - Satunnaisesti pivittyv
nettisarjisspam@outolempi.net || Gedoon-S @ IRCnet ||
rot13(xvzzb@bhgbyrzcv.arg)

## Re: Generate all possibilities

This script is *much* slower than it has to be. In every loop
iteration, strlen is being recalculated. You could simply assign \$len
to strlen(\$scope) and reference \$len through your example to save some
processing time.

\$len = strlen( \$scope );
for( \$i1 = 0; \$i1 < \$len; \$x++ ) {
// stuff ..
}

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit."  -Nietzsche

## Re: Generate all possibilities

I don't know what you are trying to accomplish with this, maybe trying to crack web sites with brute
force method??

It's easy to write the algorythm to do this however - the memory variable will time out and you will
be building a string so gigantic you will run out of system memory.

You are using the wrong tool for an online password cracker