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.
Starting Nmap 7.80 ( https://nmap.org ) at 2023-09-13 16:26 -03Nmapscanreportfor10.129.102.140Hostisup (0.26slatency).PORTSTATESERVICEVERSION22/tcpopensshOpenSSH 7.2p2Ubuntu 4ubuntu2.4 (UbuntuLinux; protocol2.0)|ssh-hostkey:|204842:90:e3:35:31:8d:8b:86:17:2a:fb:38:90:da:c4:95 (RSA)|256b7:b6:dc:c4:4c:87:9b:75:2a:00:89:83:ed:b2:80:31 (ECDSA)|_256d5:2f:19:53:b2:8e:3a:4b:b3:dd:3c:1f:c0:37:0d:00 (ED25519)5000/tcpopenhttpGunicorn19.7.1|_http-server-header:gunicorn/19.7.1|_http-title:Sitedoesn't have a title (text/html; charset=utf-8).ServiceInfo:OS:Linux; CPE:cpe:/o:linux:linux_kernel
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".
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.
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.
roosa@devoops:~$iduid=1002(roosa) gid=1002(roosa) groups=1002(roosa),4(adm),27(sudo)# group (adm), you can see the system's log with > ls -l /var/log roosa@devoops:~$lsb_release-aNoLSBmodulesareavailable.DistributorID:UbuntuDescription:Ubuntu16.04.4LTSRelease:16.04Codename:xenial#Niceroosa@devoops:~$ls-latotal156<...>drwx------3rootroot4096Mar262021.dbusdrwxrwxr-x4roosaroosa4096Mar262021deploydrwxr-xr-x2roosaroosa4096Mar262021Desktop-rw-r--r--1roosaroosa25Mar212018.dmrc<...>drwxr-xr-x2roosaroosa4096Mar262021Templates-r--------1roosaroosa33Sep1315:04user.txtdrwxr-xr-x2roosaroosa4096Mar262021Videosdrwxrwxr-x3roosaroosa4096Mar262021work<...>
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.
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.
Target Terminal [roosa]
roosa@devoops:/home$cd/tmproosa@devoops:/tmp$cp/home/roosa/work/blogfeed/resources/integration/authcredentials.key/tmp/id_rsaroosa@devoops:/tmp$chmod600id_rsaroosa@devoops:/tmp$ssh-iid_rsaroot@localhost# It requires password with every user, forget about it.
Return to the blogfeed folder with cd /home/roosa/work/blogfeed
Target Terminal [roosa]
roosa@devoops:~/work/blogfeed$gitlog
"reverted accidental commit with proper key" looks like an interesting mistake, copy the commit code.