Active Directory Offensive Security: Zero to Domain Admin/Foundations & Core Protocols
Active Directory Offensive Security: Zero to Domain Admin/Foundations & Core Protocols
Before you attack anything, you need a map in your head. Active Directory, called AD in short, is Microsoft's system that keeps one shared list of every user, every computer and every permission in a company. Because of this list, a laptop in Building A trusts the same login as a server in Building B.
Think of a company with 3,000 employees and 5,000 computers.
Without AD, every computer keeps its own list of who can log in there. A new employee joins, and someone has to add that person to every machine they will use. An employee leaves, and someone has to remove the account from every machine. One password change means the same work again. On 5,000 computers, this is impossible to manage.
AD solves this by keeping one list in one place.
One server, called the Domain Controller (DC), holds this master list of all identities. A DC is simply a Windows Server with the AD role installed on it. Every other computer in the company trusts what the DC says about you: who you are, and what you are allowed to open.
That trust is the whole game. Every attack in this course is some way of making the DC, or a computer that trusts it, believe something wrong about you.
AD keeps things in a tree, like folders inside folders. There are four levels you must know.
Rendering diagram…
Permissions and GPOs flow downward in this tree, like water. Whatever you set at the top reaches everything below it.
So if you get write permission on one OU, you can often control every object inside that OU. Keep this sentence in mind. Half the privilege escalation tricks in this course come from it.
Every new domain comes with two built-in folders: CN=Users and CN=Computers. They look like OUs in the admin tool, but they are not OUs. They are called containers.
Why does this small difference matter?
Group Policy can only be linked to an OU. It cannot be linked to a container. So a computer or a user sitting inside CN=Computers or CN=Users never receives any GPO settings. No password rules from GPO, no security hardening, nothing. Admins can change this default with the commands redircmp and redirusr, but many companies never do.
When you enumerate a real company later, look for objects still sitting in CN=Computers. Those machines are usually forgotten machines that nobody manages. Unmanaged usually also means unpatched, and unpatched machines are easy targets.
A SID looks like this:
textS-1-5-21-3623811015-3361044348-30300820-1013
Read it in two parts.
The first part, S-1-5-21- followed by three long numbers, belongs to the domain. It is different for every domain in the world. This is how Windows knows that the account alice in your company is not the same person as the account alice in some other company.
The last number, here 1013, is called the RID (Relative Identifier). AD gives it to each object one by one, like a roll number in a class. Some RIDs are fixed and the same in every domain on earth:
| RID | Who it always is |
|---|---|
| 500 | The built-in Administrator account |
| 512 |
These numbers never change, even if the admin renames the account.
This is why renaming the Administrator account to something like mgr_svc01 gives you very little protection. Windows checks the SID, not the name on screen. An attacker asks the domain for the account with RID 500 and gets the answer, whatever name it wears today.
Every AD group has a type and a scope. They sound similar, so learn them separately.
Type answers: can this group be used to give permissions?
Both look almost the same when you list them, so always check the type before you get excited about a group.
Scope answers: how far do this group's powers reach?
Why this matters when you attack: when a tool like BloodHound shows that your user is a member of some group, the scope tells you how far that membership can take you. A Domain Local group stops at the edge of that domain. A Universal group does not.
A Global Catalog (GC) is a special job that most DCs do by default.
A normal DC knows everything about its own domain. A GC server also keeps a partial copy of every object in every domain in the forest. Partial means it stores some attributes of each object, not all of them.
The GC exists so that a search across the whole company stays fast. For example, "find any user named Sharma anywhere in the company" can be answered by one GC instead of asking every domain one by one.
The GC also matters for logins. Universal group membership has to be checked across the whole forest, so a GC must be reachable when a user logs in. If you ever see strange login failures during a multi-domain job, an unreachable GC is one thing worth checking.
These two words look similar, and beginners mix them up constantly. Keep them apart from day one.
Think of an office. The security guard at the gate checks your ID card, that is authentication. The lock on the finance room door decides if your card can open it, that is authorization. Getting inside the building does not mean you can enter every room.
This matters when you attack. If you steal a Kerberos ticket, you have only stolen proof of identity. Where that ticket takes you still depends on the permissions the account behind it holds.
Not all admin accounts are equally dangerous. Microsoft uses the name Tier Zero for anything that can control the whole domain, directly or indirectly:
If you control any Tier Zero asset, you control the forest. Notice that backup software is on this list. Its name says nothing about admin rights, but a system that can restore a DC can also read everything on that DC.
On almost every real job, your work reduces to one question: starting from one ordinary user account, is there a path to Tier Zero? Every lesson after this one is another way to answer yes.
These are Microsoft's own commands for asking AD questions. They are signed by Microsoft, they write nothing to disk, and their traffic looks like normal admin work. They are available on any domain-joined Windows machine that has RSAT installed. RSAT means Remote Server Administration Tools, a free Microsoft add-on.
powershellGet-ADUser -Filter * -Properties Description,MemberOf | Where-Object {$_.Description -ne $null}
The older command-line tools from before PowerShell. They are still present on every domain-joined Windows Server. Learn them, because sometimes you land on a machine where the AD PowerShell module is not installed.
textdsquery user -name svc-* | dsget user -memberof -expand
This is your tool when you attack from a Linux machine that is not joined to the domain. It speaks LDAP directly, so it needs no Microsoft software at all.
| Option | What it does |
|---|
bashldapsearch -x -H ldap://10.10.10.5 -D "[email protected]" -w 'Passw0rd!' -b "DC=corp,DC=local" "(objectClass=user)"
dsa.msc to open Active Directory Users and Computers. Walk through the tree. Notice how OUs sit inside each other, and how and sit outside the OU structure.For defenders: keep Tier 0 credentials off ordinary user machines, so a stolen laptop never holds domain admin secrets. Give each admin only the one right they need, instead of full admin "just in case." Move new computer and user objects out of the default containers into managed OUs, so nothing escapes GPO hardening by accident. Make privileged accounts log in only from hardened admin workstations. Finally, log every OU, GPO and ACL change, and make sure a real person reviews those logs.
CN=Users and CN=Computers are containers, not OUs, so GPO settings never reach objects inside them.CN=Computers more interesting to an attacker than one placed in an OU?Sign in to track progress, submit flags, and take notes.
corp.local| The Domain Admins group |
| 519 | The Enterprise Admins group |
| Option |
|---|
| What it does |
|---|
-Filter | The question you are asking, for example -Filter {Name -like "svc-*"}. Keep it narrow, so you do not pull the whole directory. |
-Properties * | Returns every attribute of the object, not only the few shown by default. Admins often leave passwords in the Description field, so always check it. |
-SearchBase | Limits the search to one OU. Useful when you want a quiet, small query. |
-x | Use simple authentication. This is what you want when you have a username and password. |
-H ldap://dc-ip | The domain controller you are asking, by IP address or hostname. |
-b "DC=corp,DC=local" | Where to start the search. This example starts at the top of the domain. |
CN=UsersCN=ComputersGet-ADUser command above against your lab. Confirm you can see every attribute you set, including the raw SID. Find the RID of your own test Domain Admin account.