🔏
RootGuard
HomeSOC OperationsIncident ResponseWindows ForensicsLinux ForensicsKQL Investigations
  • Welcome
    • RootGuard
      • Who Am I?
        • Professional Profile
  • Resources Hub
    • Blogs
      • Articles
        • Safeguarding SMEs: The Strategic Importance of a Security Operations Center (SOC)
      • Posts
        • Roadmap to Becoming a Cybersecurity Specialist
        • Starting a Career in Cybersecurity
        • A Guide to Landing Your First Cybersecurity Analyst Role
        • Moving from Intermediate to Expert Incident Responder
  • SOC Operations
    • Introduction
      • Development Resources
        • SOC Analysts Roadmap
        • Becoming A SOC Analyst
        • SOC Analysts Prep Interview Questions
    • Essential Skills
      • Critical Windows EventIDs to Monitor
    • Junior Analyst Skills
      • Splunk Use Cases
      • KQL Use Cases
        • Reconnaissance (TA0043)
        • Initial Access (TA0001)
        • Execution (TA0002)
        • Persistence (TA0003)
        • Privilege Escalation (TA0004)
        • Defence Evasion (TA0005)
        • Credential Access (TA0006)
        • Discovery (TA0007)
        • Lateral Movement (TA0008)
        • Collection (TA0009)
        • Command and Control (TA0011)
        • Exfiltration (TA0010)
        • Impact (TA0040)
      • Investigating Common Attacks
        • Domain Dominance Attacks - Detection & Analysis
        • Investigating a Suspected AD FS Distributed Key Management (DKM) Attack
        • Authentication From Suspicious DeviceName
        • Identifying Interactive or RemoteInteractive Session From Service Account
        • Identifying Split or Part Archive File Transfers
        • Detect Potential Cleartext Credentials in Command Line
        • Detecting Command Line Interpreters Launched via Scheduled Tasks
        • Detecting Files Containing Potentially Sensitive Data
        • Detecting DeviceNetworkEvents From Windows Processes and Domains by TLD
        • Detecting Silent cmd.exe Execution With Redirected STDERR & STDOUT
        • Detecting Low Prevalence DLL Loaded From Process In User Downloads Directory
        • Detecting Virtual Drive Mounted From Archive
        • Identify Execution of Script From User's Downloads Folder
        • Identify Potential RDP Tunneled Sessions
        • Identify Instances of PowerShell Invoke-WebRequest, IWR or Net.WebClient
        • Identify Processes Launched by PowerShell Remoting (WSMProvHost.exe)
        • Detect DeviceNetworkEvents for LOLBAS with Download or Upload Functions
        • Detect Execution of PSEXESVC via Remote Systems
        • Identify Suspicious String in Service Creation ImagePath
        • Identify File with Double Extensions
        • Detect Potential Cleartext Credentials in Commandline
        • Detect When Large Number of Files Downloaded From OneDrive or SharePoint
        • Identify and Investigate Phishing Attacks with KQL
      • PowerShell for SecOps
        • Powershell Remoting
        • Reconnaissance Discovery
        • Initial Access Discovery
        • Execution Discovery
        • Persistence Discovery
        • Privilege Escalation Discovery
        • Defence Evasion Discovery
        • Credential Access Discovery
        • Discovery
        • Lateral Movement Discovery
        • Collection Discovery
        • Command & Control (C2) Discovery
        • Exfiltration Discovery
        • Impact Discovery
      • Packet Analysis (pcap)
        • Tcpdump
        • Tcpdump (Intermediate)
        • Tshark
        • Ngrep
      • Investigating Suspicious Emails Using KQL
    • Intermediate and Advanced Skills
      • Investigate Using MITRE ATT&CK Methodology
        • Reconnaissance (TA0043) Techniques
        • Resource Development (TA0042) Techniques
        • Initial Access (TA0001) Techniques
        • Command Execution (TA0002) Techniques
        • Persistence (TA0003) Techniques
        • Privilege Escalation (TA0004) Techniques
        • Defence Evasion (TA0005) Techniques
        • Credential Access (TA0006) Techniques
        • Discovery (TA0007) Techniques
        • Lateral Movement (TA0008) Techniques
        • Collection (TA0009) Techniques
        • Command and Control (C2) (TA0011) Techniques
        • Exfiltration (TA0010) Techniques
        • Impact (TA0040) Techniques
    • Vulnerability Management
    • Malware Analysis
  • DFIR
    • Incident Response
      • Incident Triage
        • Triage Types and Processes
        • PowerShell for Detection and Analysis
          • Malware or Compromise Investigation
          • Lateral Movement Discovery
        • Registry Analysis
        • Sysinternals Intrusion Analysis
        • PowerShell Intrusion Analysis
        • Velociraptor Intrusion Analysis
        • Zimmerman Tools Intrusion Analysis
      • KAPE Artifacts Analysis
      • Velociraptor Artifacts Analysis
      • Using The Unified Kill Chain Model to Analyse Individual Cyber Attacks
        • Phase 1 - Gaining an Initial Foothold
          • Gaining Access to the Network
          • Establishing a Foothold
          • Network Discovery
      • Response Strategies
        • Privilege Escalation Assessment
        • Command and Control Assessment
        • Command Execution Assessment
        • Defence Evasion Assessment
        • Detection Assessment
        • Discovery Assessment
        • Exfiltration Assessment
        • Initial Access Assessment
        • Initial Impact Assessment Techniques
        • Lateral Movement Assessment
        • Persistence Assessment
    • Windows Forensics
      • Evidence of Execution
      • Window Artifact Analysis
        • Account Usage
        • User Activity Tracking (Event Logs)
        • Program Execution
        • File and Folder Opening
        • File Download
        • Browser Usage
        • Deleted File or File Knowledge
        • External Device & USB Usage
    • Linux Forensics
      • Linux Commandline Basics
      • Host Compromise Assessment
    • KQL for Defender & Sentinel
      • MDO (Office)
      • MDI (Identity)
      • MDE (Endpoint)
    • Memory Forensics
      • Memory Forensics (Volatility 3)
    • Playbooks
      • First Responder DFIR Playbook
        • Device Isolation
        • Evidence Collection
          • Acquire Triage Image Using KAPE
          • Acquire Triage Data Using Velociraptor
          • Acquire Triage Data Using Powershell
          • Acquire Triage Memory Image
          • Acquire Image Using FTK
          • AXIOM Cyber Data Collection
        • Windows Forensic Artefacts
          • Application Execution
          • File & Folder Knowledge
          • External Device Usage
          • Network Activity
          • Windows Event Logs
        • Initial Analysis
          • Memory Analysis (Vol 3)
          • Axiom Cyber Examiner
  • Detection Engineering
    • AD Attack Detections & Mitigations
      • Kerberoasting
      • Authentication Server Response (AS-REP) Roasting
      • Password Spraying
      • MachineAccountQuota Compromise
      • Unconstrained Delegation
      • Password in Group Policy Preferences (GPP) Compromise
      • Active Directory Certificate Services (AD CS) Compromise
      • Golden Certificate
      • DCSync
      • Dumping ntds.dit
      • Golden Ticket
      • Silver Ticket
      • Golden Security Assertion Markup Language (SAML)
      • Microsoft Entra Connect Compromise
      • One-way Domain Trust Bypass
      • Security Identifier (SID) History Compromise
      • Skeleton Key
      • Active Directory Security Controls
      • Active Directory Events for Detecting Compromise
    • Attack Triage Playbooks (KQL Triage)
      • Windows Malware Detection Playbook
      • Linux Host Intrusion Detection Playbook (CLI)
      • Linux Intrusion Detection Playbook
      • Large-Scale Compromise Detection Playbook
      • Ransomware Detection Playbook
      • Phishing Email Compromise Detection Playbook
      • Scam Detection Playbook
      • Customer Phishing Detection Playbook
      • Insider Abuse Detection Playbook
      • Information Leakage Detection Playbook
      • Social Engineering Detection Playbook
      • Malicious Network Behaviour Detection Playbook
      • Windows Intrusion Detection Playbook
      • Vulnerability Detection Playbook
      • Business Email Compromise Detection Playbook
    • Process Execution (KQL Triage)
    • Threat Hunting
      • Hunting Ransomware Indicators
      • Hunting With KQL
        • Detecting Malware Infection (MITRE ATT&CK: T1566, T1059)
        • Discovery Activities (MITRE ATT&CK: T1016, T1083, T1046)
        • Credential Theft (MITRE ATT&CK: T1003, T1078)
        • Lateral Movement (MITRE ATT&CK: T1076, T1021)
        • Data Theft (MITRE ATT&CK: T1041, T1071)
        • Detecting CommandLine Executions (MITRE ATT&CK: T1059)
        • Windows Security Logs (Identity and Logon Activities)
      • Hunting With Splunk
