Apex › Security & web
How your 2FA code works (TOTP)
The 6-digit code in your authenticator app, demystified. At setup, the app and the server share one secret (the QR code); after that no messages pass between them, yet both compute the same code — it’s just HMAC-SHA1 of the current 30-second time step under that secret, dynamically truncated to 6 digits (HOTP, RFC 4226 / TOTP, RFC 6238). Real HMAC-SHA1 on the project’s sha1, verified against the RFC test vectors (counter 0 → 755224). Scrub time and watch the code recompute and flip every 30 seconds.
More in Security & web
- Certificates (PKI)
- Kerberos
- Revocation & CT
- Certificate Transparency
- Sigstore (keyless signing)
- Remote attestation (TEE)
- SSH transport
- SSH tunneling (-L/-R/-D)
- Identity & Auth
- JWT & alg=none
- Email auth (SPF/DKIM)
- Passkeys (WebAuthn)
- Cookies & sessions
- CORS / Same-Origin
- Injection (SQLi/XSS)
- How a buffer overflow hijacks a program
- How NX / DEP stops your shellcode
- How ROP bypasses NX
- How ASLR randomizes the addresses
- How a stack canary catches the overflow
- How CFI and shadow stacks kill ROP
- Request smuggling
- SSRF
- XXE (XML entities)
- DNS rebinding
- ARP spoofing (MITM)
- Tor / onion routing
- Censorship circumvention
- ECH (encrypted SNI)
- Onion services (.onion)
- Mix networks (batching anonymity)
- Traffic correlation attack
- Firewall rules (iptables)
- SIEM log correlation
- seccomp (syscall sandbox)
- Linux capabilities
- eBPF & the verifier
- Honeypot & honeytokens
- Port knocking
- CSRF & SameSite
- DNS tunneling (C2/exfil)
- IDS / IPS detection
- Clickjacking
- HSTS & SSL stripping
- Open redirect
- Prototype pollution
- Hash flooding (DoS)
- ReDoS (regex DoS)
- Subdomain takeover
- Site isolation
- Subresource Integrity
- Content-Security-Policy
- Attacks