The Bandit wargame taught me the basics needed to be able to play other wargames.
Level 0 –> 1
Login : ssh bandit0@bandit.labs.overthewire.org -p 2220
Password : bandit0
Steps to resolve :
cat readme
Level 1 -> 2
Login : ssh bandit1@bandit.labs.overthewire.org -p 2220
Password : ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If
Steps to resolve :
cat ./-prefix the filename with a path
Level 2 -> 3
Login : ssh bandit2@bandit.labs.overthewire.org -p 2220
Password : 263JGJPfgU6LtdEvgfWU1XP5yac29mFx
Steps to resolve :
cat ./'--spaces in this filename--'
Level 3 -> 4
Login : ssh bandit3@bandit.labs.overthewire.org -p 2220
Password : MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx
Steps to resolve :
ls -la inherecat inhere/...Hiding-From-You
Level 4 -> 5
Login : ssh bandit4@bandit.labs.overthewire.org -p 2220
Password : 2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ
Steps to resolve :
file inhere/*cat inhere/-file07
Key Concepts :
- Command
file= identify file types
Level 5 -> 6
Login : ssh bandit5@bandit.labs.overthewire.org -p 2220
Password : 4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw
Steps to resolve :
find inhere -size 1033c ! -executablecat inhere/maybehere07/.file2
Key Concepts :
- Command
find= search files in a given directory - Man Page (Linux Manual Pages)
-size 1033c= exactly 1033 bytes (c=bytes, k=kilobytes, M=megabytes)! -executable= excludes files with execute permission
Level 6 -> 7
Login : ssh bandit6@bandit.labs.overthewire.org -p 2220
Password : HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
Steps to resolve :
find / -user bandit7 -group bandit6 2>/dev/null= discard all lines with error orfind / -user bandit7 -group bandit6 2>&1 | grep -v 'Permission denied'= only remove the lines with ‘Permission denied’cat /var/lib/dpkg/info/bandit7.password
Key Concepts :
2= stderr = standard error, which is a stream of data that is generated by computer programs when they encounter an error or an exceptional condition.&1= stdout, which is the default output stream in a computer program/dev/null= a special file that DISCARDS all data written to it
Level 7 -> 8
Login : ssh bandit7@bandit.labs.overthewire.org -p 2220
Password : morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj
Steps to resolve :
grep 'millionth' data.txt
Level 8 -> 9
Login : ssh bandit8@bandit.labs.overthewire.org -p 2220
Password : dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc
Steps to resolve :
sort data.txt | uniq -u
Key Concepts :
- Command
uniqworks only when the content is sorted
Level 9 -> 10
Login : ssh bandit9@bandit.labs.overthewire.org -p 2220
Password : 4CKMh1JI91bUIZZPXDqGanal4xvAg0JM
Steps to resolve :
strings data.txt | grep '=='
Key Concepts :
- Command
strings= print the strings of printable characters in files (not binary)
Level 10 -> 11
Login : ssh bandit10@bandit.labs.overthewire.org -p 2220
Password : FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey
Steps to resolve :
base64 -d data.txt
Level 11 -> 12
Login : ssh bandit11@bandit.labs.overthewire.org -p 2220
Password : dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr
Steps to resolve :
cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Level 12 -> 13
Login : ssh bandit12@bandit.labs.overthewire.org -p 2220
Password : 7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4
Steps to resolve :
mktemp -dto get a tmp dir like/tmp/tmp.EgxY8rs4REcp data.txt /tmp/tmp.EgxY8rs4RE/data.txtcd /tmp/tmp.EgxY8rs4RExxd -r data.txt > datato convert hexdump to binaryfile dataresults indata: gzip compressed data...mv data data.gzto perform 7gzip -d data.gzresults indatafile dataresults indata: bzip2 compressed data...mv data data.bz2bzip2 -d data.bz2results indatarepeat decoding…file dataresults indata: POSIX tar archive (GNU)tar -xf data, -x extracts files from an archive, -f specifies the archive name repeat decoding…file data8.binresults indata8.bin: ASCII textcat data8.bin
Key Concepts :
- hexdump = a textual hexadecimal view (on screen or paper) of computer data
gzip= fast and widely used Compression Method with DEFLATE algorithmbzip2= slow but higher compression ratios than gzip using a different algorithmtar= Archiver, which Bundles multiple files and directories into a single archive file
Level 13 -> 14
Login : ssh bandit13@bandit.labs.overthewire.org -p 2220
Password : FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn
Steps to resolve :
scp -P 2220 bandit13@bandit.labs.overthewire.org:./sshkey.private ./bandit14-sshkeychmod 600 bandit14-sshkey
Level 14 -> 15
Login : ssh bandit14@bandit.labs.overthewire.org -p 2220 -i bandit14-sshkey
Password : bandit14-sshkey
Steps to resolve :
cat /etc/bandit_pass/bandit14echo 'MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS' | nc localhost 30000
Key Concepts :
- Command
nc= sends/receives raw data over network connections using TCP/UDPnc -l 1234in Terminal 1 (listener)nc localhost 1234in Terminal 2 (connector and speaker)nc localhost 1234 < file.txt= Send File Over Network<operator: Redirects file content as input to nc
Level 15 -> 16
Login : ssh bandit15@bandit.labs.overthewire.org -p 2220
Password : 8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo
Steps to resolve :
echo '8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo' | openssl s_client -connect localhost:30001 -quiet
Key Concepts :
openssl s_client= establish TCP connection + adds SSL/TLS encryption-quiet= suppress certificate and connection info, show only data
Level 16 -> 17
Login : ssh bandit16@bandit.labs.overthewire.org -p 2220
Password : kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx
Steps to resolve :
nmap localhost -p 31000-32000openssl s_client -connect localhost:31790 -quiet
Key Concepts :
- Command
nmap= Sends packets to ports and analyzes responses to determine:- Which ports are open
- What services are running
nmap localhostor Scan specific port rangenmap -p 31000-32000 localhost
Level 17 -> 18
Login : ssh bandit17@bandit.labs.overthewire.org -p 2220 -i bandit17-sshkey
Password : bandit17-sshkey
Steps to resolve :
diff passwords.old passwords.new
Level 18 -> 19
Login : ssh bandit18@bandit.labs.overthewire.org -p 2220
Password : x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO
Steps to resolve :
ssh bandit18@bandit.labs.overthewire.org -p 2220 cat ./readme
Level 19 -> 20
Login : ssh bandit19@bandit.labs.overthewire.org -p 2220
Password : cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8
Steps to resolve :
./bandit20-do./bandit20-do cat /etc/bandit_pass/bandit20
Key Concepts :
- setuid = allow users to run a file with owner’s or group’s permission
ls -l bandit20-doresults in-rwsr-x--- 1 bandit20 bandit19 14884 Oct 14 09:26 bandit20-do, s is the mark for setuid
Level 20 -> 21
Login : ssh bandit20@bandit.labs.overthewire.org -p 2220
Password : 0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO
Steps to resolve :
nc -l -p 1234 < /etc/bandit_pass/bandit20in Terminal 1./suconnect 1234in Terminal 2
Key Concepts :
nc -l < fileorecho '???' | nc -l= send text to the connector when connected
Level 21 -> 22
Login : ssh bandit21@bandit.labs.overthewire.org -p 2220
Password : EeoULMCra2q0dSkYj561DX7s1CpBuOBt
Steps to resolve :
ls /etc/cron.d/cat /etc/cron.d/cronjob_bandit22results in* * * * * bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/nullcat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
Level 22 -> 23
Login : ssh bandit22@bandit.labs.overthewire.org -p 2220
Password : tRae0UfB9v0UzbCdn9cY0gQnds9GF58Q
Steps to resolve :
cat /usr/bin/cronjob_bandit23.shecho I am user bandit23 | md5sum | cut -d ' ' -f 1cat /tmp/8ca319486bfbbc3663ea0fbe81326349
Level 23 -> 24
Login : ssh bandit23@bandit.labs.overthewire.org -p 2220
Password : 0Zf11ioIjMVN551jX3CmStKLYqjk54Ga
Steps to resolve :
cat /usr/bin/cronjob_bandit24.shmktemp -dresults in/tmp/tmp.hjOM8y07KXchmod 703 /tmp/tmp.hjOM8y07KXto allow bandit24 to create a file in this tmp dirvim /var/spool/bandit24/foo/cp_passwd.sh
#!/bin/bash
cp /etc/bandit_pass/bandit24 /tmp/tmp.hjOM8y07KX/bandit24_passwd
chmod 404 /tmp/tmp.hjOM8y07KX/bandit24_passwd
chmod 665 /var/spool/bandit24/foo/cp_passwd.shcat /tmp/tmp.hjOM8y07KX/bandit24_passwd
Key Concepts :
- Tmp dir needs Both write and execute permissions by others for bandit24 to run
cpto copy a file there because the system checks if bandit24 can enter there before copying.- Execute (x) on directory = permission to enter/traverse the directory such as
cd. - Write (w) on directory = permission to create/delete files in the directory.
- Execute (x) on directory = permission to enter/traverse the directory such as
Level 24 -> 25
Login : ssh bandit24@bandit.labs.overthewire.org -p 2220
Password : gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8
Steps to resolve :
nc localhost 30002mktemp -dresults in/tmp/tmp.nD5ZtWkbKgcd /tmp/tmp.nD5ZtWkbKgvim brute-forcing.sh
#!/bin/bash
bandit24_pass=gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8
for pin in {0000..9999}; do
echo "$bandit24_pass $pin"
done | nc localhost 30002 | grep -v 'Wrong' > bandit25_passwd
chmod 764 brute-forcing.sh./brute-forcing.shcat bandit25_passwd
Key Concepts :
- In shell script,
echowith- Double quotes “…” can expand variables = “$var” → value of var
- Single quotes ‘…’ cannot expand variables = ‘$var’ → literal $var
Level 25 -> 26
Login : ssh bandit25@bandit.labs.overthewire.org -p 2220
Password : iCi86ttT4KSNe1armKiwbQNmB3YJP3q4
Steps to resolve :
cat bandit26.sshkeygrep 'bandit26' /etc/passwdresults inbandit26:x:11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtextcat /usr/bin/showtext
#!/bin/sh
export TERM=linux
exec more ~/text.txt
exit 0
Key Concepts :
- /etc/passwd = user account information
username:password:UID:GID:comment:home_directory:shellxmeans encrypted password is in/etc/shadowshell= login shell = Program that runs when user logs in such asssh/usr/bin/showtext= custom login shell, usually /bin/bash or /bin/sh
Level 26 -> 27
Login : ssh bandit26@bandit.labs.overthewire.org -p 2220 -i bandit26-sshkey
Password : bandit26-sshkey
Steps to resolve :
- make terminal window smallest when ssh
- press v in more
:!/bin/bashto get bash shell as bandit26./bandit27-do cat /etc/bandit_pass/bandit27
Key Concepts :
:!command= run shell command from vi
Level 27 -> 28
Login : ssh bandit27@bandit.labs.overthewire.org -p 2220
Password : upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB
Steps to resolve :
git clone ssh://bandit27-git@bandit.labs.overthewire.org:2220/home/bandit27-git/repocat repo/README
Level 28 -> 29
Login : ssh bandit28@bandit.labs.overthewire.org -p 2220
Password : Yz9IpL0sBcCeuG7m9uQFt8ZNpS4HZRcN
Steps to resolve :
git clone ssh://bandit28-git@bandit.labs.overthewire.org:2220/home/bandit28-git/repocd repogit log -p= get git commit history with diff
Level 29 -> 30
Login : ssh bandit29@bandit.labs.overthewire.org -p 2220
Password : 4pT1t5DENaYuqnqvadYs1oE4QLCdjmJ7
Steps to resolve :
git clone ssh://bandit29-git@bandit.labs.overthewire.org:2220/home/bandit29-git/repocd repocat README.mdgit branch -agit checkout devcat README.md
Level 30 -> 31
Login : ssh bandit30@bandit.labs.overthewire.org -p 2220
Password : qp30ex3VLz5MDG1n91YowTv4Q8l7CDZL
Steps to resolve :
git clone ssh://bandit30-git@bandit.labs.overthewire.org:2220/home/bandit30-git/repocd repogit tagresults insecretorgit show-ref= list all refs such as branches, tags, HEAD, and so on.git show secret
Key Concepts :
tagsare Named fixed pointers to commitsHEADis Pointer to current branch/commitorigin= nickname for remote repository
Level 31 -> 32
Login : ssh bandit31@bandit.labs.overthewire.org -p 2220
Password : fb5S2xb7bRyFmAvQYQGEqsbhVyJqhnDy
Steps to resolve :
git clone ssh://bandit31-git@bandit.labs.overthewire.org:2220/home/bandit31-git/repocd repocat README.mdvim key.txt
May I come in?
cat .gitignoreresults in*.txt> .gitignoreortruncate -s 0 .gitignoregit add .git commit -m"add key.txt, delete '*.txt' in .gitignore"git push
Level 32 -> 33
Login : ssh bandit32@bandit.labs.overthewire.org -p 2220
Password : 3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K
Steps to resolve :
$0cat /etc/bandit_pass/bandit33
Key Concepts :
$0= expand to the name of the shell or shell script$0is set to them at shell initialization- At first,
$0will be set to-bashfor a login shell - Every time you run a script,
$0will be set to its path or name depending on how to run a script
Level 33 -> 34
Login : ssh bandit33@bandit.labs.overthewire.org -p 2220
Password : tQdtbs5D5i2vJwkO8mEyYEyTL8izoeJ0
Steps to resolve :
cat README.txt
Congratulations on solving the last level of this game!
Thank you for taking your time to read.