Post

HTB Linux Medium: Clicker

Clicker is a Medium rated Linux machine on HTB.

HTB Linux Medium: Clicker

Nmap

Pasted image 20240714210303.png

Initial Foothold

The web site redirects to the clicker.htb domain, add the domain to the hosts file: Pasted image 20240714210241.png

Enumerating NFS

Mount the drive locally to look through the files and folders on the share: Pasted image 20240714210246.png

In the files we find the database username and password. Pasted image 20240714210235.png

Enumerating HTTP (Port 80)

When saving a game, only 2 attributes are used, however in the save_game.php file, there are 3 attributes present, if we are able to bypass the following if statement we would be able to save our profile and become an administrator on the website. Pasted image 20240714210229.png

CRLF injection can be performed while saving a game to bypass the filter. Pasted image 20240714210224.png

After logging out and logging back in we get access to the administrator page. Pasted image 20240714210220.png

The nickname needs to be added to the save request or it will not show up in the administration portal. Pasted image 20240714210214.png

Gain RCE

We can replace the nickname with a PHP webshell. Pasted image 20240714210208.png

In order to use the webshell we need to modify the file extension to .php. We do this by intercepting the request and changing the extension. Pasted image 20240714210203.png

We now have RCE. Pasted image 20240714210159.png

Gain shell

RCE bash reverse shell payload (make sure to URL encode key characters). Pasted image 20240714210153.png

Your nc listener is now a shell. Pasted image 20240714210148.png

Lateral movement

The execute_query script allows us to read files as the jack user, we are able to retrieve the private SSH key by specifying a relative path as the input. Pasted image 20240714210143.png

Modify RSA key (otherwise invalid), don’t forget: chmod 600 id_rsa! Pasted image 20240714210138.png

SSH as jack: Pasted image 20240714210132.png

Priv Esc

Sudo -l output (IGNORE ALL:ALL). Pasted image 20240714210127.png

Content of the monitor.sh script: Pasted image 20240714210122.png

Create the following reverse shell script. Pasted image 20240714210118.png

Execute the payload. Pasted image 20240714210114.png

Start a Python server. Pasted image 20240714210109.png

Your nc listener should have turned into a shell. Pasted image 20240714210105.png

User.txt

Pasted image 20240714210050.png

Root.txt

Pasted image 20240714210045.png

You have PWNED

Pasted image 20240714210041.png

Sources

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