Foundations of Security Week7 Seminar: Password Cracking & Secure Hashing

9272 字
46 分钟
Foundations of Security Week7 Seminar: Password Cracking & Secure Hashing

Learning Outcomes#

Understand Hashing

Learn what hashing is and why it matters in security

Hashing vs Encryption

Understand the key difference between these two concepts

Generate & Compare Hashes

Practice creating password hashes using Python scripts

Dictionary Attack

Simulate a basic attack to crack weak password hashes

Rainbow Tables

Know what rainbow tables are and how attackers use them

Salting

Learn why salting protects passwords from attacks

What is Hashing#

One-Way Function

Hashing converts any input (like a password) into a fixed-length string of characters. It's a mathematical one-way street.

Irreversible

Once hashed, you cannot retrieve the original input from the hash. This is what makes hashing perfect for password storage.

Avalanche Effect

Even a tiny change in input creates a completely different hash. This ensures uniqueness and security.

How Hashing Works

Input

Any Length

Hash Function

Processing

Output

Fixed Length

Real Example: Avalanche Effect

Input: password

5f4dcc3b5aa765d61d8327deb882cf99

Input: Password (capital P)

dc647eb65e6711e155375218212b3964

How Hashing Works#

INPUT

(Any Length)

"password123"
"Hello World!"
"abc"
"MySecretP@ss2024!"

HASH
FUNCTION

OUTPUT

(Fixed 64 chars)

ef92b778...
315f5bdb...
ba7816bf...
9d4e6af0...
The hash cannot be reversed — you can never get the original password back from a hash!

How Passwords Are Stored#

Step 1

User creates
password

Step 2

System hashes
the password

Step 3

Hash is stored
in database

Step 4

Original password
is NEVER saved

Example — What a database actually stores:

Username: alice
Password Hash: 5e884898da28047151d0e56f8dc6292773603d0d6...

DANGEROUS: Plain Text

Database stores:

Username: john_doe

Password: mysecret123

  • If database is breached, attacker sees all passwords immediately
  • Users often reuse passwords across sites
  • Legal and compliance violations (GDPR, etc.)

SECURE: Hashed Storage

Database stores:

Username: john_doe

Password Hash: 5f4dcc3b5aa765d61d8327deb882cf99

  • Even if database is breached, passwords remain protected
  • Attacker cannot reverse the hash to get original password
  • Meets security compliance requirements

Never store passwords in plain text!

This is considered negligent and can result in severe penalties.

Always hash passwords!

This is the industry standard and minimum security requirement.

Common Hash Algorithms#

MD5
SHA-1
SHA-256

MD5

AVOID

Message Digest 5

Created: 1991
Output: 128 bits (32 chars)

Why Avoid:

Vulnerable to collision attacks. Can generate same hash for different inputs.

SHA-1

DEPRECATED

Secure Hash Algorithm 1

Created: 1995
Output: 160 bits (40 chars)

Why Deprecated:

Theoretical attacks proven. Google demonstrated real collision in 2017.

SHA-256

RECOMMENDED

Secure Hash Algorithm 256

Created: 2001
Output: 256 bits (64 chars)

Why Recommended:

Part of SHA-2 family. Currently secure with no practical attacks.

Hashing vs Encryption#

Hashing

  • One-Way Process
  • No Key Required
  • Fixed Output Length

Used For:

Password storage, data integrity verification, digital signatures

Encryption

  • Two-Way Process
  • Requires a Key
  • Variable Output Length

Used For:

Data transmission, file protection, secure messaging

Dictionary Attack#

What is a Dictionary Attack?

A dictionary attack uses a pre-compiled list of common passwords ("dictionary") and tries each one against a stolen hash.

Instead of trying every possible combination (brute force), attackers focus on passwords people actually use.

Common Password Lists Include:

password123
qwerty
12345678
admin
letmein
welcome1
iloveyou
monkey

Why It Works

People Use Weak Passwords

Studies show 23 million accounts use "123456"

Fast Processing

Modern GPUs can test billions of passwords per second

Password Reuse

59% of people reuse passwords across sites

Rainbow Tables#

Understanding Rainbow Tables

A rainbow table is a pre-computed database of password hashes.

