So I found an old backup and have a encrypted file. I know some of the letters in the password so I tried searching for a bruteforce program but I kinda gave up on that lol. I figured it wouldnt take much to figure this out myself.
Then I ran into this problem. If I have the possible characters into an array, I figured if I just put it into a loop and go through each character and inside that go through each charcter, etc I would get all the possibilities.
Basically if I have this it echos out:Code:<pre>
<?PHP
$eol = "\n";
$chars = array("a", "b", "c");
$i = 0;
while($i < count($chars)) {
$ii = 0;
while($ii < count($chars)) {
$iii = 0;
while($iii < count($chars)) {
echo $chars[$i].$chars[$ii].$chars[$iii].$eol;
$iii++;
}
$ii++;
}
$i++;
}
?>
</pre>
Which is correct but what if I want more than 3 caracters? Is there an easier way to do this then to embed more loops inside the loops? In that case if I wasnt sure if it was say 6 characters or 7 characters id have to run the program with 6 loops, then that fails I go again with 7? Is there a way to do this and just run it once? There has gotta be another way then 17+ embed loops lolaaa
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
ccc
Yup, you can use recursion to get it done easier. Modified this script here to fit your needs: Brute Force PHP Script : eternal rise
Ah recursion - should look more into this have not did to much with it quite yet besides the basic loop lol.
Thanks for it tho this really helps =)
It is a neat subject to look into and work with.
Yes, I believe my data structure teacher said recursion is a main concept in computer science.
Yes it is, there is even whole program languages based purely on recursion. (PROLOG at least), where you have a fact, which can contain of a fact and a list and the list can contain a fact and a list etc...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks