Soccer

Overview

A Linux machine, created by sau123, features

  • Default credential vulnerability

  • File uploading vulnerability

  • SQL injection with Websocket

  • dstat plugins

on the HackTheBox platform.

Reconnaissance

Port Scanning

The port scanning reveals that ports 22, 80, and 9091 are opened on the target.

Hostname

We see the virtual host name in the HTTP response and we add it to our hosts file /etc/hosts.

No more hostnames can be found further via the command ffuf:

Web URL Path

We found a URL path /tiny/ via the command ffuf:

Tiny File Manager

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.

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.

The new vhost leads us to another site where we can view the game match, register a new user, or log in to view the tickets for the game match.

We see that the site will use WebSocket to communicate with the server.

By inspecting the source code, we see that the established WebSocket sends messages encoded in JSON {"id": "<message>"}:

SQL Injection

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:

We can then use sqlmap to test if SQL injection vulnerability exists.

We dump the databases and find a databae soccer_db exists.

We can further get the table names.

We can then dump the table accounts.

We can log in as user player to the target with the credential PlayerOftheMatch2022 using SSH and get the user flag now.

sqlmap support WebSocket scheme in the pull request 1206.

We can directly use it to test SQL injection vulnerability like the following command:

Privilege Escalation

We can't run sudo on the localhost.

SUID Program

We found a SUID program doas using find.

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.

dstat Plugin

User can add dstat plugin in a couple of places:

One of the directory can be written.

The plugins are written in Python script.

We then wrote a malicious dstat plugin in the path /usr/local/share/dstat.

We can test if the plugin is installed via --list option:

We can invoke the plugin to get root now.

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 :

Last updated