✅ What is hexdump?
hexdump is a command-line utility that displays the binary contents of a file in hexadecimal format, often alongside ASCII representations.
In CTF challenges, hexdump is commonly used to:
- Inspect unknown binaries
- Examine file headers and magic numbers
- Detect hidden flags or embedded data
- Analyze memory or disk dumps
It’s a fast and lightweight tool for low-level forensic analysis.
🛠️ Basic hexdump Commands
1. Display a file in hex
hexdump file.bin
- Outputs the file content in hexadecimal format.
2. Canonical format (hex + ASCII)
hexdump -C file.bin
- Shows both hexadecimal bytes and their ASCII characters, making it easier to spot text and flags.
3. Specify bytes per line
hexdump -v -e '16/1 "%02X " "\n"' file.bin
- Customizes the output format (16 bytes per line in hex).
4. Inspect specific offsets
hexdump -s 1024 -C file.bin
- Starts reading from offset 1024 bytes into the file. Useful for skipping headers or irrelevant sections.
5. Output to a file
hexdump -C file.bin > output.txt
- Saves the hex view for later inspection or searching.
🎯 How hexdump is Used in CTF Challenges
1. Analyze file headers
- Identify file types via magic numbers (e.g.,
89 50 4E 47for PNG,50 4B 03 04for ZIP). - Useful for corrupted or disguised files.
2. Extract hidden flags
- Flags may be embedded in non-printable bytes or appended to a file.
- hexdump allows you to view and extract such data manually.
3. Examine binaries
- Inspect compiled programs to find strings, offsets, or instruction sequences.
- Helps in reverse-engineering challenges.
4. Analyze memory or disk dumps
- hexdump is excellent for scanning RAM or disk images for hidden data fragments or ASCII sequences.
5. Detect steganography or padding
- Patterns like repeated bytes, unusual null padding, or LSB encoding can be detected visually in hex.
🔍 Common CTF Patterns with Hexdump
| Pattern | Description | How Hexdump Helps |
|---|---|---|
| Hidden flags | Appended or embedded text in binary | Displays ASCII for quick spotting |
| Corrupted files | PNG, ZIP, or ELF with altered headers | Identify and fix magic numbers manually |
| Custom binaries | Reverse-engineering tasks | Examine offsets and instructions |
| Memory fragments | ASCII or hex data in RAM dumps | Locate secret data quickly |
| Steganography | Subtle LSB or null byte patterns | Visual inspection reveals anomalies |
| Encoded data | Base64 or XORed content | Spot hints in ASCII regions for decoding |
📌 Tips for Using hexdump in CTFs
- Combine
hexdump -Cwithgrepto search for flag patterns. - Start by inspecting magic numbers to identify file types.
- Use offset options (
-s) for large files to skip irrelevant sections. - Save output to a file for offline analysis or to try decoding later.
- hexdump is complementary to tools like
strings,binwalk, andhexedit.
🧩 Recommended Workflow in CTF
- Run
hexdump -C file.binto visualize the file content. - Inspect the header for magic numbers or anomalies.
- Scan through ASCII portions for potential flags.
- Examine specific offsets if the flag is appended or embedded.
- Combine with other tools (
strings,binwalk,zsteg) for multi-layer challenges.
Leave a Reply