Level31

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.

Solution

As with the previous few levels, we will need to use git to solve this one. If we follow the same steps as the last level we will see that there is a README and a .gitignore file in this repo. The README states that we will need to push a file to the remote repo to pass this level.

root@0xCAB: /writeups/overthewire/bandit/level31/

$ la repo
.git .gitignore README.md

$ cat repo/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

$ cat repo/.gitignore
*.txt

$

Lets first create the needed file.

root@0xCAB: /writeups/overthewire/bandit/level31/

$ cd repo

$ echo 'May I come in?' > key.txt

$

We can now add it to the index. Since the .gitignore is specifying that files with a “txt” suffix should be ignored and not tracked, we will need to force add our file with the -f flag.

root@0xCAB: /writeups/overthewire/bandit/level31/

$ git add -f key.txt

$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged ..." to unstage)
new file: key.txt

$

Finally, we can commit the change to the repo and push it to the remote. Note: the push will fail but we will get a message with bandit32’s password.

root@0xCAB: /writeups/overthewire/bandit/level31/

$ git commit -m 'added key file'
[master 8234bc2] added key file
1 file changed, 1 insertion(+)
create mode 100644 key.txt

$ git push
...
Writing objects: 100% (3/3), 326 bytes | 326.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.
...

$