Powered by GitBook
On this page
  • Introduction
  • Capabilities of PowerShell for Privilege Escalation Discovery in DFIR
  • Efficiency Provided by PowerShell in Privilege Escalation Discovery
  • Privilege Escalation Discovery
  • 1. Monitoring Process and Service Changes
  • 2. User and Group Changes
  • 3. Registry and System Configuration
  • 4. Scheduled Tasks and Services
  • 5. Access Control and Permissions
  • 6. Executable and Script Monitoring
  • 7. Application and Service Installation
  • 8. Exploit Detection and Mitigation
  • 9. Audit Policy and Event Log Monitoring
  • 10. Domain and Network-Level Privilege Escalation
  • Additional Discovery Techniques
  • 1. Monitoring Account Privilege Changes
  • 2. Service and Process Manipulation
  • 3. Scheduled Tasks and Cron Jobs
  • 4. Exploitation of Vulnerabilities and Misconfigurations
  • 5. Credential Theft and Reuse
  • 6. Exploit Local Privilege Escalation (LPE) Vulnerabilities
  • 7. Abuse of Built-in Windows Tools
  • 8. Abuse of Service Control Manager
  • 9. Manipulation of Security Policies and Settings
  • 10. Manipulation of Active Directory Objects
Edit on GitHub
  1. SOC Operations
  2. Junior Analyst Skills
  3. PowerShell for SecOps

