Jump to content

Passwords

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
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.

<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>
Basically if I have this it echos out:

Quote

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
ccc
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 lol

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Yup, you can use recursion to get it done easier. Modified this script here to fit your needs: Brute Force PHP Script : eternal rise

#3
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
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 =)

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
It is a neat subject to look into and work with.

#5
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
Yes, I believe my data structure teacher said recursion is a main concept in computer science.

#6
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
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

#7
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts

orjan said:

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...

Just because Prolog doesn't have loops doesn't mean it is based on recursion. However, Prolog _is_ based on logic.