We’re told that there are two files in the home directory, passwords.old and passwords.new. The password for level 18 is the only line that’s different between the two. This can be easily found using the diff utility:

bandit17@bandit:~$ diff passwords.old passwords.new
42c42
< XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
---
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX