Bandit Level 5
Bandit Level 5 — identify the one human-readable file among many using the file command.
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.
filereads 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
resetcommand 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
- List the directory, then run
fileon every candidate at once using a wildcard. Remember how Level 2 told you to write the paths. - Only
catthe file thatfileidentifies 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.