Showing posts with label ADsec. Show all posts
Showing posts with label ADsec. Show all posts

Sep 18, 2022

Attack Tools Collection

Here is a list of attacking tools collected recently.

AutoDeAuth - A tool built to automatically deauth local networks.

Aced - A tool to parse and resolve a single targeted Active Directory principal's DACL. will identify interesting inbound access allowed privileges against the targeted account, resolve the SIDS of the inbound permissions, and present that data to the operator. Additionally, the logging features of pyldapsearch have been integrated with Aced to log the targeted principal's LDAP attributes locally which can then be parsed by pyldapsearch's companion tool BOFHound to ingest the collected data into BloodHound.

Aura - A Python Source Code Auditing And Static Analysis On A Large Scale. It is a static analysis framework developed as a response to the ever-increasing threat of malicious packages and vulnerable code published on PyPI.

Coercer - A Python Script To Automatically Coerce A Windows Server To Authenticate On An Arbitrary Machine Through 9 Methods.

GraphCrawler - GraphQL Automated Security Testing Toolkit. It is the most powerful automated testing toolkit for any GraphQL endpoint. (Req: Python3, Docker Python dependencies)

pycvss3 - Python API for the CVSS v3.

Aug 24, 2022

Compare AD to AAD

Azure Active Directory (AAD) is the next evolution of identity and access management (IAM) solutions for the cloud. Microsoft introduced Active Directory (AD) Domain Services in Windows 2000 to give organizations the ability to manage multiple on-premises infrastructure components and systems.

Azure AD takes this approach to the next level by providing organizations with an Identity as a Service (IDaaS) solution for all their apps across cloud and on-premises.

Most IT administrators are familiar with Active Directory Domain Services concepts. The following table outlines the differences and similarities between Active Directory concepts and Azure Active Directory.

 

Links:


Jul 18, 2022

AD and Kerberos PenTest

Here, I keep the notes on the commands and tools/scripts used for pentest on AD and Kerberos.  

 

Reconnaissance Commands:

c:\> net user

c:\> whoami

c:\> whoami /groups

c:\> net user /domain

c:\> net user [username] domain

Brute Force Active Directory:

msf > use auxiliary/scanner/smb/smb_login

mimikatz # lsadump::dcsync /domain:pentestlab.local /all /csv

 

Kerberos brute-force:

  1. kerbrute - Linux tool
  2. Rubeus - Windows module

ASREPRoast and Kerberoasting

  1. GetNPUsers.py
  2. Rubeus

Cracking the AS_REP and TGS

  1. Hashcat
  2. John

Overpass The Hash/Pass The Key (PTK)

  1. getTGT.py
  2. Rubeus and PsExec

 Pass The Ticket (PTT)

  1.  tickey
  2. Mimikatz or Rubeus

Silver ticket and Golden ticket:

  1. ticketer.py
  2. Mimikatz, Rubeus and PsExec

 

Links:

Jun 22, 2022

New Attack Vector PetitPotam

Still remember PetitPotam attack?

PetitPotam is an NTLM Relay Attack tracked as CVE-2021-36942 that French security researcher GILLES Lionel discovered, aka Topotam, in July 2021. 

It is an NTLM Relay attack that allows threat actors to force devices, even domain controllers, to authenticate against malicious servers they control. Once a device authenticates, the malicious server can impersonate the device and gain all of its privileges.

The PetitPotam attack allowed unauthenticated users to use the EfsRpcOpenFileRaw function of the MS-EFSRPC API to force a device to perform NTLM authentication against attacker-controlled servers.

In 2022 (Jan ~ Mar), a security researcher, Raphael John, says that he discovered that PetitPotam was still working when conducting pentests. However, when he disclosed it to Microsoft, they fixed it under a new CVE rather than the original one assigned to PetitPotam.

A PoC tool, from Topotam, to coerce Windows hosts to authenticate to other machines via MS-EFSRPC EfsRpcOpenFileRaw. 

