Active Directory Metodologie
Tip
Leer en oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer en oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer en oefen Azure Hacking:
HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subskripsie planne!
- Sluit aan by die đŹ Discord groep of die telegram groep of volg ons op Twitter đŠ @hacktricks_live.
- Deel hacking truuks deur PRs in te dien na die HackTricks en HackTricks Cloud github repos.
Basiese oorsig
Active Directory dien as ân fundamentele tegnologie wat netwerkadministrateurs in staat stel om doeltreffend domeine, gebruikers, en items binne ân netwerk te skep en te bestuur. Dit is ontwerp om te skaal, wat die organisering van ân groot aantal gebruikers in hanteerbare groepe en subgroepe vergemaklik, terwyl toegangsregte op verskeie vlakke beheer word.
Die struktuur van Active Directory bestaan uit drie primĂȘre lae: domeine, trees, en forests. ân Domein sluit ân versameling items in, soos gebruikers of toestelle, wat ân gemeenskaplike databasis deel. Trees is groepe van hierdie domeine wat deur ân gedeelde struktuur gekoppel is, en ân forest verteenwoordig die versameling van meervoudige trees, onderling verbind deur trust relationships, wat die boonste laag van die organisasie-struktuur vorm. Spesifieke toegangs- en kommunikasie-regte kan op elk van hierdie vlakke aangewys word.
Sleutelbegrippe binne Active Directory sluit in:
- Directory â Huisves alle inligting wat verband hou met Active Directory-items.
- Object â Dui entiteite in die directory aan, insluitend gebruikers, groepe, of gedeelde gidse.
- Domain â Dien as ân houer vir directory-items, met die vermoĂ« vir verskeie domeine om koeksisterend binne ân forest te bestaan, elk met hul eie versameling items.
- Tree â ân Groepering van domeine wat ân gemeenskaplike root-domein deel.
- Forest â Die hoogste vlak van organisasie in Active Directory, saamgestel uit verskeie trees met trust relationships tussen hulle.
Active Directory Domain Services (AD DS) omvatt ân reeks dienste wat krities is vir die gesentraliseerde bestuur en kommunikasie binne ân netwerk. Hierdie dienste sluit in:
- Domain Services â Sentrale berging van data en bestuur van interaksies tussen gebruikers en domeine, insluitend authentication en search funksionaliteit.
- Certificate Services â Oorsee die skepping, verspreiding, en bestuur van veilige digital certificates.
- Lightweight Directory Services â Ondersteun directory-enabled toepassings deur die LDAP protocol.
- Directory Federation Services â Verskaf single-sign-on vermoĂ«ns om gebruikers oor veelvuldige webtoepassings in een sessie te verifieer.
- Rights Management â Help om kopieregmateriaal te beskerm deur onbevoegde verspreiding en gebruik te reguleer.
- DNS Service â Krities vir die oplossing van domain names.
For a more detailed explanation check: TechTerms - Active Directory Definition
Kerberos Authentication
Om te leer hoe om attack an AD moet jy die Kerberos authentication process baie goed verstaan.
Read this page if you still donât know how it works.
Cheat Sheet
You can take a lot to https://wadcoms.github.io/ to have a quick view of which commands you can run to enumerate/exploit an AD.
Warning
Kerberos communication requires a full qualifid name (FQDN) for performing actions. If you try to access a machine by the IP address, itâll use NTLM and not kerberos.
Recon Active Directory (Geen creds/sessies)
As jy net toegang tot ân AD-omgewing het maar geen credentials/sessies besit nie, kan jy:
- Pentest the network:
- Scan die netwerk, vind masjiene en oop poorte en probeer exploit vulnerabilities of extract credentials vanaf hulle (byvoorbeeld, printers could be very interesting targets).
- DNS-enumerasie kan inligting gee oor sleutelbedienaars in die domein soos web, printers, shares, vpn, media, ens.
gobuster dns -d domain.local -t 25 -w /opt/Seclist/Discovery/DNS/subdomain-top2000.txt- Kyk na die Algemene Pentesting Methodology vir meer inligting oor hoe om dit te doen.
- Check for null and Guest access on smb services (dit werk nie op moderne Windows weergawes nie):
enum4linux -a -u "" -p "" <DC IP> && enum4linux -a -u "guest" -p "" <DC IP>smbmap -u "" -p "" -P 445 -H <DC IP> && smbmap -u "guest" -p "" -P 445 -H <DC IP>smbclient -U '%' -L //<DC IP> && smbclient -U 'guest%' -L //- ân Meer gedetailleerde gids oor hoe om ân SMB-bediener te enumereer is te vinde hier:
- Enumerate Ldap
nmap -n -sV --script "ldap* and not brute" -p 389 <DC IP>- ân Meer gedetailleerde gids oor hoe om LDAP te enumereer is te vinde hier (let spesifiek op die anonymous access):
389, 636, 3268, 3269 - Pentesting LDAP
- Poison the network
- Versamel credentials deur impersonating services with Responder
- Verkry toegang tot ân gasheer deur abusing the relay attack
- Versamel credentials deur exposing fake UPnP services with evil-SSDP
- OSINT:
- Trek gebruikersname/names uit interne dokumente, sosialemedia, dienste (hoofsaaklik web) binne die domeinomgewings en ook vanaf publiek beskikbare bronne.
- As jy die volledige name van maatskappy-werkers vind, kan jy verskillende AD username conventions probeer (read this). Die mees algemene konvensies is: NameSurname, Name.Surname, NamSur (3 letters van elkeen), Nam.Sur, NSurname, N.Surname, SurnameName, Surname.Name, SurnameN, Surname.N, 3 random letters and 3 random numbers (abc123).
- Tools:
- w0Tx/generate-ad-username
- urbanadventurer/username-anarchy
Gebruikerenumerasie
- Anonymous SMB/LDAP enum: Kyk die pentesting SMB en pentesting LDAP bladsye.
- Kerbrute enum: Wanneer ân invalid username is requested sal die bediener reageer met die Kerberos error kode KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN, wat ons toelaat om te bepaal dat die gebruikersnaam ongeldig was. Valid usernames sal Ăłf die TGT in a AS-REP reaksie uitlok, Ăłf die fout KRB5KDC_ERR_PREAUTH_REQUIRED, wat aandui dat die gebruiker vooraf-verifikasie moet doen.
- No Authentication against MS-NRPC: Gebruik auth-level = 1 (No authentication) teen die MS-NRPC (Netlogon) koppelvlak op domain controllers. Die metode roep die
DsrGetDcNameEx2funksie aan nadat die MS-NRPC koppelvlak gebind is om te kontroleer of die gebruiker of rekenaar bestaan sonder enige credentials. Die NauthNRPC tool implementeer hierdie tipe enumerasie. Die navorsing is te vinde here
./kerbrute_linux_amd64 userenum -d lab.ropnop.com --dc 10.10.10.10 usernames.txt #From https://github.com/ropnop/kerbrute/releases
nmap -p 88 --script=krb5-enum-users --script-args="krb5-enum-users.realm='DOMAIN'" <IP>
Nmap -p 88 --script=krb5-enum-users --script-args krb5-enum-users.realm='<domain>',userdb=/root/Desktop/usernames.txt <IP>
msf> use auxiliary/gather/kerberos_enumusers
crackmapexec smb dominio.es -u '' -p '' --users | awk '{print $4}' | uniq
python3 nauth.py -t target -u users_file.txt #From https://github.com/sud0Ru/NauthNRPC
- OWA (Outlook Web Access) Bediener
As jy een van hierdie bedieners in die netwerk vind, kan jy ook user enumeration daarteen uitvoer. Byvoorbeeld, jy kan die hulpmiddel MailSniper:
ipmo C:\Tools\MailSniper\MailSniper.ps1
# Get info about the domain
Invoke-DomainHarvestOWA -ExchHostname [ip]
# Enumerate valid users from a list of potential usernames
Invoke-UsernameHarvestOWA -ExchHostname [ip] -Domain [domain] -UserList .\possible-usernames.txt -OutFile valid.txt
# Password spraying
Invoke-PasswordSprayOWA -ExchHostname [ip] -UserList .\valid.txt -Password Summer2021
# Get addresses list from the compromised mail
Get-GlobalAddressList -ExchHostname [ip] -UserName [domain]\[username] -Password Summer2021 -OutFile gal.txt
Warning
Jy kan lyste van gebruikersname vind in this github repo en in hierdie een (statistically-likely-usernames).
Jy behoort egter die name van die persone wat by die maatskappy werk te hĂȘ vanuit die recon-stap wat jy vooraf moes gedoen het. Met die voor- en vannaam kan jy die script namemash.py gebruik om potensiĂ«le geldige gebruikersname te genereer.
Knowing one or several usernames
Ok, jy weet dus al ân geldige username maar het geen wagwoorde nie⊠Probeer dan:
- ASREPRoast: As ân gebruiker nie die attribuut DONT_REQ_PREAUTH het nie, kan jy ân AS_REP message vir daardie gebruiker versoek wat data sal bevat wat deur ân afleiding van die gebruiker se wagwoord geĂ«nkripteer is.
- Password Spraying: Probeer die mees algemene passwords op elkeen van die ontdekte gebruikers; miskien gebruik iemand ân swak password (hou die password policy in gedagte!).
- Let ook dat jy OWA servers kan spray om toegang tot gebruikers se mail servers te probeer kry.
Password Spraying / Brute Force
LLMNR/NBT-NS Poisoning
Jy kan dalk sekere challenge hashes bekom om te kraak deur sommige protokolle van die netwerk te poison:
Spoofing LLMNR, NBT-NS, mDNS/DNS and WPAD and Relay Attacks
NTLM Relay
As jy daarin geslaag het om die Active Directory te enumeraat, sal jy meer e-posadresse en ân beter begrip van die netwerk hĂȘ. Jy kan dalk NTLM relay attacks afdwing om toegang tot die AD-omgewing te kry.
Steal NTLM Creds
As jy toegang tot ander PCs of shares kan kry met die null of guest user, kan jy lĂȘers plaas (bv. ân SCF-lĂȘer) wat, as dit op ân of ander manier geopen word, ân NTLM authentication teen jou sal trigger sodat jy die NTLM challenge kan steel om dit te kraak:
Enumerating Active Directory WITH credentials/session
Vir hierdie fase moet jy die credentials of ân sessie van ân geldige domain account gekompromiseer hĂȘ. As jy geldige credentials of ân shell as ân domain user het, onthou dat die opsies wat vroeĂ«r genoem is steeds opsies is om ander gebruikers te kompromitteer.
Voordat jy met geauthentiseerde enumerasie begin, moet jy weet wat die Kerberos double hop problem is.
Enumeration
Om ân account te kompromitteer is ân groot stap om die hele domain te begin kompromitteer, want jy sal dan in staat wees om met die Active Directory Enumeration te begin:
Met betrekking tot ASREPRoast kan jy nou elke moontlike kwesbare gebruiker vind, en met betrekking tot Password Spraying kan jy ân lys van al die gebruikersname kry en die password van die gekompromitteerde account, leĂ« wagwoorde en nuwe belowende passwords probeer.
- Jy kan die CMD gebruik vir basiese recon
- Jy kan ook powershell vir recon gebruik wat meer stealthy sal wees
- Jy kan ook use powerview om meer gedetaileerde inligting te onttrek
- Nog ân uitstekende tool vir recon in Active Directory is BloodHound. Dit is nie baie stealthy nie (afhangend van die collection-metodes wat jy gebruik), maar as jy nie omgee nie, behoort jy dit beslis te probeer. Vind waar gebruikers RDP kan, vind paaie na ander groups, ens.
- Ander geoutomatiseerde AD enumeration tools is: AD Explorer, ADRecon, Group3r, PingCastle.
- DNS records of the AD kan interessante inligting bevat.
- ân GUI tool wat jy kan gebruik om die directory te enumeraat is AdExplorer.exe van die SysInternal Suite.
- Jy kan ook die LDAP-databasis deursoek met ldapsearch om na credentials in velde userPassword & unixUserPassword te kyk, of selfs na Description. sien Password in AD User comment on PayloadsAllTheThings vir ander metodes.
- As jy Linux gebruik, kan jy die domain ook enumeraat met pywerview.
- Jy kan ook geoutomatiseerde tools probeer soos:
- tomcarver16/ADSearch
- 61106960/adPEAS
- Extracting all domain users
Dit is baie maklik om al die domain usernames vanaf Windows te kry (net user /domain ,Get-DomainUser of wmic useraccount get name,sid). In Linux kan jy gebruik: GetADUsers.py -all -dc-ip 10.10.10.110 domain.com/username of enum4linux -a -u "user" -p "password" <DC IP>
Selfs al lyk hierdie Enumeration-afdeling klein, dit is die belangrikste deel van alles. Toegang die skakels (hoofsaaklik diĂ© van cmd, powershell, powerview en BloodHound), leer hoe om ân domain te enumeraat en oefen totdat jy gemaklik voel. Tydens ân assessment sal dit die sleutel oomblik wees om jou pad na DA te vind of te besluit dat niks gedoen kan word nie.
Kerberoast
Kerberoasting behels die verkryging van TGS tickets wat deur services wat aan user accounts gekoppel is gebruik word, en die off-line kraak van hul enkripsie â wat gebaseer is op user passwords.
Meer hieroor in:
Remote connexion (RDP, SSH, FTP, Win-RM, etc)
Sodra jy sommige credentials bekom het, kan jy kyk of jy toegang tot enige masjien het. Hiervoor kan jy CrackMapExec gebruik om te probeer koppel op verskeie servers met verskillende protokolle, ooreenkomstig jou port scans.
Local Privilege Escalation
As jy credentials of ân sessie as ân gewone domain user gekompromitteer het en jy het met hierdie user toegang tot enige masjien in die domain, moet jy probeer om plaaslik privileges te eskaleer en na credentials te loot. Dit is omdat slegs met local administrator privileges jy hashes van ander gebruikers in geheue (LSASS) en plaaslik (SAM) kan dump.
Daar is ân volledige bladsy in hierdie boek oor local privilege escalation in Windows en ân checklist. Moet ook nie vergeet om WinPEAS te gebruik nie.
Current Session Tickets
Dit is baie onwaarskynlik dat jy tickets by die huidige user sal vind wat jou toestemming gee om onverwante resources te betree, maar jy kan dit nagaan:
## List all tickets (if not admin, only current user tickets)
.\Rubeus.exe triage
## Dump the interesting one by luid
.\Rubeus.exe dump /service:krbtgt /luid:<luid> /nowrap
[IO.File]::WriteAllBytes("ticket.kirbi", [Convert]::FromBase64String("<BASE64_TICKET>"))
NTLM Relay
As jy daarin slaag om die Active Directory te enumereer sal jy meer e-posse en ân beter begrip van die netwerk hĂȘ. You might be able to to force NTLM relay attacks.
Looks for Creds in Computer Shares | SMB Shares
Nou dat jy ân paar basiese inlogbesonderhede het, moet jy kyk of jy enige interessante lĂȘers wat binne die AD gedeel word kan vind. Jy kan dit handmatig doen, maar dit is ân baie vervelige en herhalende taak (veral as jy honderde dokumente vind wat jy moet nagaan).
Follow this link to learn about tools you could use.
Steal NTLM Creds
As jy toegang tot ander PCs of shares kan kry, kan jy lĂȘers plaas (soos ân SCF file) wat, as dit op eniger tyd geopen word, ân NTLM authentication teen jou sal uitlok sodat jy die NTLM challenge kan steel om dit te kraak:
CVE-2021-1675/CVE-2021-34527 PrintNightmare
Hierdie kwesbaarheid het enige geauthentiseerde gebruiker in staat gestel om die domain controller te kompromitteer.
Privilege escalation on Active Directory WITH privileged credentials/session
Vir die volgende tegnieke is ân gewone domain user nie genoeg nie; jy benodig spesiale voorregte/inlogbesonderhede om hierdie aanvalle uit te voer.
Hash extraction
Hopelik het jy daarin geslaag om ân local admin-rekening te kompromitteer deur gebruik te maak van AsRepRoast, Password Spraying, Kerberoast, Responder insluitend relaying, EvilSSDP, escalating privileges locally.
Dan is dit tyd om al die hashes in geheue en plaaslik uit te trek.
Read this page about different ways to obtain the hashes.
Pass the Hash
Sodra jy die hash van ân gebruiker het, kan jy dit gebruik om die gebruiker te imiteren.
Jy moet ân tool gebruik wat die NTLM authentication met daardie hash sal uitvoer, of jy kan ân nuwe sessionlogon skep en daardie hash in LSASS inject sodat wanneer enige NTLM authentication uitgevoer word, daardie hash gebruik sal word. Die laaste opsie is wat mimikatz doen.
Read this page for more information.
Over Pass the Hash/Pass the Key
Hierdie aanval poog om die gebruikers NTLM hash te gebruik om Kerberos tickets aan te vra, as ân alternatief vir die algemene Pass The Hash oor die NTLM-protokol. Dit kan veral nuttig wees in netwerke waar die NTLM-protokol gedeaktiveer is en slegs Kerberos as authentication protocol toegelaat word.
Over Pass the Hash/Pass the Key
Pass the Ticket
In die Pass The Ticket (PTT) aanvalsmethode steel aanvallers ân gebruiker se authentication ticket in plaas van hul wagwoord of hash-waardes. Hierdie gesteelde ticket word dan gebruik om die gebruiker te imiteren, en sodoende ongemagtigde toegang tot hulpbronne en dienste binne ân netwerk te verkry.
Credentials Reuse
As jy die hash of password van ân local administrator het, moet jy probeer om lokaal aan te meld op ander PCs daarmee.
# Local Auth Spray (once you found some local admin pass or hash)
## --local-auth flag indicate to only try 1 time per machine
crackmapexec smb --local-auth 10.10.10.10/23 -u administrator -H 10298e182387f9cab376ecd08491764a0 | grep +
Warning
Neem asseblief kennis dat dit redelik luidrugtig is en LAPS dit sou versag.
MSSQL Abuse & Trusted Links
Indien ân gebruiker voorregte het om toegang tot MSSQL-instances te hĂȘ, kan hy dit gebruik om opdragte op die MSSQL-gasheer uit te voer (as dit as SA loop), die NetNTLM hash te steel of selfs ân relay attack uit te voer.
Verder, as ân MSSQL-instance deur ân ander MSSQL-instance vertrou word (database link), en die gebruiker voorregte oor die vertroude databasis het, sal hy in staat wees om die vertrouensverhouding te gebruik om ook navrae in die ander instance uit te voer. Hierdie vertroue kan aaneengeskakel word en uiteindelik kan die gebruiker ân verkeerd gekonfigureerde databasis vind waar hy opdragte kan uitvoer.
Die skakels tussen databasisse werk selfs oor forest trusts.
IT asset/deployment platforms abuse
Derdeparty-inventaris- en ontplooiingsuites open dikwels kragtige paaie na credentials en code execution. Sien:
Sccm Management Point Relay Sql Policy Secrets
Unconstrained Delegation
If you find any Computer object with the attribute ADS_UF_TRUSTED_FOR_DELEGATION and you have domain privileges in the computer, you will be able to dump TGTs from memory of every users that logins onto the computer.
So, if a Domain Admin logins onto the computer, you will be able to dump his TGT and impersonate him using Pass the Ticket.
Thanks to constrained delegation you could even automatically compromise a Print Server (hopefully it will be a DC).
Constrained Delegation
If a user or computer is allowed for âConstrained Delegationâ it will be able to impersonate any user to access some services in a computer.
Then, if you compromise the hash of this user/computer you will be able to impersonate any user (even domain admins) to access some services.
Resourced-based Constrain Delegation
Having WRITE privilege on an Active Directory object of a remote computer enables the attainment of code execution with elevated privileges:
Resource-based Constrained Delegation
Permissions/ACLs Abuse
Die gekompromitteerde gebruiker kan moontlik sekere belangrike voorregte oor sommige domain objects hĂȘ wat jou later kan toelaat om lateraal te beweeg of voorregte te escalate.
Abusing Active Directory ACLs/ACEs
Printer Spooler service abuse
Om ân Spool service wat luister binne die domain te ontdek, kan misbruik word om nuwe credentials te bekom en voorregte te eskaleer.
Force NTLM Privileged Authentication
Third party sessions abuse
As ander gebruikers die gekompromitteerde masjien toegang kry, is dit moontlik om credentials uit geheue te versamel en selfs beacons in hul prosesse in te spuit om hulle te impersonate.
Gebruikers kom gewoonlik via RDP op die stelsel, so hier is hoe om ân paar aanvalle oor derdeparty RDP-sessies uit te voer:
LAPS
LAPS verskaf ân stelsel om die lokale Administrator-wagwoord op domain-joined computers te bestuur, wat verseker dat dit gerandomiseer, uniek en gereeld verander word. Hierdie wagwoorde word in Active Directory gestoor en toegang word deur ACLs tot slegs gemagtigde gebruikers beheer. Met genoegsame permisse om hierdie wagwoorde te lees, word pivoting na ander computers moontlik.
Certificate Theft
Die versameling van sertifikate vanaf die gekompromitteerde masjien kan ân manier wees om voorregte binne die omgewing te eskaleer:
Certificate Templates Abuse
Indien kwesbare templates gekonfigureer is, is dit moontlik om dit te misbruik om voorregte te eskaleer:
Post-exploitation with high privilege account
Dumping Domain Credentials
Once you get Domain Admin or even better Enterprise Admin privileges, you can dump the domain database: ntds.dit.
More information about DCSync attack can be found here.
More information about how to steal the NTDS.dit can be found here
Privesc as Persistence
Some of the techniques discussed before can be used for persistence.
For example you could:
- Make users vulnerable to Kerberoast
Set-DomainObject -Identity <username> -Set @{serviceprincipalname="fake/NOTHING"}r
- Make users vulnerable to ASREPRoast
Set-DomainObject -Identity <username> -XOR @{UserAccountControl=4194304}
- Grant DCSync privileges to a user
Add-DomainObjectAcl -TargetIdentity "DC=SUB,DC=DOMAIN,DC=LOCAL" -PrincipalIdentity bfarmer -Rights DCSync
Silver Ticket
The Silver Ticket attack creates a legitimate Ticket Granting Service (TGS) ticket for a specific service by using the NTLM hash (for instance, the hash of the PC account). This method is employed to access the service privileges.
Golden Ticket
A Golden Ticket attack involves an attacker gaining access to the NTLM hash of the krbtgt account in an Active Directory (AD) environment. This account is special because itâs used to sign all Ticket Granting Tickets (TGTs), which are essential for authenticating within the AD network.
Once the attacker obtains this hash, they can create TGTs for any account they choose (Silver ticket attack).
Diamond Ticket
These are like golden tickets forged in a way that bypasses common golden tickets detection mechanisms.
Certificates Account Persistence
Having certificates of an account or being able to request them is a very good way to be able to persist in the users account (even if he changes the password):
Certificates Domain Persistence
Using certificates is also possible to persist with high privileges inside the domain:
AdminSDHolder Group
Die AdminSDHolder-voorwerp in Active Directory verseker die sekuriteit van bevoorregte groepe (soos Domain Admins en Enterprise Admins) deur ân standaard Access Control List (ACL) oor hierdie groepe toe te pas om ongemagtigde veranderinge te voorkom. Hierdie funksie kan egter misbruik word; as ân aanvaller die AdminSDHolder se ACL wysig om volle toegang aan ân gewone gebruiker te gee, kry daardie gebruiker uitgebreide beheer oor alle bevoorregte groepe. Hierdie sekuriteitsmaatreĂ«l, bedoel om te beskerm, kan dus omgedraai word en ongerechtigde toegang moontlik maak tensy dit noukeurig gemonitor word.
More information about AdminDSHolder Group here.
DSRM Credentials
Inside every Domain Controller (DC), a local administrator account exists. By obtaining admin rights on such a machine, the local Administrator hash can be extracted using mimikatz. Following this, a registry modification is necessary to enable the use of this password, allowing for remote access to the local Administrator account.
ACL Persistence
You could give some special permissions to a user over some specific domain objects that will let the user escalate privileges in the future.
Abusing Active Directory ACLs/ACEs
Security Descriptors
Die security descriptors word gebruik om die permisse wat ân object oor ân object het te stoor. As jy net ân klein verandering in die security descriptor van ân voorwerp kan maak, kan jy baie interessante voorregte oor daardie voorwerp verkry sonder om lid van ân bevoorregte groep te wees.
Skeleton Key
Alter LSASS in memory to establish a universal password, granting access to all domain accounts.
Custom SSP
Learn what is a SSP (Security Support Provider) here.
You can create you own SSP to capture in clear text the credentials used to access the machine.
DCShadow
It registers a new Domain Controller in the AD and uses it to push attributes (SIDHistory, SPNsâŠ) on specified objects without leaving any logs regarding the modifications. You need DA privileges and be inside the root domain.
Note that if you use wrong data, pretty ugly logs will appear.
LAPS Persistence
Previously we have discussed about how to escalate privileges if you have enough permission to read LAPS passwords. However, these passwords can also be used to maintain persistence.
Check:
Forest Privilege Escalation - Domain Trusts
Microsoft views the Forest as the security boundary. This implies that compromising a single domain could potentially lead to the entire Forest being compromised.
Basic Information
A domain trust is a security mechanism that enables a user from one domain to access resources in another domain. It essentially creates a linkage between the authentication systems of the two domains, allowing authentication verifications to flow seamlessly. When domains set up a trust, they exchange and retain specific keys within their Domain Controllers (DCs), which are crucial to the trustâs integrity.
In a typical scenario, if a user intends to access a service in a trusted domain, they must first request a special ticket known as an inter-realm TGT from their own domainâs DC. This TGT is encrypted with a shared key that both domains have agreed upon. The user then presents this TGT to the DC of the trusted domain to get a service ticket (TGS). Upon successful validation of the inter-realm TGT by the trusted domainâs DC, it issues a TGS, granting the user access to the service.
Steps:
- A client computer in Domain 1 starts the process by using its NTLM hash to request a Ticket Granting Ticket (TGT) from its Domain Controller (DC1).
- DC1 issues a new TGT if the client is authenticated successfully.
- The client then requests an inter-realm TGT from DC1, which is needed to access resources in Domain 2.
- The inter-realm TGT is encrypted with a trust key shared between DC1 and DC2 as part of the two-way domain trust.
- The client takes the inter-realm TGT to Domain 2âs Domain Controller (DC2).
- DC2 verifies the inter-realm TGT using its shared trust key and, if valid, issues a Ticket Granting Service (TGS) for the server in Domain 2 the client wants to access.
- Finally, the client presents this TGS to the server, which is encrypted with the serverâs account hash, to get access to the service in Domain 2.
Different trusts
Itâs important to notice that a trust can be 1 way or 2 ways. In the 2 ways options, both domains will trust each other, but in the 1 way trust relation one of the domains will be the trusted and the other the trusting domain. In the last case, you will only be able to access resources inside the trusting domain from the trusted one.
If Domain A trusts Domain B, A is the trusting domain and B ins the trusted one. Moreover, in Domain A, this would be an Outbound trust; and in Domain B, this would be an Inbound trust.
Different trusting relationships
- Parent-Child Trusts: This is a common setup within the same forest, where a child domain automatically has a two-way transitive trust with its parent domain. Essentially, this means that authentication requests can flow seamlessly between the parent and the child.
- Cross-link Trusts: Referred to as âshortcut trusts,â these are established between child domains to expedite referral processes. In complex forests, authentication referrals typically have to travel up to the forest root and then down to the target domain. By creating cross-links, the journey is shortened, which is especially beneficial in geographically dispersed environments.
- External Trusts: These are set up between different, unrelated domains and are non-transitive by nature. According to Microsoftâs documentation, external trusts are useful for accessing resources in a domain outside of the current forest that isnât connected by a forest trust. Security is bolstered through SID filtering with external trusts.
- Tree-root Trusts: These trusts are automatically established between the forest root domain and a newly added tree root. While not commonly encountered, tree-root trusts are important for adding new domain trees to a forest, enabling them to maintain a unique domain name and ensuring two-way transitivity. More information can be found in Microsoftâs guide.
- Forest Trusts: This type of trust is a two-way transitive trust between two forest root domains, also enforcing SID filtering to enhance security measures.
- MIT Trusts: These trusts are established with non-Windows, RFC4120-compliant Kerberos domains. MIT trusts are a bit more specialized and cater to environments requiring integration with Kerberos-based systems outside the Windows ecosystem.
Other differences in trusting relationships
- A trust relationship can also be transitive (A trust B, B trust C, then A trust C) or non-transitive.
- A trust relationship can be set up as bidirectional trust (both trust each other) or as one-way trust (only one of them trust the other).
Attack Path
- Enumerate the trusting relationships
- Check if any security principal (user/group/computer) has access to resources of the other domain, maybe by ACE entries or by being in groups of the other domain. Look for relationships across domains (the trust was created for this probably).
- kerberoast in this case could be another option.
- Compromise the accounts which can pivot through domains.
Attackers with could access to resources in another domain through three primary mechanisms:
- Local Group Membership: Principals might be added to local groups on machines, such as the âAdministratorsâ group on a server, granting them significant control over that machine.
- Foreign Domain Group Membership: Principals can also be members of groups within the foreign domain. However, the effectiveness of this method depends on the nature of the trust and the scope of the group.
- Access Control Lists (ACLs): Principals might be specified in an ACL, particularly as entities in ACEs within a DACL, providing them access to specific resources. For those looking to dive deeper into the mechanics of ACLs, DACLs, and ACEs, the whitepaper titled âAn ACE Up The Sleeveâ is an invaluable resource.
Find external users/groups with permissions
You can check CN=<user_SID>,CN=ForeignSecurityPrincipals,DC=domain,DC=com to find foreign security principals in the domain. These will be user/group from an external domain/forest.
You could check this in Bloodhound or using powerview:
# Get users that are i groups outside of the current domain
Get-DomainForeignUser
# Get groups inside a domain with users our
Get-DomainForeignGroupMember
Child-to-Parent forest privilege escalation
# Fro powerview
Get-DomainTrust
SourceName : sub.domain.local --> current domain
TargetName : domain.local --> foreign domain
TrustType : WINDOWS_ACTIVE_DIRECTORY
TrustAttributes : WITHIN_FOREST --> WITHIN_FOREST: Both in the same forest
TrustDirection : Bidirectional --> Trust direction (2ways in this case)
WhenCreated : 2/19/2021 1:28:00 PM
WhenChanged : 2/19/2021 1:28:00 PM
Ander maniere om enumerate domain trusts:
# Get DCs
nltest /dsgetdc:<DOMAIN>
# Get all domain trusts
nltest /domain_trusts /all_trusts /v
# Get all trust of a domain
nltest /dclist:sub.domain.local
nltest /server:dc.sub.domain.local /domain_trusts /all_trusts
Warning
Daar is 2 vertroude sleutels, een vir Child â> Parent en ân ander vir Parent â> Child.
Jy kan die een wat deur die huidige domein gebruik word sien met:Invoke-Mimikatz -Command '"lsadump::trust /patch"' -ComputerName dc.my.domain.local Invoke-Mimikatz -Command '"lsadump::dcsync /user:dcorp\mcorp$"'
SID-History Injection
Escaleer as Enterprise admin na die child/parent-domein deur die trust te misbruik met SID-History injection:
Exploit writeable Configuration NC
Dit is noodsaaklik om te verstaan hoe die Configuration Naming Context (NC) misbruik kan word. Die Configuration NC dien as ân sentrale bewaarplek vir konfigurasiedata oor ân forest in Active Directory (AD)-omgewings. Hierdie data word na elke Domain Controller (DC) in die forest gerepliseer, en skryfbare DCs hou ân skryfbare kopie van die Configuration NC. Om dit te misbruik, moet mens SYSTEM privileges op ân DC hĂȘ, by voorkeur ân child DC.
Link GPO to root DC site
Die Sites-container van die Configuration NC bevat inligting oor die sites van alle domein-aangeslote rekenaars binne die AD-forest. Deur met SYSTEM-privileges op enige DC te werk, kan aanvalleerders GPOs aan die root DC-sites koppel. Hierdie aksie kan die root-domein moontlik kompromitteer deur die beleid wat op hierdie sites toegepas word te manipuleer.
For in-depth information, one might explore research on Bypassing SID Filtering.
Compromise any gMSA in the forest
ân Aanvalsvektor behels die teiken van bevoorregte gMSAs binne die domein. Die KDS Root key, noodsaaklik vir die berekening van gMSA-wagwoorde, is gestoor in die Configuration NC. Met SYSTEM-privileges op enige DC is dit moontlik om by die KDS Root key te kom en die wagwoorde van enige gMSA oor die hele forest te bereken.
Gedetaileerde ontleding en stap-vir-stap leiding kan gevind word in:
Aanvullende gedelegeerde MSA-aanval (BadSuccessor â misbruik van migrasie-attribuutte):
Badsuccessor Dmsa Migration Abuse
Bykomende eksterne navorsing: Golden gMSA Trust Attacks.
Schema change attack
Hierdie metode vereis geduld â wag vir die skepping van nuwe bevoorregte AD-objekte. Met SYSTEM-privileges kan ân aanvaller die AD Schema wysig om enige gebruiker volledige beheer oor alle klasse te gee. Dit kan lei tot ongemagtigde toegang en beheer oor nuut geskepte AD-objekte.
More information is available on Schema Change Trust Attacks.
From DA to EA with ADCS ESC5
Die ADCS ESC5 kwesbaarheid mik op beheer oor Public Key Infrastructure (PKI)-objekte om ân sertifikaattemplate te skep wat verifikasie as enige gebruiker binne die forest moontlik maak. Omdat PKI-objekte in die Configuration NC woon, maak die kompromittering van ân skryfbare child DC die uitvoering van ESC5-aanvalle moontlik.
More details on this can be read in From DA to EA with ESC5. In scenarios lacking ADCS, the attacker has the capability to set up the necessary components, as discussed in Escalating from Child Domain Admins to Enterprise Admins.
External Forest Domain - One-Way (Inbound) or bidirectional
Get-DomainTrust
SourceName : a.domain.local --> Current domain
TargetName : domain.external --> Destination domain
TrustType : WINDOWS-ACTIVE_DIRECTORY
TrustAttributes :
TrustDirection : Inbound --> Inboud trust
WhenCreated : 2/19/2021 10:50:56 PM
WhenChanged : 2/19/2021 10:50:56 PM
In hierdie scenario jou domein word vertrou deur ân eksterne een wat jou onbepaalde permissies daaroor gee. Jy sal moet uitvind watter principals van jou domein watter toegang tot die eksterne domein het en dit dan probeer uitbuit:
External Forest Domain - OneWay (Inbound) or bidirectional
Eksterne Forest-domein - Eenrigting (Uitgaand)
Get-DomainTrust -Domain current.local
SourceName : current.local --> Current domain
TargetName : external.local --> Destination domain
TrustType : WINDOWS_ACTIVE_DIRECTORY
TrustAttributes : FOREST_TRANSITIVE
TrustDirection : Outbound --> Outbound trust
WhenCreated : 2/19/2021 10:15:24 PM
WhenChanged : 2/19/2021 10:15:24 PM
In hierdie scenario jou domein vertrou sekere voorregte aan ân prinsipaal van ân ander domein.
Echter, wanneer ân domein vertrou word deur die vertroulike domein, skep die vertroude domein ân gebruiker met ân voorspelbare naam wat as wagwoord die vertroude wagwoord gebruik. Dit beteken dat dit moontlik is om ân gebruiker van die vertroulike domein te gebruik om toegang tot die vertroude domein te kry om dit te enumereer en te probeer om meer voorregte te eskaleer:
External Forest Domain - One-Way (Outbound)
Nog ân manier om die vertroude domein te kompromitteer is om ân SQL trusted link te vind wat in die teenoorgestelde rigting van die domeinvertroue geskep is (wat nie baie algemeen is nie).
Nog ân manier om die vertroude domein te kompromitteer is om in ân masjien te wag waar ân gebruiker van die vertroude domein toegang kan kry deur te konnekteer via RDP. Die aanvaller kan dan kode in die RDP-sessieproses inject en toegang tot die oorspronklike domein van die slachtoffer van daar af kry.
Bo en behalwe, as die slachtoffer sy hardeskyf gemonteer het, kan die aanvaller vanuit die RDP-sessie proses backdoors in die opstartmap van die hardeskyf stoor. Hierdie tegniek word RDPInception genoem.
Mitigasie van domeinvertrouensmisbruik
SID Filtering:
- Die risiko van aanvalle wat die SID history attribuut oor forest trusts uitbuit, word verminder deur SID Filtering, wat standaard geaktiveer is op alle inter-forest trusts. Dit berus op die aanname dat intra-forest trusts veilig is, en beskou die forest eerder as die sekuriteitsgrens as die domein, volgens Microsoft se standpunt.
- Daar is egter ân vangst: SID filtering kan toepassings en gebruikers toegang ontwrig, wat soms tot die deaktivering daarvan lei.
Selective Authentication:
- Vir inter-forest trusts verseker die gebruik van Selective Authentication dat gebruikers van die twee forests nie outomaties geauthentikeer word nie. In plaas daarvan is eksplisiete toestemmings nodig sodat gebruikers toegang tot domeine en bedieners binne die vertroulike domein of forest kan kry.
- Dit is belangrik om te let dat hierdie maatreëls nie beskerming bied teen die uitbuiting van die writable Configuration Naming Context (NC) of aanvalle op die trust account nie.
More information about domain trusts in ired.team.
LDAP-gebaseerde AD-misbruik vanaf On-Host Implants
The LDAP BOF Collection herimplementeer bloodyAD-styl LDAP-primitiwiteite as x64 Beacon Object Files wat heeltemal binne ân on-host implant (bv. Adaptix C2) loop. Operateurs kompileer die pakket met git clone https://github.com/P0142/ldap-bof-collection.git && cd ldap-bof-collection && make, laai ldap.axs, en roep dan ldap <subcommand> vanaf die beacon aan. Alle verkeer gebruik die huidige aanmeldsekuriteitskonteks oor LDAP (389) met signing/sealing of LDAPS (636) met outo sertifikaatvertroue, sodat geen socks-proxies of skyfartefakte benodig word nie.
Implant-kant LDAP-enumerasie
get-users,get-computers,get-groups,get-usergroups, andget-groupmemberslos kort name/OU-paaie op na volle DNs en dump die ooreenstemmende objekte.get-object,get-attribute, andget-domaininfotrek arbitrĂȘre attribuutte (insluitend security descriptors) asook die forest/domain metadata vanafrootDSE.get-uac,get-spn,get-delegation, andget-rbcdblootlĂȘ roasting candidates, delegation settings, en bestaande Resource-based Constrained Delegation descriptors direk vanaf LDAP.get-aclandget-writable --detailedontleed die DACL om trustees, regte (GenericAll/WriteDACL/WriteOwner/attribute writes), en erfenis te lys, wat onmiddellike teikens vir ACL privilege-escalasie gee.
ldap get-users --ldaps
ldap get-computers -ou "OU=Servers,DC=corp,DC=local"
ldap get-writable --detailed
ldap get-acl "CN=Tier0,OU=Admins,DC=corp,DC=local"
LDAP write primitives for escalation & persistence
- Object creation BOFs (
add-user,add-computer,add-group,add-ou) maak dit vir die operateur moontlik om nuwe principals of machine accounts te stage waar OU-regte bestaan.add-groupmember,set-password,add-attribute, enset-attributehijack targets direk sodra write-property-regte gevind word. - ACL-focused commands soos
add-ace,set-owner,add-genericall,add-genericwrite, enadd-dcsyncvertaal WriteDACL/WriteOwner op enige AD-object in wagwoordresets, groepledebeheer, of DCSync-repliseringsprivilegies sonder om PowerShell/ADSI-artifakte te laat.remove-*teenhangers ruim ingespuite ACEs op.
Delegation, roasting, and Kerberos abuse
add-spn/set-spnmaak ân gekompromitteerde gebruiker onmiddellik Kerberoastable;add-asreproastable(UAC toggle) merk dit vir AS-REP roasting sonder om die wagwoord aan te raak.- Delegation macros (
add-delegation,set-delegation,add-constrained,add-unconstrained,add-rbcd) skryfmsDS-AllowedToDelegateTo, UAC flags, ofmsDS-AllowedToActOnBehalfOfOtherIdentityvan die beacon oor, wat constrained/unconstrained/RBCD-aanvalsweë moontlik maak en die behoefte aan remote PowerShell of RSAT uitvee.
sidHistory injection, OU relocation, and attack surface shaping
add-sidhistoryinjects privileged SIDs in ân beheerde principal se SID history (sien SID-History Injection), wat stilweg toegangserwing oor LDAP/LDAPS verskaf.move-objectverander die DN/OU van rekenaars of gebruikers, wat ân aanvaller toelaat om bates na OUs te trek waar gedelegeerde regte reeds bestaan voordat hulleset-password,add-groupmember, ofadd-spnmisbruik.- Nougespekteerde verwyderingskommandoâs (
remove-attribute,remove-delegation,remove-rbcd,remove-uac,remove-groupmember, ens.) laat vinnige rollback toe nadat die operateur kredensiële of persistentie verwerf het, en minimaliseer telemetry.
AD -> Azure & Azure -> AD
Page not found - HackTricks Cloud
Some General Defenses
Leer meer oor hoe om credentials te beskerm hier.
Defensive Measures for Credential Protection
- Domain Admins Restrictions: Dit word aanbeveel dat Domain Admins slegs toegelaat word om by Domain Controllers aan te meld en dat hul gebruik op ander hosts vermy word.
- Service Account Privileges: Dienste moet nie met Domain Admin (DA) bevoegdhede uitgevoer word nie om sekuriteit te handhaaf.
- Temporal Privilege Limitation: Vir take wat DA-bevoegdhede vereis, moet die duur daarvan beperk word. Dit kan bereik word met:
Add-ADGroupMember -Identity âDomain Adminsâ -Members newDA -MemberTimeToLive (New-TimeSpan -Minutes 20)
Implementing Deception Techniques
- Implementering van misleiding behels die opstel van lokvalle, soos lokgebruikers of lokrekenaars, met eienskappe soos wagwoorde wat nooit verstryk nie of gemerk as Trusted for Delegation. ân Gedetaileerde benadering sluit in die skep van gebruikers met spesifieke regte of die toevoeging daarvan aan hoĂ«-privilegie groepe.
- ân Praktiese voorbeeld behels die gebruik van gereedskap soos:
Create-DecoyUser -UserFirstName user -UserLastName manager-uncommon -Password Pass@123 | DeployUserDeception -UserFlag PasswordNeverExpires -GUID d07da11f-8a3d-42b6-b0aa-76c962be719a -Verbose - Meer oor die ontplooiing van misleidingstegnieke is beskikbaar by Deploy-Deception on GitHub.
Identifying Deception
- For User Objects: Verdagte aanduidings sluit in atypiese ObjectSID, seldsame aanmeldings, skeppingsdatums, en lae bad password counts.
- General Indicators: Die vergelyking van attribuutâwaardes van potensiĂ«le lokobjekte met diĂ© van egte objekke kan inkonsekwenthede openbaar. Gereedskap soos HoneypotBuster kan help om sulke misleiding te identifiseer.
Bypassing Detection Systems
- Microsoft ATA Detection Bypass:
- User Enumeration: Vermy sessie-enumerasie op Domain Controllers om ATA-detectie te voorkom.
- Ticket Impersonation: Die gebruik van aes sleutels vir ticket-skepping help om opsporing te ontduik deur nie te downgrade na NTLM nie.
- DCSync Attacks: Dit word aanbeveel om vanaf ân nieâDomain Controller uit te voer om ATA-detectie te vermy, aangesien direkte uitvoering vanaf ân Domain Controller waarskuwings sal veroorsaak.
Verwysings
- http://www.harmj0y.net/blog/redteaming/a-guide-to-attacking-domain-trusts/
- https://www.labofapenetrationtester.com/2018/10/deploy-deception.html
- https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/child-domain-da-to-ea-in-parent-domain
- LDAP BOF Collection â In-Memory LDAP Toolkit for Active Directory Exploitation
Tip
Leer en oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer en oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer en oefen Azure Hacking:
HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subskripsie planne!
- Sluit aan by die đŹ Discord groep of die telegram groep of volg ons op Twitter đŠ @hacktricks_live.
- Deel hacking truuks deur PRs in te dien na die HackTricks en HackTricks Cloud github repos.
HackTricks

