How Passwords Are Stored
Learn why systems hash instead of store passwords, and where the hashes hide.
What you will learn
- -Explain the difference between hashing and encryption
- -Read a Linux /etc/shadow entry and a Windows NTLM hash
- -Recognize why a salt breaks precomputed attacks
Before you can crack a you have to understand what you are actually attacking. Well-built systems never store the password you typed. They store a hash of it: a fixed-length fingerprint produced by a one-way function.
Hashing is not encryption
is reversible with a key. is not. A like -256 or bcrypt takes any input and returns a fixed-length output, and there is no key that turns the output back into the input. When you in, the hashes what you typed and compares it to the stored hash. Match means you are in.
That one-way property is why an attacker who steals a hash database cannot simply read the passwords. They have to guess: hash a candidate, compare, repeat.
Plaintext is fatal
If an application stores passwords in , a single database leak hands the attacker every instantly. No cracking needed. This is why finding plaintext passwords in a config file or database dump is such a high-value moment on an engagement.
Where the hashes live
On Linux, hashed passwords sit in /etc/shadow, readable only by . On
Windows, they live in the database and in memory as hashes.
$sudo cat /etc/shadow$cat /etc/passwdA shadow line looks like this. The $6$ marks the algorithm (6 is SHA-512), the
next field is the , and the long string is the hash itself.
The salt: why two identical passwords differ
A salt is a random value mixed into the password before hashing. Two users
who both pick Summer2024 end up with completely different stored hashes because
their salts differ. That single trick defeats (giant
precomputed hash lookups) and forces the attacker to crack each hash separately.
NTLM, the classic Windows hash, is unsalted. That is one reason NTLM hashes fall so much faster than modern salted Linux hashes.
The algorithm tag tells you what you are up against before you spend a single GPU
cycle. A $6$ SHA-512 hash is slow but crackable. An NTLM hash is unsalted and
extremely fast to attack. bcrypt ($2b$) is deliberately slow and may not be
worth cracking at all. Identify first, attack second.
What does adding a unique salt to each password primarily defeat?
In one word, what property of a hash function prevents an attacker from reversing a stolen hash back into the password?
Hash functions are designed so there is no key or process that turns the output back into the input. That is the one-way property.