The tool uses the LSARPC named pipe with inteface c681d488-d850-11d0-8c52-00c04fd90f7e because it's more prevalent. But it's possible to trigger with the EFSRPC named pipe and interface df1941c5-fe89-4e79-bf10-463657acf44d. It doesn't need credentials against Domain Controller. And disabling the EFS service seems not to mitigate the "feature".

 

During the May 2022 Patch Tuesday, Microsoft released a security update for an actively exploited NTLM Relay Attack labeled as a 'Windows LSA Spoofing Vulnerability' and tracked as CVE-2022-26925.

In June 2022, a new DFSCoerce Windows NTLM relay attack has been discovered that uses MS-DFSNM, Microsoft's Distributed File System, to completely take over a Windows domain.

A security researcher, Filip Dragovic, released a proof-of-concept script for a new NTLM relay attack called 'DFSCoerce' that uses Microsoft's Distributed File System (MS-DFSNM) protocol to relay authentication against an arbitrary server.

The DFSCoerce script is based on the PetitPotam exploit, but instead of using MS-EFSRPC, it uses MS-DFSNM, a protocol that allows the Windows Distributed File System (DFS) to be managed over an RPC interface.

To coerce a remote server to authenticate against a malicious NTLM relay, threat actors could use various methods, including the MS-RPRN, MS-EFSRPC (PetitPotam), and MS-FSRVP protocols.

These mitigations include disabling NTLM on domain controllers, disabling web services on Active Directory Certificate Services servers, and enabling Extended Protection for Authentication and signing features, such as SMB signing, to protect Windows credentials.


Links:

Jan 15, 2022

noPac Vulnerabilty for DC

Finally noPac exploit is confirmed and released. As mentioned in last month post, these 2 vulnerabilities (cve-2021-42278 and cve-2021-42287) effectively allow a regular domain user to take control of a domain controller. This is a serious concern as the exploit was confirmed as a low-effort exploit with critical impact.

Gaining domain privileges allows threat actors to gain control over a domain and use it as a starting point to deploy malware, including ransomware.


Immediate Actions:

Make sure all the domain controllers (DC) are patched and make no exception. The whole domain remains vulnerable even with one DC remain not patched successfully. The patch is available since Nov 2021.

Also do start with any detection and apply mitigation in my previous post.


Links:

Jan 9, 2022

Active Directory Security Assessment with PowerShell

Krishna has a security assessment script that pulls important security facts from Active Directory and generates nicely viewable reports in HTML format by highlighting the spots that require attention. 

The powershell script covers:

  • User account issues and Inactive accounts
  • Users with ReversibleEncryptionPasswordArray
  • Use Kerberos DES encryption types for this account
  • Do not require Kerberos pre-authentication
  • Review the domain password policy
  • Tombstone lifetime and backups
  • Unconstrained Kerberos delegation
  • Scan SYSVOL for Group Policy Preference passwords
  • Review KRBTGT account information
  • Audit privileged AD groups

Security assessment helps to identify settings that do not meet the security standards. And remediation guidelines and best practices can be defined based on the assessment outcome.

 

Links:

Dec 23, 2021

Weaponise Exploits for samAccountName Spoofing (CVE-2021–42278) & Domain Controller Impersonation (CVE-2021–42287)

Exploit to impersonate from regular domain user released!

Microsoft released patches to address two (2) vulnerabilities that affect Windows Active Directory domain controllers: samAccountName Spoofing and Domain Controller Impersonation in November 2021. 

Both vulnerabilities, samAccountName Spoofing (CVE-2021–42278) & Domain Controller Impersonation (CVE-2021–42287), allow an adversary with access to low-privileged domain user credentials, to obtain a Kerberos Service Ticket for Domain Controller computer account. This will effectively allows a regular domain user to take control of a domain controller.

Mitigation / Detection

It is recommended to install the Microsoft patch (KB5008602) to mitigate against this attack. This patch fixes the issue with PAC confusion and S4U2self created earlier.

Another way is, setting the Machine Account Quota to 0 is also a quick fix for stopping low privileged user from being able to create machine accounts. Other than that, removing Authenticated Users from SeMachineAccountPrivilege and adding Domain Admins or another group of allowed accounts.

