Lion Cipher Lab

Identify any file by its magic bytes (when the extension lies)

Why it matters

A file's extension is cosmetic: it's just the part of the name after the dot, and anyone can rename `malware.exe` to `invoice.pdf` in one click. Email filters, users, and even some tools trust that label — which is exactly why attackers abuse it. The real identity of a file is written in its first few bytes, called magic bytes or a file signature. Learning to read those bytes, confirm them with the `file` command, and flag suspiciously high-entropy (compressed/encrypted-looking) blobs is the very first move in malware triage, forensic file carving, and checking a sketchy attachment before you…

What you'll learn

Steps in this lab

  1. The one idea: bytes tell the truth, the extension does not
  2. Make yourself a lying file (the setup)
  3. Read the first bytes as hex + ASCII with xxd
  4. A pocket table of signatures to recognise
  5. Confirm with `file` — it reads bytes, not the name
  6. Entropy: a one-number 'is this compressed or encrypted?' signal
  7. The honest limits — where this can still fool you
  8. What you can now do that you couldn't before

Open the full interactive lab →