Cyberlium

Ethical › Module 20 › Lesson 4

BeginnerModule 20Lesson 4/5

Lab — Re-hash a File and Recheck a Cert

Topic 8 labs again: YOUR file SHA-256 + example.com cert fields.

25 min+40 XP4 quiz
Module progress4 of 5

Visual · hash_cert_lab

Hash a file YOU created. Read public certificate fields on example.com. Lock ceh-crypto-lab.txt at mode 600. No hashcat. No fake CA. No MITM.

Opening

Re-hash YOUR bytes. Recheck a public leaf. Lock the notes. That is the whole cryptography lab.

Lessons 1–3 carried Topic 8 into the tester frame: hashing is a one-way fingerprint, encryption is a lockbox, the padlock is not “site is safe,” and keys do not ride in PDFs. This lab is the hands that match those sentences. You will author a small file under $HOME/cyberlium-lab, compute SHA-256 of its contents (binary read, chunked), optionally edit one character and watch the digest move, then read subject, issuer, dates, and SAN from example.com — the documentation host, not a machine you exploit — with openssl and/or Python’s ssl module. You will fill $HOME/cyberlium-lab/ceh-crypto-lab.txt and chmod 600. You will not run hashcat. You will not invert the hex. You will not hash /etc/shadow or a dump. You will not plant a fake CA. You will not MITM a café, a roommate, or a classmate. You will not fuzz example.com. You will not paste a private key into the notes. This is original Cyberlium teaching mapped to the CEH v13 cryptography domain — not official EC-Council training, not a cert, not exam dumps. Next is Quiz — Cryptography (CEH Domain): twelve APPLY items across the 20-domain path and this Topic 8 recap. Then Continue to Web Security (OWASP Top 10) — SQL Injection Theory — still no live SQLi against strangers.

1. Lab contract: YOUR file hash plus example.com public fields — nothing else

Two objects, one notes file. Object A is a file YOU created. Hash contents, not the filename. Open "rb". SHA-256 hex is 64 characters. If you edit one byte, write the new hex and DIFFER — avalanche from Lesson 1. Object B is the public HTTPS certificate for example.com (or a domain YOU own). Write subject, issuer, notBefore, notAfter, SAN, and name match. That is Topic 8’s cert lab in a CEH-shaped module. Combining them in ceh-crypto-lab.txt is how you prove you still have both muscles: integrity of your bytes, literacy of a public leaf. It is not how you prove you can crack or intercept. If openssl is missing, Python ssl is enough for Object B. If Python is missing, openssl dgst -sha256 is enough for Object A. You need both objects in the notes. One without the other fails the mission.

HOST for the cert read is the characters example.com unless you replace them with a domain YOU own. Do not replace them with a bank, a school portal, a café gateway, or “the internet for one packet.” Reading a public certificate is ordinary. Pointing the same tools at an internal hostname you are not allowed to test is not this lab. Print HOST on the first Python line so the artifact is self-explaining. Do not take argv for HOST. A flag you forget is how yesterday’s documentation read becomes today’s intercept of a stranger. example.com is not in scope as a pentest target. It is in scope as a public documentation host this course names. Do not exploit it. Do not directory-brute it. Do not treat a 200 as a finding.

Command guide

YOUR file hash plus example.com fields — WHAT/WHY

═══ COMMANDS ═══

Command — copy this

cat > "$NOTES" << 'EOF'
=== CRYPTO LAB (Cyberlium M20 L04) ===
FILE_SHA256: (MY file)
CERT_SUBJECT_OR_NOTAFTER: (example.com public fields)
ETHICS: no hashcat, no intercept, no foreign dumps
EOF

2. Hashing YOUR bytes: create, SHA-256, optional avalanche — never invert

Create m20-crypto-lab.txt (or keep m20-hash-demo.txt from Lesson 1 if you still have it — still YOUR words). hashlib.sha256() in Python is the primitive Topic 7 and Topic 8 used. Feed it bytes, then hexdigest(). openssl dgst -sha256 file does the same job. Matching hex across both tools is a nice check; mismatch usually means you hashed a different file or a text-mode newline rewrite. Do not hash /etc/passwd “because it is a file.” Do not hash a classmate’s homework. Do not add a wordlist. The lab is complete when you have a hex of a file you authored. Recovering a password from that hex is not a requirement and not allowed as a method. There is no hashcat line in the block. If a blog titled with a cert acronym publishes one, that blog is not this course.

