Overview
Once you have preserved evidence and understand its timestamps, the next skill is examining individual files. File analysis is the craft of determining what a file really is, what it contains, and whether it hides more than it shows. File names and extensions lie easily, so forensic file analysis works from the actual bytes. This lesson covers file signatures (magic numbers), metadata, strings, hashing for identification, and the idea of hidden or embedded data.
Learning objectives
- Explain why a file's true type is determined by its content, not its extension.
- Identify files by their signature (magic bytes).
- Extract useful information from metadata and embedded strings.
- Understand how data can be hidden inside files and how hashing aids identification.
Core concept
A file is just a sequence of bytes. The extension (.jpg, .pdf, .docx) is only a naming convention — a hint to the operating system about which program should open it. Anyone can rename a file, so the extension is not trustworthy evidence of what a file is. What is reliable is the file's internal structure, especially its file signature (also called a magic number): a short, fixed sequence of bytes at the very start of the file that identifies its true format.
Forensic file analysis therefore starts by asking three questions:
- What is this file, really? — determined from its signature and structure, not its name.
- What does it contain? — its readable content, metadata, and embedded data.
- Is anything hidden? — appended data, embedded files, or unusual structure.
How it works
File signatures (magic numbers). Most formats begin with recognizable bytes. For example, PNG images begin with the bytes 89 50 4E 47 (the last three are the ASCII letters PNG), a PDF begins with %PDF, and a ZIP archive begins with PK. Tools inspect these leading bytes to report the true type regardless of the extension. If a file named photo.jpg actually begins with PK, it is really a ZIP archive in disguise — an immediate red flag worth investigating.
Metadata. Many formats embed descriptive data about themselves. Images may carry EXIF metadata (camera model, settings, and sometimes location if not stripped); documents carry author, creation and modification times, and software versions. This metadata is a rich artifact source and is often exactly where a CTF flag hides.
Strings. Even a binary file usually contains runs of human-readable text — error messages, URLs, embedded comments, or configuration. Extracting the printable strings from a file is a fast way to spot interesting content: a flag, a hostname, a password left in a config, or a hint about what a program does.
Hashing for identification. The same hashing used for integrity also identifies files. If you compute a file's hash, you can compare it against known values — for instance to recognize a known-good system file, or (in real practice) to match against databases of known files so you can focus on the unknown ones.
Hidden and embedded data. Files can conceal information in several ways: data appended after the format's logical end (many viewers ignore trailing bytes), one file embedded inside another (a ZIP tucked after a JPEG's image data), or content tucked into structural fields. Recognizing that the visible content may not be the whole file is central to forensics and to the steganography category in CTFs.
Practical example
In an authorized CTF forensics challenge you are given certificate.png. Following sound method rather than trusting the name:
- Check the signature. The first bytes are
89 50 4E 47, confirming it really is a PNG. Good — the name is honest so far. - Extract strings. Scanning for printable text near the end of the file, you notice the letters
PKfollowed by what looks like a file name.PKis the ZIP signature — a ZIP archive appears to be appended after the image data. - Investigate the embedded data. You carve out the trailing ZIP portion and open it, revealing a text file whose contents are the flag, for example
flag{f1le_carv1ng_f1nds_h1dden_z1ps}. - Confirm with metadata. Checking the PNG's metadata, you also find a comment field that corroborates the challenge author's hint.
No step relied on the extension. The signature told you the container, the strings revealed the anomaly, and carving the embedded data produced the answer. (These are illustrative values for teaching; a real challenge would provide its own file and flag.)
Cybersecurity relevance
File analysis is fundamental to malware analysis and incident response. A responder must determine whether a suspicious file is what it claims to be, what it does, and whether it carries a hidden payload — all starting from the bytes, because attackers routinely disguise files with misleading names and extensions. Extracting strings can quickly reveal an attacker's infrastructure (hostnames, URLs) or embedded commands; metadata can reveal who created a document or which tool produced malware.
The same skills power the forensics and steganography categories in CTFs, where flags hide in metadata, in appended data, or inside embedded files. Building the reflex to verify a file's true type and to look past its visible content is what separates careful analysis from being fooled by a renamed file.
Common mistakes
- Trusting the file extension instead of verifying the true type from the signature.
- Overlooking metadata, which often holds the most revealing information (or the flag).
- Only viewing a file in its default application, which may ignore appended or embedded data.
- Forgetting to extract strings, missing plainly readable clues inside a binary.
- Assuming the visible content is the whole file when data may be hidden after the logical end.
Key takeaways
- A file's true type comes from its content — the signature (magic number) at its start — not its extension, which can be changed at will.
- Metadata (EXIF, document properties) and extracted printable strings are rich sources of information and common hiding places for flags and clues.
- Hashing identifies files (matching known values) as well as verifying integrity.
- Data can be appended after a file's logical end or embedded inside another file; always ask whether the visible content is the whole file.
Check your understanding
- Why is a file's signature (magic number) more trustworthy than its extension when determining what the file really is?
- Name two ways data can be hidden in a file that a default viewer would not show, and how you might detect them.

