Bandit - Overthewire.org/wargames
https://overthewire.org/wargames/bandit/bandit0.html
ssh bandit[level#]@bandit.labs.overthewire.org -p 2220
pass -> flag found in previous level
Basics
The goal of this level is for you to log into the game using SSH. The host to which you need to connect is bandit.labs.overthewire.org, on port 2220. The username is bandit0 and the password is bandit0. Once logged in, go to the Level 1 page to find out how to beat Level 1.
ssh bandit0@bandit.labs.overthewire.org -p 2220bandit0
The password for the next level is stored in a file called readme located in the home directory. Use this password to log into bandit1 using SSH. Whenever you find a password for a level, use SSH (on port 2220) to log into that level and continue the game.
lscat readmeNH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL
The password for the next level is stored in a file called - located in the home directory
lscat ./-(As if we are trying to run the "-" file)rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi
The password for the next level is stored in a file called spaces in this filename located in the home directory
lscat spaces\ in\ this\ filenameaBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG
The password for the next level is stored in a hidden file in the inhere directory.
lscd inherels -lacat .hidden2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe
The password for the next level is stored in the only human-readable file in the inhere directory. Tip: if your terminal is messed up, try the βresetβ command.
lscd inherels -lacat ./-file07lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR
The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:
human-readable
1033 bytes in size
not executable
cd inherefind . -type f -size 1033ccat ./maybehere07/.file2P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU
The password for the next level is stored somewhere on the server and has all of the following properties:
owned by user bandit7
owned by group bandit6
33 bytes in size
find / -type f -user bandit7 -group bandit6 -size 33c/var/lib/dpkg/info/bandit7.password
cat /var/lib/dpkg/info/bandit7.passwordz7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S
The password for the next level is stored in the file data.txt next to the word millionth
cat data.txt | grep millionthmillionth TESKZC0XvTetK0S9xNwm25STk5iWrBvP
The password for the next level is stored in the file data.txt and is the only line of text that occurs only once
sort data.txt | uniq -cEN632PlfYiZbn3PhVK3XOGSlNInNE00t
The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several β=β characters.
strings data.txt | grep "="G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s
Encoded
The password for the next level is stored in the file data.txt, which contains base64 encoded data
base64 -d data.txt6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM
The password for the next level is stored in the file data.txt, where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions
ROT Cipher -> https://www.dcode.fr/rot-cipher
JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv
The password for the next level is stored in the file data.txt, which is a hexdump of a file that has been repeatedly compressed. For this level it may be useful to create a directory under /tmp in which you can work using mkdir. For example: mkdir /tmp/myname123. Then copy the datafile using cp, and rename it using mv (read the manpages!)
mkdir /tmp/alvcp data.txt /tmp/alvcd /tmp/alvxxd -r data.txt > alvfile alv-> "alv: gzip compressed data"mv alv alv.gzgzip -d alv.gzfile alv-> "alv: bzip2 compressed data"mv alv alv.bz2bzip2 -d alv.bz2file alvmv alv alv.tartar xf alv.tarfile data5.bin....
wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw
SSH and SSL
The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. For this level, you donβt get the next password, but you get a private SSH key that can be used to log into the next level. Note: localhost is a hostname that refers to the machine you are working on
ssh -i sshkey.private bandit14@localhost -p 2220cat /etc/bandit_pass/bandit14fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq
The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost.
nc localhost 30000fGrHPx402xGC7U7rXKDaxiWFTOiF0ENqjN2kgmIXJ6fShzhT2avhotn4Zcka6tnt
The password for the next level can be retrieved by submitting the password of the current level to port 30001 on localhost using SSL encryption.
Helpful note: Getting βHEARTBEATINGβ and βRead R BLOCKβ? Use -ign_eof and read the βCONNECTED COMMANDSβ section in the manpage. Next to βRβ and βQβ, the βBβ command also works in this version of that commandβ¦
ncat --ssl localhost 30001jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt
JQttfApK4SeyHwDlI9SXGR50qclOAil1
The credentials for the next level can be retrieved by submitting the password of the current level to a port on localhost in the range 31000 to 32000. First find out which of these ports have a server listening on them. Then find out which of those speak SSL and which donβt. There is only 1 server that will give the next credentials, the others will simply send back to you whatever you send to it.
nmap localhost -p 31000-32000-> 5 ports openedncat --ssl localhost 31790Copy the RSA private key into a .txt file
ssh -i pass17.txt bandit17@bandit.labs.overthewire.org -p 2220-> "permission 0644 for 'pass17.txt' are too open"chmod 400 pass17.txtssh -i pass17.txt bandit17@bandit.labs.overthewire.org -p 2220cat /etc/bandit/bandit_pass/bandit17VwOSWtCA7lRKkTfbr2IDh6awj9RNZM5e
There are 2 files in the homedirectory: passwords.old and passwords.new. The password for the next level is in passwords.new and is the only line that has been changed between passwords.old and passwords.new
NOTE: if you have solved this level and see βByebye!β when trying to log into bandit18, this is related to the next level, bandit19
diff passwords.new passwords.oldhga5tuuCLF6fFzUpnagiMN8ssu9LFrdg
The password for the next level is stored in a file readme in the homedirectory. Unfortunately, someone has modified .bashrc to log you out when you log in with SSH.
ssh -t bandit18@bandit.labs.overthewire.org -p 2220 '/bin/sh'hga5tuuCLF6fFzUpnagiMN8ssu9LFrdgcat readmeawhqfNnAbc1naukrpqDYcF95h7HoMTrC
SUID
To gain access to the next level, you should use the setuid binary in the homedirectory. Execute it without arguments to find out how to use it. The password for this level can be found in the usual place (/etc/bandit_pass), after you have used the setuid binary.
./bandit20-do./bandit20-do id./bandit20-do cat /etc/bandit_pass/bandit20VxCazJaVykI6W36BkBU0mJTCM8rR95XT
There is a setuid binary in the homedirectory that does the following: it makes a connection to localhost on the port you specify as a commandline argument. It then reads a line of text from the connection and compares it to the password in the previous level (bandit20). If the password is correct, it will transmit the password for the next level (bandit21).
NOTE: Try connecting to your own network daemon to see if it works as you think
./suconnect(new bandit20 tab)
nc localhost -l 4444(old bandit20 tab)
./suconnect 4444(new bandit20 tab)
VxCazJaVykI6W36BkBU0mJTCM8rR95XTNvEJF7oVjkddltPSrdKEFOllh9V1IBcq
Cron
A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
cd /etc/cron.dls -lacat cronjob_bandit22cat /usr/bin/cronjob_bandit22.sh
cat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgvWdDozAdTM2z9DiFEQ2mGlwngMfj4EZff
A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
NOTE: Looking at shell scripts written by other people is a very useful skill. The script for this level is intentionally made easy to read. If you are having problems understanding what it does, try executing it to see the debug information it prints.
cd /etc/cron.dcat cronjob_bandit23cat usr/bin/cronjob_bandit23.sh
. usr/bin/cronjob_bandit23.shmyname=bandit23$mynameecho I am user $myname | md5sum | cut -d ' ' -f 1cat /tmp/8ca319486bfbbc3663ea0fbe81326349QYw0Y2aiA672PsMmh9puTQuhoz8SyR2G
A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
NOTE: This level requires you to create your own first shell-script. This is a very big step and you should be proud of yourself when you beat this level!
NOTE 2: Keep in mind that your shell script is removed once executed, so you may want to keep a copy aroundβ¦
cd /etc/cron.d/cat cronjob_bandit24cat /usr/bin/cronjob_bandit24.sh
cd /var/spool/bandit24ls -laPermission denied
cd tmpmkdir alvcd alvecho "cat /etc/bandit_pass/bandit24 > /tmp/alv/password.txt" > script_alv.shchmod 777 script_alv.shtouch password.txtchmod 777 password.txtcp script_alv.sh /var/spool/bandit24/fooWait for 1 minute
cat password.txtVAfGXJ1PBSsPSnvsjI8p759leLZ9GGar
Ncat Python
A daemon is listening on port 30002 and will give you the password for bandit25 if given the password for bandit24 and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing. You do not need to create new connections each time.
nc localhost 30002Paste VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar 6789
Invalid code
echo "[below text code]" > file.shif not working remove the "#!/bin/bash" part
./file.shp7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d
VIM
Logging in to bandit26 from bandit25 should be fairly easy⦠The shell for user bandit26 is not /bin/bash, but something else. Find out what it is, how it works and how to break out of it.
cat /etc/passwd | grep bandit26cat /usr/bin/showtextssh -i bandit26.sshkey bandit26@localhost -p2220make the window small, so the "--More -- (X%)" appears
type
v-> VIM editor is openedreturn screen to normal size
:set shell=/bin/bash:shellcat /etc/bandit_pass/bandit26
c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1
Good job getting a shell! Now hurry and grab the password for bandit27!
ls./bandit27-do./bandit27-do cat /etc/bandit_pass/bandit27YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS
Git
There is a git repository at
ssh://bandit27-git@localhost/home/bandit27-git/repovia the port2220. The password for the userbandit27-gitis the same as for the userbandit27.Clone the repository and find the password for the next level.
mkdir /tmp/alv27cd /tmp/alv27git clone ssh://bandit27-git@localhost:2220/home/bandit27-git/repocd repocat READMEAVanL161y9rsbcJIsFHuw35rjaOM19nR
There is a git repository at
ssh://bandit28-git@localhost/home/bandit28-git/repovia the port2220. The password for the userbandit28-gitis the same as for the userbandit28.Clone the repository and find the password for the next level.
mkdir /tmp/alv28cd /tmp/alv28git clone ssh://bandit28-git@localhost:2220/home/bandit28-git/repocd repocat README.mdInfo was removed
git loggit checkout f08b9cc63fa1a4602fb065257633c2dae6e5651bcat README.mdtQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S
There is a git repository at
ssh://bandit29-git@localhost/home/bandit29-git/repovia the port2220. The password for the userbandit29-gitis the same as for the userbandit29.Clone the repository and find the password for the next level.
mkdir /tmp/alv29cd /tmp/alv29git clone ssh://bandit29-git@localhost:2220/home/bandit29-git/repocd repocat README.mdNo info
git branch -rgit checkout devcat README.mdxbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS
There is a git repository at
ssh://bandit30-git@localhost/home/bandit30-git/repovia the port2220. The password for the userbandit30-gitis the same as for the userbandit30.Clone the repository and find the password for the next level.
mkdir /tmp/alv30cd /tmp/alv30git clone ssh://bandit30-git@localhost:2220/home/bandit30-git/repocd repocat README.md"empty file"
git taggit show secretOoffzGDlzhAlerFJ2cAiz1D41JW1Mhmt
There is a git repository at
ssh://bandit31-git@localhost/home/bandit31-git/repovia the port2220. The password for the userbandit31-gitis the same as for the userbandit31.Clone the repository and find the password for the next level.
mkdir /tmp/alv31cd /tmp/alv31git clone ssh://bandit31-git@localhost:2220/home/bandit31-git/repocd repocat README.mdFile is in a remote repository
cat .gitignorerm .gitignoreecho "May I come in?" > key.txtgit add key.txtgit commit -m "new commit"git pushrmCBvG56y58BXzv98yZGdO7ATVL5dW8y
Shell
After all this
gitstuff its time for another escape. Good luck!$0export SHELL=/bin/bash$SHELLcat /etc/bandit_pass/bandit33odHo63fHiFqcWWJG9rLiLDtPm45KzUKy
At this moment, level 34 does not exist yet.
Last updated