Links:


Dec 15, 2021

NEW Native Azure AD KERBEROS!!!

This is a short demo on showing Azure AD is supporting native Kerberos now. 


Command lines:

  1. dsregcmd /status
  2. klist 
  3. klist purge
  4. klist get krbtgt

 

Dec 14, 2021

Picking which Azure AD Synchronization Technology!

This is a short video to show you the difference between the 2 Azure AD sync technologies:  AAD Connect vs Cloud Sync.


Notes - 3 rules:

  1. AAD Connect instance sync to a single AAD instance
  2. AAD instance only sync with single AAD Connect instance
  3. An object can only replicate by one sync instace

 

Links:

Nov 25, 2021

Guide and Tools for AD Kill Chain Attack & Defense

Tushar is kind enough to compile a complete guide and tools for Active Directory kill chain attack and defense. 

It covers the tactics, techniques, and procedures (TTPs) attackers are leveraging to compromise AD and guidance to mitigation, detection, and prevention. 

  1. Discovery
  2. Privilege Escalation
  3. Domain Trusts
  4. Lateral Movement
  5. Defense Evasion
  6. OpSec
  7. Credential Dumping
  8. Persistence
  9. Tools, Scripts, eBooks, Cheatsheets
  10. Defense and Detection
  11. Active Directory Security Checks

Links:

Nov 3, 2021

Hunting backdoors in Active Directory Environment

 

 Notes:

  • Abusing AD permissions for standard user.
    • DS Replication permissions (DC Sync attack)
      • DS-Replication-Get-Changes
      • DS-Replication-Get-Changes-All
      • Alows a principal to retrieve NT hashes remotely via the MS-DRSR protocol for any security principal (krbgt a/c or domain admin)
      • Detection: event ID 4662
      • Hunting: DS Replication permission
    • Send as Permission
      • Can be configured in AD or Exchange Admin Center
      • Detection: Event ID 1
      • Hunting: SendAs permission
    • Commonly targeted AD permission
      • GenericAll, Generic Write, WriteDACL, WiteOwner, User Force change password
    • Valuable AD attributes
      • ms-mcs-admpwd, msDS-Key-CredentialLink, msDS-AllowedToActOnBehalfOfOtheridentity
  • Added backdoor to access to ADFS Token Signing Certificate (TSC)
    • Golden SAML token attack
      • Bypass MFA and access cloud services
      • considered the bedrock of security 
      • ADFS service account and local administrators can access the container
      • Hunting: review authentication policy for backdoor access to Token Signing Certificate
  • Admin SD Holder and SDProp
    • Hunting: review DACL templates of AdminSD Holder container
    • Detection: directory service access event ID 4662
  • Credential harvesting via AAD with PTA agent 
    • PTA - pass thru authentication
    • Hunting: suspicious DLL at PTA agent
    • Detection: PTA spy
  • Machine$ Account
    • Steal hash and create silver ticket.
    • password rotated every 30 days
    • Hunting: suspicious registry value (MaximumPasswordAge)
    • Detection: un-approved changes
  • Creating malicious GPO
    • delegation right to edit GPO
    • push ransomware via logon script
    • schedule malicious task
    • enable weak LANMAN hash authentication
    • create restricted group
    • Hunting: review GPOPermissions and the DACL for sysvol folder
    • Detection: event ID 5136, 5137

 Links:

  •  https://www.youtube.com/watch?v=xeCCYmE4bZM

Oct 26, 2021

Active Directory Penetration Testing Checklist

A short article that show Active Directory Penetration Testing, including reconnaissance commands and brute force Active Directory.

Links:

  • https://gbhackers.com/active-directory-penetration-testing-checklist/
  • https://github.com/sense-of-security/ADRecon

Aug 2, 2021

AD Security Administration Best Practices

Secure AD Administration

  • Separate accounts for each administrative tier
    • Tier 2: workstations
    • Tier 1: servers
    • Tier 0: AD/DC, PKI, ADFS, AAD connect, etc.
  • AD admins only use admin workstations
  • AD admins only logon to admin servers/DC
  • Block AD admin groups from logging on to workstations & servers via Group Policy
  • Limit DC management protocols (RDP, WMI, WinRM) to AD admin systems/subnets
  • Limit service accounts with privileged AD rights

Secure AD Admin OU

  • Create a new top-level OU in the domain
    • Eg.: Management, AD Management, Administrative, etc
  • Modify security so Authenticated Users don't have view access
    • Remove Authenticated Users from OU permissions.
  • Block GPO Inheritance. Create, apply & link Admin OU specifics GPOs.
  • Create child OUs
    • Admin Servers
    • Admin Workstations
    • Admin Accounts
    • Admin Groups
  •  Place all AD Admin related objects (users/groups) in this OU structure
  • Only AD Admin have:
    • Modify rights to this OU structure
    • Modify/Owner rights to GPOs linked to this OU

 Securing AD: Level 1

  • Randomize computer local Administrator account passwords. (MS LAPS)
  • Minimize groups/users with DC admin/logon scripts.
  • Separate user and admin accounts
  • No user accounts in admin groups
  • Admin accounts = "sensitive and cannot be delegated"
  • All AD Admin accounts added to "Protected Users" group
  • Long and complex (> 25 characters) passwords for SA
  • Set GPO to prevent local accounts from connecting over network to computers.

 Securing AD: Level 2

  • Service Accounts (SA):
    • Leverage "(Group) Managed Service Accounts"
    • Implement Fine-Grained Password Policies (DFL > 2008)
    • Limit SA to systems of the same security tier, not shared between workstations and servers.
    • Ensure passwords are >25 char
  • Ensure all computers are talking NTLMv2 & Kerberos, deny LM/NTLMv1
  • Disable SMBv1
  • Separate Admin workstations for administrators (locked-down and no Internet)
  • No Domain Admin service account on non-DCs
  • Limit management protocol access on DC to admin subnets
    • RDP, WMI, WinRM, etc.

Securing AD: Level 3

  • Complete separation of administration
  • AD Admin never logon to other security tier
  • AD Admin should only logo to a DC (or admin workstation or admin server)
  • Time-based, temporary group membership
  • Restrict workstation to workstation communication with host firewalls
    • AD clients don't need special rules, default Block All Inbound works (add exceptions for authorized management systems)
  • Implement network segmentation
    • Start by reserving IP ranges/VLAN by device type (routers, switches, DC, servers, workstations, printers,etc).

Protect Admin Creds

  • Ensure all admin only log onto approaved admin workstations and servers.
  • Add all admin accounts to Protected Users group (requires Windows 2012 R2 DC).
  • Admin workstation and server:
    • Control and limit access to admin workstations and servers.
    • Remove NetBIOS over TCP/IP.
    • Disable LLMNR.
    • Disable WPAD. 

