Bandit 20 → 21
Goal: get the next password from a setuid program that connects to a port and checks what it reads against the current password.
Approach
Section titled “Approach”Background a one-shot listener that prints the current password, then point the setuid client at that port.
bandit20@bandit:~$ echo "<password>" | nc -lp 1337 &[1] 2478116bandit20@bandit:~$ ./suconnect 1337Read: <password>Password matches, sending next passwordThe password you are looking for is: <password>Password
EeoULMCra2q0dSkYj561DX7s1CpBuOBtWhy it works
Section titled “Why it works”suconnect runs setuid as bandit21 and connects to a port you name, reads one line, and compares it against the current password. Upon a successful match it sends back the next one. The backgrounded nc -l listener serves the current password on localhost, so the two ends complete the handshake.