tutorial · bandit

Bandit Level 13

Rebuild a repeatedly-compressed file from a hexdump (xxd + file + decompress loop).
banditxxdgzipbzip2tarfile
Optional narration
Marks this level complete in your browser.

Goal

data.txt is a hexdump of a file that has been repeatedly compressed.

You need to reconstruct the binary, then repeatedly identify and decompress until you reach the plaintext password.

Hints

  • Work in /tmp (use mktemp -d so you don’t collide with other players).
  • Convert hexdump → binary with xxd -r.
  • Use file after each step to learn what format you’re holding.
  • Expect a chain like: gzip → bzip2 → tar → gzip → … (varies).
Solution (click to reveal)
  1. SSH in and create a scratch dir:
ssh bandit13@bandit.labs.overthewire.org -p 2220
workdir=$(mktemp -d)
cd "$workdir"
  1. Copy the hexdump file into your scratch space:
cp ~/data.txt .
  1. Convert hexdump to a binary file:
xxd -r data.txt > blob
  1. Now iterate:
file blob

Depending on what file says, do one of these and rename the output back to blob:

  • If it’s gzip:

    mv blob blob.gz && gunzip blob.gz && mv blob blob
    
  • If it’s bzip2:

    mv blob blob.bz2 && bunzip2 blob.bz2 && mv blob blob
    
  • If it’s a tar archive:

    mv blob blob.tar && tar -xf blob.tar
    # then identify the extracted file and continue
    ls -la
    

Repeat until file blob reports plain text. Then:

cat blob

That output is the password for Level 14.

Notes

  • This level is about feedback loops: file tells you what to do next.
  • Keep filenames explicit; compression tools can overwrite if you’re sloppy.