← Bandit Solutions

Level 6 → Level 7 Walkthrough

Level 6 → Level 7

Completed

📋 Level Information

Host: bandit.labs.overthewire. org
Port: 2220
Username: bandit6
Password: P4L4vucdmLnm8I7Vl7jG1ApG fjYKqJU

🎯 Level Goal

The password for the next level is stored somewhere on the server and has the following properties:

  • Owned by user bandit7
  • Owned by group bandit6
  • 33 bytes in size

🔧 Solution Steps

Step 1: Connect to Bandit6

Use the password from Level 5 to log in:

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

Password: P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU

Step 2: Search the Entire Server

Use the find command starting from root (/) with the specified criteria:

find / -user bandit7 -group bandit6 -size 33c 2>/dev/null

Command breakdown:

  • find / - Search from root directory
  • -user bandit7 - Owned by user bandit7
  • -group bandit6 - Owned by group bandit6
  • -size 33c - Exactly 33 bytes in size
  • 2>/dev/null - Suppress permission denied errors

Step 3: Locate the File

The command will return the path to the file:

/var/lib/dpkg/info/bandit7.password

Step 4: Read the File

Read the file to get the password:

cat /var/lib/dpkg/info/bandit7.password

Step 5: Get the Password

The file contains the password for Level 7:

z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S

🔄 Alternative Methods

Method 2: Using sudo with find

If you have sudo privileges, you can search without suppressing errors:

sudo find / -user bandit7 -group bandit6 -size 33c

Method 3: Searching common directories

Manually check common locations where such files might be stored:

find /var -user bandit7 -group bandit6 -size 33c 2>/dev/null
find /etc -user bandit7 -group bandit6 -size 33c 2>/dev/null
find /home -user bandit7 -group bandit6 -size 33c 2>/dev/null

💡 Explanation

This level expands on the find command by searching the entire filesystem and dealing with permission issues.

Key Concepts:

  • Filesystem Hierarchy: Understanding where files are typically stored
  • File Permissions: Dealing with permission denied errors
  • Error Suppression: Using 2>/dev/null to hide errors

Find Command Options:

  • -user - Search by file owner
  • -group - Search by group owner
  • -size - Search by file size
  • 2>/dev/null - Redirects stderr (error messages) to /dev/null

Why Search from Root:

  • The file could be anywhere on the system
  • Starting from / ensures we search all directories
  • Some system directories require root access

⚠️ Common Mistakes

  • Forgetting error suppression: Getting overwhelmed with "Permission denied" messages
  • Wrong search path: Not starting from root and missing the file
  • Incorrect size format: Using wrong units for file size
  • Case sensitivity: Usernames and groups are case-sensitive

💡 Pro Tips

  • Use 2>/dev/null whenever searching system directories to reduce noise
  • You can combine multiple find conditions for precise searching
  • The file is typically in an unexpected location to teach filesystem navigation
  • Remember that file sizes are exact matches with the c suffix
← Previous Level Next Level →