How to use Rainbow Tables


I have this script in Linux which finds a password by using brute force:


space="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 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 ]
	echo "Usage: " $0 SALT PASSWORD_CODED

for i in $space
for j in $space
for k in $space

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

Open in new window

If I execute it as:
 ./script ok okZdSfLRp/FqA

Open in new window

then I get the password "abc".

However, if I execute it as:
./script vt vt/4.cscQFn1M

Open in new window

then the program last a lot.

Is there a way to modify this script so it works quickly? Maybe using the Rainbow Tables technique? How can this be done?

Thank you
LVL 15
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Second password is >wA
It took about one minute on NVIDIA ION2 (very old and slow HTPC GPU) to brute-force all 3-character DES passwords with the most popular password audit tool in the world - john the ripper.
gplanaAuthor Commented:
Thank you, but by the way the goal is not to get the password by John the ripper, but to understand how can it be get, or how can I modify my code to get it faster than now (even if it's not as fast as John the ripper).

Thank you.
Rainbow tables are just pre-generated tables and you just do a match to it.  You'll have to generate a full table of possible passwords and just match it.

Your script will always be slower than a compiled cracker because it's spending its time calling another binary to check each hashed password, then closing it.
Webinar: Cyber Crime Becomes Big Business

The rising threat of malware-as-a-service is not one to be overlooked. Malware-as-a-service is growing and easily purchased from a full-service cyber-criminal store in a “Virus Depot” fashion. Join us in our upcoming webinar as we discuss how to best defend against these attacks!

You need to vectorize and parallelize loops, rainbow tables help only with fixed salt+popular password. bash cannot help to learn much, you need to learn C (without++) first.

(like oracle using salt "oracle", or access point name as part of WPA1 authentication)
computing DES is way faster than any memory access for a rainbow table lookup.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gplanaAuthor Commented:
Can you explain a little more what is "vectorize and parallelize" ?
Please read GCC or CLANG documentation on topic. Nothing of that fixes bash scripts
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.