infosecfamily
← Back to catalog
HackTheBox  /  Medium  /  Linux

EvilCUPS

Tested by: Testing performed by Nikolay Kravtsov, a novice information security specialist at 13:13 (*passed quite quickly, if you don’t take into account that I was constantly thrown out*)

Testing scope and services used.

IP/domain Port Service Target Server Service
localhost 5901 WinKexServer -
localhost - Nmap Port Scanner -
localhost - Obsidian Notes -
localhost 8000 Python HTTP Simple Server -
localhost 12345 Python HTTP Simple Serverfor CVE-2024-47176 -
10.10.11.40 631 CUPS WEB Server +
10.10.11.40 22 SSH +

Files used:

  • linpeas.sh - Privilege Escalation Awesome Scripts SUITE new generation.
  • CVE-2024-47176 PoC- Remote Command Execution in CUPS 2.4.2.
  • d00001-001 - print file for the printer and obtaining a password from root.
  • user.txt - flag.
  • root.txt - flag.

    Procedure

1) Launch openvpn for access; kex to make Linux more convenient

  • kex --win && sudo openvpn lab_Kolya080808.ovpn

    2) Scanning ports using nmap.

  • Results:

PORT    STATE SERVICE VERSION
22/tcp  open  ssh     OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0)
| ssh-hostkey:
|   256 36:49:95:03:8d:b4:4c:6e:a9:25:92:af:3c:9e:06:66 (ECDSA)
|_  256 9f:a4:a9:39:11:20:e0:96:ee:c4:9a:69:28:95:0c:60 (ED25519)
631/tcp open  ipp     CUPS 2.4
| http-robots.txt: 1 disallowed entry
|_/
|_http-title: Home - CUPS 2.4.2
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

3) Without searching for directories, we look at the site.

  • 4) Let's look for an exploit for this version of CUPS and use it.

  • Search and use:

  • Result:

5) Read user FLAG:

  • Result:

    6) Let's download linPEAS and see what we can do:

  • Actions:

  • Expected result: judging by what I saw, you need to look at that printed page on the printer: this one

    7) Let's look in /var/spool/cups

  • Result: Hooray!

8) In the file itself I found the password for the root user:

  • Result:

    9) Log in via ssh and read the root user flag:

  • Result:

Note: Cool room, but you need to understand how CUPS works and the exploit itself. For me it was quite simple. But anyway, thanks to HackTheBox for the awesome room!!!

Vulnerabilities found

Information Disclosure

PoC:

(point 7)

CVSSv3 Score: 10.0 (Critical)

Description:

Information Disclosure in this case is associated with access to data in the /var/spool/cups directory, which contains a file with a record of the root user’s password.

Reproducing the vulnerability:

Same as PoC.

Remediation recommendations:

  • Check specific files for sensitive data
  • Delete or store the file with confidential information in a place inaccessible to users.

    CVE-2024-47176

PoC:

(point 4)

CVSSv3 Score: 10.0 (Critical)

Description:

This exploit allows remote execution of commands on the server without the knowledge of the administrator.

Reproducing the vulnerability:

Remediation recommendations:

  • Update CUPS to the latest version.
  • Keep track of vulnerabilities and fixes on their official website.

    Video walkthrough