Privilege Escalation Discovery

Introduction

PowerShell is an indispensable tool for security operations (SecOps), offering extensive capabilities for managing and securing enterprise networks. Its deep integration with Windows systems, robust scripting functionality, and comprehensive library of cmdlets make it a critical asset for conducting Privilege Escalation Discovery activities in digital forensics and incident response (DFIR) investigations. Privilege escalation is a tactic commonly used by attackers to gain elevated access within a network, enabling them to execute unauthorised actions and evade security measures. PowerShell empowers SecOps teams to efficiently detect and analyse privilege escalation techniques, providing actionable insights to mitigate threats and protect enterprise systems.


Capabilities of PowerShell for Privilege Escalation Discovery in DFIR

1. Enumerating Local and Domain Users:

PowerShell enables analysts to query user accounts and groups on local systems and Active Directory (AD). This helps detect newly created accounts, unauthorised privilege assignments, or abnormal group memberships that could indicate privilege escalation attempts.

2. Analysing Privilege Changes:

With PowerShell, analysts can monitor privilege escalation events, such as changes to user rights, group policies, or role assignments. This includes tracking modifications to critical groups like Administrators, Domain Admins, or Enterprise Admins.

3. Detecting Misconfigurations and Exploitable Settings:

Attackers often exploit misconfigurations to elevate privileges. PowerShell allows for the inspection of file and folder permissions, service configurations, and registry keys to identify weaknesses, such as improperly set SeTakeOwnershipPrivilege or SeDebugPrivilege.

4. Identifying Credential Exposure:

Privilege escalation often involves harvesting credentials from compromised systems. PowerShell facilitates the detection of exposed credentials, such as plaintext passwords in scripts, memory, or configuration files, which attackers might use to gain elevated access.

5. Monitoring Process and Service Escalation:

PowerShell provides detailed insights into running processes and services, helping analysts identify processes with elevated privileges or services that have been modified to execute malicious binaries.

6. Event Log Analysis:

Privilege escalation activities often leave traces in Windows event logs. PowerShell enables querying of security logs for specific events, such as changes to user rights, process creation with elevated privileges, or attempts to exploit privileged accounts.

7. Hunting for Privilege Escalation Tools:

Attackers commonly use tools like Mimikatz or PsExec for privilege escalation. PowerShell allows analysts to search for the presence of these tools, as well as their execution traces in system logs or memory.


