Bandit Level 9
Bandit Level 9 — find the only unique line in a file by pairing sort with uniq through a pipe.
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Level Goal
The password for the next level is stored in the file data.txt and is the only line of text that occurs only once
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
Study guide
Level map: logged in as bandit8, find the password for bandit9.
What this level teaches
Chaining small tools with pipes, and a classic gotcha: uniq only compares neighbouring lines.
Key ideas
- Pipes.
cmd1 | cmd2feeds the output of the first command to the second, so simple tools combine into powerful ones. sortorders lines so duplicates become adjacent.uniqcollapses adjacent duplicate lines; with options it can count them or print only those that occur once.- Reading
man uniqcarefully shows the option you need.
How to approach it
- Run
uniqon the unsorted file and see why it does not help. - Sort first, then pipe into
uniqwith the right option.
Why it matters
“Sort, then count unique” is the backbone of countless one-liners, from finding the most frequent IP address in a log to spotting an outlier.