Overthewire-Bandit Level 7 - Grep
Ref:
Bandit Level 7
Level Goal The password for the next level is stored in the file data.txt next to the word millionth
Commands you may need to solve this level man, grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
#
SSH
1
2
ssh bandit7@bandit.labs.overthewire.org -p 2220
morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj
Grep
To extract only the word next to it: Commands:
1
grep millionth data.txt | awk '{print $2}'
1
grep millionth data.txt
- data.txt contains many words, one per line
- The password is on the same line as the word millionth
- grep prints that entire line
Command:
1
2
bandit7@bandit:~$
grep millionth data.txt
Output:
1
millionth dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc
Sort
Sort and then search
1
sort data.txt | grep millionth
Uniq
uniq — remove duplicates (needs sort)
1
sort data.txt | uniq | grep millionth
Strings
strings — extract printable text
1
strings data.txt | grep millionth
base64
base64 — decode before searching
1
base64 -d data.txt | grep millionth
Output:
1
base64: invalid input
✅ ASCII text → do NOT use base64 ✅ Base64 ASCII text → YES, decode
tar
tar — extract then search If data.txt were inside an archive:
1
tar -xf archive.targrep millionth data.txt
Or directly:
1
tar -Oxf archive.tar data.txt | grep millionth
gzip
gzip — search compressed file
If data.txt.gz exists:
1
gzip -dc data.txt.gz | grep millionth
1
zgrep millionth data.txt.gz
bzip2
bzip2 — search bzip2-compressed file
1
bzip2 -dc data.txt.bz2 | grep millionth
1
bzgrep millionth data.txt.bz2
xxd — hex view → convert back → search
1
xxd data.txt | xxd -r | grep millionth
This post is licensed under CC BY 4.0 by the author.
