Sample VM Writeup
Sample VM Writeup
Port 22 is ssh and port 80 is http. This means there is a web server running on port 80. Let’s
open a browser and check it out.
We can see a webpage that allows us to file complaints. If you file one, it will take you to another
page.
Checking the website's sources doesn’t reveal anything else as well. Fuzzing the web
application to find other directories.
The tools ffuf allows to perform directory brute forcing.
This is an image analysis website. We can upload an image, it is analyzed by exiftool and its
metadata is printed on the webpage. The version of exiftool is 12.37.
Searching for vulnerabilities for this version of Exiftool.
https://github.com/cowsecurity/CVE-2022-23935
CVE-2022-23935
The vulnerability arises due to improper file check, which leads to command injection.
Downloading the PoC from Git Hub. The PoC requires the pwn module in Python.
Running the PoC, with the attacker machine ip address and the port we will be listening to.
ip addr
Make sure to change the ip and port value to your machine's IP address and the port number
you want to listen to, as seen in the image above.
This will generate an image with the malicious file name which will cause the exiftool to execute
commands.
Uploading the image file.
The next step is to start enumerating the machine to find information that can help us to gain
higher privileges on the machine.
But people copy these private keys in other folders or some cases people generate keys in
certain locations and then copy them to the .ssh directory.
There is a .bak folder. There is an id_rsa key present, with permission 444.
Grabbing the ssh key.
cat /home/kermit/.bak/id_rsa
Once we get the ssh-key, we will copy it to a file and save it in the attacker's machine. Change
the file permissions of the private key.
cat user.txt
user{cdc2ec2673abd58db14c8a70e231d007f6c2ae347b27b7c8e4eeb93e1ed61fdb}
There is a local web application running in the system. We can find this out by enumerating the
file system. An entrypoint.sh file is present which shows that a php server is being run on port
8000 with the file system being /var/www/html.
You can also do netstat check to find ports that are in use in the system.
netstat -an
We can route this local web server to a port in the attacker machine using ssh.
We can see that the app is called cacti and the version is 1.2.22
https://github.com/FredBrave/CVE-2022-46169-CACTI-1.2.22
The vulnerability arises due to the fact that in the file remote_agent.php, the poller_id parameter
is vulnerable. Below you can see the vulnerable code. The proc_open can be used to execute
commands and any unauthorized user can manipulate the poller_id parameter. There is no
validation as well.
We need to log in to the application to create a graph first since it’s required for this to work.
The default creds admin:admin will work for the login. Once we are in the system, click on
Create Graphs.
You might have to install the application first. The system admin only set up the application a
few days back.
You can choose several templates in the create option. What we are looking for are the
templates that monitor the system. In this case, Device uptime is one.
Click create. This will create a template that we can exploit.
Create a listener on the port where you want to get the shell.
nc -nvlp 1337
Now use the PoC given in the above link.