Vulnhub HarryPotter:Nagini walkthrough!!
Hi all!! In this write-up I will walk you through how to get root access on the Vulnhub Harry Potter: Nagini. This is the second machine of the Harry Potter series by the creator Mansoor R. I would really say that to get the initial shell on the box was really difficult for me.
If you also want to try you can download it from this link.
Let’s begin with nmap scan for all open ports. Only couple of ports are open.
Let’s detect the running services and their versions.
When I opened the page in the page in the browser, below image was displayed.
I downloaded this image on my local machine used exiftool, strings to find hidden message if any, but no luck. Then I used gobuster to enumerate the directories and web pages. The gobuster gives couple of important hints, note.txt and joomla.
When opened note.txt in browser, it has below hint.
So I updated hosts file on my local machine with the above entry for the IP address of nagini machine. Again used gobuster on this, but of no use. I searched for HTTP3 on google and came across the github page.
Downloaded and make a build of it on my local machine. This program supports HTTP3.
After opening the URL with curl that support httpv3, it says there is some php page “internalResourceFeTcher.php” is running. I visited the page in the browser.
I tried for both LFI and RFI, but it did not work for me, as it is taking the URL as parameter possibility that it is vulnerable to SSRF (Server Side Request Forgery), for checking that I tried to open the note.txt and able to read it.
It is also possible to read sensitive file using SSRF using ‘file’ schema so I used file:///etc/passwd and it gave me the contents of the passwd file.
I tried to read some other files like id_rsa or authorized_keys etc. but failed. Then I turned out towards Joomla and scan it using joomscan. It gave me the backup of the configuration.php file.
Downloaded the backup file on my local machine and it has below information.
I downloaded the configuration.php file using SSRF but the contents of both the files are same.
After spending hours I am unable to make any progress, while reading about the SSRF, I came across this article, and decided to give it a try. But to use this we need to know the db username, db name etc. which we have from backup file. So I tried to fetch the users from joomla_users table from joomla db.
This gave me the contents of the joomla_users table.
After this, I tried to create a new admin but my query failed, so decided to change the password for existing admin. I decided to set the password as “admin2” MD5 hash of the password “c84258e9c39059a89ab77d846ddab909".
USE joomla; UPDATE joomla_users SET password = ‘c84258e9c39059a89ab77d846ddab909’ WHERE email= ‘firstname.lastname@example.org’;
I am able to successfully update the password of site_admin with the new password.
Now from here, just need to add the PHP RCE payload, and we are done. For detail, follow steps mentioned here.
Visit the URL “http://192.168.1.11/joomla/templates/protostar/my_shell.ph” pin browser.
Copied the reverse shell payload, made changes to get reverse shell and started the netcat listener on local host on port 4242.
After gaining shell, when I checked found two users on box snape and hermoine. I am able to read some files for their home directories.
Creds for user snape.
With this password, I am able to login as snape user. The find command showed a guid binary owned by user hermoine.
The binary is nothing but the binary for cp with name changed.
Privilege Escalate to user hermonie
To escalate my privilege to user hermonie, I decided to generate the ssh keys and copy it to .ssh directory of the user hermoine.
Then copied id_rsa.pub key to the /home/hermoine/.ssh/authorized_keys using suid binary.
SSH as hermoine:
In home directory of hermoine, there is a .mozilla directory.
So I decided to recover the username and password from it. I used a firefox_decrypt script for that.
Copied the whole .mozilla folder on my kali machine. Clone the firefox_decrypt on Kali and recovered the username and password.
It is really a good box to get the initial foothold. SSRF is interesting.
Hope you like it. Thanks for reading.
SSRF Through Gopher://
I am writing the blog after a year because I didn't get any interesting Vulnerability throughout the year. Recently I…
What is SSRF (Server-side request forgery)? Tutorial & Examples | Web Security Academy
In this section, we'll explain what server-side request forgery is, describe some common examples, and explain how to…
A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER…
If you know a place which is SSRF vulnerable then, this tool will help you to generate Gopher payload for exploiting…
As of 1.0.0 Python 3.9+ is required. Python 2 is no longer supported. If you encounter a problem, try the latest…
A list of useful payloads and bypass for Web Application Security and Pentest/CTF - swisskyrepo/PayloadsAllTheThings