Additional Mitigations

  • Enable NTLM Auditing on DC.
  • Enable SMB Auditing on DC and file servers.
  • Enable PowerShell logging everywhere and send to SIEM.
  • Monitor scheduled tasks on sensitive systems (DC, etc)
  • Block Internet access to DC and servers.
  • Change the KRBTGT account password (twice) every year and when an AD admin leaves
  • Use Invoke-TrimarcADChecks (https://trimarc.co/ADCheckScript) to help identify problematic AD configurations. 

Aug 1, 2021

Trimarc Security Assessment: Protecting AD Administration



Compromise mgmt system for access:

  • Microsoft SCCM admin account - push packages
  • Microsoft SCOM admin account - run commands
  • Splunk server - run scripts on system (Splunk Universal Forwarder)
  • Vuln Scanners - extract stored credential.
  • Endpoint Detection/Response (EDR) - run scripts/commands/code
  • Microsoft Intune - run scripts on Azure AD.

Notes:

  1. DON'T run management tools on local workstations.
  2. Smart card PIN is cached and can be extracted by Mimikatz.
  3. Hijack Jump-server with tscon.exe (as SYSTEM).
  4. MFA is only as good as its configuration.
  5. MFA can be subverted. (self-service/SMS)
  6. MFA may be configured to be fail-open.
  7. Password vault becomes part of the AD security posture.
  8. Password vault: vulnerable to keylogger.
  9. Password vault: RDP Proxy (browser extension)
  10. Admin Deployment: AD admins, Virtual Infra admins, Cloud admins, Server admins, workstation admins.
  11. Admin Forest = Red Forest (ESAE)
  12. Admin Forest doesn't fix production AD security issues.
  13. Agents on DC will be the target.
  14. Modern Admin Forest = "Cloud" Admin Forest / ESAE
  15. Quick lockdown via Microsoft Intune by leveraging policies.

Jul 31, 2021

Trimarc Security Assessment: Securing Active Directory


This is a great presentation that talks about:

  • Active Directory security assessment
    • Identifying AD Security Issues: 8:44 
    • AD Duplicate SPNs: 17:54 
    • AD Admin Account Checks: 20:26 
    • Protected Users: 22:48 
    • Kerberos Delegation Recommendations: 38:00 
    • Tools for Reviewing AD: 50:35 
    • Invoke-TrimarcADChecks: 51:18 
    • Q&A: 53:25

AD security reviews:

  •  User account issues
  • Domain Password policy
  • Tombstone Lifetime & Backups
  • Trusts
  • Duplicate SPNs
  • Group Policy Preference Passwords
  • AD Administration & Privileged Accounts
  • KRGTGT
  • Kerberos Delegation
  • Domain & GPO Permissions
  • Domain Controller Security

 Links:

Jul 19, 2021

Attacking and Defending Active Directory: Domain Enumeration with BloodHound


My notes:

  • More useful for Blue Team (than Red Team).
  • A very noisy domain enumeration tool at network.
  • 2 parts: Ingestors and GUI.
  • snapshot of the status pf AD.
  • Find all Domain Admins
  • Show the shortest path to Domain Admins
  • Show principals with DCSync rights
  • Map domain trusts
  • show shortest paths to unconstrained delegation systems
  • show shortest paths from kerberoastable users
  • show shortestpatch to domain admins from kerberoastable users
  • show shortest paths from owned principals
  • show shortest paths to domain admins from owned principals
  • show shortest paths to high value targets

 

. .\SharpHound.ps1

Invoke-BloodHound -CollectionMethod All -Verbose 

c:\neo4j\neo4j-win\bin\neo4j.bat 

bolt:localhost:7687

neo4j:neo4j 

Invoke-BloodHound -CollectionMethod LoggedOn -Verbose

# Avoid detection like ATA

Invoke-BloodHound -CollectionMethod All -ExcludeDC

 

 

Jul 9, 2021

Active Directory Security with ALSID and Trustwave

My notes:

  • No agent, no privilege solution that proactively detect AD attacks (it is done through AD replication API).
  • Alsid is known as Tenable.AD now.
  • Attacks: authentication protocols, privilege control (SDProp and SPN), user trust, cross-company department, shared IT team, old-configuration, lack of monitoring, cannot disable the account.
  • 300+ misconfigurations in AD can be weaponised to compromise AD.
  • Kerberoast attacks (cannot be fixed).
  • Password stored in memory.
  • Prevention is always better than a cure.
  • Auditing privileged users.
  • Go after legacy: smbv1, NTLMv1, sensitive privileges.
  • Old config.

Securing Active Directory and Disrupt Attack Paths

 


 

Links:

  • [Webinar] https://lookbook.tenable.com/webinar-replay-tenable-ad-secure-active-directory/od-webinar-tenable-ad-launch 
  • [Slides] https://lookbook.tenable.com/webinar-replay-tenable-ad-secure-active-directory/preso-tenable-ad-secure-active-directory-disrupt-attack-paths
  • [Datasheet] https://lookbook.tenable.com/webinar-replay-tenable-ad-secure-active-directory/datasheet-tenable-ad-secure-active-directory-disrupt-attack-paths
  • [Blog] https://lookbook.tenable.com/webinar-replay-tenable-ad-secure-active-directory/disrupting-the-pervasive-attacks-against-active-directory