🔏
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 Exfiltration Discovery in DFIR
  • Efficiency Provided by PowerShell in Exfiltration Discovery
  • Exfiltration Discovery
  • 1. Network Traffic and Connection Monitoring
  • 2. Cloud Storage and Remote Access
  • 3. Email-Based Exfiltration
  • 4. USB and Removable Media
  • 5. Compression and Encryption
  • 6. Steganography and Data Hiding
  • 7. Network Protocol Abuse
  • 8. SFTP and FTP Transfers
  • 9. Physical Media Exfiltration
  • 10. HTTP/S and Web-based Exfiltration
Edit on GitHub
  1. SOC Operations
  2. Junior Analyst Skills
  3. PowerShell for SecOps

Exfiltration Discovery

Introduction

PowerShell is an indispensable tool for security operations (SecOps), providing powerful capabilities for system management, automation, and in-depth investigations. Its tight integration with the Windows operating system, robust scripting capabilities, and ability to interact with network and system components make it a key resource for Digital Forensics and Incident Response (DFIR). In the context of Exfiltration Discovery, PowerShell enables SecOps teams to identify and investigate the unauthorised transfer of sensitive data from enterprise networks. Attackers often use sophisticated techniques to evade detection, making PowerShell’s ability to monitor, analyse, and automate investigative tasks crucial for the timely containment and mitigation of threats.


Capabilities of PowerShell for Exfiltration Discovery in DFIR

1. Monitoring Network Traffic for Suspicious Activity:

PowerShell can analyse active network connections and detect unusual data flows, such as large outbound transfers or connections to untrusted external IPs. This includes identifying common exfiltration channels, such as HTTP/HTTPS, FTP, or DNS tunnelling.

2. Detecting Use of Exfiltration Tools:

Attackers often use tools like curl, scp, or custom scripts to exfiltrate data. PowerShell can query system processes and command-line arguments to identify such tools in use, including the detection of encoded or obfuscated commands.

3. Investigating File System Activity:

PowerShell enables the tracking of suspicious file activity, such as the creation of compressed or encrypted archives (.zip, .rar) or unusual access to sensitive directories. This helps uncover potential staging of files for exfiltration.

4. Identifying the Use of Cloud Services:

Exfiltration often involves uploading data to cloud storage platforms like Google Drive, Dropbox, or OneDrive. PowerShell can detect unauthorised use of these services by analysing logs, network activity, or relevant processes.

5. Analysing USB and External Device Usage:

PowerShell can query USB device logs and file access events to detect the use of external storage devices, a common method of exfiltration. It can also monitor for unauthorised access to removable drives.

6. Monitoring Email and Messaging Channels:

Exfiltration via email or messaging apps is another common tactic. PowerShell can query logs from mail servers or messaging platforms to identify large attachments, unusual recipient patterns, or abnormal usage of communication tools.

7. Event Log Analysis for Exfiltration Indicators:

PowerShell provides access to security and system logs to identify signs of exfiltration, such as repeated file access attempts, network connection anomalies, or events indicating compression and transfer of sensitive data.

8. Detecting Data Compression and Encryption:

PowerShell can analyse system activity to detect the use of tools or commands for compressing and encrypting files, both of which are common preparatory steps for data exfiltration.


Efficiency Provided by PowerShell in Exfiltration Discovery

  1. Comprehensive Visibility: PowerShell provides detailed insights into system and network activity, enabling the detection of exfiltration attempts across multiple attack vectors, including network, USB, and cloud-based methods.

  2. Real-Time Detection: PowerShell enables real-time monitoring of network connections, file system changes, and other system activities, allowing security teams to quickly identify and respond to exfiltration attempts.

  3. Scalability: With PowerShell Remoting, SecOps teams can investigate exfiltration activities across numerous endpoints simultaneously, making it highly efficient for enterprise-scale environments.

  4. Automation of Investigative Tasks: PowerShell scripts can automate repetitive tasks, such as querying logs or inspecting file system activity, ensuring consistent and efficient workflows for detecting exfiltration.

  5. Tailored Detection: PowerShell allows for the creation of custom scripts that align with organisational baselines and threat models, including techniques from the MITRE ATT&CK framework, ensuring precise detection of exfiltration methods.

  6. Integration with Security Ecosystems: PowerShell integrates seamlessly with platforms like Microsoft Sentinel, Defender for Endpoint, and SIEM tools, enabling enriched data collection, automated alerts, and effective incident response workflows.


By leveraging PowerShell’s extensive capabilities, SecOps teams can efficiently uncover and mitigate Exfiltration Discovery activities, protecting sensitive data and ensuring the integrity of enterprise networks during DFIR investigations.

Exfiltration Discovery

1. Network Traffic and Connection Monitoring

1.1. Detecting Large Data Transfers

Purpose: Identify large data transfers to external IP addresses, which may indicate data exfiltration.

Get-NetTCPConnection | Where-Object {$_.State -eq 'Established' -and $_.RemoteAddress -notin 'KnownGoodIPs'} | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, @{n='DataTransferred';e={($_.OwningProcess).ToString()}}

1.2. Monitoring Unusual Outbound Connections

Purpose: Detect outbound connections to suspicious or uncommon destinations.

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

2. Cloud Storage and Remote Access

2.1. Detecting Access to Cloud Storage Services

Purpose: Monitor for access to cloud storage platforms like Dropbox, Google Drive, and OneDrive.

Get-Process | Where-Object {$_.ProcessName -match 'Dropbox|GoogleDrive|OneDrive'} | Select-Object ProcessName, Id, StartTime

2.2. Monitoring for File Uploads to Remote Servers

Purpose: Identify file uploads to remote servers, which may indicate exfiltration.

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

3. Email-Based Exfiltration

3.1. Detecting Large Email Attachments

Purpose: Identify large email attachments that may contain exfiltrated data.

Get-WinEvent -LogName "Microsoft-Windows-EventLog/Email" | Where-Object {($_.Message -match 'Attachment: ') -and ($_.Message -match '[0-9]{5,} bytes')} | Select-Object TimeCreated, @{n='Attachment';e={$_.Message -match 'Attachment: (.*)' -replace 'Attachment: '}}

3.2. Monitoring Use of Personal Email Accounts

Purpose: Detect the use of personal email accounts for data exfiltration.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" | Where-Object {($_.Message -match 'Subject: ') -and ($_.Message -match '@gmail.com|@yahoo.com')} | Select-Object TimeCreated, @{n='Recipient';e={$_.Message -match 'Recipient: (.*)' -replace 'Recipient: '}}

4. USB and Removable Media

4.1. Detecting USB Device Insertions

Purpose: Monitor the insertion of USB devices, which may be used for data exfiltration.

Get-WinEvent -FilterHashtable @{LogName='System'; ID=20001} | Where-Object {$_.Message -match 'USB'} | Select-Object TimeCreated, @{n='Device';e={$_.Message -match 'Device: (.*)' -replace 'Device: '}}

4.2. Monitoring File Transfers to USB Drives

Purpose: Detect file transfers to USB devices.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4663} | Where-Object {$_.Properties[6].Value -match 'E:\\'} |  # Assuming E: is the USB drive letter Select-Object TimeCreated, @{n='FileName';e={$_.Properties[6].Value}}

5. Compression and Encryption

5.1. Detecting Use of Compression Tools

Purpose: Identify the use of tools like WinRAR or 7-Zip for compressing data.

Get-Process | Where-Object {$_.ProcessName -match 'WinRAR|7z'} | Select-Object ProcessName, Id, StartTime

5.2. Monitoring Encryption Tool Usage

Purpose: Detect the use of encryption tools, indicating attempts to secure exfiltrated data.

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

6. Steganography and Data Hiding

6.1. Detecting Steganography Tools

Purpose: Identify the use of steganography tools for hiding data in images or other files.

Get-ChildItem -Path "C:\Program Files\*" -Recurse -Include *steg* | Select-Object FullName, LastWriteTime

6.2. Monitoring for Unusual File Types in Sensitive Locations

Purpose: Detect unusual file types or hidden data in sensitive directories.

Get-ChildItem -Path "C:\SensitiveData\*" -Recurse -Include *.jpg, *.png | Select-Object FullName, LastWriteTime

7. Network Protocol Abuse

7.1. Detecting ICMP Exfiltration

Purpose: Monitor for data exfiltration attempts using ICMP (ping).

Get-NetTCPConnection | Where-Object {$_.RemotePort -eq 7} |  # ICMP Echo Select-Object LocalAddress, RemoteAddress, RemotePort

7.2. Monitoring for DNS Data Exfiltration

Purpose: Identify attempts to use DNS queries for data exfiltration.

Get-WinEvent -LogName "Microsoft-Windows-DNS-Client/Operational" |  Where-Object {($_.Message -match "TXT") -or ($_.Message -match "TXT Record")} | Select-Object TimeCreated, @{n='DomainName';e={$_.Message -match 'QueryName: (.*)' -replace 'QueryName: '}}

8. SFTP and FTP Transfers

8.1. Detecting SFTP Transfers

Purpose: Identify data transfers using SFTP.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" |  Where-Object {($_.Message -match "SFTP") -and ($_.Message -match "Upload")} | Select-Object TimeCreated, @{n='RemoteAddress';e={$_.Message -match 'RemoteAddress: (.*)' -replace 'RemoteAddress: '}}

8.2. Monitoring FTP Uploads

Purpose: Detect data uploads via FTP.

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

9. Physical Media Exfiltration

9.1. Monitoring CD/DVD Write Events

Purpose: Detect attempts to write data to CD/DVD media.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" |  Where-Object {($_.Message -match "CD") -or ($_.Message -match "DVD")} | Select-Object TimeCreated, @{n='Action';e={$_.Message -match 'Action: (.*)' -replace 'Action: '}}

9.2. Detecting Data Copy to External Hard Drives

Purpose: Monitor for data copies to external hard drives.

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4663} | Where-Object {$_.Properties[6].Value -match 'F:\\'} |  # Assuming F: is the external drive letter Select-Object TimeCreated, @{n='FileName';e={$_.Properties[6].Value}}

10. HTTP/S and Web-based Exfiltration

10.1. Detecting HTTP POST Requests

Purpose: Identify HTTP POST requests that may be used for data exfiltration.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" |  Where-Object {($_.Message -match "POST") -and ($_.Message -match "http")} | Select-Object TimeCreated, @{n='URL';e={$_.Message -match 'URL: (.*)' -replace 'URL: '}}

10.2. Monitoring Web Uploads

Purpose: Detect uploads via web forms or other HTTP/S methods.

Get-WinEvent -LogName "Microsoft-Windows-Security-Auditing" |  Where-Object {($_.Message -match "Upload") -and ($_.Message -match "http")} | Select-Object TimeCreated, @{n='URL';e={$_.Message -match 'URL: (.*)' -replace 'URL: '}}
PreviousCommand & Control (C2) DiscoveryNextImpact Discovery

Last updated 4 months ago