bandit7-bandit-13 walkthrough

Sekina MuradSekina Murad
3 min read

This levels can be solved using man, grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd.

Command breakdown

  1. man

    • Displays command manuals

    • Usage: man [command] (Example: man grep)

    • Press q to exit, / to search within manual

  2. grep

    • Pattern search in files

    • Key flags:

      • -i (case-insensitive)

      • -v (invert match)

      • -l (show filenames only)

    • Example: grep "password" data.txt

  3. sort

    • Sorts file contents

    • Important options:

      • -n (numeric sort)

      • -r (reverse order)

      • -u (remove duplicates)

    • Example: sort -n passwords.txt

  4. uniq

    • Filters duplicate lines (requires sorted input)

    • Useful flags:

      • -c (count occurrences)

      • -d (show duplicates only)

    • Example: sort file.txt | uniq -c

  5. strings

    • Extracts printable text from binaries

    • Example: strings binary_file | grep "flag"

    • Often used with grep for CTF challenges

  6. base64

    • Encodes/decodes Base64

    • Decoding: base64 -d encoded.txt

    • Encoding: cat file | base64

  7. tr

    • Character translation/substitution

    • Common uses:

      • ROT13: tr 'A-Za-z' 'N-ZA-Mn-za-m'

      • Remove spaces: tr -d ' '

    • Example: echo "text" | tr 'a-z' 'A-Z'

  8. tar

    • Handles .tar archives

    • Key operations:

      • Extract: tar -xf archive.tar

      • Create: tar -cf archive.tar files/

      • List: tar -tf archive.tar

  9. gzip/gunzip

    • Compress: gzip file (creates file.gz)

    • Decompress: gunzip file.gz

    • Works with tar: tar -czf archive.tar.gz dir/

  10. bzip2/bunzip2

    • Compress: bzip2 file (creates file.bz2)

    • Decompress: bunzip2 file.bz2

    • Often alternates with gzip in multi-layer compression

  11. xxd

    • Hexdump utility

    • Create hexdump: xxd file > hex.txt

    • Reverse: xxd -r hex.txt > original

    • Essential for binary analysis

bandit7-bandit8

bandit8-bandit9

The uniq command only compares adjacent lines – it won't detect duplicates separated by other lines. That's why we must sort first (sort data.txt | uniq -u) to group identical lines together before filtering

bandit9-bandit10

bandit10-bandit11

Base64 is an encoding method that converts binary data to ASCII text, often ending with = or == as padding. It uses 64 characters (A-Z, a-z, 0-9, +, /) to represent data. In Bandit, base64 -d decodes these strings back to their original form. The == at the end is a telltale sign of Base64 encoding.

bandit11-bandit12

ROT13 is a simple cipher that rotates each letter by 13 positions in the alphabet (A becomes N, B becomes O, etc.), wrapping around from Z to A. It's reversible - applying ROT13 twice returns the original text. In Bandit, we use tr 'A-Za-z' 'N-ZA-Mn-za-m' to decode ROT13 text.The cipher was commonly used in early internet forums to hide spoilers or offensive content.

bandit12-bandit13

The Bandit 12→13 challenge is essentially a compression puzzle game. You start with a hexdump that needs to be converted back to binary using xxd -r, then begin a series of decompression steps where you must:

  1. Identify the compression type using file

  2. Rename the file with the correct extension (.gz, .bz2, .tar)

  3. Decompress using the right tool (gzip -d, bzip2 -d, tar -xf)

  4. Repeat until you find the final ASCII password


0
Subscribe to my newsletter

Read articles from Sekina Murad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sekina Murad
Sekina Murad