liveBook · Manning

Dictionary attack

As explained in Hacking Cryptography

A dictionary attack is a password-cracking technique that hashes many possible passwords and compares the resulting digests with target digests.

A dictionary attack cracks stored password digests by hashing a large set of possible passwords with the same hash function, then looking up a target digest among those results. It does not reverse a hash function; it finds an input whose computed digest matches a stored target. section 6.4.2 section 6.5

The attack becomes practical when the candidate password space is limited. If an application permits only lowercase six-character passwords, an attacker can precompute digests for that space, store digest-to-password pairs, and perform a nearly immediate lookup after a database leak. Longer, more complex passwords enlarge the required dictionary. section 6.4.2

Figure 6.8 Hash digests are the keys. Passwords that resulted in those digests are stored as values.
figure

Read the table as a reverse index: hash digests are lookup keys, and the password guesses that produced them are stored as values. section 6.4.2

A dictionary attack follows this pattern:

  • Choose a candidate-password space, often informed by word lists or application password restrictions. section 6.4.2
  • Hash every candidate with the target system's hash function and retain the resulting digest mappings. section 6.4.2
  • Obtain target digests, such as hashed passwords exposed in a leaked username-and-digest database. section 6.4.2
  • Look up each target digest and verify any recovered candidate through the normal authentication check. section 6.4.2

Storage is the main cost of retaining every digest-to-password mapping. Hash chains reduce that storage through a time-space trade-off: they alternate hashing with a reduction function that maps a digest back into the candidate-password space. Rainbow tables refine this approach by varying the reduction function by column, helping prevent chains from merging. section 6.4.2 section 6.5

Unsalted SHA-256 password database

A Go implementation stores SHA-256 digests for randomly generated six-character passwords. A rainbow-table test generates millions of chain rows, tries to crack 100 stored user digests, and authenticates each recovered password against the database. The scenario demonstrates that hashing alone does not stop precomputed guessing when passwords come from a constrained space. section 6.4.2

Salts counter precomputed tables made without the salt. A salt is stored in plaintext alongside the digest, but it changes the hash output so an attacker must account for that salt rather than reuse a single unsalted dictionary across targets. section 6.4.2 section 6.5

How Hacking Cryptography covers it

How deep it goes
Works through digest tables, hash chains, rainbow-table code, and lookup verification; defers broader hash-function attack details.
Examples
Uses a leaked username-and-digest database, six-character passwords, SHA-256 Go code, and a 100-user rainbow-table cracking test.
What it assumes
Introduces dictionary attacks through password digests while relating them to preimage attacks and hash functions.
What you can do after
Evaluate/understand why constrained unsalted password spaces permit fast digest-to-password lookups and why salts disrupt reused tables.
How it connects
Connects password hashing with salts, rainbow tables, hash chains, reduction functions, and preimage resistance.

Also explained in

Compare how 2 books explain dictionary attack →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.