The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:
ls , cd , cat , file , du , find
bandit5@bandit:~$ ls
inhere
bandit5@bandit:~$ cd inhere/
bandit5@bandit:~/inhere$ ls
maybehere00 maybehere03 maybehere06 maybehere09 maybehere12 maybehere15 maybehere18
maybehere01 maybehere04 maybehere07 maybehere10 maybehere13 maybehere16 maybehere19
maybehere02 maybehere05 maybehere08 maybehere11 maybehere14 maybehere17
bandit5@bandit:~/inhere$ ls -a maybehere*
maybehere00:
. .. -file1 .file1 -file2 .file2 -file3 .file3 spaces file1 spaces file2 spaces file3
maybehere01:
. .. -file1 .file1 -file2 .file2 -file3 .file3 spaces file1 spaces file2 spaces file3
In the `inhere` directory, there are many files. How can we find the specific one?
bandit5@bandit:~/inhere$ find . -type f -exec file {} \;
./maybehere07/-file3: data
./maybehere07/spaces file2: ASCII text, with very long lines (9063)
........
bandit5@bandit:~/inhere$ find . -type f -exec file {} \; | grep -i text
./maybehere07/spaces file2: ASCII text, with very long lines (9063)
./maybehere07/-file2: ASCII text, with very long lines (2487)
First, we can find human-readable file by using the `-type`, `-exec` options and the `grep` command. `find . type -f` means searching for all files from the current directory and all its subdirectories. `-exec file {} \;` means that for each file found, the `file` command is excuted. `{}` is replaced with the file name, and `\;` ends the `-exec` command. Additionally, by using the `grep` command, we can exclude files that are not of the text types.
bandit5@bandit:~/inhere$ find . -type f -size 1033c -exec file {} \; | grep -i text
./maybehere07/.file2: ASCII text, with very long lines (1000)
Next, by using the `-size` options, we can find files that are exactly 1033 bytes in size. The `-size` options specifies that the file uses less than, more than or exactly a specified number of units of space, with `c` indicating bytes.
bandit5@bandit:~/inhere$ find . -type f ! -perm /111 -size 1033c -exec file {} \; | grep -i text
./maybehere07/.file2: ASCII text, with very long lines (1000)
Lastly, by using the `-perm` options, we can search for files that have any of the excute permissions set for the owner, group, or others. However, `! -perm` searches for files that do not have any of the excute permissions set for the owner, group, or others. The `!` before the options negates the condition. Therefore, `find ! -perm /111` will find files where none of the excute permissions are set for the owner, group, or others.
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
Finally, we can find the password!
Next Level : Level 6 -> 7
Bandit Level 7 -> Level 8 (0) | 2024.09.07 |
---|---|
Bandit Level 6 -> Level 7 (0) | 2024.09.06 |
Bandit Level 4 -> Level 5 (0) | 2024.08.12 |
Bandit Level 3 -> Level 4 (0) | 2024.08.10 |
Bandit Level 2 -> Level 3 (0) | 2024.08.07 |