Cyberlium

Cryptography › Module 1 › Lesson 4

BeginnerModule 1Lesson 4/5

Lab — Hash Cracking Basics

Practice ethical hash lookup on sample digests you create yourself—never real victim hashes

25 min+48 XP3 quiz
Module progress4 of 5

Opening

Lookup only what you hashed — a toy word YOU chose, in a tiny list YOU wrote. Not hashcat. Not dumps.

Last lesson, unsalted fast SHA-256 of a short password is a storage failure because guesses are cheap. This lab lets you feel that on a digest you created: you pick a toy password (not a live account secret), you write an 8-word list that includes that toy and the word password, you SHA-256 the toy with hashlib, then you compare each list word’s SHA-256 to your hex. When the toy is in the list, you “find” it instantly. When you try a word that is not in the list, you do not. That is dictionary lookup against YOUR hex, not password cracking as a service, not GPU hashcat, not rainbow tables, not HaveIBeenPwned, not /etc/shadow, not a classmate’s hash. The teaching goal is why unsalted fast MD5/SHA-256 of short words is guessable: the search space of an 8-word list you authored is eight hashes. Real attackers use huge lists and hardware — which is why Lesson 3’s slow salted KDFs exist. You will not scale this script. You will not import dumped hashes. You will not paste a hex you found online. You will write hash-crack-lab-notes.txt in $HOME/cyberlium-lab and chmod 600. Empty notes fail. Notes that contain other people’s hashes fail ethics even if Python ran. Next is Quiz — Hashing, then Symmetric Encryption (AES) in Module 2 — still not a cracking track.

1. What the script is doing: hashlib.sha256 of YOUR toy, compare to YOUR 8-word list

You encode each candidate as UTF-8 bytes, hashlib.sha256(...).hexdigest(), compare to the target hex you produced from the same toy. No salt in this demo on purpose: Lesson 3 already showed that a unique salt means the naive loop must hash salt+word per row, and a slow KDF makes each guess expensive. Here the hash is fast and unsalted so eight comparisons finish before you blink. That is the uncomfortable lesson. Include password in the list even if your toy is something else: separately hash the literal b"password" and look it up so you see a famous short word is instantly findable IN THEIR LIST — not on the internet, not in a downloaded corpus. The list is five to ten words (eight is the target). You wrote every line. If the toy is missing from the list, the script should print that it was not found — that is a successful negative, not a reason to fetch rockyou.

hexdigest() is lowercase hex; if you paste a target, strip and lower it so comparison is not a case trap. Do not use MD5 for the main path “because it is shorter” — you may print MD5 of the same toy as a sidebar to remember Lesson 2 retired it for security, but the lookup you record is SHA-256. Do not call an online hash-lookup API. Do not install hashcat. Do not use hashlib to attack a login. The target variable is a hex you just printed from a word you chose. If a tutorial says paste hashes from a breach, that tutorial is not this lab.

2. Ethics line: YOUR digest, YOUR list — never dumps, never shadow, never HIBP, never others

Password cracking as an industry practice against stolen hashes is a different problem, a different authorization boundary, and out of this course. Rainbow tables are precomputed guess maps; you will not download them. /etc/shadow holds real account verifiers on a Unix system; you will not hash it, copy it, or point the script at it. HaveIBeenPwned and other dump sites are other people’s data; you will not import them to “make the lab realistic.” hashcat against those materials is forbidden here even as “just seeing how it works.” Coworker mailbox passwords, classmate hashes, and hexes from a paste site are forbidden. The only ethical target is a digest you created from a toy you put in a list you authored, on a machine you own, in cyberlium-lab.

Notes can mention the toy word because you invented it for class — still chmod 600 so a shared account does not read your lab tree, and still never reuse that toy as a real password. Do not put banking passwords in the list “so it is realistic.” Do not email the notes. If you cannot explain the lab without a dump, you have not met the mission. Topic 7 already used hashlib for integrity; this lab uses the same library to show a storage failure mode. Same function, opposite ethics if you aim it at victims. Aim it at your eight words.

3. Wrong vs right: hashcat-on-dumps vs lookup of a toy YOU hashed in a list YOU wrote

Worked failure — same SHA-256 compare loop, opposite input. Right never includes dumped hashes, shadow, HIBP, or rainbow tables.

  • Wrong

    Paste hashes from a breach, HaveIBeenPwned, or a classmate. openssl/hashlib /etc/shadow. Install hashcat and aim it at a dump. Download rainbow tables. Expand the 8-word list into rockyou to “finish.” Call the lab complete only if you recovered someone else’s plaintext. Skip notes or chmod 644 on a shared machine.

  • Right

    Write an 8-word list including your toy and the word password. SHA-256 the toy (and separately password) with hashlib. Look each up in YOUR list. Record found/not-found, why unsalted fast hashes of short words are guessable, and the ethics line. chmod 600 script, list, and hash-crack-lab-notes.txt under $HOME/cyberlium-lab. Next: Quiz — Hashing.

4. Hands-on: toy word, 8-word list, unsalted SHA-256 lookup, lock the notes

Create wordlist.txt with eight lines you typed (include your toy and password). Run the script to print the toy’s SHA-256, then scan the list. Confirm the toy is found. Confirm a word you did not include is not found if you add a second target. Hash password and confirm it is found because it is in the list. Fill the notes. chmod 600 everything. Do not add a ninth million words from the internet.

Command guide

hash_lookup_lab.py — YOUR toy, YOUR 8-word list, unsalted SHA-256 compare only