Efficiency Provided by PowerShell in Privilege Escalation Discovery

  1. Comprehensive Visibility: PowerShell offers access to critical system components and logs, allowing security teams to detect privilege escalation attempts across both local systems and domain environments.

  2. Real-Time Analysis: PowerShell’s dynamic querying capabilities provide real-time insights into privilege-related activities, enabling rapid detection and response to escalation attempts.

  3. Scalability: Using PowerShell Remoting, analysts can perform privilege escalation discovery across multiple endpoints simultaneously, ensuring coverage in large enterprise networks.

  4. Automation and Consistency: PowerShell scripts automate repetitive tasks, such as querying group memberships or analysing user rights, ensuring consistent and efficient investigation workflows.

  5. Customisable Detection: PowerShell can be tailored to detect specific privilege escalation techniques outlined in the MITRE ATT&CK framework, ensuring alignment with known adversarial tactics.

  6. Integration with Security Tools: PowerShell integrates seamlessly with platforms like Microsoft Sentinel, Defender for Endpoint, and other SIEMs, enabling enriched detection and automated remediation workflows.


By leveraging PowerShell’s capabilities, SecOps teams can efficiently identify and mitigate privilege escalation activities, enhancing their ability to protect enterprise networks and maintain a robust security posture.

Privilege Escalation Discovery

1. Monitoring Process and Service Changes

1.1. Detecting New Administrative Process Creation

Purpose: Identify processes started with administrative privileges that may indicate privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4688} | Where-Object {$_.Properties[5].Value -match 'Administrator'} | Select-Object TimeCreated, @{n='ProcessName';e={$_.Properties[5].Value}}, @{n='CommandLine';e={$_.Properties[9].Value}}

1.2. Monitoring for New Services with Elevated Privileges

Purpose: Detect the creation of new services that run with elevated privileges.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=7045} | Select-Object TimeCreated, @{n='ServiceName';e={$_.Properties[0].Value}}, @{n='ServiceFile';e={$_.Properties[5].Value}}

2. User and Group Changes

2.1. Detecting New User Account Creation

Purpose: Identify new user accounts that may have been created with elevated privileges.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4720} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[0].Value}}, @{n='CreatedBy';e={$_.Properties[1].Value}}

2.2. Monitoring for Group Membership Changes

Purpose: Detect changes in group memberships, particularly in administrative groups.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4732,4746,4756} | Select-Object TimeCreated, @{n='GroupName';e={$_.Properties[0].Value}}, @{n='MemberName';e={$_.Properties[1].Value}}

3. Registry and System Configuration

3.1. Monitoring Registry Key Changes for Escalation Paths

Purpose: Identify changes to registry keys that may enable privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4657} | Where-Object {$_.Properties[6].Value -match 'HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System'}

3.2. Detecting UAC Bypass Techniques

Purpose: Detect changes to registry keys or system settings that might indicate UAC bypass attempts.

Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name ConsentPromptBehaviorAdmin

4. Scheduled Tasks and Services

4.1. Detecting Changes to Scheduled Tasks

Purpose: Identify changes to scheduled tasks that may allow privilege escalation.

Get-ScheduledTask | Where-Object {$_.Principal.RunLevel -eq "Highest"} | Select-Object TaskName, Principal, Actions

4.2. Monitoring Service Configuration Changes

Purpose: Detect changes to service configurations that may provide elevated access.

Get-WmiObject -Class Win32_Service | Where-Object {$_.StartMode -eq "Auto" -and $_.StartName -eq "LocalSystem"} | Select-Object Name, DisplayName, PathName, StartMode

5. Access Control and Permissions

5.1. Monitoring Changes to ACLs on Sensitive Files

Purpose: Detect modifications to access control lists (ACLs) on sensitive system files.

Get-Acl -Path "C:\Windows\System32\*" |  Where-Object {$_.Access -like '*Everyone*'} | Select-Object Path, Access

5.2. Detecting Changes to Important Security Settings

Purpose: Identify changes to security settings that might indicate privilege escalation.

Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\LanmanServer\Parameters" -Name NullSessionShares

6. Executable and Script Monitoring

6.1. Detecting Unusual Executables in System Directories

Purpose: Identify executables in system directories that may be used for privilege escalation.

Get-ChildItem -Path "C:\Windows\System32\*" -Filter "*.exe" | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-1)}

6.2. Monitoring Script Execution with Elevated Privileges

Purpose: Detect the execution of scripts with administrative privileges.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; ID=4104} | Where-Object {$_.Message -match 'RunAsAdministrator'}