Windows: py the Python files, or Git Bash/WSL for openssl. Record which OS you used. chmod 600 the demo file, the scripts, and the notes. If chmod is missing, restrict the NTFS ACL on those files in your profile. World-writable 777 fails. Notes that list dumped hashes fail ethics even if YOUR file also hashed. Empty placeholders fail. You may copy Lesson 1’s known-string hex into this notes file as extra literacy; you must still hash a file. A string-only lab is incomplete.

Command guide

Hash YOUR bytes — WHAT/WHY (never invert)

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install python3

macOS:

Command — copy this

brew install python3

Windows: Download https://python.org/downloads/

═══ COMMANDS ═══

Command — copy this

python3 - << 'PY'
from pathlib import Path
import hashlib
b = (Path.home()/'cyberlium-lab'/'crypto-lab.bin').read_bytes()
print('sha256', hashlib.sha256(b).hexdigest())
b2 = b[:-1] + bytes([(b[-1] ^ 1)])
print('avalanche_sha256', hashlib.sha256(b2).hexdigest())
print('never_invert')
PY

3. Public cert literacy: openssl or Python ssl on example.com — not exploiting it

echo | openssl s_client -connect example.com:443 -servername example.com piped to openssl x509 -noout -subject -issuer -dates -ext subjectAltName prints the fields. Python ssl.create_default_context().wrap_socket(..., server_hostname=HOST) then getpeercert() prints a dict with the same ideas. curl -vI --connect-timeout 10 https://example.com is optional confirmation that HTTPS answered — copy status and TLS version, not cookies, not a body dump of someone else’s session (there isn’t one; do not go looking). -servername matters. Without SNI you may see a default cert; write that observation if it happens, then rerun with SNI. Save a PEM of the public leaf if you want; chmod 600 because the folder holds toy-lab-secret.txt from Lesson 3. Never save a private key. Never addstore. Never mitmproxy.

Failure modes that still pass if you tell the truth: offline, TLS timeout, openssl missing — switch to Python or retry later on the same HOST; write “openssl missing, used Python ssl” in the notes. Failure modes that fail the course: success against a bank you do not own, HOST rewritten to campus, fake CA on a tablet, hashcat beside the hasher, notes chmod 644 on a shared PC, claiming example.com was “pwned” because you read a public field. Reading notAfter is not an exploit. Calling it an exploit in Discord is theater and a hygiene miss.

Command guide

Public cert literacy — WHAT/WHY then lock

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install python3

macOS:

Command — copy this

brew install python3

Windows: Download https://python.org/downloads/

═══ COMMANDS ═══

Command — copy this

python3 - << 'PY'
import ssl, socket
ctx = ssl.create_default_context()
with ctx.wrap_socket(socket.socket(), server_hostname='example.com') as s:
s.settimeout(8); s.connect(('example.com', 443))
print('notAfter', s.getpeercert().get('notAfter'))
PY

4. The artifact: ceh-crypto-lab.txt mode 600 — both objects, legal line, refuse line

Required rows: legal line (original Cyberlium teaching mapped to the CEH v13 cryptography domain — not official EC-Council training, not a cert, not exam dumps); file path you authored; file SHA-256 before (and after edit if you did avalanche); MATCH/DIFFER; hashing_is_not_encryption: True; host_typed example.com or YOUR domain; subject; issuer; notBefore; notAfter; SAN; name_match; padlock_means (encrypted path to a matching name, not site-is-safe); ethics (no hashcat, no dumps, no MITM, no fake CA, no private keys in this file, no exploiting example.com); chmod reminder. If Lesson 3’s toy secret still exists, do not paste it here. This notes file also travels in the sense that you might screenshot it — keep it REDACTED of keys.

Fill placeholders in your own words. A template you did not edit fails. Dates you copy from openssl/Python are evidence of YOUR read, not a password. If name_match is no, say so and still do not intercept to “fix” it. If you used a domain you own, write that hostname instead of example.com and keep every other ethics line. Two public leaves are optional, not a reason to add a third host you do not own.

