TryHackMe – Enumerating Active Directory

Enumerating Active Directory is a TryHackMe room that covers the various Active Directory enumeration techniques such as through CMD, PowerShell and Bloodhound. AD Enumeration can be a difficult undertaking especially if you don’t know what your looking for. Being able to enumerate over AD requires a relatively deep understanding of the structure of the domain which then can be used to determine attack paths that can then be used for lateral movement and ideally privilege escalation. This is the second walkthrough that I’ve written and directly follows the Breaching Active Directory room.

Task 1 – Why Active Directory Enumeration

Task one is an introduction, mostly consisting of preliminary knowledge, theory and setup. TryHackMe has the wonderful format of doing the boring stuff first so that you lose all motivation then begin the awesome stuff to pick you back up again. The information in this task will get you set up for the tasks ahead.

Head on over to http://distributor.za.tryhackme.com/creds from your connected VM to get the credentials we’ll use through out this room. You should see the same as below.

Credential Provider giving credentials
Credential Provider giving credentials

Now that we’ve got some credentials we are going to need to test them out. SSH into the “THMJMP1” machine. I’ll be using the command “ssh za.tryhackme.com\\simon.evans@thmjmp1.za.tryhackme.com” which results in:

SSH login
SSH login

Once everything is working mark the question on the task as done.

Task 2 – Credential Injection

Run as

To start with we are going to learn a bit about the “runas” tool. “runas.exe” is a command-line tool that enables one to run a command in the context of another user, it can be directly compared in principle to the Linux command “sudo”. Both tools make it possible to run a command pseudo as the specified user. You can read more about the “runas” tool on Microsoft’s official documentation.

DNS Problems

If you are using your own Windows machines for this room you’ll need to know how to configure an IP as your DNS server via the command line. Determining what IP on a network corresponds to a DNS server can be done in many ways which are detailed in this HackTricks page. However, to make things easier THM have told us that the DNS server is the domain controller on this network. If you’re on a Windows machine execure the following command:

$index = Get-NetAdapter -Name 'Ethernet' | Select-Object -ExpandProperty 'ifIndex'
Set-DnsClientServerAddress -InterfaceIndex $index -ServerAddresses <DC IP>

You can test that everything is working using the command “nslookup za.tryhackme.com” If your DNS is not working try redoing the connection stage and resetting the network settings on your machine. Now we can finally test our our credentials. From the machine that you logged into earlier try listing the files in the domain controllers SYSVOL directory. The room doesn’t go through what this directory is used for and that information can be found nicely presented by Microsoft here.

Contents of SYSVOL directory
Contents of SYSVOL directory

Read through the rest of the information provided and move onto the questions. Click on the question below to see the answer. However, it’s best you are able to figure it out yourself.

What native Windows binary allows us to inject credentials legitimately into memory? runas.exe
What parameter option of the runas binary will ensure that the injected credentials are used for all network connections? /netonly
What network folder on a domain controller is accessible by any authenticated AD account and stores GPO information? SYSVOL
When performing dir //za.tryhackme.com/SYSVOL, what type of authentication is performed by default? Kerberos Authentication

Task 3 – Enumeration through Microsoft Management Console

The Microsoft Management Console (MMC) is the only GUI method of enumeration that we’ll use until the last task. Connect to the “THMJMP1” via RDP with the credentials we got in the first task. I’d recommend doing this over setting it up yourself as MMC in my experience can be temperamental. Once you’ve read through the tutorials this task should be very easy as it’s just opening the drop down menu on the left of the AD users and computers screen and finding an account. We can now move onto the questions.

Active Directory Users and Computers browser
Active Directory Users and Computers browser
How many Computer objects are part of the Servers OU? 2
How many Computer objects are part of the Workstations OU? 1
How many departments (Organisational Units) does this organisation consist of? 7
How many Admin tiers does this organisation have? 3
What is the value of the flag stored in the description attribute of the t0_tinus.green account? THM{Enumerating.Via.MMC}

Task 4 – Enumeration through Command Prompt

Enumerating through command prompt should be the first option you go for when you have it available. Enumeration is all about sorting and managing information, I find that a command line utility provides me a way to filter information more efficiently. Read through the information provided and then we’ll move onto the tasks.

Users

Enumerating over users can be very useful especially in CTF style tasks where password change dates or comments will be useful. To get stated the first question is to find out what other group arron.harris is a member of. To do this we’ll use the “net user” command from earlier with the “/domain” option after the username.

arron.harris groups
arron.harris groups

The next task is to find out if the Guest account is active. To do this we’ll list all users on the domain and pipe that to the “findstr” command where we’ll look for guest user. If there’s output that means that the account is enabled, if there is no output the account must be disabled.

Testing for the guest account
Testing for the guest account

Groups

Firstly we need to fine out how many accounts are a member of the Tier 1 Admin group. To do this we’ll use the “net group” command with the “/domain” option after the group name. This command is very similar in syntax to the command we used earlier for the first question.

Users in the Tier 1 Admins group
Users in the Tier 1 Admins group

The final question wants us to determine what the account lockout duration of the current password policy is in minutes. Knowing when passwords are set to expire can be incredibly useful such as if the password expires every four months a common method of choosing passwords may be “Spring2022”. To find the password expiry date we’ll use the “net accounts” command with the “/domain” option.

net accounts /domain output
net accounts /domain output

Now we can answer the questions.

Apart from the Domain Users group, what other group is the aaron.harris account a member of? Internet Access
Is the Guest account active? (Yay,Nay) Nay
How many accounts are a member of the Tier 1 Admins group? 7
What is the account lockout duration of the current password policy in minutes? 30

Task 5 – Enumeration through PowerShell

