Home > Archive > PHP Language > October 2006 > Generate all possibilities
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Generate all possibilities
|
|
| Hans Worst 2006-10-02, 3:58 am |
| 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:abcdefghijklmnopqrstuvwxyzABCDEFGH
IJKLMNOPQRSTUVWXYZ01234567890!@#$%^&*()_
Can anybody help me with a compact code for generating all possibilities?
| |
| Bob Stearns 2006-10-02, 3:58 am |
| Hans Worst wrote:
> 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:abcdefghijklmnopqrstuvwxyzABCDEFGH
IJKLMNOPQRSTUVWXYZ01234567890!@#$%^&*()_
>
> Can anybody help me with a compact code for generating all possibilities?
>
>
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
| |
| Hans Worst 2006-10-02, 3:58 am |
|
"Bob Stearns" <rstearns1241@charter.net> schreef in bericht
news:PU3Ug.2834$xt3.194@newsfe07.lga...
> 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
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
| |
| Kimmo Laine 2006-10-02, 3:58 am |
| "Hans Worst" <hans@worst.invalid> wrote in message
news:noSdnZa8GfspSr3YnZ2dnUVZ8sidnZ2d@sc
arlet.biz...
>
> "Bob Stearns" <rstearns1241@charter.net> schreef in bericht
> news:PU3Ug.2834$xt3.194@newsfe07.lga...
> 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
>
try indexing the keys as well:
for($i1=0; $i1<strlen($scope); $i1++) {
$key1 = $scope{$i1};
print $key1;
for($i2=0; $i2<strlen($scope); $i2++) {
$key2 = $key1 . $scope{$i2};
print $key2;
for($i3=0; $i3<strlen(scope); $i++) {
$key3 = $key2 . $scope{$i3};
print $key3;
}
}
}
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)
| |
| Hans Worst 2006-10-02, 7:58 am |
|
"Kimmo Laine" <spam@outolempi.net> schreef in bericht
news:_t5Ug.24461$yn7.16238@reader1.news.jippii.net...
> "Hans Worst" <hans@worst.invalid> wrote in message
> news:noSdnZa8GfspSr3YnZ2dnUVZ8sidnZ2d@sc
arlet.biz...
>
> try indexing the keys as well:
>
> for($i1=0; $i1<strlen($scope); $i1++) {
> $key1 = $scope{$i1};
> print $key1;
> for($i2=0; $i2<strlen($scope); $i2++) {
> $key2 = $key1 . $scope{$i2};
> print $key2;
> for($i3=0; $i3<strlen(scope); $i++) {
> $key3 = $key2 . $scope{$i3};
> print $key3;
> }
> }
> }
I still only get aaaaaaaaaaaaaaaaaaaaaaaa...
| |
| Kimmo Laine 2006-10-02, 7:58 am |
| "Hans Worst" <hans@worst.invalid> wrote in message
news:_bSdnS2yHsoVe73YRVnyiw@scarlet.biz...
>
> "Kimmo Laine" <spam@outolempi.net> schreef in bericht
> news:_t5Ug.24461$yn7.16238@reader1.news.jippii.net...
> I still only get aaaaaaaaaaaaaaaaaaaaaaaa...
Strange... I just tried this:
$scope = 'abcdef';
for($i1=0; $i1<strlen($scope); $i1++) {
$key1 = $scope{$i1};
print $key1.'<br>';
for($i2=0; $i2<strlen($scope); $i2++) {
$key2 = $key1 . $scope{$i2};
print $key2.'<br>';
for($i3=0; $i3<strlen($scope); $i3++) {
$key3 = $key2 . $scope{$i3};
print $key3.'<br>';
}
}
}
And it prints
a
aa
aaa
aab
aac
aad
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 päivittyvä
nettisarjisspam@outolempi.net || Gedoon-S @ IRCnet ||
rot13(xvzzb@bhgbyrzcv.arg)
| |
|
| On Mon, 2 Oct 2006 09:34:13 +0800, "Hans Worst" <hans@worst.invalid> wrote:
>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:abcdefghijklmnopqrstuvwxyzABCDEFGH
IJKLMNOPQRSTUVWXYZ01234567890!@#$%^&*()_
>
>Can anybody help me with a compact code for generating 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
| |
| Koncept 2006-10-12, 6:59 pm |
| In article <PU3Ug.2834$xt3.194@newsfe07.lga>, Bob Stearns
<rstearns1241@charter.net> wrote:
> 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;
> }
> }
> }
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
|
|
|
|
|