What is Rainbow Table Attack and How to Defend Against It?

What is Rainbow Table Attack and How to Defend Against It?

4 mins readComment
Anshuman
Anshuman Singh
Senior Executive - Content
Updated on May 6, 2024 15:00 IST

With hackers coming up with new ways to crack passwords every day, it's essential to be aware of their techniques and how to defend against them. One such attack is the Rainbow Table Attack, which involves pre-computing and storing a massive database of hashes and their corresponding plaintext passwords. 

Rainbow Table Attack

In this article, we'll discuss the Rainbow Table Attack in detail. But before diving further, let's explore the topics we will cover in this article.

Table of Content (TOC)

What is the Rainbow Table Attack?

A Rainbow Table Attack is a way for hackers to crack passwords quickly. It involves pre-computing and storing a huge database of hashes (encrypted passwords) and their corresponding plaintext (original) passwords. This database is called a "rainbow table."

When a hacker gets a list of hashed passwords, they can look up each hash in the rainbow table to find the original password almost instantly, without having to brute-force each one individually.

The strength of this attack lies in the fact that rainbow tables can be pre-computed once and reused endlessly to crack passwords. However, they require a massive amount of storage space and computing power to generate.

Rainbow tables are especially effective against passwords encrypted with fast hash functions like LAN Manager (LM) or NT LAN Manager (NTLM). They are less practical against modern, slow hash algorithms like bcrypt or Argon2.

Recommended online courses

Best-suited Cyber Security courses for you

Learn Cyber Security with these high-rated online courses

– / –
33 hours
– / –
60 hours
– / –
40 hours
– / –
80 hours
– / –
32 hours
– / –
32 hours
β‚Ή1.5 L
3 years

How Does Rainbow Table Attack Work?

To understand how the attacks work, let's go through an example:

Imagine there's a website that stores user passwords using the old and insecure LM hash algorithm. As a hacker, I want to crack as many passwords as possible.

First, I pre-compute a huge rainbow table for LM hashes. It involves running every possible password combination (e.g. aaa, aab, aac, ..., zzz) through the LM hash function and storing the results in a giant database file.

This initial computation takes immense time and computing power, but it only has to be done once. Let's say the final rainbow table is 20 GB and covers all passwords up to 7 characters lo

Now, I managed to hack into the website's database and steal the file containing all the users' LM-hashed passwords. To crack a user's password using the rainbow table, I look up their hash value in my pre-computed 20 GB table. If a match is found, the corresponding plaintext password is instantly revealed.

For example, if a user's LM hash is 0x8BD6628B5783189D7A41A03B5F1830C0, I can look that up in my rainbow table and see that the original password is - money. With the rainbow table, I can keep looking up hash after hash until I have cracked most or all passwords.

Must Read Articles:

How to Defend Against a Rainbow Table Attack?

To defend against a rainbow table attack, you can take the following measures:

  • Use a modern, slow hashing algorithm like bcrypt, scrypt, or Argon2 instead of fast hashes like MD5 or SHA-1.
  • Salt the passwords uniquely for each user before hashing.
  • Use a high cost factor or iteration count for the hashing algorithm.
  • Increase the key length or hash size to make pre-computation more difficult.
  • Use a key derivation function designed to resist rainbow tables like PBKDF2, bcrypt, or Argon2.
  • Implement rate-limiting and account lockouts to slow down brute-force attempts.
  • Keep your hashed password database strongly encrypted and inaccessible.
  • Educate users on using long, complex, and unique passwords for each account.
  • Implement multi-factor authentication to add an extra layer of security.

Difference Between Rainbow Table and Brute Force Attacks

Here are the differences between these two attacks:

  • In a brute force attack, an attacker tries every possible password combination one by one until the correct password is found. Meanwhile, in a rainbow attack, an attacker pre-computes and stores a large database (rainbow table) of hashes and their corresponding plaintext passwords.
  • The brute force attack requires computing the hash for every guess and comparing it to the target hash. In contrast, the rainbow table attack looks up the hash in the pre-computed rainbow table to instantly retrieve the plaintext password.
  • Rainbow tables require significant storage and pre-computation time but allow for extremely fast cracking of any hash found in the table. Brute force is computationally expensive for each hash but does not require pre-computation or storage of a large database.
  • Rainbow tables are most effective against fast hash functions like LM or NTLM. On the other hand, brute force remains more practical for cracking modern, slow hash functions like bcrypt or Argon2.

Must Read Articles:

About the Author
author-image
Anshuman Singh
Senior Executive - Content

Anshuman Singh is an accomplished content writer with over three years of experience specializing in cybersecurity, cloud computing, networking, and software testing. Known for his clear, concise, and informative wr... Read Full Bio