Lazyadmin
Have some fun! There might be multiple ways to get user access.
https://tryhackme.com/room/lazyadmin
Enumeration
First off lets start with enumerating the machine!.
Start off with nmap -sC -sV -v -oA nmap/machine_name $IP
.
-sC
will use the default scripts on the discovered services.
-sV
will enumerate the versions of the discovered services.
-v
for a verbose output
-oA
output the result in different formats(xml, txt, html)
With that we get the following result.
There are two services running OpenSSH
and Apache
and they both tell us that this is a Linux box, notably Ubuntu.
Upon opening the webpage, we are greeted with the default page when you first start up Apache.
There is nothing much we can do here, so lets check for hidden directories with gobuster
.
dir -u $url
is the target IP.
-w
is which wordlist to use.
-t #
this indicated how many threads to use, the bigger the number, the more requests the faster the discovery, however there could be chances that you might get blocked from the webserver if you go too fast.
-o
store the result in a file.
After finishing we get
The only interesting directory is /content
.
Opening it it shows us Welcome to SweetRice
. This is our first clue on what is running on Apache.
There is also a link that will show you a few tips on what to do after installing Sweet Rice CMS.
Reading the tips, you'll notice that tip #2 is quite interesting.
This is our second clue on where to look for stored information and credentials.
And if we check if the /inc
directory is available, it indeed is and it has interesting files.
.htaccess.txt
doesn't do us any good, however latest.txt
and mysql_backup/
have valuable stuff.
Latest shows us which version of Sweet Rice is running and we can lookup online to see any vulnerabilities for that version and in the mysql_backup/
directory there could be stored credentials in it.
Downloading the SQL file and reading it (you can view it with a simple text editor or just cat
it) closely, we can see that there are credentials stored in for Sweet Rice CMS.
The user is manager
and the password is an MD5 hash which can be easily cracked.
Next is to find where the dashboard is as the website said. Do another gobuster
scan on the /content
directory.
With this we get
In the /as
directory we are greeted with a login page for Sweet Rice.
Login in with the discovered credentials we are in the Dashboard as an admin.
Now lets search for an exploit for version 1.5.1.
Using searchsploit sweetrice
we get a bunch of exploits for version 1.5.1 if you don't have searchsploit on your machine, just search Sweet Rice CMS 1.5.1 exploit online and you'll find the same results on ExploitDB
I'll be using the Arbitrary File Upload, but manually without using the script.
I'll paste the whole source code of the python exploit here and will go through it on what it does and how to exploit the service without using the script.
Lets start from the top.
The script wants us to pass a username, password and a file to upload(preferably a PHP reverse shell).
Then it creates a session and does a POST request to the login page and logs in with the credentials we passed.
After that it uploads the file to the media_center
tab which you can find it on the left side and it tells you where the file is stored. http://IP/attachment/file
.
Instead of using the script lets do this on our own.
Navigate to the Media Center tab on the left
Now grab a PHP reverse shell from Pentestmonkey and set your local IP and PORT and set the PHP extension to .php5
.
Start nc -lvnp PORT
to listen on your desired port.
Now upload your PHP script to the Media Center and navigate to the /attachment
directory an execute the script.
Privilege Escalation
Once you're in, always stabilize your shell.
After you've done that you can get the user flag in its default place :)
After that listing through the user directory we see two interesting files.
backup.pl
and mysql_login.txt
Now I haven't done much exploring with MySQL on the machine and haven't found anything. Maybe you can search around and find something.
Looking at what the Perl script does
It simply executes a shell script as system.
Looking at what we can do with that script
We can Read Write and eXecute, basically we can do anything with it.
Lets get a bash shell as root.
Simply rewrite the script with
Now, if we simply execute the backup.pl
script it doesn't do anything special. It just spawns another bash shell. This means there might be another way.
Checking sudo -l
we can see
This means we can execute the Perl script as sudo
without a password.
Simply running
Will spawn us in a root
shell.
With this, you can get the root flag in the root directory :)
Final Thoughts
This challenge was very easy. I had an easy time exploiting it.
As the challenge says, there might be multiple ways to exploit this. And there are sorta different ways to get a root shell with the backup.pl
and copy.sh
scripts.
Other different ways I haven't really found.
Hope you enjoyed my way of exploitation :)
Last updated