Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Active Directory and Windows attacks

Lab · Medium · 2 hoursFree account

AD Enumeration with CrackMapExec

Sweep, spray, enumerate and execute across a Windows domain with CrackMapExec.

  • crackmapexec
  • smb
  • active-directory
  • credential-testing
On this page 14 sections
  1. ·Why CrackMapExec Scales Where Manual Tools Do Not
  2. ·Prerequisites
  3. ·Lab Setup
  4. 1Sweep the Network and Fingerprint Hosts
  5. 2Spray and Validate Credentials Safely
  6. Locked: Confirm Admin Access and Harvest Session Data
  7. Locked: Enumerate Shares
  8. Locked: Enumerate Domain Users and Groups
  9. Locked: Execute Commands Across Many Hosts
  10. Locked: Authenticate with a Hash Instead of a Password
  11. Locked: Harvest Local Secrets with a Module
  12. Locked: Detect and Defend Against CrackMapExec
  13. Locked: Check Your Work
  14. Locked: Clean Up and Next Lab

CrackMapExec packages SMB, LDAP and WinRM checks into one tool that runs them across every host in a subnet. Attackers use it to validate stolen credentials fast, map share access and pivot before defenders notice. Here you sweep an AD lab, spray passwords safely, enumerate shares and users, execute commands and dump the local SAM — with every log signal a defender can catch.

Lab Objectives

  • Sweep a subnet with CrackMapExec and fingerprint every SMB host
  • Spray and validate credentials across many hosts without locking out accounts
  • Enumerate shares, sessions and the password policy with valid credentials
  • Enumerate domain users and groups through SMB and LDAP
  • Execute commands on multiple hosts at once and authenticate with a hash instead of a password
  • Explain the log and EDR signals each technique leaves for a defender

Why CrackMapExec Scales Where Manual Tools Do Not

A manual check — one smbclient connection, one RDP login — tells you about one host. CrackMapExec (CME) takes a target list, a protocol, and a set of credentials, and repeats the same check across every host in one command. That is its real value on an engagement: it turns "is this account valid?" or "does this share exist?" into a single sweep across a whole subnet, with the result for each host on its own line.

This lab uses CME against SMB, the protocol it supports best, to validate credentials, enumerate shares and sessions, run commands, and harvest local secrets. Every technique maps to a Windows event or an EDR signal a defender can use to catch it.

Prerequisites

  • SMB Enumeration — do this first. CME wraps the same SMB checks (shares, sessions, null sessions) in a tool that runs them across many hosts at once.
  • Active Directory Basics — covers the AD terms this lab assumes: domain, Domain Controller, Kerberos, LDAP, and the account types CME authenticates as.
  • Active Directory Fundamentals — read this first if the terms above are new. It is the theory; this lab is the practice.
  • Windows Command Line & PowerShell — useful background for Step 6, where CME runs cmd.exe and PowerShell commands remotely.

Lab Setup

KaliRange hosts no targets, no virtual machines and no lab files. Build and run this domain on your own machine; the domain, addresses and accounts below are the example values of this lab. Replace them with your own.

  • Domain. corp.local, an isolated Active Directory lab domain. Never run these commands against a real organisation's network.
  • Domain Controller — DC01, 192.168.1.10. Windows Server, holds the domain user and group accounts.
  • Workstation — WKSTN01, 192.168.1.50. Domain-joined Windows 10 host. A GPO adds the domain group Workstation Admins to its local Administrators group — a common misconfiguration you use in Steps 3, 6 and 8.
  • Accounts.
    • corp.local\john / Password123 — a normal domain user, member of Workstation Admins.
    • corp.local\administrator / Password123 — Domain Admin, used only to confirm the lab is set up correctly.
    • localadmin on WKSTN01 — a local account with the NTLM hash aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c (the NTLM hash of the password password), used in Step 7 for pass-the-hash.
  • Attack box. Kali Linux with crackmapexec and Impacket installed.

Build such a domain from free, legal parts: an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days), in virtual machines on your own computer, with the GPO above added to WKSTN01's local Administrators group. Take a snapshot of each virtual machine before Step 1, so you can go back.

Authorised lab only. Run every command in this lab only against 192.168.1.10 and 192.168.1.50 inside your own isolated AD lab. Spraying credentials or executing commands against a network you do not own, or do not have written authorisation to test, is unauthorised access.

Step 1: Sweep the Network and Fingerprint Hosts

1

Run CME against the whole subnet with no credentials

CME accepts a CIDR range as a target and tries each host in turn. With no credentials, SMB still answers enough to name the operating system, hostname, domain, and whether SMB signing is on.

crackmapexec smb 192.168.1.0/24

Example output:

SMB   192.168.1.10   445   DC01       [*] Windows Server 2019 (name:DC01) (domain:corp.local) (signing:True)
SMB   192.168.1.50   445   WKSTN01    [*] Windows 10 (name:WKSTN01) (domain:corp.local) (signing:False)

Why it matters. One command tells you which host is the Domain Controller, which hosts are workstations, and which hosts have SMB signing off. The OS string says Windows Server, and only the Domain Controller has signing on. A workstation with signing off is a relay target, the subject of the NTLM Relay Attacks lab.

Defender view. A single source host opening an SMB connection to every address in a subnet within seconds is a sweep signature, whether it uses CME or another tool. Look for many Windows Security Event ID 4624 (logon) or 4625 (failed logon) entries, Logon Type 3, from one source IP across many destination hosts in a short window. A network IDS rule for "one host, many SMB endpoints, short time" catches this independently of which tool made the connections.

Step 2: Spray and Validate Credentials Safely

2

Test one password against many usernames, not the reverse

Trying many passwords against one account risks a lockout. Trying one likely password against many accounts does not — each account only sees one attempt. Check the lockout threshold before you spray.

# Check the password policy first — note the lockout threshold
crackmapexec smb 192.168.1.10 -u john -p Password123 --pass-pol

Example output:

SMB   192.168.1.10   445   DC01   [+] Dumping password policy
SMB   192.168.1.10   445   DC01   Minimum password length: 7
SMB   192.168.1.10   445   DC01   Password history length: 24
SMB   192.168.1.10   445   DC01   Password Complexity Flags: 000000
SMB   192.168.1.10   445   DC01   Reset Account Lockout Counter: 30 minutes
SMB   192.168.1.10   445   DC01   Locked Account Duration: 30 minutes
SMB   192.168.1.10   445   DC01   Account Lockout Threshold: 5
# Spray one password against a list of usernames
crackmapexec smb 192.168.1.10 -u users.txt -p 'Spring2026!' --continue-on-success

Example output:

SMB   192.168.1.10   445   DC01   [+] corp.local\john:Password123
SMB   192.168.1.10   445   DC01   [-] corp.local\jsmith:Spring2026! STATUS_LOGON_FAILURE
SMB   192.168.1.10   445   DC01   [+] corp.local\mward:Spring2026!

Why it matters. A [+] line is a confirmed valid credential pair. --continue-on-success tells CME to keep testing the rest of the username list even after a hit, instead of stopping — useful when you need every valid account, not only the first one.

Defender view. The password policy query is a single authenticated SAMR (Security Account Manager Remote) call — quiet on its own. The spray is not: many 4625 failures for different usernames from one source IP, inside one short window, is the spray signature. Windows Event ID 4740 (account locked out) firing for several accounts at once means a spray crossed the lockout threshold. Tune your spray rate against the policy you read in Step 2 to avoid it.

Sign in to continue

9 more sections are for signed-in members. It is free: sign in with Google.

Related