PowerShell is essentially a more extensive command prompt, much like the step up from sh to bash. You can upgrade your command prompt to a PowerShell using the command “powershell”. Firstly read through the information provided then we’ll move onto the task.

Tasks

Firstly we need to find the value of the title attribute of Beth Nolans account. Their username is “beth.nolan” and we’ll be using the “Get-ADUser” command where we’ll need to specify the user, server and that we want to see all properties. We’ll then filter that output using the “findstr” command to filter out for the Title attribute.

beth.nolan account Title attribute
beth.nolan account Title attribute

The next task is to find the value of the “DistunguishedName” attribute. we;ll use the same command as before this time filtering for “Dist” just to find the relevant information.

DistinguishedName Attribute
DistinguishedName Attribute

Now we are going to start looking at groups. To start with we need to find out when the Tier 2 Admins group was created. To do this we’ll use the “Get-ADGroup” command specifying the group, server and asking for all properties then filtering for “when” in order to find the “whenCreated” tag.

Tier 2 Admins whenCreated
Tier 2 Admins whenCreated

The next task is to find out the value of the SID attribute of the Enterprise Admins. Here I just used the “Get-ADGroup” command and looked at the output to get the SID value.

Enterprise Admins attributes
Enterprise Admins attributes

The last task is to find what container is used to store deleted AD objects. To do this we’ll use the “Get-ADDomain” command and filter for the string “Deleted”

Get-ADDomain deleted AD objects
Get-ADDomain deleted AD objects

Now we can answer the questions.

What is the value of the Title attribute of Beth Nolan (beth.nolan)? Senior
What is the value of the DistinguishedName attribute of Annette Manning (annette.manning)? CN=annette.manning,OU=Marketing,OU=People,DC=za,DC=tryhackme,DC=com
When was the Tier 2 Admins group created? 2/24/2022 10:04:41 PM
What is the value of the SID attribute of the Enterprise Admins group? S-1-5-21-3330634377-1326264276-632209373-519
Which container is used to store deleted AD objects? CN=Deleted Objects,DC=za,DC=tryhackme,DC=com

Task 6 – Enumeration through Bloodhound

Firstly this task requires running bloodhound on your VM however I had a lot of issues trying to get it to work. I don’t think it’s worth the effort and you’ll notice that the terminal I use changes before we run bloodhound, that’s me switching over to the TryHackMe Attack Box VM. Read over the information provided in the task and we’ll get started with the tasks.

SharpHound

Firstly from our CMD we’ll move over the SharpHound executable from the C:\Tools directory to our users Documents folder.

Copying SharpHound.exe file
Copying SharpHound.exe file

Now we need to run the command and get the answer to the first question. We are going to run SharpHound using the command “Sharphound.exe –CollectionMethods Session –Domain za.tryhackme.com –ExcludeDCs”, The collection method “Session” just does user session collection, this is a stealthy method of collection and only touches systems that are most likely to have user session data. Then the domain is specified which in this case is “za.tryhackme.com”, finally, the “–ExcludeDCs” instructs SharpHound not to touch the Domain Controller.

Running SharpHound
Running SharpHound

Once we’ve ran SharpHound we’ll need to move the data that SharpHound has generated over to the attack box. Use the secure copy command “scp simon.evans@THMJMP1.za.tryhackme.com:C:/Users/simon.evans/Documents/20221112191320_BloodHound.zip .”. The syntax for secure copy in this case was “scp <username>@<host>:<full file path> <output path>”.

Next to start BloodHound on the attack box we need to firstly run “neo4j console start” which will start the neo4j backend, a graphing data platform, basically database management. Once that’s started run “bloodhound –no-sandbox” in another instance to start BloodHound.

Starting neo4j and BloodHound
Starting neo4j and BloodHound

BloodHound is a really simple tool, once loaded drag and drop the SharpHound zip file onto the BloodHound window.

Uploading the zip file to BloodHound
Uploading the zip file to BloodHound

Once things have all loaded in have a play around with the interface and following the steps on the page you can make your way to this screen where you’ll be able to begin the next task.

All the domain admins
All the domain admins

From there open up the analysis tab and click on “List all Kerberoastable Accounts” to see all the accounts that are potentially kerberoastable, excluding the “krbtgt” account there are four others.

All kerberoastable accounts
All kerberoastable accounts

Next we’ll take a look at the “Tier 1 Admin” group display and try to find out how many machines this group have administrative access to.

Tier 1 Admins Node Info
Tier 1 Admins Node Info

After scrolling we can see that the “Group Delegated Local Admin Rights” has a value of 2. This is a reference to the 2 machines that the admins can access.

Tier 1 admins machine admin access
Tier 1 admins machine admin access

Lastly we’ll find all the members of the Tier 2 Admins group. Search for the group and click on the “Note Info” tab and we can see that there are 15 direct members of the Tier 2 admins group.

Tier 2 Admins group Node Info
Tier 2 Admins group Node Info

We can now finally answer the questions

What command can be used to execute Sharphound.exe and request that it recovers Session information only from the za.tryhackme.com domain without touching domain controllers? Sharphound.exe –CollectionMethods Session –Domain za.tryhackme.com –ExcludeDCs
Apart from the krbtgt account, how many other accounts are potentially kerberoastable? 4
How many machines do members of the Tier 1 Admins group have administrative access to? 2
How many users are members of the Tier 2 Admins group? 15

Task 7 – Conclusion

The conclusion has some interesting comments on other methods however I’d recommend looking at Power View or AD Explorer. Unfortunately we don’t get the Armatage style cracked boxes on the screen at the top however this was a job well done.

Network State, not impressive
Network State, not impressive

Related Posts

One thought on “TryHackMe – Enumerating Active Directory

Leave a Reply

Your email address will not be published. Required fields are marked *