ACTIVE DIRECTORY//NETEXEC / NXC//LDAP / SMB / WINRM / MSSQL//AUTHORIZED TESTING//NETEXEC / NXC//
← ACTIVE DIRECTORY CHEAT SHEETS

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.

NETEXEC / NXCLDAPSMBWINRMMSSQLKALI LINUX
Authorized-use note: Run these commands only in your own lab or within a written assessment scope. Replace every placeholder with approved target and account values. Avoid putting real passwords directly on command lines: they can be exposed through shell history, process listings, terminal recordings, or logs. Credential dumping, password changes, remote command execution, and domain-level actions are high-impact; they are intentionally not included as copy-and-run recipes here. Use vendor documentation and your rules of engagement for any approved validation of those paths.

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.

Set target variables
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.

Inspect local host mappings
cat /etc/hosts

If 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.

Validate a test account with LDAP
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.

Enumerate domain users
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --users

Review account names and available password-related metadata. Treat directory output as sensitive and store it only in approved assessment evidence.

Review accounts marked with adminCount
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --admin-count

The attribute can indicate current or historical membership in protected groups; validate actual group membership rather than assuming every result is privileged.

Filter to enabled accounts
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --active-users

Helps exclude disabled accounts from an inventory. It does not itself authorize or make password testing safe; confirm lockout thresholds and scope first.

Query a specific directory object
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.

Enumerate a user's group memberships (module)
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.

List members of a named group
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.

Collect BloodHound data (All methods)
nxc ldap $DC_IP -u "$USER" -p "$LAB_PASSWORD" --bloodhound --collection All --dns-server $DC_IP

Use only the collection methods allowed by the engagement. Protect the resulting archive as sensitive assessment data and remove it according to retention policy.

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.

Check SMB authentication
nxc smb $DC_IP -u "$USER" -p "$LAB_PASSWORD"

Use a designated test account. Review the returned host/domain details and authentication status.

Review PowerShell-history module availability (do not dump secrets)
nxc smb --help

The 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.

Check one approved account over WinRM
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.

Check MSSQL authentication
nxc mssql $SQL_IP -u "$SQL_USER" -p "$LAB_PASSWORD" --local-auth

Set SQL_IP and SQL_USER for your approved test instance. Use local authentication only when it matches the intended account context.

Review impersonation privilege exposure
nxc mssql $SQL_IP -u "$SQL_USER" -p "$LAB_PASSWORD" -M enum_impersonate --local-auth

Treat unexpected ability to impersonate privileged logins as a finding. Remediation may include revoking unnecessary IMPERSONATE grants and reviewing sysadmin membership.

Review SQL privilege module options
nxc mssql --help

The 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.

Quick workflow: validate scope → confirm name resolution → validate one approved account → enumerate users and groups → map relationships → verify only authorized access paths → document evidence → recommend and retest remediation.
Copied to clipboard