February 20, 2022
Hello everybody. Here is a writeup of Pit that I made a while ago which I decided to upload here.
I always like to add the ip to /etc/hosts, because then I don't have to remember the ip anymore.
To add the ip to /etc/hosts: Where BOXIP is the box ip
First lets check what ports are open with masscan. This command will check all open ports on both udp and tcp on the tun0 virtual adapter. Only downside is that it takes much time.
Then I ran a script-scan on the port from masscan
Ports:
At port 80 there is an unconfigured nginx webserver.
At port 9090 there is some kind of CentOs login.
Nmap also showed that 9090 had a certificate with the name (dms-pit.htb) which I also added to my /etc/hosts.
http://dms-pit.htb returned a forbidden status code.
Since snmp was running on port 161, I tried taking it on a walk with snmpwalk ;)
Which printed some data:
Here we see a user named michelle and its that it's running Centos 8.3.2011.
To get some more information I ran this command:
After searching for a while, I saw a /var/www/html directory with seeddms (A free document management system):
/var/www/html/x is often the root of websites, so I tried visiting http://pit.htb/seeddms51x/seeddms but got a 404.
http://dms-pit.htb/seeddms51x/seeddms didn't return a 404, here is a login panel.
Here is a login page there we can input a User ID, a password and a language. I put michelle as User ID (since I found a user called it in the snmpwalk) then tried some basic passwords. After a while I tried "michelle" as a password and it worked and I'm in :)
By digging arround on the website for a bit I found this from /Docs/Users
.
Here it seems like I can upload files.
http://dms-pit.htb/seeddms51x/seeddms/out/out.ViewFolder.php?folderid=8&showtree=1
I created a file named 1.php with this content (from exploit-db) and uploaded it with the "Add Document button"
Files in SeedDms are stored in http://dms-pit.htb/seeddms51x/data/1048576/documentid/filename.someextension
The documentId can be found by rightclicking the download button of the uploaded document ?documentid=31
Now the file is uploaded and commands can be executed with the cmd parameter http://dms-pit.htb/seeddms51x/data/1048576/31/1.php?cmd=cat+/etc/passwd
I tried to get a reverse shell but it didn't work so I navigated around the system and found ../../../conf/
which contains a settings.xml
file.
The webpage will show a white page. This is because the browser is trying to parse the xml as html. To view the xml go into the View Page Source
tab.
Here is a databse user and a database password.
I could not really access the database from sql cli since its localhost only. I also tried to ssh into michelle with the db password, but no success.
Then i decided to try the dbpassword on the pit.htb:9090 login page with michelle
as username and the db password as password. It worked.
Here is some kinda admin dashboard. On the left there is a Terminal button. I pressed it and now I got user.
I started by checking the output of snmp again snmpwalk -c public -v 2c boxip .1 > file.txt
I digged arround for some time and found something interesting. NET-SNMP-EXTEND-MIB
, which is a extension that allows running scripts triggered by snmp.
I checked who could execute the /usr/bin/monitor
in the michelle terminal. And turns out its only the owner, which is root.
This is the content of /usr/bin/monitor
.
It is basically a script that executes all .sh scripts starting with check
inside /usr/local/monitoring
I ran "ls -ld /usr/local/monitoring"
There is a +
at the end of the permissions, which means michelle has additional ACLs set (See here).
I ran getfacl /usr/local/monitoring/
to get more about it, and saw that michelle has read and execute permissions.
This script will write my public ssh key to /root/.ssh/authorized_keys
and will allow me to ssh into root.
To trigger the script
Oh hey, I'm on Twitter too if you'd like to follow more about what I'm up to. Hopefully I'll see you there! 😊
20 Jul
10 May
08 Feb
07 Feb
05 Dec