SwagShop HTB
IP
initial nmap scan
we can see we have the following two ports open
22,80
Lets run a more in-depth scan of the target
results
we can see the following
SSH is running
Apache 2.4.29 is in place (web server)
Domain name
swagshop.htb
we can add this to our hosts file
HTTP Port 80
Lets get feroxbuster running in the background to identify any interesting web pages
Looking at the web server we can see the following
Already we can see the webserver is
Ubuntu server
running magento
magento 2014 is vulnerable to RCE
runs on php
MySQLis present
When we look at the about us we can see a possible username
John Doe
We can see there is an option to create an account
Lets create an account a proxy through Burp and see if there are any interesting requests being made
We now have an account
nothing to interesting
Let's see if we can exploit Magento
after some quick googling we can see this version is vulnerable to SQLI which we can utilise to create a admin account on the system
we can use the following script
What is the actual scripts doing
This script appears to perform SQLI on a Magento CMS (Content Management System) website. It targets the admin interface of the Magento CMS and attempts to create a new admin user with specified credentials. Here's a step-by-step breakdown:
Import Libraries:
Retrieve Target URL:
The script expects the target website URL as a command-line argument.
Ensure Target URL Format:
These lines ensure that the target URL starts with "http://" and does not end with a trailing slash.
Construct Target URL for Admin Interface:
The target URL is constructed for the Magento admin interface.
SQL Injection Payload:
This is the SQL injection payload. It inserts a new admin user into the
admin_user
table with a specified username and password.Format and Encode Payload:
The payload is formatted into a single line, and the username and password are specified. The payload is then encoded using base64.
Craft HTTP Request:
An HTTP POST request is sent to the target URL with the encoded payload.
Check Response:
If the request is successful (HTTP status code 200), it prints a success message along with the admin URL and credentials. Otherwise, it prints a failure message.
Okay once we have ran the script we should get a admin user within the Content Management System so
Looking through the CMS we can see we have the option to add pages and knowing the site runs off php we could potentially upload a php reverse shell and gain access to the system
We will use PHP monkeys reverse shell
edit the script with our local ip and port
Lets start a nc listner
Now lets upload the php file
hmmm this didnt seem to work when we tried to upload the file as a page, Lets re think this
What we can is add a custom option within one of the files, that allows for uploading php files
to do this we can
within the catalogue -> manage products we can Edit one of the existing products
within the left panel we click on Custom Options
click on Add New Option
then we would specify a file and extention
Click save
Now when we navigate to the chosen product we can see the ability to upload a php file
Once we have uploaded our reverse shell and added the product to cart we should be able to navigate to
we can see our shell sitting here once we click it it will call back to our lkistner
Priv esc via www-data
First lets stabilize our shell
Checking our sudo privs
we can run vi as root this is good lets check out
so we can run vi as root on any file within the /var/www/html
directory
we are now root
Last updated