BARIH0x
GITHUBHTB
  • 📀BARIHO
    • 📜 CERTIFICACIONES
      • ✅eJPT
      • ✅OSWP
      • OSCP
  • 🛡️ PROYECTOS
    • ⚙️HOME LAB
      • 🍓PI-HOLE
      • 🗄️OPENMEDIAVAULT
      • ⛓️HOME ASSISTANTS [TRABAJANDO]
      • 🌐OPNSense [PROXIMO]
    • ⛔T-POT
  • ⚔️ WALKTHROUGH
    • 📄 HackTheBox
      • Legacy
      • Blue
      • Lame
    • 📄 TryHackme
      • 27 ~ Cmess - Linux
      • 26 ~ Battery - Linux
      • 25 ~ ConvertMyVideo - Linux
      • 24 ~ DogCat - Linux
      • 23 ~ Wonderland - Linux
      • 22 ~ Lian_Yu - Linux
      • 21 ~ Tomghost - Linux
      • 20 ~ LazyAdmin - Linux
      • 19 ~Boiler CTF - Linux
      • 18 ~ Couchdb - Linux
      • 17 ~ 0day - Linux
      • 16 ~ Brute It - Linux
      • 15 ~ Blog - Linux
      • 14 ~ Madness - Linux
      • 13 ~ Year Of The Rabbit - Linux
      • 12 ~ Inclusion - Linux
      • 11 ~ UltraTech - Linux
      • 10 ~ Anonymous - Linux
      • 9 ~ Ignite - Linux
      • 8 ~ Vulnversity - Linux
      • 7 ~ Basic Pentesting - Linux
      • 6 ~ MrRobot - Linux
      • 5 ~ Agent-Sudo - Linux
      • 4 ~ EasyCTF - Linux
      • 3 ~ Thompson - Linux
      • 2 ~ RootMe - Linux
      • 1 ~ Bounty Hacker - Linux
    • 🎮 OverTheWire
      • BANDIT
      • NATAS
        • Natas 0
    • 🎮 DVWA
      • Instalación DVWA (XAMPP)
      • Instalación DVWA (DOCKER)
      • Command Injection
      • File Inclusion
      • SQL Injection
  • 🛠️RECURSOS
  • Herramientas
  • 🗃️ Scripts
    • KillSSH
  • 💣 Maquinas
    • Login Wordpress - MrRobot
    • Fuzzing - Madness
  • 🔎 LINKS DE INTERERES
Con tecnología de GitBook
En esta página
  • ¬ Level 0
  • ¬ Level 0 → Level 1
  • ¬ Level 1 → Level 2
  • ¬ Level 2 → Level 3
  • ¬ Level 3 → Level 4
  • ¬ Level 4 → Level 5
  • ¬ Level 5 → Level 6
  • ¬ Level 6 → Level 7
  • ¬ Level 7 → Level 8
  • ¬ Level 8 → Level 9
  • ¬ Level 9 → Level 10
  • ¬ Level 10 → Level 11
  • ¬ Level 11 → Level 12
  • ¬ Level 12 → Level 13
  • ¬ Level 13 → Level 14
  • ¬ Level 14 → Level 15
  • ¬ Level 15 → Level 16
  • ¬ Level 16 → Level 17
  • ¬ Level 17 → Level 18
  • ¬ Level 18 → Level 19
  • ¬ Level 19 → Level 20
  • ¬ Level 20 → Level 21
  • ¬ Level 21 → Level 22
  • ¬ Level 22 → Level 23
  • ¬ Level 23 → Level 24
  • ¬ Level 24 → Level 25
  • ¬ Level 25 → Level 26
  • ¬ Level 26 → Level 27
  • ¬ Level 27 → Level 28
  • ¬ Level 28 → Level 29
  • ¬ Level 29 → Level 30
  • ¬ Level 30 → Level 31
  • ¬ Level 31 → Level 32
  • ¬ Level 32 → Level 33
  • ¬ Level 33 → Level 34
  1. ⚔️ WALKTHROUGH
  2. 🎮 OverTheWire

BANDIT

Anterior🎮 OverTheWire SiguienteNATAS

Última actualización hace 3 años

Hay muchas formas de completar los niveles.

Falta describir los últimos niveles.