5. Ethics hard stops: no hashcat, no cracking, no fake CAs, no MITM, no stranger files

Named so you can refuse them: hashcat, John, Hydra, rainbow tables, /etc/shadow, HaveIBeenPwned, classmate disks, mitmproxy, sslstrip, addstore, fake CA on family/classmate devices, verify=False at a bank, fuzzing or scanning example.com, pasting BEGIN PRIVATE KEY into ceh-crypto-lab.txt, chmod 777. This lab does not become complete when those tools run. It becomes incomplete. Module 1’s permission line still wins: “I was practicing” is not a defense. A cert acronym in a blog title is not a warrant. Skill does not create consent. example.com’s public certificate is documentation. Other people’s sessions are not.

If the client (Python) refuses because you edited HOST to something you do not own, that refusal is a passing ethics check — put HOST back to example.com or a domain you own and rerun. If hashcat is already installed from some other life, do not point it at this hex. Close it. Write the refuse line. The hex is an integrity fingerprint of a file you wrote, not a password verifier to attack.

6. Wrong vs right: cracking / intercepting vs YOUR SHA-256 plus a public leaf

Worked failure — same hashlib and openssl, opposite job. Right never needs a dump, a fake CA, or a second host when YOUR file and example.com can answer.

  • Wrong

    HOST = bank, campus, café, classmate, or argv. Hash /etc/shadow or a HIBP paste. hashcat the lab hex. mitmproxy / fake CA / sslstrip. Fuzz example.com. Paste a private key into the notes. chmod 777. Call the lab incomplete without recovered plaintext. This course is not official CEH training and does not grade that hunt.

  • Right

    Author a file, SHA-256 the bytes, read example.com (or YOUR domain) subject/issuer/dates/SAN, write hashing ≠ encryption and padlock ≠ safe, fill ceh-crypto-lab.txt, chmod 600 under $HOME/cyberlium-lab. No hashcat. No MITM. No fake CA. Next: Quiz — Cryptography (CEH Domain) — twelve APPLY items, then Web Security (OWASP Top 10).

7. Hands-on: hash YOUR file, read example.com fields, lock ceh-crypto-lab.txt

Follow the block. Create the file with your own sentence. Run the hasher. Run the cert reader. Fill every notes placeholder. chmod 600. Windows notes sit in the comments. Do not merge this with a flood, a scan, or a phishing kit. When notes are filled, you are done. Stop. Do not add a stranger’s host because example.com felt later.

Command guide

ceh_crypto_lab.sh — YOUR SHA-256 + example.com fields; ceh-crypto-lab.txt chmod 600

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install openssl
sudo apt install python3
sudo apt install dnsutils

macOS:

Command — copy this

brew install python3

Windows:

Command — copy this

choco install openssl

Download https://python.org/downloads/ Use nslookup (built-in)

═══ COMMANDS ═══

Command — copy this

cd "$HOME/cyberlium-lab"

Command — copy this

cat > "$HOME/cyberlium-lab/m20-crypto-lab.txt" << 'TXT'
cyberlium m20 crypto lab — I authored this file for SHA-256 integrity.
edit one character later if you want avalanche (MATCH/DIFFER).
TXT

Command — copy this

cat > "$HOME/cyberlium-lab/ceh_crypto_hash.py" << 'PY'
"""SHA-256 of a file YOU created. Integrity, not cracking."""
import hashlib
from pathlib import Path

lab = Path.home() / "cyberlium-lab"
demo = lab / "m20-crypto-lab.txt"
if not demo.is_file():
raise SystemExit("create m20-crypto-lab.txt under cyberlium-lab first")

h = hashlib.sha256()
with demo.open("rb") as f:
for chunk in iter(lambda: f.read(65536), b""):
    h.update(chunk)
print("file:", demo)
print("file_sha256:", h.hexdigest())
print("hashing_is_not_encryption: True")
print("ethics: YOUR bytes only; NEVER hashcat; NEVER /etc/shadow; NEVER dumps")
PY

Command — copy this

