> 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/hack-the-box-writeup.md).

# Hack The Box — WriteUP

Hack The Box — WriteUP walkthrough

#### Hack The Box — WriteUp <a href="#f615" id="f615"></a>

Hey folks, today we have one of **HackTheBox** machines “**WriteUP**” which seems like CTF challenges and depends on CVE’s exploitation. It has more than trick, let’s take a look at its info

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

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

**`Nmap` Scan**

As usual, we start our scan with `nmap` to get top open ports, service running and more

`nmap -A -T4 -oG writeup.gnmap 10.10.10.138`

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

We have only 2 open ports `80/22` and the services which running on them is not vulnerable, so the start point will be on the website

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

so there’s nothing here and also after using `dirsearch and gobuster` there’s nothing useful returned from them, so I tried `/machine_name` directory which will be `/writeup` as one of CTF techniques which used at many challenges, and it works, we have directory called `/writeup`

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

After checking its source code trying to find the used CMS if there’s or any keyword for something vulnerable

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

**User Flag**

I’ve found something called `CMS Made Simple` and after searching for CVE’s related to this type

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

We have a bunch of vulnerabilities related to it, let’s try to use `SQLi` exploit by using `-m` option and exploit path to get it into our directory as you can see here

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

So after running it, you will have username `jkr` and hashed password (pass and salt)

After searching for a method to crack it, I’ve found that `hashcat` can crack it by using `-m 10` or `-m 20`

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

I’ll put the pass and the salt into one file separated by `pass:salt` like this

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

let’s use `hashcat`

`hashcat -m 20 -a 0 hash /path/to/wordlist —-force`

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

The results…

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

It works and we have the password `raykayjay9`

Let’s try to login to ssh using this creds

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

That’s good, we have the user flag

**Root flag**

We have some steps to find a way in escaping to root account

1. Enumerate all the files and directories to find any file which led us to password or any other secrets
2. Using `LinPEAS.sh` to perform multiple tasks and get back the important files
3. Use `PsPy` to check the processes

I’ve done the first 2 steps and found nothing important, so after downloading `PsPy` to my vulnerable machine and executing it, I’ve found something execute after every login process

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

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

It executes `run-parts` file.

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

At every time `jkr` login to the system, the file `run-parts` executes, so I’ve created this file to contain the reverse shell and logged in as `jkr` to let it executes

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

and the results

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

It works :)

**Congrats ❤**
