Watersnake
Last updated
Last updated
target
Let's download the files from hackthebox
we can unzip the files using the following tool
Looking at the web application we can see the following
we can see
the application name and version watersnake v3
we can also see information related to to the firmware update
when we open the challenge folder is vs code we can see
this is a java application
if we look in vscode we have
Looking in Controller.java
Within the bottom box it looks like from our input stream it's grabbing some yaml, doing a yaml load
if we look at the top of the code we can see where it has been imported
so if we go over to our pom.xml
what is pom.xml
is a configuration file used in Apache Maven, a widely used build and project management tool in the java ecosystem, the POM stands for Project Object Model. This file contains information about the project (for us watersnake) and configuration details used by Maven to manage the project buld lifecycle, dependencies, plugins, and other aspects
some key details we could find in the pom.xml
file is
Project information
Build configuration
Dependencies
Repositories
plugin configurations
we can also find the version of snakeyaml
being used
Now we can google any vulns associated with this specific version
looks like it is vulnerable to CVE-2022-1471
, which is a unsafe deserialization vulnerability, deserializing yaml content provided by an attacker can lead to RCE
here is a blog that can explain it better then i can
Okay let's work with this
within the Controller.java
we can see there is a function, that does indeed execute a command to the backend system
if we look the the GetWaterLevel.java
file we can see
we can see
it is taking the value as input and splitting it
then it is feeding that value into our command
it then tries to run the command
we know now we have our gadget GetWaterLevel
so we can use this
Essentially we are going to put together a YAML payload (more information within the blog)
Let's start a ngrok server
2. Let's start a python servers
our yaml payload
some-var
: this is a variable
!!com.lean.watersnake.GetWaterLevel
: path to the gadget we will be utilising
then our commands we ant to run on the system for this we will ruynning a python script
Our python script run.py
Now to grab our python script we are going to utilize the firmware update panel
From here we should have a hit, our script was downloaded successfully
Now we just need to execute the script, we can create another yaml payload to do this
Now if we look at our python3 server we should see a base64 encoded flag
decode the flag