7. Application and Service Installation

7.1. Detecting Installation of Potentially Malicious Software

Purpose: Identify the installation of software that may be used for privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Application'; ID=11707} | Select-Object TimeCreated, @{n='Product';e={$_.Properties[0].Value}}, @{n='InstalledBy';e={$_.Properties[1].Value}}

7.2. Monitoring Changes to Auto-Start Applications

Purpose: Detect changes to auto-start applications that could indicate persistence or privilege escalation.

Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run" | Select-Object PSChildName, *

8. Exploit Detection and Mitigation

8.1. Monitoring for Known Exploit Attempts

Purpose: Detect attempts to exploit known vulnerabilities for privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4625} |  Where-Object {$_.Properties[10].Value -match '0xc000006a'} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[5].Value}}, @{n='FailureReason';e={$_.Properties[9].Value}}

8.2. Detecting Kernel Driver Installation

Purpose: Identify the installation of kernel drivers, which may be used to escalate privileges.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=7040} |  Where-Object {$_.Properties[1].Value -match 'Driver'}

9. Audit Policy and Event Log Monitoring

9.1. Monitoring Changes to Audit Policies

Purpose: Detect changes to audit policies that might indicate attempts to cover privilege escalation activities.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4719}

9.2. Detecting Clearing of Event Logs

Purpose: Identify attempts to clear event logs, which may indicate an attempt to hide evidence of privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=1102}

10. Domain and Network-Level Privilege Escalation

10.1. Monitoring Changes to Domain Admin Group

Purpose: Detect unauthorized changes to the Domain Admins group.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4728} | Where-Object {$_.Properties[2].Value -eq "Domain Admins"}

10.2. Detecting Changes to Group Policy Objects (GPOs)

Purpose: Identify changes to GPOs that may indicate attempts to escalate privileges.

Get-GPO -All | Get-GPOReport -ReportType XML | Select-String -Pattern "Administrator"

Additional Discovery Techniques

1. Monitoring Account Privilege Changes

1.1. Detecting Changes in User Group Membership

Purpose: Identify users added to high-privilege groups, such as Administrators.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4732,4728} | Select-Object TimeCreated, @{n='Group';e={$_.Properties[6].Value}}, @{n='User';e={$_.Properties[1].Value}}

1.2. Monitoring User Account Control (UAC) Changes

Purpose: Detect changes to UAC settings that may indicate privilege escalation attempts.

Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name ConsentPromptBehaviorAdmin, EnableLUA

2. Service and Process Manipulation

2.1. Detecting Service Configuration Changes

Purpose: Identify changes to service configurations that might be used for privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=7040} | Select-Object TimeCreated, @{n='ServiceName';e={$_.Properties[0].Value}}, @{n='Change';e={$_.Properties[2].Value}}

2.2. Monitoring for Abnormal Parent-Child Process Relationships

Purpose: Detect unusual parent-child process relationships that might indicate process injection or manipulation.

Get-CimInstance -ClassName Win32_Process |  Select-Object ProcessId, Name, ParentProcessId | Where-Object {($_.ParentProcessId -ne 0) -and ($_.Name -match "cmd.exe|powershell.exe")}

3. Scheduled Tasks and Cron Jobs

3.1. Detecting Creation of High-Privilege Scheduled Tasks

Purpose: Monitor for the creation of scheduled tasks with high privileges.

Get-ScheduledTask | Where-Object {$_.Principal.UserId -like "*"} | Select-Object TaskName, Principal, @{n='Actions';e={$_.Actions}}

3.2. Monitoring Modification of Scheduled Tasks

Purpose: Identify modifications to scheduled tasks, which can be used for privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4698} | Select-Object TimeCreated, @{n='TaskName';e={$_.Properties[0].Value}}, @{n='Operation';e={$_.Properties[1].Value}}

4. Exploitation of Vulnerabilities and Misconfigurations

4.1. Detecting Exploitation of Known Vulnerabilities

Purpose: Identify attempts to exploit known vulnerabilities for privilege escalation.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" |  Where-Object {$_.Message -match "exploit"} | Select-Object TimeCreated, @{n='Details';e={$_.Message}}

4.2. Monitoring for Misconfigured File or Folder Permissions

Purpose: Detect weak permissions on critical files or folders that may allow privilege escalation.

