On this page 33 sections
- What CrackMapExec does
- Target syntax
- Username and password authentication
- Password lists
- NTLM hash authentication
- SMB — identify hosts
- SMB — authenticated access
- SMB — list shares
- SMB — enumerate users
- SMB — enumerate groups
- SMB — logged-on users
- SMB — password policy
- SMB — RID brute-force enumeration
- SMB — execute a command
- SMB — PowerShell execution
- SMB — modules
- WinRM — test authentication
- WinRM — command execution
- LDAP — connect to a domain controller
- LDAP — enumerate users
- LDAP — enumerate groups
- LDAP — password policy
- LDAP — trusted domains
- MSSQL — test authentication
- MSSQL — execute SQL query
- MSSQL — execute operating-system command
- SSH — test authentication
- SSH — command execution
- Custom ports
- Continue after successful login
- Useful output filters
- Protocol help
- CrackMapExec and NetExec
What CrackMapExec does
CrackMapExec, commonly abbreviated as CME, is a post-exploitation and network assessment tool used to interact with services such as SMB, WinRM, LDAP, MSSQL and SSH. It is especially common in Windows and Active Directory labs.
Use these commands only against systems you own or are explicitly authorized to test.
crackmapexec --helpcrackmapexec smb --helpTarget syntax
Targets can be single hosts, CIDR networks or files containing one target per line.
crackmapexec smb 10.10.10.20crackmapexec smb 10.10.10.0/24crackmapexec smb targets.txtUsername and password authentication
-u specifies the username and -p specifies the password. A domain can be supplied with -d when authenticating to Active Directory.
crackmapexec smb 10.10.10.20 -u administrator -p 'Password123!'crackmapexec smb 10.10.10.20 -d corp.local -u samir -p 'Password123!'crackmapexec smb 10.10.10.20 -u administrator -p 'Password123!' --local-authPassword lists
CME can accept username and password files. This is useful in authorized password-auditing labs.
crackmapexec smb 10.10.10.20 -u users.txt -p 'Password123!'crackmapexec smb 10.10.10.20 -u samir -p passwords.txtcrackmapexec smb 10.10.10.20 -u users.txt -p passwords.txtNTLM hash authentication
For protocols that support NTLM authentication, CME can authenticate using an NTLM hash instead of the plaintext password.
crackmapexec smb 10.10.10.20 -u administrator -H '<NTLM_HASH>'crackmapexec smb 10.10.10.20 -d corp.local -u administrator -H '<NTLM_HASH>'SMB — identify hosts
SMB mode can identify Windows hosts, domains, SMB signing state and SMBv1 support.
crackmapexec smb 10.10.10.0/24SMB — authenticated access
Valid credentials can be checked across one or more SMB targets.
crackmapexec smb 10.10.10.20 -u samir -p 'Password123!'crackmapexec smb 10.10.10.0/24 -d corp.local -u samir -p 'Password123!'SMB — list shares
--shares lists SMB shares visible to the authenticated account together with available permissions.
crackmapexec smb 10.10.10.20 -u samir -p 'Password123!' --sharescrackmapexec smb 10.10.10.20 -d corp.local -u samir -p 'Password123!' --sharesSMB — enumerate users
--users enumerates domain users when the target and account permissions allow it.
crackmapexec smb 10.10.10.20 -d corp.local -u samir -p 'Password123!' --usersSMB — enumerate groups
--groups lists groups visible through SMB or domain enumeration.
crackmapexec smb 10.10.10.20 -d corp.local -u samir -p 'Password123!' --groupsSMB — logged-on users
--loggedon-users attempts to enumerate users currently logged on to the target.
crackmapexec smb 10.10.10.20 -u administrator -p 'Password123!' --loggedon-usersSMB — password policy
--pass-pol retrieves domain password-policy information when available.
crackmapexec smb 10.10.10.20 -d corp.local -u samir -p 'Password123!' --pass-polSMB — RID brute-force enumeration
--rid-brute enumerates accounts by querying Windows RIDs. This can reveal users and groups when normal enumeration is restricted.
crackmapexec smb 10.10.10.20 -u samir -p 'Password123!' --rid-bruteSMB — execute a command
With sufficient administrative privileges, -x can execute a command through the SMB execution methods supported by CME.
crackmapexec smb 10.10.10.20 -u administrator -p 'Password123!' -x "whoami"crackmapexec smb 10.10.10.20 -u administrator -p 'Password123!' -x "hostname"SMB — PowerShell execution
-X executes a PowerShell command when supported by the target and permissions.
crackmapexec smb 10.10.10.20 -u administrator -p 'Password123!' -X '$env:COMPUTERNAME'SMB — modules
CME includes protocol-specific modules. -L lists available modules and -M selects one.
crackmapexec smb -Lcrackmapexec smb -M MODULE_NAME --optionscrackmapexec smb 10.10.10.20 -u administrator -p 'Password123!' -M MODULE_NAMEWinRM — test authentication
WinRM is commonly exposed on TCP 5985 for HTTP and 5986 for HTTPS. CME can verify whether credentials provide WinRM access.
crackmapexec winrm 10.10.10.20 -u administrator -p 'Password123!'crackmapexec winrm 10.10.10.20 -d corp.local -u samir -p 'Password123!'crackmapexec winrm 10.10.10.20 -u administrator -H '<NTLM_HASH>'WinRM — command execution
If the account has the required WinRM permissions, commands can be executed remotely.
crackmapexec winrm 10.10.10.20 -u administrator -p 'Password123!' -x "whoami"crackmapexec winrm 10.10.10.20 -u administrator -p 'Password123!' -x "ipconfig"LDAP — connect to a domain controller
LDAP mode is useful for Active Directory enumeration. The target is normally a domain controller.
crackmapexec ldap 10.10.10.10 -d corp.local -u samir -p 'Password123!'crackmapexec ldap 10.10.10.10 -d corp.local -u samir -H '<NTLM_HASH>'LDAP — enumerate users
crackmapexec ldap 10.10.10.10 -d corp.local -u samir -p 'Password123!' --usersLDAP — enumerate groups
crackmapexec ldap 10.10.10.10 -d corp.local -u samir -p 'Password123!' --groupsLDAP — password policy
crackmapexec ldap 10.10.10.10 -d corp.local -u samir -p 'Password123!' --pass-polLDAP — trusted domains
crackmapexec ldap 10.10.10.10 -d corp.local -u samir -p 'Password123!' --trusted-for-delegationMSSQL — test authentication
MSSQL mode checks Microsoft SQL Server authentication using Windows or SQL credentials depending on the environment.
crackmapexec mssql 10.10.10.30 -d corp.local -u samir -p 'Password123!'crackmapexec mssql 10.10.10.30 -u sa -p 'Password123!' --local-authcrackmapexec mssql 10.10.10.30 -d corp.local -u samir -H '<NTLM_HASH>'MSSQL — execute SQL query
-q executes a SQL query against the target after successful authentication.
crackmapexec mssql 10.10.10.30 -u sa -p 'Password123!' --local-auth -q "SELECT @@VERSION"crackmapexec mssql 10.10.10.30 -u sa -p 'Password123!' --local-auth -q "SELECT DB_NAME()"crackmapexec mssql 10.10.10.30 -u sa -p 'Password123!' --local-auth -q "SELECT name FROM sys.databases"MSSQL — execute operating-system command
When the SQL Server account and server configuration allow it, CME can request operating-system command execution through MSSQL.
crackmapexec mssql 10.10.10.30 -u sa -p 'Password123!' --local-auth -x "whoami"SSH — test authentication
SSH mode verifies credentials against SSH services, typically on TCP port 22.
crackmapexec ssh 10.10.10.40 -u samir -p 'Password123!'crackmapexec ssh 10.10.10.0/24 -u samir -p 'Password123!'SSH — command execution
With valid SSH credentials, CME can execute commands on the remote system.
crackmapexec ssh 10.10.10.40 -u samir -p 'Password123!' -x "whoami"crackmapexec ssh 10.10.10.40 -u samir -p 'Password123!' -x "uname -a"Custom ports
Some protocol implementations allow a custom destination port to be specified with --port.
crackmapexec smb 10.10.10.20 --port 445 -u samir -p 'Password123!'crackmapexec ssh 10.10.10.40 --port 2222 -u samir -p 'Password123!'Continue after successful login
By default, credential testing behavior may stop after a successful combination depending on the protocol and version. --continue-on-success continues testing additional combinations.
crackmapexec smb 10.10.10.20 -u users.txt -p passwords.txt --continue-on-successUseful output filters
CME output can be combined with standard Linux tools when working through larger lab networks.
crackmapexec smb 10.10.10.0/24 -u samir -p 'Password123!' | grep "[+]"crackmapexec smb 10.10.10.0/24 -u samir -p 'Password123!' | tee cme-results.txtProtocol help
CME versions differ in the options exposed by each protocol. Checking the built-in help is the fastest way to verify supported flags.
crackmapexec smb --helpcrackmapexec winrm --helpcrackmapexec ldap --helpcrackmapexec mssql --helpcrackmapexec ssh --helpCrackMapExec and NetExec
CrackMapExec is the older project name commonly found in training material, writeups and labs. Many newer environments use NetExec, whose command is typically nxc and whose syntax is largely derived from CrackMapExec.
nxc smb 10.10.10.20 -u samir -p 'Password123!' --shares