¬ Level 0

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 page to find out how to beat Level 1.

¬ Level 0 → Level 1

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.

Lo primero que haremos será conectarnos mediante ssh con las credenciales que nos da la pagina.

  • USER: bandit0

  • PASS: bandit0

  • PORT: 2220

ssh bandit0@bandit.labs.overthewire.org -P 2220

Con un simple listado en el propio directorio podremos ver un archivo README, que mediante con una cat podremos ver la credencial del siguiente nivel.

cat readme

¬ Level 1 → Level 2

The password for the next level is stored in a file called - located in the home directory.

Ahora tenemos que modificar el usuario de la conexión ssh.

  • USER: bandit1

  • PASS: boJ9jbbUNNfktd78OOpsqOltutMc3MY1

Con un listado en el propio directorio vemos un archivo llamado "-", para poder ver el contenido del archivo haremos lo siguiente.

cat $(pwd)/-

Con esto podremos ver la credencial del siguiente nivel.

¬ Level 2 → Level 3

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit2

  • PASS: CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9

Vemos que en el propio directorio hay un archivo, el nombre del archivo contiene espacios, para ver ese directorio podemos hacer un cat escribir la primeras letras y tabular, y con esto veremos la credencial del siguiente nivel.

cat spaces\ in\ this\ filename

¬ Level 3 → Level 4

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit3

  • PASS: UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK

Vemos que tenemos un directorio, al ingresar en el vemos que hay un archivo oculto en el.

Para listar el archivo oculto simplemente hacemos un cat con el nombre del archivo completo y nos dará la credencial del siguiente nivel.

cat .hidden

¬ Level 4 → Level 5

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.

Modificamos el usuario de la conexión ssh.

  • USER: bandit4

  • PASS: pIwrPrtPN36QITSp3EQaw936yaFoFgAB

Vemos que contiene un directorio y al ingresar en el vemos que hay varios archivos que comienzan con un "-", para no ir uno por uno vamos a realizar el siguiente comando.

