Background
The Bandit wargame is aimed at absolute beginners. It will teach the basics needed to be able to play other wargames as well as the basics of the Linux command line.
sshpass Command
| |
Levels 0 thru 4
Bandit 0 (https://overthewire.org/wargames/bandit/bandit0.html)
| |
Navigate to your bandit working directory:
cd ~/Documents/overthewire/bandit
We are going to store the SSH credentials for each level in seperate files within the directory that we just navigated to and use sshpass to manage our credentials. The title of the file is the username and the password is entered on the first line of the file.
Install sshpass with the following on debian-based distros:
sudo apt install sshpass
Enter the following command:
nano bandit0
Enter the provided password:
bandit0
Begin to exit nano by hitting Ctrl + x
Nano will ask “Save modified buffer?”
y
Nano will ask “File Name to Write: bandit0”, hit enter
Bandit 0 –> 1 (https://overthewire.org/wargames/bandit/bandit1.html)
| |
Connect to the Bandit 0 level with sshpass:
| |
ls -la
cat readme
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 1 –> 2 (https://overthewire.org/wargames/bandit/bandit2.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. For example:
| |
Note how bandit0 has changed to bandit1 for the next level. Connect to the level.
ls -la
cat ./-
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 2 –> 3 (https://overthewire.org/wargames/bandit/bandit3.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
cat 'spaces in this filename'
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 3 –> 4 (https://overthewire.org/wargames/bandit/bandit4.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
cd inhere
ls -la
cat '.hidden'
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Levels 5 thru 9
Bandit 4 –> 5 (https://overthewire.org/wargames/bandit/bandit5.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
cd inhere
file ./* #all files but list ‘data’ except -file07 lists ‘ASCII text’
strings ./* #prints strings of all files. doesnt specify file per line though
cat ./-file00
cat ./-file01
cat ./-file02
cat ./-file03
cat ./-file04
cat ./-file05
cat ./-file06
cat ./-file07
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 5 –> 6 (https://overthewire.org/wargames/bandit/bandit6.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
cd inhere
ls -lR #Recursively list files in all folders
find \! -executable -size 1033c
cat ./maybehere07/.file2
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 6 –> 7 (https://overthewire.org/wargames/bandit/bandit7.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
find / -size 33c -user bandit7 -group bandit6
find / -size 33c -user bandit7 -group bandit6 2>/dev/null #redirect stderror output to trash
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 7 –> 8 (https://overthewire.org/wargames/bandit/bandit8.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
cat data.txt
cat data.txt | grep millionth
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 8 –> 9 (https://overthewire.org/wargames/bandit/bandit9.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat data.txt
cat data.txt | sort | uniq -c | grep -v "10"
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Levels 10 thru 14
Bandit 9 –> 10 (https://overthewire.org/wargames/bandit/bandit10.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat data.txt
cat data.txt | strings | grep "===="
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 10 –> 11 (https://overthewire.org/wargames/bandit/bandit11.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat data.txt | base64 -d
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 11 –> 12 (https://overthewire.org/wargames/bandit/bandit12.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat data.txt
echo "echo "Gur cnffjbeq vf WIAOOSFzMjXXBC0KoSKBbJ8puQm5lIEi" | rot13"
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 12 –> 13 (https://overthewire.org/wargames/bandit/bandit13.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
mkdir /tmp/t0nberry
cp data.txt /tmp/t0nberry
cd /tmp/t0nberry
xxd -reverse data.txt > reverse
file reverse gzip compressed data
mv reverse reverse.gz
gunzip reverse.gz
file reverse bzip2 compressed data
bunzip2 reverse
file reverse.out gzip compressed data
mv reverse.out reverse.gz
gunzip reverse.gz
file reverse tar archive
tar xf reverse
file * data5.bin is tar
tar xvf data5.bin
file *
bunzip2 data6.bin
file *
tar xvf data6.bin.out
file *
mv data8.bin data8.gz
gunzip data8.gz
cat data8
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 13 –> 14 (https://overthewire.org/wargames/bandit/bandit14.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
ssh -i sshkey.private bandit14@localhost -p 2220
Levels 15 thru 19
Bandit 14 –> 15 (https://overthewire.org/wargames/bandit/bandit15.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat /etc/bandit_pass/bandit14 | nc localhost 30000
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 15 –> 16 (https://overthewire.org/wargames/bandit/bandit16.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat /etc/bandit_pass/bandit15
cat /etc/bandit_pass/bandit15 | openssl s_client -connect localhost:30001
cat /etc/bandit_pass/bandit15 | openssl s_client -connect localhost:30001 -ign_eof
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 16 –> 17 (https://overthewire.org/wargames/bandit/bandit17.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
nmap localhost -p31000-32000
| |
cat /etc/bandit_pass/bandit16
cat /etc/bandit_pass/bandit16 | openssl s_client -connect localhost:31046
cat /etc/bandit_pass/bandit16 | openssl s_client -connect localhost:31518 -ign_eof
cat /etc/bandit_pass/bandit16 | openssl s_client -connect localhost:31691 -ign_eof
cat /etc/bandit_pass/bandit16 | openssl s_client -connect localhost:31790 -ign_eof
| |
ssh -i bandit17 bandit17@bandit.labs.overthewire.org -p 2220
Bandit 17 –> 18 (https://overthewire.org/wargames/bandit/bandit18.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat passwords.old
cat passwords.new
diff passwords.old passwords.new
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 18 –> 19 (https://overthewire.org/wargames/bandit/bandit19.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
sshpass -p cat bandit18 ssh bandit18@bandit.labs.overthewire.org -p 2220 “cat readme”
Levels 20 thru 24
Bandit 19 –> 20 (https://overthewire.org/wargames/bandit/bandit20.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
ls -la
./bandit20-do cat /etc/bandit_pass/bandit20
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 20 –> 21 (https://overthewire.org/wargames/bandit/bandit21.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
nc -lvp 8888
./suconnect 8888 supply bandit20 pass in listener window after connecting to receive bandit21 pass
Bandit 21 –> 22 (https://overthewire.org/wargames/bandit/bandit22.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cd /etc/cron.d
cat cronjob_bandit22
cat /usr/bin/cronjob_bandit22.sh
cat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 22 –> 23 (https://overthewire.org/wargames/bandit/bandit23.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cd /etc/cron.d
cat cronjob_bandit23
echo I am user bandit23 | md5sum | cut -d ' ' -f 1
cat /tmp/8ca319486bfbbc3663ea0fbe81326349
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 23 –> 24 (https://overthewire.org/wargames/bandit/bandit24.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cd /etc/cron.d
ls -la
cat cronjob_bandit24
cat /usr/bin/cronjob_bandit24.sh
myname=bandit24
cd /var/spool/bandit24/foo
mkdir /tmp/t0nberry2
chmod 777 /tmp/t0nberry2
nano getpass.sh
| |
chmod +x getpass.sh
cat /tmp/t0nberry2/bandit24
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Levels 25 thru 29
Bandit 24 –> 25 (https://overthewire.org/wargames/bandit/bandit25.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
cat /etc/bandit_pass/bandit24
nc localhost 30002
mkdir /tmp/t0nberry3
cd /tmp/t0nberry3
| |
chmod +x index.sh
./brute.sh
cat combinations.txt | nc localhost 30002 >> result.txt
sort result.txt | uniq -u
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 25 –> 26 (https://overthewire.org/wargames/bandit/bandit26.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
shrink screen small
ssh -i bandit26.sshkey bandit26@localhost -p 2220
press v to enter vim
:r /etc/bandit_pass/bandit26
Bandit 26 –> 27 (https://overthewire.org/wargames/bandit/bandit27.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
shrink screen small
ssh -i bandit26.sshkey bandit26@localhost -p 2220
press v to enter vim
:set shell=/bin/bash
:shell
cat /etc/bandit_pass/bandit27
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 27 –> 28 (https://overthewire.org/wargames/bandit/bandit28.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
mkdir /tmp/t0nberry4
cd /tmp/t0nberry4
git clone "ssh://bandit27-git@localhost:2220/home/bandit27-git/repo"
ls
cd repo
cat README
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 28 –> 29 (https://overthewire.org/wargames/bandit/bandit29.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
mkdir /tmp/t0nberry5
cd /tmp/t0nberry5
git clone "ssh://bandit28-git@localhost:2220/home/bandit28-git/repo"
cd repo
cat README.md
git log
git show bdf3099fb1fb05faa29e80ea79d9db1e29d6c9b9 #change history shows password
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Levels 30 thru 34
Bandit 29 –> 30 (https://overthewire.org/wargames/bandit/bandit30.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
mkdir /tmp/t0nberry6
cd /tmp/t0nberry6
git clone "ssh://bandit29-git@localhost:2220/home/bandit29-git/repo"
cd repo
ls
cat README.md
git branch -a
git checkout remotes/origin/dev
git log
git show 2b1395f00cfb986163082c50100be5be8f249f64 #log for dev commit
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 30 –> 31 (https://overthewire.org/wargames/bandit/bandit31.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
mkdir /tmp/t0nberry7
cd /tmp/t0nberry7
cd repo
cat README.md
ls -la
cd .git
cat packed-refs
git show 831aac2e2341f009e40e46392a4f5dd318483019
git show-ref #will also show the secret branch containing the key
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 31 –> 32 (https://overthewire.org/wargames/bandit/bandit32.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
mkdir /tmp/t0nberry8
cd /tmp/t0nberry8
cd repo
cat README.md
nano key.txt #May I come in? added
git add .
git commit #key.txt was ignored
git add key.txt #notes .gitignore ignores .txt files. use -f to override ignore.
git add key.txt -f
git commit
Added file #to commit message
git push
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 32 –> 33 (https://overthewire.org/wargames/bandit/bandit33.html)
| |
Arrow up to get to retrieve your previously entered sshpass command and increment bandit by one. Connect to the ssh server.
$0
cat /etc/bandit_pass/bandit33
Highlight and copy the returned password
Break the ssh connection by typing logout or hitting Ctrl + d
Enter nano bandit1, paste the copied password, save & exit (Ctrl + x, y, enter)
Bandit 33 –> 34 (https://overthewire.org/wargames/bandit/bandit34.html)
| |