CS-11 // ACTIVE DIRECTORY
NETEXEC AD PENTESTING
A practical NetExec (nxc) reference based on the supplied “NetExec for OSCP: AD Pentesting” article. Covers initial LDAP checks, user and group enumeration, BloodHound collection, SMB/WinRM validation, and MSSQL privilege review.
01 // Setup & name resolution
Use variables to keep the target details consistent. Add the domain controller FQDN to your lab's host-resolution setup when DNS does not resolve it correctly.
export DC_IP='10.10.10.10'
export DOMAIN='corp.local'
export USER='audituser'Use a test account and a password-handling method approved for your lab. The values above are placeholders.
cat /etc/hostsIf required in the lab, map the domain controller IP to its FQDN and short hostname. Do not overwrite unrelated entries.
02 // LDAP credential validation & enumeration
LDAP is often the quickest way to validate an approved test account and inventory directory objects. Use the same protocol/target syntax for each check.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD"Confirms whether the supplied credential can bind to LDAP. Prefer an interactive or approved secret store when available; command-line passwords may be visible locally.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --usersReview account names and available password-related metadata. Treat directory output as sensitive and store it only in approved assessment evidence.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --admin-countThe attribute can indicate current or historical membership in protected groups; validate actual group membership rather than assuming every result is privileged.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --active-usersHelps exclude disabled accounts from an inventory. It does not itself authorize or make password testing safe; confirm lockout thresholds and scope first.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --query '(sAMAccountName=TEST_USER)' ''Replace TEST_USER with an in-scope account. LDAP filters should be quoted to prevent shell interpretation.
03 // Group membership & attack-path context
Membership and ACL relationships are often more important than a raw user list. Confirm findings against directory data and your authorized scope.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" -M groupmembership -o USER='TEST_USER'Replace TEST_USER. Review memberships such as Remote Management Users or Backup Operators as high-priority items for a defensive audit.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --groups 'Backup Operators'Change the group name to another approved audit target. Verify unexpected membership and remove excessive privileges through the normal change process.
04 // BloodHound collection
Use collection output to map relationships and prioritize remediation. Collection can create sensitive data about users, computers, sessions, and privileges.
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --bloodhound --collection All --dns-server $DC_IPUse only the collection methods allowed by the engagement. Protect the resulting archive as sensitive assessment data and remove it according to retention policy.
- Review paths to privileged groups, dangerous ACLs, delegation, and excessive local administration.
- Validate each path with the system owner before attempting any change or privilege transition.
- Prioritize remediation of unnecessary rights and verify fixes with a fresh collection.
05 // SMB reconnaissance & remote-access review
SMB checks can confirm whether approved credentials authenticate and help identify configuration exposure. This reference focuses on low-impact validation.
nxc smb $DC_IP -u "$USER" -p "$LAB_PASSWORD"Use a designated test account. Review the returned host/domain details and authentication status.
nxc smb --helpThe source article describes modules that can expose command history and credentials. For defensive work, inspect endpoint controls and logs with the system owner; do not collect other users' secrets without explicit authorization.
06 // WinRM authentication validation
Validate only a designated account against an in-scope host. Avoid broad password spraying: it can lock accounts and disrupt operations.
nxc winrm $DC_IP -u "$USER" -p "$LAB_PASSWORD"This validates one account/credential pair. If your engagement requires a password audit, agree on a safe test method, account set, rate limits, and lockout monitoring in advance.
07 // MSSQL privilege review
NetExec can query SQL Server with approved credentials. Review impersonation rights and dangerous configuration from a least-privilege perspective.
nxc mssql $SQL_IP -u "$SQL_USER" -p "$LAB_PASSWORD" --local-authSet SQL_IP and SQL_USER for your approved test instance. Use local authentication only when it matches the intended account context.
nxc mssql $SQL_IP -u "$SQL_USER" -p "$LAB_PASSWORD" -M enum_impersonate --local-authTreat unexpected ability to impersonate privileged logins as a finding. Remediation may include revoking unnecessary IMPERSONATE grants and reviewing sysadmin membership.
nxc mssql --helpThe source walkthrough proceeds from impersonation to OS command execution. Those high-impact steps are omitted from this copy-ready reference; review them only under explicit rules of engagement.
08 // Defensive validation checklist
Use enumeration findings to create actionable remediation tasks. Confirm changes with system owners and retain only approved evidence.
- LDAP: require LDAP signing/channel binding where supported; monitor unusual bulk directory reads.
- Privileged groups: audit Domain Admins, Backup Operators, Remote Management Users, and nested memberships.
- ACLs: review ForceChangePassword, GenericAll, WriteDACL, and other dangerous rights; remediate unnecessary edges.
- Credential protection: enable LSA protection and Credential Guard where supported; use Windows LAPS and managed service accounts.
- SMB / WinRM / RDP: restrict reachability, enforce signing and Network Level Authentication as appropriate, and centralize authentication logs.
- MSSQL: disable xp_cmdshell unless explicitly required, restrict impersonation, minimize sysadmin membership, and use least-privilege service accounts.
- Monitoring: alert on unusual logons, privileged-group changes, password resets, bulk LDAP activity, and directory replication rights exercised by non-DCs.