Bandit3->4
Level Goal
The password for the next level is stored in a hidden file in the inhere directory.
Commands useful to solve the level
Helpful Reading Material
- Hidden file and hidden directory
- What are directories, if everything on Linux is a file?
- inode(7) man page
Where to start?
In this challenge, we're now introduced to 2 new notions : directories and hidden files. The reading material gives valuable information and helps us understand better what actually is a directory and what are hidden files. One key takeaway is that hidden files are not safer that regular files, they are just not listed by default by listing utilities. However, the information that they are not listed by default already gives us two hints :
- The file is there
- We can access it
Now, let's dive into how we are going to actually view and access the file in this hidden directory.
Let's move, I want to be close to the file I'm looking for
Part 1 : the cd builtin
Let's now meet a new friend, the cd builtin. We will need to use
this builtin to navigate to the directory named inhere.
Hint
man cd doesn't work here. Indeed, the cd builtin is part of the shell
you're using (I'll assume you're using bash).
However, you can view the SHELL BUILTIN COMMANDS section of the gnu bash manual.
Solution
To effectively change directory to the inhere directory, we need to run the command cd inhere.
Part 2 : listing hidden files
Now that we are in the inhere directory, if we run the ls command, this is the output we get :
bandit3@bandit:~/inhere$ ls
bandit3@bandit:~/inhere$
However, we know that there is a hidden file in this directory, we need to find a way to retrive that file.
Hint
Look at the DESCRIPTION section of ls. The option you're looking for should be near the top
Solution
The -a or --all is the option you're looking for. It allows to not ignore the entries starting with a ..
This is the output we get after listing all of our directory contents :
bandit3@bandit:~/inhere$ ls --all
. .. .hidden
bandit3@bandit:~/inhere$
Now that we know that the file we're are looking for, we can print its content with cat .hidden
Full Solution
cd inhereto change directory to the inhere directoryls --allto print all the contents of the inhere directorycat .hiddento print the hidden file
Why move ? I can do everything from my home directory
The idea is basically the same than if we wanted to move, with a slight variation.
Part 1 : listing the directory contents
Up until now, we used the ls utility with options but without any argument.
We need to find a way to specify a directory to the ls command.
Hint
Once again, we'll look in the ls man page, but this time we need to have a look in the SYNOPSYS section.
Solution
The command ls --all inhere it the command we're looking for. this command will allow us to list the contents of the inhere directory,
without moving nor ignoring the hidden files.
Running it gives us the following output :
bandit3@bandit:~$ ls --all inhere
. .. .hidden
bandit3@bandit:~$
Part 2 : printing the hidden file
Now that we now that the hidden file in the inhere directory is called .hidden, we can run cat and give it the relative path
to the .hidden file as an argument : cat inhere/.hidden. This will dump the password string to stdout
Full Solution
ls --all inhereto list the contents of the inhere directorycat inhere/.hiddento print the contents of the.hiddenfile
You can now jump to the next level