Tenten is an medium-rated Linux machine from HackTheBox created by Iokori. In the current post, my IP is 10.10.14.76, and the target’s IP is 10.129.102.140
The machine is a good review of concepts, the recognition step is standard and involves fuzzing to find new attack vectors, but it is necessary to have a reliable tool to detect the target's technologies, like Wappalyzer.
Once the correct vector is found, you have to exploit an explicit XXE to extract relevant files and log in as roosa. By the other hand, Privilege Escalation is patience, searching for information from a git project and other important files to extract the public key.
Recon
Local Terminal
> ping -c 1 10.129.102.140PING10.129.102.140 (10.129.102.140) 56(84) bytes of data.64bytesfrom10.129.102.140:icmp_seq=1ttl=63time=273ms---10.129.102.140pingstatistics---1packetstransmitted,1received,0%packetloss,time0msrttmin/avg/max/mdev=273.347/273.347/273.347/0.000ms
The machine is alive, and by the TTL (close but no more than 64), it is possible to think that the target is a Linux Machine.
StartingNmap7.80(https://nmap.org ) at 2023-09-13 16:24 -03Warning:10.129.102.140givinguponportbecauseretransmissioncaphit (10).Nmapscanreportfor10.129.102.140Hostisup (0.27slatency).Notshown:65533closedportsPORTSTATESERVICE22/tcpopenssh5000/tcpopenupnp
There are two open ports. First the port 22 with ssh, if you search about "OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 launchpad", we can see that the target is an "Ubuntu Xenial".
Place to upload files, with XML elements, interesting.
This place says XXE everywhere
First, upload an empty file to see how it reacts, with vi test.xml, the create the proper XML, with vi exploit.xml
Fails with test.xml
Works with exploit.xml
From here we got a lot of information. First, the output is visible, this means that is possible to execute an XXE, and second, there is an user called "roosa" at the system.
Exploitation
Let's see if the exploits works, creating a file with vi exploit_proof.xml, then upload it.
Target's /etc/passwd
Perfect, it works, remember that with Ctrl+U (view:source) you can see in a better format the targeted file.
Now, time to exploit, upload exploit_exec.xml.
Unencrypted id_rsa
In many machines, this exploits fails, an alternative to these situation, because the target use php, is the use of wrappers, like "php://filter/convert.base64-encode/resource=/var/www/html/index.php" after SYSTEM.
Reverse Shell - roosa
Perfect, we can read the id_rsa.
See the content of the "Cross-Site Scripting" exploit, it's the version 4.1.0, it should be that.
Privileges Escalation
A lot of files, but there are two curious folder, deploy and work. Let's check work.
Good, there is git, in those cases is always a good practice to see the commits for old relevant information... ALWAYS! But first, let's see if there is another hidden file here.
A file with credentials?
Another id_rsa, go to home to check for more users.
Another way to see the user list with bash, is by reading the /etc/passwd file and check who has the "bash" available.
Many user to test the id_rsa, if is not the correct one, we should check the past-commits for mistakes.
Copy the authcredentials.keys as id_rsa to the tmp folder, then connect through ssh.
Return to the blogfeed folder with cd /home/roosa/work/blogfeed
"reverted accidental commit with proper key" looks like an interesting mistake, copy the commit code.
It shows a deleted id_rsa, copy the red one at /tmp and try to use it.
Starting Nmap 7.80 ( https://nmap.org ) at 2023-09-13 16:26 -03
Nmap scan report for 10.129.102.140
Host is up (0.26s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 42:90:e3:35:31:8d:8b:86:17:2a:fb:38:90:da:c4:95 (RSA)
| 256 b7:b6:dc:c4:4c:87:9b:75:2a:00:89:83:ed:b2:80:31 (ECDSA)
|_ 256 d5:2f:19:53:b2:8e:3a:4b:b3:dd:3c:1f:c0:37:0d:00 (ED25519)
5000/tcp open http Gunicorn 19.7.1
|_http-server-header: gunicorn/19.7.1
|_http-title: Site doesn't have a title (text/html; charset=utf-8).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
roosa@devoops:/home$ cd /tmp
roosa@devoops:/tmp$ cp /home/roosa/work/blogfeed/resources/integration/authcredentials.key /tmp/id_rsa
roosa@devoops:/tmp$ chmod 600 id_rsa
roosa@devoops:/tmp$ ssh -i id_rsa root@localhost
# It requires password with every user, forget about it.