File Formats#
Reference of common file formats with their magic-byte
signatures (file headers used by file(1) and forensic tools
to identify types regardless of extension), MIME types, and
typical operator-relevant notes.
The file command on Linux + macOS reads /usr/share/file/magic
or /etc/magic (compiled to magic.mgc) and reports the
detected type. binwalk and foremost use similar
signatures for carving from raw images.
Documents#
Format |
Magic bytes (hex) |
Notes |
|---|---|---|
25 50 44 46 |
Adobe PDF; “%%EOF” trailer; offsets in xref. |
|
Office Open XML |
50 4B 03 04 |
ZIP container: .docx, .xlsx, .pptx, .ods, .odt. |
Microsoft CFBF |
D0 CF 11 E0 A1 B1 1A E1 |
Compound File Binary Format: legacy .doc, .xls, .ppt, .msi, .msg. |
RTF |
7B 5C 72 74 66 |
- |
PostScript |
25 21 50 53 |
- |
PS / EPS |
25 21 |
- |
Images#
Format |
Magic bytes (hex) |
Notes |
|---|---|---|
PNG |
89 50 4E 47 0D 0A 1A 0A |
8-byte signature; chunks (IHDR, IDAT, IEND). |
JPEG (JFIF / EXIF) |
FF D8 FF E0 (JFIF) / FF D8 FF E1 (EXIF) |
Trailer FF D9. |
GIF87a / 89a |
47 49 46 38 37 61 / 38 39 61 |
- |
BMP |
42 4D |
- |
TIFF (LE / BE) |
49 49 2A 00 / 4D 4D 00 2A |
EXIF tag-based; many variants. |
WebP |
52 49 46 46 ?? ?? ?? ?? 57 45 42 50 |
RIFF container. |
HEIF / HEIC |
00 00 00 ?? 66 74 79 70 68 65 69 63 |
ftyp box, “heic” brand. |
AVIF |
00 00 00 ?? 66 74 79 70 61 76 69 66 |
ftyp box, “avif” brand. |
SVG |
3C 3F 78 6D 6C / 3C 73 76 67 |
|
ICO |
00 00 01 00 |
- |
PSD |
38 42 50 53 |
- |
Audio / video#
Format |
Magic bytes (hex) |
Notes |
|---|---|---|
MP3 (ID3v2) |
49 44 33 |
Then 0xFF 0xFB sync. |
MP3 (no ID3) |
FF FB / FF F3 / FF F2 |
Frame sync. |
WAV |
52 49 46 46 ?? ?? ?? ?? 57 41 56 45 |
RIFF “WAVE”. |
FLAC |
66 4C 61 43 |
- |
OGG |
4F 67 67 53 |
Vorbis / Opus / Theora. |
M4A / AAC |
00 00 00 ?? 66 74 79 70 4D 34 41 20 |
ftyp “M4A “. |
MIDI |
4D 54 68 64 |
- |
MP4 / MOV / 3GP |
00 00 00 ?? 66 74 79 70 |
ftyp box; brand identifies sub-format. |
MKV / WebM |
1A 45 DF A3 |
Matroska EBML. |
AVI |
52 49 46 46 ?? ?? ?? ?? 41 56 49 20 |
RIFF “AVI “. |
ASF / WMV / WMA |
30 26 B2 75 8E 66 CF 11 |
- |
Archives#
Format |
Magic bytes (hex) |
Notes |
|---|---|---|
ZIP |
50 4B 03 04 / 50 4B 05 06 (empty) / 50 4B 07 08 (spanned) |
|
GZIP |
1F 8B 08 |
- |
BZIP2 |
42 5A 68 |
- |
XZ |
FD 37 7A 58 5A 00 |
- |
LZ4 |
04 22 4D 18 |
- |
Zstandard |
28 B5 2F FD |
- |
RAR (1.5+) |
52 61 72 21 1A 07 00 |
- |
RAR (5+) |
52 61 72 21 1A 07 01 00 |
- |
7-Zip |
37 7A BC AF 27 1C |
- |
TAR (POSIX ustar) |
75 73 74 61 72 |
- |
ARJ |
60 EA |
- |
LZH |
-lh0- / -lz0- (5 chars at offset 2) |
- |
ISO 9660 |
43 44 30 30 31 |
- |
EAR / WAR / JAR |
50 4B 03 04 |
ZIP-based. |
Executables#
Format |
Magic bytes (hex) |
Notes |
|---|---|---|
Windows PE |
4D 5A |
COFF; e_lfanew points to PE header. |
ELF |
7F 45 4C 46 |
Linux / BSD / Solaris. |
Mach-O 32 LE |
CE FA ED FE / FE ED FA CE |
- |
Mach-O 64 LE |
CF FA ED FE / FE ED FA CF |
- |
Mach-O Fat (Univ.) |
CA FE BA BE / BE BA FE CA |
“FAT”; multi-arch container. |
Java class |
CA FE BA BE |
Same first 4 bytes as Mach-O Fat (disambiguate via length). |
WebAssembly |
00 61 73 6D |
- |
DEX (Android) |
64 65 78 0A 30 33 35 00 |
- |
.NET Assembly |
4D 5A … PE32 with CLR header |
- |
EFI / PE+ |
4D 5A |
- |
DOS COM |
(no magic; loaded at CS:0100) |
- |
Bash script |
23 21 2F |
- |
Python (.pyc 3.11) |
CB 0D 0D 0A |
- |
Filesystems#
FS |
Magic / superblock |
Notes |
|---|---|---|
ext2 / ext3 / ext4 |
53 EF at offset 1080 (super) |
Linux native. |
NTFS |
EB 52 90 4E 54 46 53 20 20 20 20 |
Windows native. |
FAT12 / FAT16 |
55 AA at offset 510 |
MBR boot sector signature. |
FAT32 |
41 41 55 AA at offsets 0x1FE / 0x200 |
Boot sector. |
exFAT |
EB 76 90 EXFAT |
- |
HFS+ |
48 2B / 48 58 |
Apple HFS+. |
APFS |
NXSB at offset 32 |
Apple File System (modern macOS). |
ISO 9660 |
CD001 at offset 32769 |
Optical disc / image. |
UDF |
BEA01 at offset 32768 |
Optical / Blu-ray. |
SquashFS |
68 73 71 73 |
Compressed read-only Linux FS. |
Btrfs |
5F 42 48 52 66 53 5F 4D |
at offset 0x10040. |
ZFS |
0C B1 BA 00 |
“ZBOC”. |
LUKS |
4C 55 4B 53 BA BE |
Encrypted disk header. |
VHD / VHDX |
63 6F 6E 65 63 74 69 78 |
Virtual hard disk. |
VMDK |
4B 44 4D |
- |
QCOW |
51 46 49 FB |
- |
Network captures#
Format |
Magic |
Notes |
|---|---|---|
PCAP (classic) |
D4 C3 B2 A1 (LE) / A1 B2 C3 D4 (BE) |
libpcap / tcpdump. |
PCAP-NG |
0A 0D 0D 0A |
Modern multi-interface. |
ETL (Windows) |
45 56 4E 54 |
Windows event-trace log. |
Snoop (Solaris) |
73 6E 6F 6F 70 |
“snoop”. |
Data formats#
Format |
Notes |
- |
|---|---|---|
JSON |
Plain text; no magic. |
- |
JSON Lines (ndjson) |
one JSON value per line. |
- |
YAML |
Plain text; |
- |
TOML |
Plain text. |
- |
CSV / TSV |
Plain text; magic-by-content. |
- |
XML |
|
- |
HTML |
|
- |
Parquet |
|
- |
Avro |
4F 62 6A 01 |
- |
ORC |
4F 52 43 17 |
- |
HDF5 |
89 48 44 46 0D 0A 1A 0A |
- |
Feather / Arrow IPC |
41 52 52 4F 57 31 |
- |
SQLite |
53 51 4C 69 74 65 20 66 6F 72 6D 61 74 |
|
LevelDB |
ldb segments per file. |
- |
RocksDB |
segments per file. |
- |
Parquet (modular) |
columnar; PAR1 markers. |
- |
Protobuf wire |
no magic; varint type+length. |
- |
MsgPack |
no fixed magic; per-type tag. |
- |
Mail / message#
Format |
Notes |
- |
|---|---|---|
mbox |
|
- |
Maildir |
one file per message in cur/new/tmp. |
- |
PST |
21 42 44 4E |
Outlook. |
OST |
21 42 44 4E |
Outlook offline. |
EML / MSG (RFC 5322 |
) plain headers + body. |
- |
PEM |
—–BEGIN …—– |
Cert / key. |
DER |
ASN.1 binary; no fixed magic. |
- |
Forensic / specialty#
Format |
Notes |
- |
|---|---|---|
EnCase E01 / Ex01 |
45 56 46 09 0D 0A FF 00 |
Forensic image. |
AFF |
41 46 46 |
Advanced Forensic Format. |
Raw / dd |
no magic; full disk image. |
- |
Volatility VMEM |
no magic; raw memory. |
- |
PCAPng |
0A 0D 0D 0A |
Capture format (above). |
Tooling#
Tool |
Notes |
|---|---|
|
POSIX; magic-database driven. |
|
recursive carving + entropy analysis. |
|
carving by header / footer. |
|
carving fork. |
|
trIDscan; rich identifier database. |
|
pattern matching; can encode “is this format?”. |
|
rich audio / video metadata. |
|
metadata for nearly every format. |
|
Google ML-based file-type identifier (2024+). |
|
raw byte inspection. |
|
structured parsing of many formats. |
|
declarative format-parser DSL. |
|
commercial hex editor with templates. |
|
OSS hex editor with patterns. |
Operator notes#
Magic bytes ≠ ground truth, attackers tamper headers, use polyglot files (valid in multiple formats), or strip magic. Use multiple identifiers (file + binwalk + entropy).
Polyglots, a single file can be valid PDF + JAR + ZIP + GIF; routine in CTF and exploit work.
Containers, ZIP-based formats (.docx, .jar, .apk, .epub) all share the PKx03x04 magic; check the inner layout (mimetype file in EPUB, AndroidManifest in APK).
Header-only signatures fail for streamed protocols and archive carving; check trailers + cross-format constraints.
Encrypted containers (LUKS, VeraCrypt, BitLocker) have recognisable headers but no content fingerprint without the key.
Magika (Google, 2024) uses a small CNN; better than rule-based on adversarial inputs.
References#
file(1), the standard magic-database tool.
IANA Media Types, MIME registry.
Digital Forensics, broader forensic toolkit.
YARA, pattern format.