Niveau 32

Niveau 32

Level Goal

There is a git repository at ssh://bandit31-git@localhost/home/bandit31-git/repo. The password for the user bandit31-git is the same as for the user bandit31.

Clone the repository and find the password for the next level.

Commands you may need to solve this level

git

Sans grande surprise ce niveau est encore un niveau git. Clonons le repo et regardons le contenu du README.md :

bandit31@bandit:/tmp/bandit31/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

Le but semble être d'effectuer un commit sur le repository.

On notera qu'il y a aussi un fichier .gitignore présent sur le repository dont le contenu est le suivant :

bandit31@bandit:/tmp/bandit31/repo$ cat .gitignore
*.txt

Commençons par créer un fichier key.txt avec le contenu attendu :

bandit31@bandit:/tmp/bandit31/repo$ echo "May I come in?" > key.txt

Essayons de l'ajouter à un commit :

bandit31@bandit:/tmp/bandit31/repo$ git add key.txt
The following paths are ignored by one of your .gitignore files:
key.txt
Use -f if you really want to add them.

Le fichier .gitignore bloque le fichier, il suffit de rajouter le paramètre -f pour pouvoir l'ajouter à notre commit :

bandit31@bandit:/tmp/bandit31/repo$ git add key.txt -f

Puis créons notre commit :

bandit31@bandit:/tmp/bandit31/repo$ git commit -m "lack of imagination commit's title"
[master 3468082] lack of imagination commit's title
 1 file changed, 1 insertion(+)
 create mode 100644 key.txt

Enfin pushons notre commit pour obtenir le mot de passe :

bandit31@bandit:/tmp/bandit31/repo$ git push origin master
Could not create directory '/home/bandit31/.ssh'.
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:98UL0ZWr85496EtCRkKlo20X3OPnyPSB5tB5RPbhczc.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/bandit31/.ssh/known_hosts).
This is a OverTheWire game server. More information on http://www.overthewire.org/wargames

bandit31-git@localhost's password: 
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 339 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 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: 56a9bf19c63d650ce78e6ec0354ee45e
remote: 
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote: 
To ssh://localhost/home/bandit31-git/repo
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://bandit31-git@localhost/home/bandit31-git/repo'