Skip to main content

Bandit 5 Over The Wire

Lessons learned

Find has a size modifier

Logging into Bandit 5

On a kali vm/ linux machine
Type:

ssh bandit5@bandit.labs.overthewire.org -p 2220 
koReBOKuIDDepwhWk7jZC0RTdopnAYKh

Completing The Challenge

The Goal:

password for next level located in a file somewhere under the inhere directory and has all of the following properties:

  • human-readable
  • 1033 bytes in size
  • not executable

The Solution:

My Solution:

bandit5@bandit:~$ ls inhere 
bandit5@bandit:~$ cd inhere/ 
bandit5@bandit:~/inhere$ find -size 1033c 
./maybehere07/.file2 
bandit5@bandit:~/inhere$ file maybehere07/.file2 
maybehere07/.file2: ASCII text, with very long lines 
bandit5@bandit:~/inhere$ cat maybehere07/.file2 
DXjZPULLxYr17uwoI01bNLQbtFemEgo7

use find -size 1033c t find all files of size 1033 bytes
since there is only one, check that it is human readable and read it

A much better Solution:

find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII

picked from terdon on stackoverflow in the https://unix.stackexchange.com/questions/313442/find-human-readable-files

i added this so that i could find it more easily but also so i could explain it and how it works and also modify it to make things easier. I hope

the . tells find to start in the current directory. not necessarily needed

-type f means regular file, opposed to directories or pipes. not necessarily needed

-size tells find what size to look for, but the c in 1033c is what tells it to actually check the size and not round up

! means negate, so since we have a -executable modifier which is capable of finding executable files, this will remove those instead

-exec file {} + is the part that makes me happiest

the file here is the same file command we have previously used to check file information, in this scenario the find command has the capability of running any command on the results of a find query if you add -exec CMD {} + to the find cmd.

therefore for most things this command could be written as 

find -size 1033c ! -executable -exec file {} + | grep ASCII

but the terdon's is safer and depending on the situation could be faster

Comments

Popular posts from this blog

Bandit 6 Over The Wire

Lessons learned Find has modifiers for user, group, size, and can execute a command on find files Logging into Bandit 6 On a kali vm/ linux machine Type: ssh bandit6@bandit.labs.overthewire.org -p 2220  DXjZPULLxYr17uwoI01bNLQbtFemEgo7 Completing The Challenge The Goal: password for next level located in a file somewhere in the server and has all of the following properties: owned by user bandit7 owned by group bandit6 33 bytes in size The Solution: bandit6@bandit:~$ find / -user bandit7 -group bandit6 -size 33c 2>/dev/null  /var/lib/dpkg/info/bandit7.password bandit6@bandit:~$ find / -user bandit7 -group bandit6 -size 33c 2>/dev/null -exec cat {} + HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs using what we learned previously we know how to get size an easy way to look for modifiers if you already have an idea of what your looking for is to do:   man CMD | grep MOD this pipes/lets grep read the output of the man page and then look for certain strings in this case i looked ...

Bandit 12 Over The Wire

Lessons Learned extracting and decompressing files using the following tools: file, xxd -r, gunzip, bunsip2, and tar -xf Logging in On a kali vm/ linux machine Type: ssh bandit12@bandit.labs.overthewire.org -p 2220  5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu Completing The Challenge The 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!) The Solution:      Revamped:         I decided to write a bash file that solves the problem.                    mkdir /tmp/a_name/                    mv data.txt /tmp/a_name      ...

Bandit 13 Over The Wire

Lessons Learned using ssh -i filename user@localhost which is the private key ssh connection Logging in On a kali vm/ linux machine Type: ssh bandit13@bandit.labs.overthewire.org -p 2220 8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL Completing The Challenge The 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 The Solution: ssh -i sshkey.private bandit14@localhost the above command is use because we already have the private key. private keys should be used very carefully. Since we are already on the machine that hosts Bandit Over The Wire, we don't need to call the correct name, localhost will means the machine talks to itself. I don't know why, but specifying a port here caused issues. My assumption is the profiles is listeni...