Repository navigation
Detection
Soaphound.py is explicit about which Windows ports it uses, which Microsoft specifications it rides, and which audit subcategories a defender needs to turn on to see anything. This page is the operator-facing summary from the defender's seat.
Most of the open-source conversation on BloodHound detection targets tcp/389 LDAP and tcp/445 SMB. Soaphound.py uses neither for its primary collection path, and its primitives (--enroll-ws, --adcap-*, --badsuccessor) write to the DC without touching LDAP at all. A detection stack scoped to the LDAP + SMB default misses the full feature set documented in this wiki. This page lists the DC-side signals that actually fire, which audit policy turns each one on, and how to correlate them.
| Event | Where | What |
|---|---|---|
5156 on tcp/9389
|
DC — Windows Filtering Platform | Any ADWS session (every collection preset, every primitive). Enable through Advanced Audit Policy → Object Access → Filtering Platform Connection, plus auditpol /set /subcategory:"Filtering Platform Connection" /success:enable. |
5156 on tcp/443 to the CA host |
CA | HTTPS CEP/CES calls (--list-policies-ws, --enroll-ws). |
5156 on tcp/445 to DC and member hosts |
DC + members | Default-preset SYSVOL and session collection only. Not emitted by Stealth. |
The 5156 baseline is noisy. Hunt by source IP: a single Linux host opening dozens of ADWS sessions in a short window is the primary signal.
| Event | Trigger | SACL needed? |
|---|---|---|
5136 |
Any attribute change on a monitored object (ADCS template, dMSA, trust TDO). Fires for the ADWS writes documented in BadSuccessor and the ESC4 template flip. | Yes — per-object or per-container SACL plus Directory Service Changes subcategory. |
5137 |
Any object creation under a monitored container. Fires for the dMSA creation in BadSuccessor. | Yes — same as 5136. |
5141 |
Any object deletion. Fires on --badsuccessor --rollback. |
Yes — same as 5136. |
4662 |
LDAP writeProperty. Does not fire for ADWS writes because they do not transit the LDAP interface. | n/a |
Key point: 5136/5137 are not generated by default. Without the SACLs, the ADWS writes are completely silent.
| Event | What to look for |
|---|---|
4768 with Pre-Authentication Type 16
|
PKINIT — the AS exchange that happens right after --enroll-ws + --auth-dc. Strongest post-hoc indicator of certificate-based primary authentication. |
4769 with Ticket Options 0x40810000
|
S4U2Self or similar impersonation; relevant for the BadSuccessor TGS request. |
4624 LogonType 3 on the CA |
NTLM relay fallback when EPA is misconfigured — ESC8 posture check. |
| Event | Where | What |
|---|---|---|
4886 |
CA Security | Certificate request received. Fires on every --enroll-ws. |
4887 |
CA Security | Request approved and certificate issued. |
4899 |
CA Security | Request handled by the policy module (template evaluation). |
Correlate 4886 → 4887 on the CA with 4768+Pre-Auth 16 on the DC within a 60-second window to catch the full ESC chain.
The NTDS Diagnostics logging ("Field Engineering") surface emits 1138 and 1644 on expensive and inefficient searches. ADWS pulls route through the same engine as LDAP, so these events apply to Soaphound traffic too — but only if the thresholds are tuned low enough.
HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics
Value: "15 Field Engineering" Type: REG_DWORD Data: 5
HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Parameters
Value: "Expensive Search Results Threshold" Data: 10000
Value: "Inefficient Search Results Threshold" Data: 1000
Value: "Search Time Threshold (msecs)" Data: 50
Without this tuning, 1138 and 1644 are effectively disabled, which is the Microsoft default.
The Huntress research on ADWS detection groups the signals into two correlation stacks:
-
5a — Pair
5156ontcp/9389(source IP = non-domain-joined) with1644on the DC within a 1-minute window. The 5156 proves ADWS was opened; the 1644 proves a BloodHound-shaped bulk pull was issued. -
5b — Pair
5156ontcp/9389with5137or5136on any object within the Configuration NC (CN=Configuration,DC=...). This catches the write primitives (--adcap-change-feature, the ESC4 template flip, BadSuccessor's three writes) regardless of their specific target class.
Both correlations assume SACLs are in place for the 5136/5137 branch and that NTDS Diagnostics is tuned for the 1644 branch. Without either, the pattern degrades to a bare 5156 signal.
- Per-object SACL on the monitored object with "Write All Properties" audit entry for
Everyone(success). - Advanced Audit Policy: Account Management → Directory Service Changes = Success.
- Reboot or
auditpol /get /subcategory:"Directory Service Changes"to confirm the subcategory is live.
Default-installed Windows domains have no SACL on CN=Certificate Templates, CN=Partitions,CN=Configuration or dMSA parent OUs — the three locations Soaphound.py's write primitives touch. These SACLs are an explicit hardening step; without them, every --adcap-change-feature, every ESC4 flip and every BadSuccessor write is silent.
| Layer | Config | Reason |
|---|---|---|
| Windows Firewall | Audit Filtering Platform Connection = Success | Catches 5156 on tcp/9389. |
| Advanced Audit Policy | Account Management → Directory Service Changes = Success | Enables 5136/5137 where SACLs exist. |
| SACLs | On CN=Certificate Templates, CN=Partitions,CN=Configuration, every dMSA-eligible OU |
Required for the writes to actually generate events. |
| NTDS Diagnostics |
15 Field Engineering = 5, threshold registry values tuned |
Enables 1138/1644. |
| CA logging | Default AD CS auditing + "Issue and manage certificate requests" | Enables 4886/4887/4899. |
| SIEM | Correlation rule for 5156+1644 within 60s + grouped by source IP |
Huntress 5a. |
Without this stack a Soaphound.py run against the DC is almost invisible.
- Microsoft, "Audit Directory Service Changes" — https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/audit-directory-service-changes
- Microsoft, "Audit Filtering Platform Connection" — https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/audit-filtering-platform-connection
- Microsoft, "NTDS logging" — https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/configure-ad-and-lds-event-logging