Lessons learned
Logging into Bandit 5
On a kali vm/ linux machine
Type:
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:
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
Post a Comment