Get-Acl -Path "C:\Windows\System32" | Select-Object -ExpandProperty Access |  Where-Object {$_.FileSystemRights -match 'FullControl' -and $_.IdentityReference -ne 'BUILTIN\Administrators'}

5. Credential Theft and Reuse

5.1. Detecting Use of Pass-the-Hash

Purpose: Identify the use of NTLM hashes for authentication, bypassing standard credentials.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4624} | Where-Object {$_.Properties[8].Value -eq 'NTLM'} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[5].Value}}, @{n='LogonType';e={$_.Properties[10].Value}}

5.2. Monitoring for Token Manipulation

Purpose: Detect attempts to manipulate tokens, such as by using tools like incognito.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4673} | Where-Object {$_.Properties[10].Value -match "SeDebugPrivilege"} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[5].Value}}

6. Exploit Local Privilege Escalation (LPE) Vulnerabilities

6.1. Detecting Execution of Exploits

Purpose: Identify the execution of known exploit tools for local privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4688} | Where-Object {$_.Properties[9].Value -match "exploit"} | Select-Object TimeCreated, @{n='ProcessName';e={$_.Properties[5].Value}}, @{n='CommandLine';e={$_.Properties[9].Value}}

6.2. Monitoring for Privilege Escalation via DLL Hijacking

Purpose: Detect attempts to use DLL hijacking for privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4688} | Where-Object {$_.Properties[9].Value -match "rundll32.exe"} | Select-Object TimeCreated, @{n='CommandLine';e={$_.Properties[9].Value}}

7. Abuse of Built-in Windows Tools

7.1. Detecting Use of WMI for Privilege Escalation

Purpose: Identify the use of Windows Management Instrumentation (WMI) for privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-WMI-Activity/Operational'; ID=5857} | Where-Object {$_.Message -match 'MethodInvocation'} | Select-Object TimeCreated, @{n='CommandLine';e={$_.Message}}

7.2. Monitoring for PowerShell Privilege Escalation Attempts

Purpose: Detect the use of PowerShell scripts or commands to escalate privileges.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; ID=4104} | Where-Object {$_.Message -match 'New-Object System.Security.Principal.WindowsPrincipal'} | Select-Object TimeCreated, @{n='ScriptBlock';e={$_.Message}}

8. Abuse of Service Control Manager

8.1. Detecting Service Installation by Non-Admins

Purpose: Identify attempts by non-administrative users to install services.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=7045} | Where-Object {($_.Properties[1].Value -ne 'SYSTEM')} | Select-Object TimeCreated, @{n='ServiceName';e={$_.Properties[0].Value}}, @{n='ServiceFile';e={$_.Properties[5].Value}}

8.2. Monitoring for Unauthorized Service Modifications

Purpose: Detect modifications to existing services that could indicate privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=7040} | Where-Object {($_.Properties[2].Value -match 'change')} | Select-Object TimeCreated, @{n='ServiceName';e={$_.Properties[0].Value}}, @{n='Change';e={$_.Properties[2].Value}}

9. Manipulation of Security Policies and Settings

9.1. Monitoring Changes to Local Security Policies

Purpose: Detect changes to local security policies that may indicate attempts to weaken security.

secedit /export /cfg C:\securitypolicy.cfg Get-Content C:\securitypolicy.cfg | Where-Object {$_ -match "AuditPolicyChange"}

9.2. Detecting Changes to User Rights Assignments

Purpose: Identify changes to user rights assignments, which can indicate privilege escalation.

`Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name SeDebugPrivilege`

10. Manipulation of Active Directory Objects

10.1. Detecting Unusual Changes to Group Policy Objects (GPOs)

Purpose: Monitor for unauthorized changes to GPOs that could indicate privilege escalation.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=5136} | Where-Object {$_.Message -match "groupPolicyContainer"} | Select-Object TimeCreated, @{n='AttributeName';e={$_.Properties[9].Value}}

10.2. Monitoring for Unusual Delegation of Privileges in AD

Purpose: Identify unusual delegation of privileges within Active Directory.

Get-ADUser -Filter {MemberOf -eq "Administrators"} -Property MemberOf | Select-Object Name, MemberOf
PreviousPersistence DiscoveryNextDefence Evasion Discovery

Last updated 4 months ago