cat > "$HOME/cyberlium-lab/ceh_crypto_cert.py" << 'PY'
"""Public cert fields for example.com. Documentation host — not a pentest."""
import socket
import ssl

HOST = "example.com"  # HARDCODED documentation host, or replace with a domain YOU own.
if HOST != "example.com":
print("warning: HOST changed — allowed only if YOU own this domain")

ctx = ssl.create_default_context()
with socket.create_connection((HOST, 443), timeout=10) as sock:
with ctx.wrap_socket(sock, server_hostname=HOST) as ssock:
    cert = ssock.getpeercert()
    print("host:", HOST)
    print("tls_version:", ssock.version())
    print("subject:", cert.get("subject"))
    print("issuer:", cert.get("issuer"))
    print("notBefore:", cert.get("notBefore"))
    print("notAfter:", cert.get("notAfter"))
    print("SAN:", cert.get("subjectAltName"))
    print("padlock_means: encrypted path to a matching name — NOT site is safe")
    print("ethics: public cert only; NEVER MITM; NEVER fake CA; NEVER intercept others")
PY

Command — copy this

python3 "$HOME/cyberlium-lab/ceh_crypto_hash.py" || python "$HOME/cyberlium-lab/ceh_crypto_hash.py"

Command — copy this

if command -v openssl >/dev/null 2>&1; then
| openssl x509 -noout -subject -issuer -dates -ext subjectAltName
openssl dgst -sha256 "$HOME/cyberlium-lab/m20-crypto-lab.txt"

Command — copy this

python3 "$HOME/cyberlium-lab/ceh_crypto_cert.py" || python "$HOME/cyberlium-lab/ceh_crypto_cert.py"

Command — copy this

{

Command — copy this

"$HOME/cyberlium-lab/ceh_crypto_hash.py" \
      "$HOME/cyberlium-lab/ceh_crypto_cert.py" \
      "$NOTES"

Mission: ceh-crypto-lab.txt — YOUR SHA-256 + example.com fields, chmod 600

1) Author a file under $HOME/cyberlium-lab, compute SHA-256 of its contents (optional one-character edit + MATCH/DIFFER). 2) Read subject, issuer, dates, and SAN from example.com or a domain YOU own (openssl and/or Python ssl). Fill $HOME/cyberlium-lab/ceh-crypto-lab.txt, chmod 600. 3) Ethics: no hashcat, no dumps, no MITM, no fake CA, no exploiting example.com, no private keys in the notes. Hashing ≠ encryption. Padlock ≠ safe.

Stuck? Ask Cyberlium AI Mentor

If “the lab is incomplete without hashcat or a proxy” still feels true, ask for a hint — not a cracker. Try: "Hint only: why SHA-256 of MY file is integrity, how Python ssl or openssl prints example.com fields, why hashing is not encryption, and why MITM/fake CA/hashcat fail ethics?" You still fill ceh-crypto-lab.txt. No dumps. No other HOST.

You ran a real cryptography lab without leaving integrity and public documentation: YOUR SHA-256, example.com fields, locked notes, no cracking, no intercept. That is authorized crypto practice as Cyberlium teaches it — original, not an exam dump, not EC-Council lab text, not a cert. Next — Quiz — Cryptography (CEH Domain) — twelve APPLY items on the 20-domain permission line and this Topic 8 recap. Then Continue to Web Security (OWASP Top 10): SQL Injection Theory. Parameterized queries remain the fix. Random sites remain out of scope.

Knowledge Check

1

APPLY: A classmate says the lab is incomplete without hashcat on the hex and mitmproxy on example.com. What is the assigned pair, and what do you do?

Multiple choice

Knowledge Check

2

APPLY: True or False: Reading example.com certificate dates with Python ssl is exploiting IANA, so the ethical substitute is a fake CA against classmates.

True or False

Knowledge Check

3

APPLY: You ran the Lesson 4 lab. Which completion matches ethics and hygiene?

Multiple choice

Knowledge Check

4

APPLY: curl of http://192.168.0.1/ shows a home router login (TP-Link / Netgear / Huawei / "Router Admin"). Is that DEMO in scope as a hacking target?

Multiple choice

← Previous

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