ETHICAL LOOKUP LAB. Hash a toy YOU chose. Search a list YOU wrote. NOT hashcat. NOT /etc/shadow. NOT HaveIBeenPwned. NOT rainbow tables. NOT other people's hashes. Goal: unsalted fast SHA-256 of short words is guessable.

Command — copy this

mkdir -p "$HOME/cyberlium-lab"
cd "$HOME/cyberlium-lab"

8-word list YOU type. Include your toy AND the word password. Replace "maple-toy" with a toy you invented — NOT a live account password.

Command — copy this

cat > wordlist.txt << 'EOF'
password
admin
maple-toy
letmein
cyberlium
summerlab
guest
welcome
EOF

Command — copy this

cat > hash_lookup_lab.py << 'PY'
import hashlib
from pathlib import Path

lab = Path.home() / "cyberlium-lab"
words = [
    line.strip()
    for line in (lab / "wordlist.txt").read_text(encoding="utf-8").splitlines()
    if line.strip()
]
if not 5 <= len(words) <= 10:
    raise SystemExit("wordlist must be 5–10 words you wrote (8 is the target)")

toy = "maple-toy"  # must appear in wordlist.txt — change both together
target = hashlib.sha256(toy.encode("utf-8")).hexdigest()
print("toy:", toy)
print("unsalted SHA-256:", target)

found = None
for word in words:
    digest = hashlib.sha256(word.encode("utf-8")).hexdigest()
    if digest == target:
        found = word
        break
print("lookup in MY list:", found if found else "not in this tiny list")

# Famous short word — instantly findable IN THIS LIST because you included it.
pw_hex = hashlib.sha256(b"password").hexdigest()
pw_hit = "password" in words and hashlib.sha256(b"password").hexdigest() == pw_hex
print("sha256(password) in MY list:", pw_hit)
print("ethics: my toy, my list; no dumps; no shadow; no hashcat")
PY

Command — copy this

python3 hash_lookup_lab.py || python hash_lookup_lab.py

Command — copy this

NOTES="$HOME/cyberlium-lab/hash-crack-lab-notes.txt"
{
  echo "=== HASH LOOKUP LAB (MY digest, MY 8-word list) ==="
  echo "toy_word: (I chose this; not a live password)"
  echo "toy_sha256:"
  echo "found_in_my_list: yes (toy was one of 8 words I wrote)"
  echo "sha256_of_literal_password_found_in_my_list: yes — short word, fast unsalted hash"
  echo "why: unsalted MD5/SHA-256 of short words is guessable against even a tiny list"
  echo "not_this_lab: hashcat, rainbow tables, /etc/shadow, HIBP dumps, other people's hashes"
  echo "storage_fix_from_L03: unique salt + bcrypt/Argon2/scrypt via a library"
} > "$NOTES"

Command — copy this

chmod 600 "$HOME/cyberlium-lab/hash_lookup_lab.py" \
          "$HOME/cyberlium-lab/wordlist.txt" \
          "$NOTES"

Windows without chmod: WSL/Git Bash, or restrict files in your profile.

NEVER: paste dumped hashes into target = NEVER: hashcat -m 1400 dump.txt NEVER: python3 hash_lookup_lab.py with /etc/shadow NEVER: curl a rainbow table or HaveIBeenPwned corpus

Mission: hash-crack-lab-notes.txt — YOUR toy lookup, chmod 600

1) Write an 8-word list (5–10 allowed) that includes a toy password you chose and the word password. SHA-256 the toy with hashlib; look it up in YOUR list; also show unsalted SHA-256 of password is findable IN THAT LIST. 2) Write hash-crack-lab-notes.txt: found/not-found, why unsalted fast hashes of short words are guessable, ethics line (no dumps, no shadow, no HIBP, no hashcat, no other people’s hashes). chmod 600 script, list, notes under $HOME/cyberlium-lab. 3) Never import dumped hashes. Never download rainbow tables.

Stuck? Ask Cyberlium AI Mentor

If “this lab means I should run hashcat on a dump” still feels true, ask for a hint — not a wordlist download. Try: "Hint only: why unsalted SHA-256 of a short toy I put in an 8-word list I wrote is instantly findable, why that shows a storage failure, and why /etc/shadow, HaveIBeenPwned, rainbow tables, and other people’s hashes are out of scope?" You still fill the notes. No hashcat. No victim hexes.

You felt the storage failure on a digest you own: eight unsalted SHA-256 comparisons found a short toy because the toy was in a list you wrote, and password was findable for the same reason. That is why Lesson 3 demanded unique salts and slow KDFs — not why you download a dump. Integrity hashing (Topic 7, Lessons 1–2) and password storage stay different jobs. Next — Quiz — Hashing — ten APPLY items on properties, MD5/SHA-1/SHA-256, salt and slow hashes, and this lab’s ethics line. Then Module 2 opens Symmetric Encryption (AES). Still not a cracking shop.

Knowledge Check

1

APPLY: hash_lookup_lab.py finds maple-toy (or your toy) in an 8-word list you wrote, and sha256(b"password") hits because password is on that list. What did you demonstrate, and what is this lab not?

Multiple choice

Knowledge Check

2

APPLY: True or False: Fast unsalted hashes of common passwords are easy to recover with dictionaries, so the ethical next step is hashcat against a stolen dump and a rainbow-table download.

True or False

Knowledge Check

3

APPLY: A classmate pastes a hex from an online dump into target = and wants to grow wordlist.txt from the internet. Correct pair?

Multiple choice

← Previous

Answer all 3 knowledge checks to continue. (0/3 answered)