Overthewire bandit прохождение

Обновлено: 30.06.2024

День добрый, бандиты. Досмотрев первый сезон Mr. Robot я решил, что ни чем не хуже главного героя и установил себе Kali Linux, готовый бороздить просторы домашней сети в поисках уязвимостей и картинок голых девок на телефоне своего брата. Запустив nmap три раза и обнаружив, без особого удивления, что жизнь — не кино, я решил применить более структурированный подход к своим поискам и начать с азов информационной безопасности и поиска уязвимостей.

Уровень 0

Уровень 1

Пароль для перехода на следующий уровень находится в файле readme в домашней директории. Для его прочтения нам понадобится команда cat , выводящая в окне терминала содержимое файла:


В конце каждого уровня подключаемся с помощью ssh к следующему пользователю на localhost :


Я не обращал внимания на предупреждения о localhost , потому что у меня не было прав на создание файлов, очевидно. Но это не мешает перейти на следующий уровень.

Уровень 2

Пароль к следующему уровню хранится в файле с названием - и это единственное, чем он отличается от предыдущего. Используем ту же команду cat с небольшим изменением:


Пропускаем мимо ушей предупреждение, подключаемся к bandit2 и переходим на следующий уровень.

Уровень 3

Уровень 4

Пароль к следующему уровню находится в скрытом файле в директории inhere , чтобы его показать в консоли используем команду ls , выводящую в терминал содержимое директории, с флагом -a , включающим в список содержимое, название которого начинается с точки. Перейдем в директорию командой cd , через пробел указав ее название:

Уровень 5

Пароль находится в единственном файле, который вы сможете прочитать (буквально), в директории inhere . Чтобы получить информацию о типе файле будем использовать команду file . Для начала перейдем в директорию и посмотрим, что внутри:


Все файлы начинаются с - , поэтому используем синтаксис из второго уровня и дополним * (символ wildcard, обозначающий сколько угодно любых знаков до или, в нашем случае, после), чтобы получить информацию о всех файлах сразу:


Как мы видим, единственный файл, который мы можем прочитать это -file07 . Чем и займемся, используя знакомую нам команду cat .

Уровень 6

Теперь, помимо читаемости файла, нужно учесть размер в 1033 байта и факт, что файл не исполняемый. Для этого воспользуемся командой find с параметром -size 1033c ( c потому что байты. Почему не b ? Потому что это 512-байтовые блоки, смиритесь). Сначала сменим директорию, конечно же, и посмотрим, что внутри.


Мы легко избежали блуждания по папкам командой find , это не может не радовать!

Уровень 7

Продолжаем изучать возможные тесты команды find и ищем файл на сервере, который принадлежит пользователю bandit7, группе bandit6 и весит 33 байта. Перейдем в корень и начнем поиски, используя для уточнения поиска флаги -user для пользователя и -group для группы пользователей, а также знакомый -size :


Мы видим единственный файл, к которому имеем доступ. Так давайте откроем его!

Спойлеры и нарушение правил площадки это конечно на совести каждого, но если уж вы пишете райтап, то пишите больше деталей, а не просто наборы команд. Проходил сам бандита и дальше там будет больше не очевидных вещей, которые новичкам (вроде как на них и расчитана данная статья) будет не понять. Добавьте описания флагов команд, почему именно их использовали и т.п. Стоит упомянуть что в самих заданиях есть подсказки о том какие команды могут быть полезны для решение. В общем раскройте тему больше. А спойлеры с паролями мне кажется можно в принципе выпилить, от этого ничего не изменится

Комментарий пока не оценивали 0

Ответить Добавить в закладки Ещё

Показать предыдущий комментарий

b-i-b спасибо, замечание дельное, добавлю описания флагов и причину использования той или иной команды. Поставил бы Вам лайк, да карма не выросла:(


Bandit Level 1→ Level 2

Level Goal
The password for the next level is stored in a file called — located in the home directory

Bandit Level 2 → Level 3

Level Goal
The password for the next level is stored in a file called spaces in this filename located in the home directory

Bandit Level 3 → Level 4

Level Goal
The password for the next level is stored in a hidden file in the inhere directory.

Bandit Level 4 → Level 5

Level Goal
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.

Bandit Level 5 → Level 6

Level Goal
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

Bandit Level 6 → Level 7

Level Goal
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

Bandit Level 7 → Level 8

Level Goal
The password for the next level is stored in the file data.txt next to the word millionth

Bandit Level 8 → Level 9

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

Bandit Level 9 → Level 10

Level Goal
The password for the next level is stored in the file data.txt in one of the few human-readable strings, beginning with several ‘=’ characters.

Bandit Level 10 → Level 11

Level Goal
The password for the next level is stored in the file data.txt, which contains base64 encoded data

Bandit Level 11 → Level 12

Level Goal
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

Bandit Level 12 → Level 13

Level Goal
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!)

Key Takeaways

Ba n dit Level 13 → Level 14

Level Goal
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

Bandit Level 14 → Level 15

Level Goal
The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost.

Bandit Level 15 → Level 16

Level Goal
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…

  • -ign_eof

Bandit Level 16 → Level 17

Level Goal
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.

Bandit Level 17 → Level 18

Level Goal
There are 2 files in the home directory: 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

Bandit Level 18 → Level 19

Level Goal
The password for the next level is stored in a file readme in the home directory. Unfortunately, someone has modified .bashrc to log you out when you log in with SSH.

Bandit Level 19 → Level 20

Level Goal
To gain access to the next level, you should use the setuid binary in the home directory. 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.

Bandit Level 20 → Level 21

Level Goal
There is a setuid binary in the home directory that does the following: it makes a connection to localhost on the port you specify as a command line 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: To beat this level, you need to login twice: once to run the setuid command, and once to start a network daemon to which the setuid will connect.
NOTE 2: Try connecting to your own network daemon to see if it works as you think


Bandit Level 21 → Level 22

Level Goal
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.

Bandit Level 22 → Level 23

Level Goal
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.

The script is run as bandit23 and not bandit22. I missed that 👽

Bandit Level 23 → Level 24

Level Goal
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…

Solution
Create a directory in the /tmp/ folder. Create a shell script to copy the /etc/bandit_pass/bandit24 to our /tmp/folder. Copy the shell script to /var/spool/bandit24/. Give the shell script and the /tmp/ folder appropriate permissions.

Bandit Level 24 → Level 25

Level Goal
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.

Shell script that generated the combination of password and pin

Bandit Level 25 → Level 26

Level Goal
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.

The moment we login in we are kicked out. So lets inspect the shell this user has.

It uses a custom shell called showtext

We can safely assume that the shell uses more to read banner and later exit the shell with an exit status 0. So the trick lies in the way we use more to access the next level. Going through the man page of more we discover that there is a built in editor.

If VISUAL is defines in the environment variable it will take that editor or it will use vi by default. So we need to use this to escape the shell and spawn /bin/bash.

Make the terminal small enough to activate more. Press v to enter visual mode


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

Use ssh to login the server with the following information.

Let’s find the password for the next level.

First, we set up a simple TCP server which listens to port 61337 and we let the process running in the background.

Читайте также: