Bandit 27 -–❯ 33


Juegos de Guerra "Bandit" Overthewire

Published on August 29, 2023 by Gmichet

LINUX BANDIT

14 min READ

Finalmente los últimos nivel de los juegos “Bandido” de la página OverTheWire

SkillsEnlace
Clonando repositorios de githubgit clone
Listando commits de githubgit log -p
Cambiendo de branch en githubgit branch -r
Listando etiquetas secretas de githubResolviendo Nivel 30
Subir fichero en githubgit push
Spawneando una shell$shell

Indice


Bandit 27 al 28

Hay un repositorio de git en ssh://bandit27-git@localhost/home/bandit27-git/repo. La contraseña para el usuario bandit27-git es la misma que para el usuario bandit27.

Clona el repositorio y encuentra la contraseña para el siguiente nivel.

Sitio Oficial

Resolviendo Nivel 27

Creamos un directorio temporal

bandit27@bandit:~$ mktemp -d
/tmp/tmp.5oNFeUkKUp
bandit27@bandit:~$ cd /tmp/tmp.5oNFeUkKUp
  • Procedemos a clonar el repositorio:
bandit27@bandit:/tmp/tmp.5oNFeUkKUp$ git clone ssh://bandit27-git@localhost:2220/home/bandit27-git/repo
Cloning into 'repo'...
The authenticity of host '[localhost]:2220 ([127.0.0.1]:2220)' can't be established.
ED25519 key fingerprint is SHA256:C2ihUBV7ihnV1wUXRb4RrEcLfXC5CXlhmAAM/urerLY.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/bandit27/.ssh' (Permission denied).
Failed to add the host to the list of known hosts (/home/bandit27/.ssh/known_hosts).
                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \ / _` | '_ \ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \__,_|_| |_|\__,_|_|\__|
                                                       

                      This is an OverTheWire game server. 
            More information on http://www.overthewire.org/wargames

bandit27-git@localhost's password: 
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
  • Accedemos al repositorio:
bandit27@bandit:/tmp/tmp.5oNFeUkKUp$ ls
repo
bandit27@bandit:/tmp/tmp.5oNFeUkKUp$ cd repo/
bandit27@bandit:/tmp/tmp.5oNFeUkKUp/repo$ ls
README
bandit27@bandit:/tmp/tmp.5oNFeUkKUp/repo$ cat README 
The password to the next level is: AVanL161y9rsbcJIsFHuw35rjaOM19nR

Bandit 28 al 29

Hay un repositorio de git en ssh://bandit28-git@localhost/home/bandit28-git/repo. La contraseña para el usuario bandit28-git es la misma que para el usuario bandit28.

Clona el repositorio y encuentra la contraseña para el siguiente nivel.

Sitio Oficial

Iniciamos:

ssh bandit28@bandit.labs.overthewire.org -p 2220

Resolviendo Nivel 28

Creamos un directorio temporal, clonamos el repositorio, accedemos y listamos el “README.md”

bandit28@bandit:/tmp/tmp.dJfhVr6FMi/repo$ cat README.md 
# Bandit Notes
Some notes for level29 of bandit.

## credentials

- username: bandit29
- password: xxxxxxxxxx
  • Podemos listar los “commits” que son un registro de cambios realizados en un repositorio.
bandit28@bandit:/tmp/tmp.dJfhVr6FMi/repo$ git log -p
commit 899ba88df296331cc01f30d022c006775d467f28 (HEAD -> master, origin/master, origin/HEAD)
Author: Morla Porla <morla@overthewire.org>
Date:   Sun Apr 23 18:04:39 2023 +0000

    fix info leak

diff --git a/README.md b/README.md
index b302105..5c6457b 100644
--- a/README.md
+++ b/README.md
@@ -4,5 +4,5 @@ Some notes for level29 of bandit.
 ## credentials
 
 - username: bandit29
-- password: tQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S
+- password: xxxxxxxxxx
 

commit abcff758fa6343a0d002a1c0add1ad8c71b88534
Author: Morla Porla <morla@overthewire.org>
Date:   Sun Apr 23 18:04:39 2023 +0000

    add missing data

diff --git a/README.md b/README.md
index 7ba2d2f..b302105 100644
--- a/README.md
+++ b/README.md
@@ -4,5 +4,5 @@ Some notes for level29 of bandit.
 ## credentials
 
 - username: bandit29
-- password: <TBD>
+- password: tQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S
 

commit c0a8c3cf093fba65f4ee0e1fe2a530b799508c78
Author: Ben Dover <noone@overthewire.org>
Date:   Sun Apr 23 18:04:39 2023 +0000

    initial commit of README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7ba2d2f
  • En los commits se puede ver uno antiguo que pertenece a la contraseña para bandit29.

Bandit 29 al 30

Hay un repositorio de git en ssh://bandit29-git@localhost/home/bandit29-git/repo. La contraseña para el usuario bandit29-git es la misma que para el usuario bandit29.

Clona el repositorio y encuentra la contraseña para el siguiente nivel.

Sitio Oficial

Iniciamos:

ssh bandit29@bandit.labs.overthewire.org -p 2220

Resolviendo Nivel 29

Lo mismo creamos un directorio temporal, clonamos el repositorio, accedemos y miramos el “README.md”:

bandit29@bandit:/tmp/tmp.EIeKaeHLPV/repo$ cat README.md 
# Bandit Notes
Some notes for bandit30 of bandit.

## credentials

- username: bandit30
- password: <no passwords in production!>
  • Intentemos ver los commits de nuevo:
bandit29@bandit:/tmp/tmp.EIeKaeHLPV/repo$ git log -p
commit 4bd5389f9f2b9e96ba517aa751ee58d051905761 (HEAD -> master, origin/master, origin/HEAD)
Author: Ben Dover <noone@overthewire.org>
Date:   Sun Apr 23 18:04:40 2023 +0000

    fix username

diff --git a/README.md b/README.md
index 2da2f39..1af21d3 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,6 @@ Some notes for bandit30 of bandit.
 
 ## credentials
 
-- username: bandit29
+- username: bandit30
 - password: <no passwords in production!>
 

commit 1a57cf10158f133c4f40ff82251f605a7618631d
Author: Ben Dover <noone@overthewire.org>
Date:   Sun Apr 23 18:04:40 2023 +0000

    initial commit of README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2da2f39
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+# Bandit Notes
+Some notes for bandit30 of bandit.
+
+## credentials
+
+- username: bandit29
+- password: <no passwords in production!>
+
  • Como no hay contraseñas en producción vamos a intentar ver una lista de todas las ramas remotas disponibles en el repositorio git actual se le conoce como branch.

Un branch (rama) es simplemente una línea de desarrollo separada, lo que significa que es una serie de commits que se han realizado en paralelo con respecto a otra serie de commits.

bandit29@bandit:/tmp/tmp.EIeKaeHLPV/repo$ git branch -r
  origin/HEAD -> origin/master
  origin/dev
  origin/master
  origin/sploits-dev
  • Para cambiar a otra rama en Git, se utiliza el comando **git checkout **.
bandit29@bandit:/tmp/tmp.EIeKaeHLPV/repo$ git checkout dev
Branch 'dev' set up to track remote branch 'dev' from 'origin'.
Switched to a new branch 'dev'
  • Ya cambiada la rama intentamos de nuevo ver los commits:
bandit29@bandit:/tmp/tmp.EIeKaeHLPV/repo$ git log -p
commit 13e735685c73e5e396252074f2dca2e415fbcc98 (HEAD -> dev, origin/dev)
Author: Morla Porla <morla@overthewire.org>
Date:   Sun Apr 23 18:04:40 2023 +0000

    add data needed for development

diff --git a/README.md b/README.md
index 1af21d3..a4b1cf1 100644
--- a/README.md
+++ b/README.md
@@ -4,5 +4,5 @@ Some notes for bandit30 of bandit.
 ## credentials
 
 - username: bandit30
-- password: <no passwords in production!>
+- password: xbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS
 

commit 8caf551dba9f9e39bc8ea4163de7902e6fa85f3a
Author: Ben Dover <noone@overthewire.org>
Date:   Sun Apr 23 18:04:40 2023 +0000

    add gif2ascii

diff --git a/code/gif2ascii.py b/code/gif2ascii.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/code/gif2ascii.py
@@ -0,0 +1 @@
+

commit 4bd5389f9f2b9e96ba517aa751ee58d051905761 (origin/master, origin/HEAD, master)
Author: Ben Dover <noone@overthewire.org>
Date:   Sun Apr 23 18:04:40 2023 +0000

    fix username

diff --git a/README.md b/README.md
index 2da2f39..1af21d3 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,6 @@ Some notes for bandit30 of bandit.
 
 ## credentials
  • Efectivamente en la rama dev podemos ver los cambios en producción:
 - username: bandit30
-- password: <no passwords in production!>
+- password: xbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS

Bandit 30 al 31

Hay un repositorio de git en ssh://bandit30-git@localhost/home/bandit30-git/repo. La contraseña para el usuario bandit30-git es la misma que para el usuario bandit30.

Clona el repositorio y encuentra la contraseña para el siguiente nivel.

Iniciamos:

ssh bandit30@bandit.labs.overthewire.org -p 2220

Resolviendo Nivel 30

Nuevamente creamos un directorio temporal, clonamos el repositorio, accedemos y miramos el “README.md”:

bandit30@bandit:/tmp/tmp.ZDVDAm3Ol8/repo$ cat README.md 
just an epmty file... muahaha
  • Intentamos ver los commits y la rama en la que estamos:
bandit30@bandit:/tmp/tmp.ZDVDAm3Ol8/repo$ git log -p
commit 59530d30d299ff2e3e9719c096ebf46a65cc1424 (HEAD -> master, origin/master, origin/HEAD)
Author: Ben Dover <noone@overthewire.org>
Date:   Sun Apr 23 18:04:42 2023 +0000

    initial commit of README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..029ba42
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+just an epmty file... muahaha

bandit30@bandit:/tmp/tmp.ZDVDAm3Ol8/repo$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  • No hay ramas adicionales ni commits que podamos ver porque no se crearon.

tag

Las etiquetas son una forma útil de identificar y marcar los hitos importantes de un proyecto.

Miramos si hay etiquetas:

bandit30@bandit:/tmp/tmp.ZDVDAm3Ol8/repo$ git tag
secret
  • Mostramos la tag:
bandit30@bandit:/tmp/tmp.ZDVDAm3Ol8/repo$ git show secret 
OoffzGDlzhAlerFJ2cAiz1D41JW1Mhmt

Bandit 31 al 32

Hay un repositorio de git en ssh://bandit31-git@localhost/home/bandit31-git/repo. La contraseña para el usuario bandit31-git es la misma que para el usuario bandit31.

Clona el repositorio y encuentra la contraseña para el siguiente nivel.

Sitio Oficial

Iniciamos:

ssh bandit31@bandit.labs.overthewire.org -p 2220

Resolviendo Nivel 31

Una vez que ya tengas creado el directorio temporal y clonado el repositorio miramos el “README.md”:

bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ cat README.md 
This time your task is to push a file to the remote repository.

Details:
    File name: key.txt
    Content: 'May I come in?'
    Branch: master
  • El objetivo es “enviar un fichero al repositorio remoto” y especifican los detalles de fichero.

  • Primero verificamos en que rama estamos, al parecer estamos en la rama master:

bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  • Entonces creamos un archivo key.txt que contendrá el siguiente mensaje “May I come in?”:
bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ echo "May I come in?" > key.txt
bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ ls
key.txt  README.md
  • Ahora es momento de añadir los elementos a nuestro repositorio
bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ git add key.txt 
The following paths are ignored by one of your .gitignore files:
key.txt
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
  • Como no lo permitio forzamos con -f para añadirlo, luego comprobamos con git status que se haya subido:
bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ git add key.txt -f

bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   key.txt
  • Ahora con un commit documentamos los cambios en esta caso añadimos el file “key.txt”
bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ git commit -m "Add key.txt"
[master cbc673d] Add key.txt
 1 file changed, 1 insertion(+)
 create mode 100644 key.txt
  • LLego el momento de subir los cambios con un push y el nombre de la rama actual, ingresas la contraseña del nivel actual:
bandit31@bandit:/tmp/tmp.zlM5S7XaBA/repo$ git push origin master
The authenticity of host '[localhost]:2220 ([127.0.0.1]:2220)' can't be established.
ED25519 key fingerprint is SHA256:C2ihUBV7ihnV1wUXRb4RrEcLfXC5CXlhmAAM/urerLY.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/bandit31/.ssh' (Permission denied).
Failed to add the host to the list of known hosts (/home/bandit31/.ssh/known_hosts).
                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \ / _` | '_ \ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \__,_|_| |_|\__,_|_|\__|
                                                       

                      This is an OverTheWire game server. 
            More information on http://www.overthewire.org/wargames

bandit31-git@localhost's password: 
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 325 bytes | 325.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: ### Attempting to validate files... ####
remote: 
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote: 
remote: Well done! Here is the password for the next level:
remote: rmCBvG56y58BXzv98yZGdO7ATVL5dW8y 
remote: 
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote: 
To ssh://localhost:2220/home/bandit31-git/repo
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://localhost:2220/home/bandit31-git/repo'
  • Y en una parte del mensjae esta la contraseña :
remote: Well done! Here is the password for the next level:
remote: rmCBvG56y58BXzv98yZGdO7ATVL5dW8y 

Bandit 32 al 33

Después de todo esto, es hora de otro escape. ¡Buena suerte!

Sitio Oficial

Iniciamos:

ssh bandit32@bandit.labs.overthewire.org -p 2220

Resolviendo Nivel 32

En este nivel cuando iniciamos ya estamos dentro del nivel pero ahora la minúsculas están a mayúsculas lo que hace dificil ver y listar las cosas:

WELCOME TO THE UPPERCASE SHELL
>> whoami
sh: 1: WHOAMI: Permission denied
>> $path
sh: 1: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: not found
>> $shell
WELCOME TO THE UPPERCASE SHELL
  • El objetivo es buscar un comando que me spawnee una shell pero teniendo en cuenta que las letras que introduzcas se convertiran en mayúsculas, por suerte hay un comando para pedir una shell:
>> $0
$ ls
uppershell
$ cat /etc/bandit_pass/bandit33
odHo63fHiFqcWWJG9rLiLDtPm45KzUKy

Bandit 33

Y por último llegamos al nivel final “bandit33”.

Sitio Oficial

Iniciamos:

ssh bandit33@bandit.labs.overthewire.org -p 2220

Resolviendo Nivel 33

Una vez dentro podemos listar y ver el contenido del archivo:

bandit33@bandit:~$ ls
README.txt
bandit33@bandit:~$ cat README.txt 
Congratulations on solving the last level of this game!

At this moment, there are no more levels to play in this game. However, we are constantly working
on new levels and will most likely expand this game with more levels soon.
Keep an eye out for an announcement on our usual communication channels!
In the meantime, you could play some of our other wargames.

If you have an idea for an awesome new level, please let us know!
  • Y pues nada se acabaron los nivels “Bandido”. Felicitaciones por seguir esta pequeña guia nivel a nivel!.

Referencias

Bash Scripthing para Principiantes

Gmichet

Autodidacta apasionado por la informática y entusiasta de los CTF. Constantemente aprendiendo.

2023 | WhatATheme - A Theme made with by Gmichet Powered by Jekyll