$ nmap -p- --min-rate 3000 -Pn 192.168.157.113
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-14 16:01 +08
Nmap scan report for 192.168.157.113
Host is up (0.18s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
8080/tcp open http-proxy
Web Enumeration -> File Upload
Visiting both the websites shows nothing. The page source just shows this:
This was a PHP page, so uploading PHP reverse shells is the priority, and there's a pretty good WAF. I tested loads of method of bypassing it, and this machine requires a combination of quite a few.
File Header Spoofing
Double File Extension
Content-Type Spoofing
We can get a reverse shell by loading the uploaded file:
Privilege Escalation
SNMP -> Docker Escape
We spawned in a Docker container. The /var/backups folder contained a .conf file for SNMP:
www-data@a7c367c2113d:/var/backups$ ls -la
total 20
drwxr-xr-x 1 root root 4096 Dec 21 2020 .
drwxr-xr-x 1 root root 4096 Nov 18 2020 ..
-rwxr--r-- 1 root root 7340 Dec 9 2020 .snmpd.conf
Here are the interesting bits:
###############################################################################
#
# ACCESS CONTROL
#
# system + hrSystem groups only
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
# Full access from the local host
#rocommunity public localhost
# Default access to basic system info
rocommunity public default -V systemonly
# rocommunity6 is for IPv6
rocommunity6 public default -V systemonly
rocommunity 53cur3M0NiT0riNg
<TRUNCATED>
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
extend-sh test3 /bin/sh /tmp/shtest
<TRUNCATED>
Firstly, we have the password string required. Next, we have some sort of script execution within the machine. We can put a reverse shell there instead.
Then, place this within /tmp and chmod 777 it. Afterwards, change the PATH variable and run the logconsole binary to check for CPU information.
export PATH=/tmp:$PATH
OpenSSL -> File Read
Within the /opt directory, there's an openssl binary that only tom can execute:
tom@escape:/opt/cert$ ls -la
total 724
drwxr-xr-x 2 root root 4096 Dec 9 2020 .
drwxr-xr-x 4 root root 4096 Dec 9 2020 ..
-rwx------ 1 root root 1245 Dec 9 2020 certificate.pem
-rwx------ 1 root root 1704 Dec 9 2020 key.pem
-rwxr-x--- 1 tom tom 723944 Dec 9 2020 openssl
We are also given some certs and keys. I first checked this openssl binary using getcap, finding that it has all capabilities enabled, meaning that we can read any file: