← Bandit Solutions

Level 4 → Level 5 Walkthrough

Level 4 → Level 5

Completed

📋 Level Information

Host: bandit.labs.overthewire. org
Port: 2220
Username: bandit4
Password: 2EW7BBsr6aMMoJ2HjW067dm8 EgX26xNe

🎯 Level Goal

The password for the next level is stored in the only human-readable file in the inhere directory.

Challenge: The directory contains multiple files with different file types. Only one file is human-readable ASCII text.

🔧 Solution Steps

Step 1: Connect to Bandit4

Use the password from Level 3 to log in:

ssh bandit4@bandit.labs.overthewire.org -p 2220

Password: 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe

Step 2: Navigate to the inhere Directory

Change into the inhere directory:

cd inhere

Step 3: List Files

See what files are available:

ls

You should see multiple files named with dashes: -file00, -file01, etc.

Step 4: Check File Types (Method 1 - file command)

Use the file command to identify file types:

file ./*

Output will show something like:

./-file00: data
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data

Step 5: Read the Human-Readable File

Read the file that shows "ASCII text":

cat ./-file07

Step 6: Get the Password

The file contains the password for Level 5:

lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR

🔄 Alternative Methods

Method 2: Using grep to Find Text Files

Search for files containing text:

grep -r .

This will search recursively and show content of readable files.

Method 3: Using strings command

Check each file for readable strings:

for f in ./*; do echo "=== $f ==="; strings "$f"; done

Method 4: Quick Manual Check

Since there are only 10 files, you can quickly check each one:

cat ./-file00
cat ./-file01
cat ./-file02
# ... until you find the readable one

💡 Explanation

This level teaches you about file types and how to identify them.

File Command Explained:

  • The file command determines file type by checking magic numbers
  • It can distinguish between text, binary, data, and other file types
  • file ./* checks all files in the current directory

Why Some Files Aren't Readable:

  • Binary files contain non-printable characters
  • Data files might be in specific formats
  • Only ASCII text files display properly with cat

Wildcard Usage:

  • ./* matches all files in current directory
  • Using ./ prefix helps with files starting with dashes
  • Alternative: file * also works in most cases

⚠️ Common Mistakes

  • Forgetting the ./ prefix: Files starting with dashes might be interpreted as command options
  • Not checking all files: Assuming the first file is readable
  • Misreading file output: Look specifically for "ASCII text"

💡 Pro Tips

  • You can use file ./* | grep text to filter only text files
  • The strings command can extract readable text from binary files
  • Use head or less to preview files without displaying all content
  • Tab completion works: type cat ./-f then press Tab multiple times