Turn the hexdump back into binary with xxd -r, then loop: run file, rename the result to the matching extension, decompress with gunzip, bunzip2 or tar xf — until file finally reports ASCII text.
| Platform | OverTheWire Bandit |
| Verified against | OverTheWire — official level page |
| Category | Linux Fundamentals |
| Level | 12 → 13 |
| Difficulty | Beginner |
| Technique | xxd -r, file, gzip/bzip2/tar |
This is the first Bandit level that takes more than one or two commands. The trick isn't any single tool, it's the habit of asking file what you're holding after every step instead of guessing.
"Level Goal: The password for the next level is stored in the file data.txt, which is a hexdump of a file that has been repeatedly compressed. For this level it may be useful to create a directory under /tmp in which you can work."
Stuck? Try a hint before reading the solution
Turn the hexdump back into binary first, in a writable temp directory.
xxd -r, then loop: file, rename, decompress — until it's ASCII text.
The home directory isn't writable, so work in a fresh temporary directory. mktemp -d creates one with an unguessable name, so other players on the shared server can't see your files:
ssh bandit12@bandit.labs.overthewire.org -p 2220
cd "$(mktemp -d)"
cp ~/data.txt .
The file is the output of xxd — offsets on the left, hex bytes in the middle, an ASCII column on the right. xxd -r reads that format and writes the original bytes back out:
xxd -r data.txt > data
file data
data: gzip compressed data, was "data2.bin", ...
The magic bytes at the start of the rebuilt file identify it as gzip — the first of many layers.
The decompressors care about extensions, so rename before each step. The three formats you'll meet and how to open each:
# gzip compressed data
mv data data.gz && gunzip data.gz
# bzip2 compressed data
mv data data.bz2 && bunzip2 data.bz2
# POSIX tar archive
tar xf data # then run file on whatever it extracted
After every command, run file on the newest file and pick the matching line. The layers alternate in no obvious pattern, and tar archives extract to a new filename — so ls often matters as much as file.
Keep going until file stops reporting an archive or compressed data:
file data8
data8: ASCII text
cat data8
The password is [PASSWORD FOR bandit13]
The password is deliberately hidden — follow the method, you've earned it. 💪
The level is deliberately tedious to teach one lasting reflex: never guess a file's type when file can tell you. That same loop — identify, unpack, re-identify — is how you handle most forensics challenges that hand you a mystery blob.
xxd makes hexdumps and xxd -r turns them back into binaryfile reads magic bytes, not extensions — trust it over the filenamemktemp -d on shared machines so your files stay privateNew to CTFs? Start here: beginner's guide to CTFs — what a CTF is, the categories, the tools and a step-by-step plan.
Discuss this writeup with the community on the CTFdojo Discord.
Join the Discord →