Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

In a homework, there is exercice when I have a script that is used to search a password.

One of the questions is if is possible to make it "more inteligent", and I'm stuck on it.

The script:

#!/bin/bash

space1="a b c d e f g h i j k l m n o p q r s t u v w x y z"

if [  $# -le 1 ]
then 
    echo "Ussage: " $0 SALT PASSWORD_CODED
    exit
fi

for i in $space1
do
for j in $space1
do
for k in $space1
do

    variable=$(openssl passwd -crypt -salt "$1" "$i$j$k")
    if [ "$variable" = $2 ]
        then
        echo password found: $i$j$k
        exit
    fi
done
done
done

DISCLAIMER: This is homework.

If is possible I prefer only a clue to help me to discover the answer correct. Not the answer itself. I promise to put the result when I get the answer for myself.

share|improve this question
3  
+1 for request only for clue –  Sunny Oct 7 '11 at 16:17
1  
As suggested, you could use common words first or a dictionary, but brute force is brute force. In this case it's only 3 lower case characters, so it should take no time at all. I don't know if there is any other way to make the algorithm more intelligent. –  Matt Oct 9 '11 at 8:16
    
What does "more intelligent" mean? –  palacsint Nov 6 '11 at 21:57
add comment

4 Answers 4

up vote 2 down vote accepted

There's no real way to speed up the brute-force enumeration of all possible 3-letter passwords.

Perhaps you could use the dictionary. There's a finite list of 3-letter English words. They may be slightly more common.

Also, if you google for "most common passwords", some kind of 3-letter version of that list could be tried before anything else.

share|improve this answer
add comment

Look at the man page for openssl http://www.openssl.org/docs/apps/openssl.html

It is the command being executed here:

$(openssl passwd -crypt -salt "$1" "$i$j$k")

Another Clue below.
Only roll your curser over it if you need the extra help.

Do you need to pass the passwords one at a time.

Still have not worked it out!

Try: openssl passwd -crypt -salt <salt> <passwd1> <password2> <password3> ....

share|improve this answer
add comment

The best way to do

space1="a b c d e f g h i j k l m n o p q r s t u v w x y z"
for i in $space1; do
    for j in $space1; do
        for k in $space1; do
            echo $i$j$k
        done
     done
done

in bash is probably :

for i in {a..z}{a..z}{a..z}; do echo $i; done    

Then, depending on what your homeworks says, it might or might not be what you are looking for.

share|improve this answer
add comment

If you want to support passwords with 4-5-6-n characters without more loops you could write a bijective function which maps integers to strings.

Maybe you want to check the homepage of the John the Ripper password cracker. It has downloadable word lists and maybe you can find some information about how John generates the passwords. Also check the Methods of attack chapter in Rob Shimonski's Hacking techniques article.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.