Expert · Deeper lab skills: passwords, privilege, Metasploit, wireless · topic 25 of 35 · 20 min
Password hashing and cracking (your own hashes only)
Explanation
Why hashes exist
A hash is a one-way fingerprint of some data: the same input always gives the same hash, but you cannot reverse the hash back into the input. Systems store the hash of your password, not the password itself, so that a database leak does not immediately reveal everyone's password.
What "cracking" really is
Because hashing is one-way, an attacker who steals hashes cannot reverse them. Instead they guess: take a candidate password, hash it, and see if it matches the stolen hash. Tools like hashcat and John the Ripper automate this at huge speed, trying dictionary words and variations. This is "cracking". It is only practised, legally and safely, on hashes you generated yourself for learning.
Why slow, salted hashing wins
- Fast hashes (like plain SHA-256) are made for speed, so attackers can try billions of guesses per second. They are wrong for storing passwords.
- Slow hashes (bcrypt, scrypt, Argon2) are deliberately expensive, so each guess is slow and cracking becomes impractical.
- A salt is random data added to each password before hashing, so identical passwords get different hashes and precomputed tables (rainbow tables) do not work.
- The best defence of all is strong, unique passwords (or passphrases) plus MFA, so even a cracked hash has limited value.
Detection and defence
Cracking happens offline on stolen hashes, so it cannot be detected directly. The defences are preventive: store passwords with a slow, salted algorithm; enforce strong passwords and check them against known-breached lists; add MFA; and protect the password database so it is never stolen in the first place. Detection focuses on the theft (unusual database access) and on login abuse, not on the offline cracking itself.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Password hashing and cracking (your own hashes only) · 1/7
A hash is a one-way fingerprint: same input, same hash, but not reversible.
Prefer a video by a teacher? Find free videos on “password hashing salting bcrypt vs sha256 explained” on YouTube ↗
In real life: Feeling the difference
A learner hashes the word "password" with SHA-256 and with bcrypt in her lab, on hashes she made herself. A dictionary guess against the fast SHA-256 hash is found almost instantly; the same guess against the slow bcrypt hash takes far longer per attempt. The lesson lands physically: fast hashes are wrong for passwords. She writes the fix for any app she reviews: bcrypt or Argon2, with a salt, plus MFA.
Practice (0/3 done)
A hash is…
Why is bcrypt better than plain SHA-256 for storing passwords?
Use Python's standard library to hash text. Write sha256_hex(text) that returns the SHA-256 hex digest of the text (encode it as UTF-8 first). Import hashlib.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Privilege escalation concepts (labs only)Deeper lab skills: passwords, privilege, Metasploit, wireless · same module
- Metasploit basics (in the lab)Deeper lab skills: passwords, privilege, Metasploit, wireless · same module
- Wireless security conceptsDeeper lab skills: passwords, privilege, Metasploit, wireless · same module
- Storing passwords safelyBackend Development · Authentication and authorization
- Hashing: fingerprints for dataCyber Security: from zero to SOC analyst · Systems and cryptography
- Project: password strength checkerPython Programming · Projects: put it all together
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Cracking a hash means…
Answer: Hashing guesses until one matches
You cannot reverse a hash; you guess and compare.
A salt is used to…
Answer: Make identical passwords hash differently and defeat rainbow tables
A unique salt per password defeats precomputed tables.
You may practise cracking on…
Answer: Only hashes you created or are authorised to test
Only your own or explicitly authorised hashes.
Even a cracked password matters less when the account has…
Answer: Multi-factor authentication
MFA requires a second factor beyond the password.
Why is plain SHA-256 a bad password hash?Related
Answer: It is too fast, so attackers can try billions of guesses per second
Password hashes must be slow. Fast hashes let attackers test huge password lists quickly.
Why is a salt added before hashing passwords?Related
Answer: So identical passwords get different hashes and pre-computed tables fail
A unique random salt per user defeats rainbow tables and hides reused passwords.
A salt in password hashing is…Related
Answer: Extra random data so identical passwords hash differently
A salt makes each hash unique and defeats precomputed tables.
What should a website store instead of your plain password?Related
Answer: A slow, salted password hash such as bcrypt or Argon2
A slow salted hash lets the site check your password at login without keeping the password itself.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 3 more topics in “Deeper lab skills: passwords, privilege, Metasploit, wireless” before its exam: Privilege escalation concepts (labs only), Metasploit basics (in the lab), Wireless security concepts.
- Module 8 exam: deeper lab skills · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
- Then the next module, Post-exploitation ethics and reporting. 35 topics left in the course before the final exam.