Skip to content

Bandit Level 5

Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.

Level Goal

The password for the next level is stored in the only human-readable file in the inhere directory. Tip: if your terminal is messed up, try the "reset" command.

Commands you may need to solve this level

ls , cd , cat , file , du , find

Study guide

Level map: logged in as bandit4, find the password for bandit5.

What this level teaches

A filename or extension tells you nothing reliable about contents. The file command inspects the data itself.

Key ideas

  • Magic numbers. Many file formats begin with signature bytes. file reads them and reports a type such as ASCII text, data or executable.
  • Why printing binary files hurts. Sending arbitrary bytes to a terminal can send control codes that garble your display. If that happens, the reset command restores it.
  • Filenames can still be awkward. The files in this directory begin with a character that already caused trouble in an earlier level.

How to approach it

  1. List the directory, then run file on every candidate at once using a wildcard. Remember how Level 2 told you to write the paths.
  2. Only cat the file that file identifies as text.

Why it matters

Forensics, malware triage and upload filters all rely on content-based identification rather than trusting names, a theme that returns strongly in the web-security game Natas.