Information
Room
- Name: VulnNet: Internal
- Profile: tryhackme.com
- Difficulty: Easy
- Description: VulnNet Entertainment learns from its mistakes, and now they have something new for you...
Write-up
Overview
Install tools used in this WU on BlackArch Linux:
Network enumeration
Port and service scan:
NFS
Let's show the mounts available from NFS:
Let's mount it:
Let's see the kind of information that is stored on this share:
Many configuration files, for example in the redis file we can find the password
required to access the server.
Redis
As we now know, the redis server requires authentication.
The INFO
command will gives some generic information on the system:
In the keyspace config we saw that database 0 was containing 5 keys.
In addition of the flag we also get the rsync credentials.
RPC checks
With enum4linux-ng
we can have an overview of what is exposed and unprotected
on different services.
Interestingly the shares
SMB share is accessible.
SMB
Let's confirm what I saw with enum4linux-ng
Let's open the available share with a capable SMB browser (in my case with dolphin):
Here we can find the file services.txt
.
Rsync
Let's see the name of the directory share:
Then we can copy all files on our machine:
User flag is here:
Gain shell access
We can copy our public SSH key into the authorized_keys
file to able able to
connect via SSH.
Elevation of Privilege (EoP)
In the root folder of the server there is an uncommon folder: TeamCity
.
We can see that TeamCity is running as root.
By reading /TeamCity/conf/server.xml
it seems the port used is 8111.
But the server is only listing on the loopback.
So we need to port forward this local port to be able to access it. It should be
easy enough with the SSH access.
You can read my article Overview of network pivoting and tunneling
to discover all possible techniques.
A simple SSH local port forwarding we be enough.
Now we can access TeamCity at http://127.0.0.1:9999/login.html
There is a message:
So instead we are asked to login at http://127.0.0.1:9999/login.html?super=1
as a super user using an authentication token rather than credentials.
So let's see if we can read it from the server configuration:
The token could be in the catalina configuration be it's read protected. So
let's see in the logs instead.
Once authenticated, we can create a new project, add a build configuration,
add a build step of type Command Line that run a Custom script.
To backdoor the server as root we can write our SSH key to the root authorized_keys
.
It will work because the default value of PermitRootLogin
in sshd_config
is
prohibit-password
. So authenticating via SSH using a key is alright.
Then we just have to run the project and log as root via SSH: