🔏
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 Initial Access Discovery in DFIR
  • Efficiency Provided by PowerShell in Initial Access Discovery
  • Initial Access Discovery
  • 1. Suspicious Process Execution
  • 2. User Account Activity Monitoring
  • 3. File and Directory Monitoring
  • 4. Network Activity Analysis
  • 5. Scheduled Tasks and Services
  • 6. Registry Modifications
  • 7. Event Log Monitoring
  • 8. Email Security Monitoring
  • 9. Application Execution Monitoring
  • 10. System and Security Configuration
  • Additional Discovery Techniques
  • 1. Phishing and Spear Phishing
  • 2. Exploiting Vulnerabilities
  • 3. Credential Theft and Brute Force
  • 4. Malicious Code Execution
  • 5. Malicious File and Malware Deployment
  • 6. Abuse of Valid Accounts
  • 7. Phishing Landing Pages and Fake Websites
  • 8. Remote Services and Exploitation
  • 9. Abuse of Application Layer Protocols
  • 10. Malicious Use of Legitimate Tools
Edit on GitHub
  1. SOC Operations
  2. Junior Analyst Skills
  3. PowerShell for SecOps

Initial Access Discovery

Introduction

PowerShell is an indispensable tool for security operations (SecOps) teams in enterprise networks, offering robust capabilities for managing systems, analyzing logs, and automating security tasks. Its deep integration with Windows and extensive library of cmdlets make it a critical asset for digital forensics and incident response (DFIR) investigations. Specifically, PowerShell excels in uncovering Initial Access Discovery activities, helping security analysts identify how attackers gained entry into the network and what reconnaissance they conducted post-compromise. By providing granular visibility into system events and enabling automated data collection and analysis, PowerShell empowers SecOps teams to detect, investigate, and mitigate threats effectively.


Capabilities of PowerShell for Initial Access Discovery in DFIR

1. Identifying Suspicious Logins and Account Activity:

  • Failed and Successful Login Events:

    • Use Get-WinEvent or Get-EventLog to extract authentication events (e.g., EventID 4624 for successful logins and 4625 for failed attempts) and correlate them with potential brute force or credential stuffing attacks.

    • Example: Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4624} | Where-Object { $_.Properties[5].Value -notlike "NT AUTHORITY" }.

  • Account Usage Anomalies:

    • Query Active Directory (AD) logs with cmdlets like Get-ADUser to detect anomalous account activity, such as login times outside regular working hours.

2. Detecting Malicious Execution:

  • PowerShell Execution Monitoring:

    • Analyse script block logs (e.g., EventID 4104) to detect suspicious PowerShell commands indicative of initial compromise.

    • Example: Search for encoded or obfuscated PowerShell commands: Get-WinEvent -LogName 'Microsoft-Windows-PowerShell/Operational' | Where-Object {$_.Message -like '*EncodedCommand*'}.

  • Process Analysis:

    • Use Get-Process or Get-CimInstance -ClassName Win32_Process to detect malicious processes initiated by attackers, such as those tied to tools like Mimikatz or Cobalt Strike.

3. Investigating Email-Based Initial Access:

  • Phishing Analysis:

    • Query logs related to mail flows using Exchange cmdlets like Get-MessageTrackingLog to identify suspicious emails containing malicious attachments or links.

  • Attachment Scanning:

    • Use PowerShell to analyse downloaded files for malware signatures or anomalous behaviour.

4. Detecting Exploitation of Public-Facing Services:

  • Network Connection Analysis:

    • Use cmdlets like Get-NetTCPConnection to identify suspicious inbound connections to services that attackers might exploit, such as RDP or IIS.

  • Service Enumeration:

    • Query running services (Get-Service) to identify unauthorised changes or unusual activity.

5. Artifact Collection for Initial Access Investigation:

  • Log and Artifact Collection:

    • Automate the gathering of critical artifacts such as system logs, registry hives, and memory dumps using Export-Csv and Copy-Item.

  • Registry Inspection:

    • Inspect registry keys using Get-ItemProperty to detect malicious persistence techniques or exploitation artifacts.


Efficiency Provided by PowerShell in Initial Access Discovery

  1. Centralised Investigation:

    • PowerShell allows SecOps teams to investigate multiple endpoints from a central console, enabling rapid data collection and analysis across the network.

  2. Real-Time Detection:

    • PowerShell provides near-instantaneous insights into system activity, allowing analysts to uncover signs of initial access, such as suspicious logins or unusual process executions, in real-time.

  3. Scalability:

    • With PowerShell Remoting and scripting, analysts can scale their investigations to thousands of endpoints, dramatically reducing time-to-detection in large environments.

  4. Automation and Repeatability:

    • PowerShell scripts automate routine discovery tasks, such as parsing logs or inspecting artifacts, ensuring consistency and reducing the likelihood of human error.

  5. Custom Detection Rules:

    • PowerShell’s scripting flexibility allows SecOps teams to create tailored detection rules aligned with MITRE ATT&CK techniques for specific initial access vectors.

  6. Integration with Security Tools:

    • Seamlessly integrates with tools like Microsoft Sentinel, Defender for Endpoint, and SIEM solutions, enabling enriched detection workflows and automated responses.


By leveraging PowerShell's capabilities, SecOps teams can efficiently identify initial access vectors during a DFIR investigation, gaining a clear understanding of how adversaries infiltrated the network and empowering organisations to respond with precision and speed.

Initial Access Discovery

1. Suspicious Process Execution

1.1. Detect Encoded PowerShell Commands

Purpose: Identify potentially malicious encoded commands executed via PowerShell.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; ID=4104} |  Where-Object {$_.Message -like '*-enc*'} | Format-Table -Autosize -Wrap

**Detect Encoded Commands:**
Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" | Where-Object { $_.Message -like "*-EncodedCommand*" }

1.2. Identify Executions of CMD or PowerShell

Purpose: Detect command-line executions that might indicate malicious activities.

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

**Detect Obfuscated Scripts:**
- Look for common obfuscation patterns like concatenation, split, or char conversion.
Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" | Where-Object { $_.Message -match "(\s|\.|\+|\|)+.*-j(\s|\.|\+|\|)+" }

2. User Account Activity Monitoring

2.1. Identify Unusual Logon Attempts

Purpose: Detect unusual logon activities that could indicate credential misuse.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4624} |  Where-Object {$_.Properties[8].Value -notin @("Domain Admins", "Enterprise Admins")} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[5].Value}}, @{n='LogonType';e={$_.Properties[10].Value}}

2.2. Detect Enumeration of User Accounts

Purpose: Identify enumeration attempts against user accounts.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4648} |  Where-Object {$_.Properties[5].Value -notin @("Domain Admins", "Enterprise Admins")}

3. File and Directory Monitoring

3.1. Detect New Executable Files

Purpose: Identify new executable files created in specific directories.

Get-ChildItem -Path "C:\Users\*\AppData\Local\Temp" -Recurse -Filter *.exe | Where-Object {$_.CreationTime -gt (Get-Date).AddDays(-1)}

3.2. Identify Suspicious File Downloads

Purpose: Detect suspicious file downloads, potentially indicating a dropper or payload.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Sysmon/Operational'; ID=11} |  Where-Object {$_.Message -like '*File*'}

**Detect Use of DownloadString or Invoke-Expression:**
Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" | Where-Object { $_.Message -like "*DownloadString*" -or $_.Message -like "*Invoke-Expression*" }

4. Network Activity Analysis

4.1. Unusual Outbound Connections

Purpose: Detect unusual outbound network connections.

Get-NetTCPConnection |  Where-Object {$_.State -eq 'Established' -and $_.RemoteAddress -notin 'KnownGoodIPs'} | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort

4.2. Identify DNS Requests to Suspicious Domains

Purpose: Detect DNS queries to suspicious or known malicious domains.

Get-WinEvent -LogName "Microsoft-Windows-DNS-Client/Operational" |  Where-Object {($_.Message -match 'SuspiciousDomain')}

5. Scheduled Tasks and Services

5.1. Newly Created Scheduled Tasks

Purpose: Identify newly created scheduled tasks that might indicate malicious activity.

Get-ScheduledTask | Where-Object {$_.Principal.UserId -notlike "NT AUTHORITY\*"} | Select-Object TaskName, Principal, @{n='Action';e={$_.Actions.Context}}

5.2. Detect Unusual Service Installations

Purpose: Identify the installation of unusual or suspicious services.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=7045} |  Where-Object {$_.Properties[1].Value -notin @("KnownGoodServices")}

6. Registry Modifications

6.1. Registry Run Key Changes

Purpose: Detect changes to registry keys commonly used for persistence.

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

6.2. Monitor AppInit_DLLs Changes

Purpose: Identify changes to AppInit_DLLs, which may indicate DLL injection attempts.

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name AppInit_DLLs

7. Event Log Monitoring

7.1. Detection of Cleared Event Logs

Purpose: Identify attempts to clear event logs, indicating possible cover-up actions.

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

7.2. Audit Policy Changes

Purpose: Detect changes in audit policies that could disable logging and monitoring.

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

8. Email Security Monitoring

8.1. Detect Phishing Emails

Purpose: Identify potential phishing emails by searching for known indicators.

Get-WinEvent -LogName Application |  Where-Object {($_.Message -like "*Subject:*") -and ($_.Message -like "*attachment*" -or $_.Message -like "*click here*")}

8.2. Monitor Email Client Configuration Changes

Purpose: Identify unauthorized changes to email client configurations.

Get-ItemProperty -Path "HKCU:\Software\Microsoft\Office\*\Outlook\Preferences" | Select-Object PSChildName, *

9. Application Execution Monitoring

9.1. Detect Execution of Unsigned Binaries

Purpose: Identify executions of unsigned binaries that could indicate untrusted applications.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4688} |  Where-Object {$_.Properties[8].Value -eq '0'}  # Unsigned

9.2. Exploitation Tool Detection

Purpose: Detect known exploitation tools on the system.

Get-ChildItem -Path "C:\Windows\Temp\*" -Recurse -Filter *.exe |  Where-Object {$_.Name -in @("mimikatz.exe", "cobaltstrike.exe")}

10. System and Security Configuration

10.1. Group Policy Object Modifications

Purpose: Detect unauthorised changes to Group Policy Objects.

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

10.2. Changes to Security Settings

Purpose: Identify changes to critical security settings within the registry.

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

Additional Discovery Techniques

1. Phishing and Spear Phishing

1.1. Detecting Suspicious Email Attachments

Purpose: Identify emails with potentially malicious attachments.

Get-WinEvent -LogName "Microsoft-Windows-EventLog/Email" |  Where-Object {($_.Message -match "Attachment: ") -and ($_.Message -match "exe|zip|rar|docm|xlsm|pptm")} | Select-Object TimeCreated, @{n='Attachment';e={$_.Message -match 'Attachment: (.*)' -replace 'Attachment: '}}

1.2. Monitoring for Malicious Links in Emails

Purpose: Detect emails containing suspicious or malicious URLs.

Get-WinEvent -LogName "Microsoft-Windows-EventLog/Email" |  Where-Object {($_.Message -match "http://") -or ($_.Message -match "https://")} | Select-Object TimeCreated, @{n='URL';e={$_.Message -match 'http(s)?://[^ ]+' -replace '(http(s)?://[^ ]+)' }}

2. Exploiting Vulnerabilities

2.1. Detecting Exploit Attempts in Web Servers

Purpose: Identify attempts to exploit vulnerabilities in web applications.

Get-WinEvent -LogName "Microsoft-Windows-IIS-Logging" |  Where-Object {($_.Message -match "exploit") -or ($_.Message -match "injection")} | Select-Object TimeCreated, @{n='Request';e={$_.Message}}

2.2. Monitoring for SMB Vulnerability Exploits

Purpose: Detect exploit attempts against SMB vulnerabilities.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4625} | Where-Object {$_.Message -match 'SMB'} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[5].Value}}, @{n='SourceIP';e={$_.Properties[18].Value}}

3. Credential Theft and Brute Force

3.1. Detecting Brute Force Attack Attempts

Purpose: Identify multiple failed login attempts, indicating a brute force attack.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4625} | Where-Object {$_.Properties[19].Value -eq "0xc000006a"} | Group-Object -Property {$_.Properties[5].Value} |  Where-Object {$_.Count -gt 10} | Select-Object Name, Count

3.2. Monitoring for Use of Stolen Credentials

Purpose: Detect successful logins from unusual locations or devices.

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

4. Malicious Code Execution

4.1. Detecting Script Execution from Email Attachments

Purpose: Identify scripts executed from email attachments.

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

4.2. Monitoring Macro-Enabled Document Execution

Purpose: Detect execution of macro-enabled documents (e.g., Word, Excel).

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Office-Alerts'; ID=300} | Where-Object {($_.Message -match ".docm") -or ($_.Message -match ".xlsm")} | Select-Object TimeCreated, @{n='DocumentName';e={$_.Message}}

5. Malicious File and Malware Deployment

5.1. Detecting Newly Created Executables

Purpose: Identify the creation of new executable files, potentially indicating a dropper or payload.

Get-ChildItem -Path "C:\Users\*\AppData\Local\Temp" -Recurse -Include *.exe | Where-Object {$_.CreationTime -gt (Get-Date).AddDays(-1)}

5.2. Monitoring Suspicious File Downloads

Purpose: Detect files downloaded from potentially malicious sources.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Security-Auditing'; ID=4663} | Where-Object {$_.Properties[8].Value -match 'File Download'} | Select-Object TimeCreated, @{n='FileName';e={$_.Properties[6].Value}}

6. Abuse of Valid Accounts

6.1. Detecting Account Creation and Privilege Escalation

Purpose: Identify unauthorized creation of accounts or escalation of privileges.

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

6.2. Monitoring for Unusual Admin Account Activity

Purpose: Detect unusual activities from administrative accounts.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4672} | Where-Object {$_.Properties[9].Value -eq "%%500"} | Select-Object TimeCreated, @{n='AccountName';e={$_.Properties[5].Value}}

7. Phishing Landing Pages and Fake Websites

7.1. Detecting Redirection to Phishing Sites

Purpose: Identify redirection attempts to known phishing sites.

Get-WinEvent -LogName "Microsoft-Windows-DNS-Client/Operational" | Where-Object {$_.Message -match "phishing-site.com"} | Select-Object TimeCreated, @{n='RedirectedURL';e={$_.Message}}

7.2. Monitoring Access to Fake Login Pages

Purpose: Detect access to fake login pages hosted within the organization.

Get-WinEvent -LogName "Microsoft-Windows-IIS-Logging" | Where-Object {$_.Message -match "login.html" -and $_.Message -match "FakeLoginPage"} | Select-Object TimeCreated, @{n='URL';e={$_.Message}}

8. Remote Services and Exploitation

8.1. Detecting Remote Desktop Protocol (RDP) Access

Purpose: Identify unauthorized RDP access attempts.

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

8.2. Monitoring for Remote PowerShell Sessions

Purpose: Detect unauthorized remote PowerShell sessions.

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; ID=4103} | Where-Object {$_.Message -match "New-PSSession"} | Select-Object TimeCreated, @{n='Command';e={$_.Message}}

9. Abuse of Application Layer Protocols

9.1. Monitoring for Suspicious HTTP/S Traffic

Purpose: Detect suspicious HTTP/S traffic that may indicate exploitation or command and control.

Get-WinEvent -LogName "Microsoft-Windows-IIS-Logging" | Where-Object {$_.Message -match "suspicious"} | Select-Object TimeCreated, @{n='Request';e={$_.Message}}

9.2. Detecting Use of Anonymous FTP

Purpose: Identify the use of anonymous FTP, potentially indicating unauthorized data transfer.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" | Where-Object {($_.Message -match "Anonymous") -and ($_.Message -match "FTP")} | Select-Object TimeCreated, @{n='Action';e={$_.Message}}

10. Malicious Use of Legitimate Tools

10.1. Detecting Execution of PsExec

Purpose: Identify the use of PsExec, a legitimate tool that can be misused for lateral movement.

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

10.2. Monitoring for Use of WMI

Purpose: Detect the use of WMI for potentially malicious purposes.

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

Last updated 4 months ago