file $(pwd)/*

Con esto veremos el archivo en formato ASCII text, donde estará la credencial del siguiente nivel.

cat $(pwd)/-file07

¬ Level 5 → Level 6

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit5

  • PASS: koReBOKuIDDepwhWk7jZC0RTdopnAYKh

Vemos que tenemos una carpeta que contiene mas carpetas con archivos, y nos dice que el archivo es leíble, pesa 1033 bytes y no es ejecutable.

find inthere/ -type f -readable -size 1033c ! -executable 2>/dev/null | xargs cat | tr -d ' '

¬ Level 6 → Level 7

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit6

  • PASS: DXjZPULLxYr17uwoI01bNLQbtFemEgo7

Vemos que no tenemos nada en el directorio, pero nos da los siguientes datos:

  • Dueño: bandit7

  • Grupo: bandit6

  • Tamaño: 33 bytes

find / -type f -user bandit7 -group bandit6 -size 33c 2>/dev/null | xargs cat

¬ Level 7 → Level 8

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit7

  • PASS: HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs

Tenemos un archivo .txt y nos dice que la contraseña esta al lado de la palabra millionth.

grep "milionth" data.txt | awk '{print $2}'

¬ Level 8 → Level 9

The password for the next level is stored in the file data.txt and is the only line of text that occurs only once.

Modificamos el usuario de la conexión ssh.

  • USER: bandit8

  • PASS: cvX2JJa4CFALtqS87jk27qwqGhBM9plV

Vemos una archivo donde hay muchas credenciales y y nuestra credencial solo aparece una vez.

sort data.txt | uniq -u 

¬ Level 9 → Level 10

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.

Modificamos el usuario de la conexión ssh.

  • USER: bandit9

  • PASS: UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR

Vemos que tenemos un archivo data, y nos dice que un carácter leíble es el "="

strings data | grep "===" | tail -n 1 | awk '{print $2}'

¬ Level 10 → Level 11

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit10

  • PASS: truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk

base64 -d data.txt | awk '{print $4}'

¬ Level 11 → Level 12

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.

Modificamos el usuario de la conexión ssh.

  • USER: bandit11

  • PASS: IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR

Vemos que esta codificado como ROT13.

cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m' | awk '{print $4}'

¬ Level 12 → Level 13

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit12

  • PASS: 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu

Vemos que tenemos un archivo en hexadecimal, copiamos el archivo y lo pegamos en nuestra maquina para analizarlo.

Con la herramienta xxd podremos ver que hay un contenido, lo guardamos en otro archivo y vemos que es un .gzip. Al descomprimirlo vemos que hay otro comprimible dentro, volvemos a descomprimirlo y hay otro.

Vamos a scriptearlo para mayor comodidad.

#!/bin/bash

name_compressed=$(7z l $1 | grep "Name" -A 2 | tail -n 1 | awk 'NF{print $NF}')
7z x $1 > /dev/null 2>&1

while true; do
	7z l $name_compressed > /dev/null 2>&1
	
	if [ "$(echo $?)" == "0" ];then
		decompressed_next=$(7z l $name_compressed | grep "Name" -A 2 | tail -n 1 | awk 'NF{print $NF}')
		7z x $name_compressed > /dev/null 2>&1 && name_compressed=$decompressed_next
	else
		cat $name_compressed | awk '{print $4}'; rm data* 2>/dev/null
		exit 1
	fi
done

¬ Level 13 → Level 14

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.

Modificamos el usuario de la conexión ssh.

  • USER: bandit13

  • PASS: 8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL

Vemos que tenemos una id_rsa, vamos a conectarnos al usuario bandit14.

ssh -i sshkey.private bandit14@localhost

¬ Level 14 → Level 15

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit14

  • PASS: 4wcYUJFw0k0XLShlDzztnTBHiqxU3b3e

El enunciado nos dice que tenemos que enviar la contraseña al puerto 30000 en localhost.

nc localhost 30000 <PASSWORD>

¬ Level 15 → Level 16

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…

Modificamos el usuario de la conexión ssh.

  • USER: bandit15

  • PASS: BfMYroe26WYalil77FoDi9qh59eK5xNr

Tenemos que mandar la contraseña usando la encriptación ssl.

echo <PASSWORD> | openssl s_client -quiet -connect localhost:30001

¬ Level 16 → Level 17

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.

Modificamos el usuario de la conexión ssh.

  • USER: bandit16

  • PASS: cluFn7wTiGryunymYOu4RcffSxQluehd

Nos dice que tenemos que buscar un puerto abierto en un rango que nos ofrece. Vemos que tenemos nmap para escanear los puertos.

nmap --open -T5 -v -n localhost

Luego nos dice que tenemos que mandarle la contraseña por ssl.

openssl s_client -connect localhost:31790

Y nos da una id_rsa, para conectarnos al usuario bandit17 y ver la contraseña del mismo.

¬ Level 17 → Level 18

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

Modificamos el usuario de la conexión ssh.

  • USER: bandit17

  • PASS: xLYVMN9WE5zQ5vHacb0sZEVqbrp7nBTn

Con la herramienta diff podemos ver los cambios en los dos archivos, donde podremos ver la contraseña del siguiente nivel.

diff passwords.new passwords.old

¬ Level 18 → Level 19

Modificamos el usuario de la conexión ssh.

  • USER: bandit18

  • PASS: kfBf3eYk5BPBRzwjqutbbfE887SVc5Yd

Vemos que nos echa de la sesión ssh, intentamos ejecutar comandos con la sesión ssh y vemos que podemos ejecutar comandos, vamos a ver la contraseña.

ssh bandit18@bandit.labs.overthewire.org -p 2220 cat readme

¬ Level 19 → Level 20

Modificamos el usuario de la conexión ssh.

  • USER: bandit19

  • PASS: IueksS7Ubh8G3DCwVzrTd8rAVOwq3M5x

Vemos un ejecutable, y al ejecutarlo nos pide un comando, vamos a ver la flag.

./bandit20-do cat /etc/bandit_pass/bandit20

¬ Level 20 → Level 21

Modificamos el usuario de la conexión ssh.

  • USER: bandit20

  • PASS: GbKksEFF4yrVs6il55v6gwY5aVje5f0j

Abriremos dos sesiones de ssh, en una nos pondremos en escucha y en la otra ejecutaremos el ejecutable con el puerto en escucha, pasamos la contraseña en la sesión de escucha y listo

¬ Level 21 → Level 22

Modificamos el usuario de la conexión ssh.

  • USER: bandit21

  • PASS: gE269g2h3mw3pwgrj0Ha9Uoqen1c9DGr

Vemos que hay una tarea cron, al ver la tarea cron vemos que la contraseña esta alojada en una carpeta /tmp.

¬ Level 22 → Level 23

Modificamos el usuario de la conexión ssh.

  • USER: bandit22

  • PASS: Yk7owGAcWjwMVRwrTesJEwB7WVOiILLI

Vemos otra tarea cron, donde tendremos que pasar md5sum para poder ver la contraseña.

¬ Level 23 → Level 24

Modificamos el usuario de la conexión ssh.

  • USER: bandit23

  • PASS: jc1udXuA1tiHqjIsL8yaapX5XIAI6i0n

Vemos que tenemos un archivo cron, que ejecuta el siguiente scrip.

Creamos un script donde copiamos la contraseña y la peguemos a un directorio temporal que creamos.

A continuación copiamos el script a la ruta /var/spool/bandti24 y toca esperar.

¬ Level 24 → Level 25

Modificamos el usuario de la conexión ssh.

  • USER: bandit24

  • PASS: UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ

Creamos un directorio temp, y creamos un script para generar el pin code y la contraseña

Y luego lo mandamos por nc para que nos de la siguiente contraseña.

cat dictionary.txt | nc localhost 30002 | grep -v -E "Wrong|Please"

¬ Level 25 → Level 26

Modificamos el usuario de la conexión ssh.

  • USER: bandit25

  • PASS: uNG9O58gUE7snukf3bvZ0rxhtnjzSGzG

Nos da una id_rsa para conectarnos a bandit 26, pero nos echa de la sesion, investigando vemos que reducir la ventana de la shell para que aparezca el "more" y poder sacar una bash.

¬ Level 26 → Level 27

Modificamos el usuario de la conexión ssh.

  • USER: bandit26

  • PASS: 5czgV9L3Xx8JPOyRbXh6lQbmIOWvPT6Z

En el directorio vemos un ejecutable de bandit27, simplemente lanzamos el script con bash -p y nos convertimos en bandit27.

¬ Level 27 → Level 28

Modificamos el usuario de la conexión ssh.

  • USER: bandit27

  • PASS: 3ba3118a22e93127a4ed485be72ef5ea

Nos descargamos un repositorio de github, y dentro esta la contraseña del siguiente nivel.

¬ Level 28 → Level 29

Modificamos el usuario de la conexión ssh.

  • USER: bandit28

  • PASS: 0ef186ac70e04ea33b4c1853d2526fa2

Nos descargamos un repositorio de github, y vemos en los log del git, si han habido cambios

git log -p

¬ Level 29 → Level 30

Modificamos el usuario de la conexión ssh.

  • USER: bandit29

  • PASS: bbc96594b4e001778eee9975372716b2

Nos descargamos un repositorio de github, y vemos los branch.

git branch -r

git checkout dev

Volvemos a ver los logs

git log -p

Y tenemos la contraseña

¬ Level 30 → Level 31

Modificamos el usuario de la conexión ssh.

  • USER: bandit30

  • PASS: 5b90576bedb2cc04c86a9e924ce42faf

Nos descargamos un repositorio de github, y vemos que contiene un tag, al verlo vemos la contraseña del siguiente nivel.

git tag

git show secret

¬ Level 31 → Level 32

Modificamos el usuario de la conexión ssh.

  • USER: bandit31

  • PASS: 47e603bb428404d265f59c42920d81e5

Nos descargamos un repositorio de github, y tenemos que subir un archivo al repositorio, pero antes tenemos que borrar un archivo del repo.

git add key.txt

git commit "ALGO"

git push -u origin master

Y vemos la contraseña del siguiente usuario.

¬ Level 32 → Level 33

Modificamos el usuario de la conexión ssh.

  • USER: bandit32

  • PASS: 56a9bf19c63d650ce78e6ec0354ee45e

Para escapar de esta consola, simplemente ponemos $0 y tenemos una bash, ya podremos ver la contraseña del siguiente nivel.

¬ Level 33 → Level 34

Modificamos el usuario de la conexión ssh.

  • USER: bandit33

  • PASS: c9c3199ddf4121b10cf581a98d51caee

Terminamos todos los niveles.

Level 1