Skip to content

Bandit Level 20

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

Level Goal

To gain access to the next level, you should use the setuid binary in the homedirectory. Execute it without arguments to find out how to use it. The password for this level can be found in the usual place (/etc/bandit_pass), after you have used the setuid binary.

Helpful Reading Material

Study guide

Level map: logged in as bandit19, find the password for bandit20.

What this level teaches

How Unix lets a program run with its owner's privileges, and why that is both useful and dangerous.

Key ideas

  • User IDs. A process has a real UID (who started it) and an effective UID (whose permissions it uses for access checks).
  • setuid. When a file has the setuid bit (shown as s in ls -l), running it makes the effective UID the file's owner. The classic example is passwd, which lets ordinary users update a root-owned file.
  • id prints your current user and group IDs.
  • Boundary. Every setuid program is a deliberate crack in the privilege wall, so it must be written very carefully.

How to approach it

  1. Look at the binary with ls -l and note the s.
  2. Run it with no arguments, as the Level Goal suggests, and read how it wants to be used.
  3. The password then sits in the usual place under /etc/bandit_pass.

Why it matters

Hunting for setuid binaries (find / -perm -4000) is a standard step in Linux privilege escalation, both for attackers and for hardening audits.