Pollution
Overview
A hard Linux machine created by Tr1s0n features techniques including:
Web Enumeration
XML External Entity
Redis Session Handler
PHP LFI to RCE
PHP-FPM
Reconnaissance
Services Discovery
We found ports 22 and 80 open on the target.
URL Path Discovery
We can find the following URL paths without authentication:
/login/register
We registered a new account via /register and we can find more paths including:
/home/logout
vHosts
On the home page, we see the email address info@collect.htb, and hence we shall add the domain to the file /etc/hosts.

We can then use the tool ffuf to try to fuzz the vHosts and we shall see the virtual hosts forum and developers exist.
The host developers.colloect.htb requires us to be authenticated through HTTP authentication.
Forum
The virtual host forum.collect.htb hosts a forum powered by MyBB.

In a thread, we found an attachment that can be downloaded via a valid account.

The content of the attachment is generated by the BurpSuite with base64 encoded request/response payload.

Admin Role
We see a relevant URL collect.htb/set/role/admin in the file.
By decoding the payload, we see the admin token may be used to set our account to be of the admin role.
We successfully updated our collect.htb account to the admin role using that token and we see that we are redirected to /admin.

We can access the administration panel now.

Internal API
There's a form on the admin page which will post data in the XML format.

It looks like the form data is passed to an internal API.

Initial Access
XXE
We try to test if the endpoint /api above has the XXE vulnerability.
From the error message, we see that the endpoint may have the XXE vulnerability.

Out-of-band XXE
We can exfiltrate data by serving an external malicious DTD file as the following explanation.
To demonstrate the out-of-band XXE, we set up an Express app which will
serve the varying DTD files and
decode the base64 encoded out-of-band information,
Then we can use the following Python script to read files on the target interactively.
We see that we can read the local files now.

Given that, there's a virtual host developers.collect.htb, here we need to guess the config file's name for it.

We see the usage of the .htpasswd file in the config and we shall try to crack the password to access the site.

htpasswd Crack
We can try to crack the htpasswd hash using hashcat with mode 1600.
We successfully got the credential developers_group:r0cket.
Developers
After we get access to the site developers.collect.htb, we use the file-reading ability to inspect the source code of the site.
We see that we need to be authenticated to access the page index.php.
We found there's an LFI vulnerability we can exploit if we can get authenticated.
By inspecting the file bootstrap.php, we see that the site uses Redis to manage sessions, refer to session.save_hander.

Redis Session Handler
We can authenticate to the Redis server using nc with password COLLECTR3D1SPASS found above.
We can manipulate our session data to be authenticated via the above Redis connection.
We can access the page and abuse the LFI now.

LFI to RCE
With full control of the PHP include path, we may try to upgrade the LFI ability to RCE via PHP filters.
As in the above article, we can get the RCE using a chain of PHP filters.

Lateral Movement
PHP-FPM
We first found the port 9000, which may be used by PHP-FPM, is opened on the localhost.

We can check if this port is used by php-fpm using ps and check the user running it is victor by checking the config www.conf under /etc/php/8.1/fpm/pool.d, refer to the documentation.

List of pool directives
With FPM you can run several pools of processes with different setting. These are settings that can be tweaked per pool.
... SNIP
user string
FastCGI Protocol
We can talk to the PHP-FPM using the FastCGI Procotol.
By uploading the Python script fpm.py, we can run commands under the user victor now.

We can use Python to get our reverse shell now.
Privilege Escalation
We found an Express app source code under the user victor's home directory and the app seems to be running under the user root.

The story goes on...
Reference
Last updated
