How to Hack Domain Persistence Attacks Using LDAP, LDAPS, and MSRPC

Listen to this Post

Featured Image

Introduction:

Domain persistence attacks are a critical threat in cybersecurity, where attackers maintain long-term access to compromised networks. Techniques like LDAP/LDAPS exploitation, MSRPC abuse, and NTDS.dit dumping enable attackers to bypass permissions and move laterally across domains. This article explores detection and mitigation strategies, including Splunk queries and registry hardening.

Learning Objectives:

  • Identify attacker tactics leveraging LDAP, LDAPS, and MSRPC interfaces.
  • Mitigate BloodHound-based reconnaissance on ports 389/636.
  • Implement Splunk use cases to detect unauthorized group membership changes.

1. Detecting LDAP/LDAPS Recon Activity

Command (Linux):

tcpdump -i eth0 port 389 or port 636 -w ldap_traffic.pcap 

Step-by-Step:

Capture LDAP/LDAPS traffic to analyze reconnaissance attempts. Monitor for unusual queries targeting `samr` or `drsuapi` RPC interfaces. Use Wireshark to filter for `ldap.bind` or `ldap.search` requests from non-admin users.

2. Hardening Against BloodHound Attacks

Registry Key (Windows):

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "RestrictRemoteSamAccess" -Value "1" 

Step-by-Step:

This restricts SAMR access to non-admin users, hindering BloodHound’s ability to enumerate users via LDAPS (port 636). Coordinate with Linux admins to block outbound connections to these ports.

3. Splunk Query for Unauthorized Group Changes

Splunk SPL:

| tstats count from datamodel=Change where (change.action=added OR change.change_type=GroupMembership) AND change.object="Backup Operators" by _time, change.user, change.object, change.object_attrs, change.src 
| lookup authorized_admins.csv user AS change.user OUTPUT user AS authorized_user 
| where isnull(authorized_user) 

Step-by-Step:

This query flags unauthorized additions to privileged groups (e.g., “Backup Operators”). Exclude known admins via a lookup file (authorized_admins.csv).

4. Blocking RPC Exploits

Windows Firewall Rule:

New-NetFirewallRule -DisplayName "Block SAMR/RPC" -Direction Inbound -Protocol TCP -LocalPort 135,445 -Action Block 

Step-by-Step:

Prevent `samr` and `drsuapi` RPC exploitation by blocking inbound traffic to ports 135/445. Audit existing rules with Get-NetFirewallRule.

5. Mitigating NTDS.dit Dumping

Command (Windows):

ntdsutil "ac i ntds" "ifm" "create full C:\temp\ndts_backup" q q 

Step-by-Step:

Create a secure backup of NTDS.dit to detect tampering. Monitor `C:\Windows\NTDS` for unauthorized access using Sysmon (Event ID 11).

6. Detecting Forest Trust Exploitation

PowerShell (AD Module):

Get-ADTrust -Filter  | Select Name, Direction, TrustType 

Step-by-Step:

Audit trust relationships between forests. Attackers abuse `Tree-root` or `External` trusts—alert on unusual cross-domain authentication events.

What Undercode Say:

  • Key Takeaway 1: Attackers bypass SOC detections by exploiting excluded users in Splunk lookups. Always validate exclusion lists.
  • Key Takeaway 2: Multi-forest environments are high-risk; monitor trust relationships and lateral movement.

Analysis:

The post highlights gaps in traditional SOC use cases, such as over-reliance on static allowlists. Future attacks will likely abuse cloud-integrated AD trusts, requiring real-time behavioral analytics. Proactive measures like RPC hardening and LDAP traffic analysis are critical.

Prediction:

As hybrid cloud adoption grows, attackers will increasingly abuse federated trusts (e.g., Azure AD Connect). Organizations must extend detection to cloud APIs and automate trust relationship monitoring.

Tags: Forenisc PurpleTeaming SOC RedTeaming BOFHound

IT/Security Reporter URL:

Reported By: Hassan Sohrabian – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin