# Bandit 5 ( level 4->5 )

{% embed url="<https://overthewire.org/wargames/bandit/bandit5.html>" %}

### Level Goal <a href="#level-goal" id="level-goal"></a>

The password for the next level is stored in the only human-readable file in the **inhere** directory. Tip: if your terminal is messed up, try the “reset” command.

### Commands you may need to solve this level <a href="#commands-you-may-need-to-solve-this-level" id="commands-you-may-need-to-solve-this-level"></a>

[ls](https://manpages.ubuntu.com/manpages/noble/man1/ls.1.html) , [cd](https://manpages.ubuntu.com/manpages/noble/man1/cd.1posix.html) , [cat](https://manpages.ubuntu.com/manpages/noble/man1/cat.1.html) , [file](https://manpages.ubuntu.com/manpages/noble/man1/file.1.html) , [du](https://manpages.ubuntu.com/manpages/noble/man1/du.1.html) , [find](https://manpages.ubuntu.com/manpages/noble/man1/find.1.html)

### Solving

ssh into bandit4:

```
ssh -p 2220 bandit4@bandit.labs.overthewire.org
```

<figure><img src="https://2709089421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeYJYZBkmMR8RE96AFddn%2Fuploads%2Fx8agyGxbJqMOQvIKo24T%2Fimage.png?alt=media&#x26;token=35f7d5bc-3d76-4f29-8bf6-1b2924aa05fa" alt=""><figcaption><p>img1</p></figcaption></figure>

As you can see in the img1, we have 10 files in the directory.\
There's only one file that's our flag, you can brute-forcing and `cat` all the files out one by one.\
But learning to get the job done smarter is not a bad attempt right ?\
\
We'll be using the `file` command.\
This command is mostly used to identify the types of any specific files.\
In this case, we have our files named '-file..' \
There's a trick of using wildcard '\*' in our command to let them match the files with our condition.\
Like in this case, we can use:

```
file ./-file*
```

The './' before a file name is used to directly refers to the files.\
And the '\*' after the '-file' tells the command to identify all of the files those names started with "-file".

<figure><img src="https://2709089421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeYJYZBkmMR8RE96AFddn%2Fuploads%2F8OeSl19VcpKKkf7SyEUS%2Fimage.png?alt=media&#x26;token=cd37b00f-1248-47e8-a2d2-b553fb7774f9" alt=""><figcaption><p>img2</p></figcaption></figure>

As you can see in the img2, there's only one file which contains ASCII text. That's probably our flag.

<figure><img src="https://2709089421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeYJYZBkmMR8RE96AFddn%2Fuploads%2F52CnL5SKxW3AaQJ6rZXF%2Fimage.png?alt=media&#x26;token=669e94ee-de1f-4989-bbaa-cde0c0c44a16" alt=""><figcaption><p>FLAG !</p></figcaption></figure>

There we go, we captured our flag.

```
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw
```
