HackTheBox "Busqueda"

April 14th, 2023

Info Card
Info Card

Introduction

Busqueda is an easy box released on April 8th, 2023 by kavigihan.

User Own

Nmap scan:

The box is running a website called Searcher.

Going to the website http://searcher.htb, we get the homepage. The website takes a search engine and a query, then generates a valid query for that website. Looking at the bottom of the page, the website uses Flask and Searchor.

Searchor is a CLI tool for generating search queries. Using the query --help shows this much.

Burp Suite Repeater
Burp Suite Repeater

Looking at the source code, we can see:

The URL gets created in an eval, and the query parameter is wrapped in single quotes. This eval can be hijacked.

Commands can be run by using:

This is basically:

So the eval uses our exec function as an argument which unintentionally runs it.

USER OWN
USER OWN

System Own

Checking the app directory:

Checking the .git directory:

Checking config:

config contains credentials for cody. These credentials also work to login as svc through SSH.

sudo -l reveals:

Inside /opt/scripts:

Running sudo /usr/bin/python3 /opt/scripts/system-checkup.py *:

Output of full-checkup:

MySQL and a new subdomain, gitea.searcher.htb. Adding that to /etc/hosts leads to a Gitea page. The login credentials for cody from before work, but there is nothing of interest.

Output of docker-inspect after checking the config of MySQL:

Documentation for docker inspect formatting

The administrator account of Gitea can be logged into with MYSQL_PASSWORD. This gives us the previously inaccessible source code of the scripts in /opt/scripts.

scripts Repository
scripts Repository

The source code of system-checkup.py can help us figure out how to exploit it. In the condition for full-checkup:

system-checkup.py runs full-checkup.sh, but only grabs the relative file. This means a custom bash script with the name full-checkup.sh can be run in a different directory. Putting a reverse shell in the custom bash script will give us access to root.

SYSTEM OWN
SYSTEM OWN

And that's the box!

PWNED
PWNED

Last updated