Attackers create these tables in advance, then use them to crack passwords instantly without computing hashes during the attack.

What a Rainbow Table Looks Like:

Plain Text MD5 Hash
password 5f4dcc3b5aa765d61d...
123456 e10adc3949ba59abbe...
qwerty d8578edf8458ce06fbc...
admin 21232f297a57a5a7438...
letmein 0d107d09f5bbe40cade...

Why They're Dangerous

Instant Cracking

No computation needed during attack - just a table lookup

Mass Cracking

One table can crack millions of passwords

Freely Available

Tables for common passwords can be downloaded online

Comparison#

Attack Type Main Idea How it Works Speed Main Weakness Best Defense
Dictionary
Attack
Tries likely
passwords
Uses a list of common
words, names, and weak
password patterns
Faster than brute
force
Fails if password is
uncommon and strong
Strong, unique
passwords and
account lockout
Brute Force
Attack
Tries every possible
combination
Tests all possible
characters and lengths
until the correct password
is found
Slowest Very time consuming
for long complex
passwords
Long, complex
passwords and rate
limiting
Rainbow
Table Attack
Looks up
precomputed
hash values
Compares stolen
password hashes against a
prebuilt table of
password-hash pairs
Very fast once
table exists
Fails against salted
hashes
Salting and strong
hash algorithms

Salting#

Understanding Salting

Salting is the process of adding a unique, random string to each password before hashing. This ensures that even identical passwords produce completely different hashes.

How Salting Works:

1
User enters password: password123
2
System generates random salt: x7#K9mP$
3
Combines: password123x7#K9mP$
4
Hashes combined string → stores salt + hash

Storage Format

Database stores:

Username: john_doe
Salt: x7#K9mP$
Hash: a3f7c2d8...

Salt is stored in plain text! Its purpose is to make pre-computed attacks impossible, not to be secret.


Same password, but different hashes — because of unique salts:

Simple Database illustration#

user_idusernamesalthashed_password
1001johnX7p@9Lm#2Qa9f3c7d8e2a4b1c6d7e8f9012ab34cd56ef78ab90cd12ef34
1002maryT4n$8Vb!1Zo4b2d8f1a7c9e3d5f6a1b2c3d4e5f6789ab12cd34ef56ab78
1003davidM2q&7Hy*5Lpc7e1a9d4b3f8c2e6d5a7b9c0ef12ab34cd56ef78ab90de12
1004sarahR9k!3Wd@8Xs1d8f7c6b5a4e3d2c9b0aef12cd34ab56ef78ab90cd12ef45
1005michaelP6m#1Qr$7Jn8a3d1f7c9e2b4d6f5a8c0e12ab34cd56ef78ab90cd12aa67

Password Security Best Practices#

1. Use Strong Hash Algorithms

Choose algorithms specifically designed for password hashing:

SHA-256 (OK with proper salting)

3. Enforce Strong Password Policies

Help users create secure passwords:

  • Minimum 12 characters
  • Require mixed case, numbers, symbols
  • Check against known breached passwords
  • Encourage password managers

2. Always Add Unique Salts

Every password must have its own random salt:

  • Generate 16+ byte random salt per user
  • Use cryptographically secure random generator
  • Store salt alongside hash (not a secret)

4. Implement Additional Layers

Defense in depth approach:

  • Rate limiting (prevent brute force)
  • Account lockout after failed attempts
  • Two-factor authentication (2FA)
  • Pepper (optional secret salt)

Password Hashing & Cracking Activity#

Create a directory to work in, copy the extracted files and change to it by entering cd followed by that directory name.

Option 1: Use an old project’s already installed flask and virtual environment

Option 2: Create new virtual environment and install flask mysql-connector-python

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
Foundations of Security Week7 Seminar: Password Cracking & Secure Hashing
https://firefly.anka2.top/posts/obu/level5/semester2/fos/week7/seminar/
作者
🐦‍🔥不死鸟Anka
发布于
2026-04-23
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
A-n-k-a
Over the Frontier / Into the Front
看这里~
合作翻译官绝赞招募中!
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
59
分类
6
标签
20
总字数
550,118
运行时长
0
最后活动
0 天前

目录