🔏
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
  • Pre-Incident Preparation
  • Incident Detection and Initial Assessment
  • Containment (Short-Term)
Edit on GitHub
  1. DFIR
  2. Playbooks
  3. First Responder DFIR Playbook

Device Isolation

Pre-Incident Preparation

Environment Familiarisation

Get-CimInstance Win32_OperatingSystem | Select-Object @{N='Name';E={$_.CSName}},@{N='OS';E={$_.Caption}},@{N='Version';E={$_.Version}},@{N='Build';E={$_.BuildNumber}},@{N='InstallDate';E={$_.InstallDate}},@{N='LastBoot';E={$_.LastBootUpTime}},@{N='FreeMemoryMB';E={[math]::Round($_.FreePhysicalMemory/1024,2)}} | Export-Csv "C:\Inventory\device_$(Get-Date -Format 'yyyyMMdd_HHmmss').csv" -NoTypeInformation
Get-CimInstance Win32_NetworkAdapterConfiguration -Filter "IPEnabled = TRUE" | Select-Object @{N='Adapter';E={$_.Description}},@{N='IPAddress';E={($_.IPAddress -join ', ')}},@{N='Subnet';E={($_.IPSubnet -join ', ')}},@{N='Gateway';E={($_.DefaultIPGateway -join ', ')}},@{N='MAC';E={$_.MACAddress}},@{N='DHCP';E={$_.DHCPEnabled}},@{N='DNSServers';E={($_.DNSServerSearchOrder -join ', ')}} | Export-Csv "C:\Inventory\ip_details_$(Get-Date -Format 'yyyyMMdd_HHmmss').csv" -NoTypeInformation
DeviceNetworkEvents
| where TimeGenerated > ago(30d)
| summarize ConnectedIPs = make_set(RemoteIP), Protocols = make_set(Protocol), EventCount = count() by DeviceName, LocalIP
| project DeviceName, LocalIP, ConnectedIPs, Protocols, EventCount

DeviceNetworkEvents
| where TimeGenerated > ago(30d)
| summarize ConnectedIPs = make_set(RemoteIP), Protocols = make_set(Protocol), ConnectionCount = count() by DeviceName, LocalIP
| project DeviceName, LocalIP, ConnectedIPs, Protocols, ConnectionCount

Incident Detection and Initial Assessment

Detection Triggers

SecurityEvent
| where EventID in (4624, 4625, 4672, 4688) // Common security-related Event IDs
| project TimeGenerated, Account, EventID, Activity, Computer, IpAddress
| order by TimeGenerated desc
index=windows sourcetype="WinEventLog:Security" EventCode IN (4624, 4625, 4672, 4688)
| table _time, user, EventCode, action, host, src_ip
| sort - _time

Scope Assessment

DeviceProcessEvents
| where FileName == "svch0st.exe"
| summarize AffectedHosts = dcount(DeviceName), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), ProcessCount = count(), AffectedHostsList = make_set(DeviceName) by FileName
index=edr process_name="svch0st.exe"
| stats dc(host) as AffectedHosts, earliest(_time) as FirstSeen, latest(_time) as LastSeen, count as ProcessCount, values(host) as AffectedHostsList by process_name

Containment (Short-Term)

Network-Level Containment

Isolate a Device Using the Defender Live Response Console

  1. Initiate Live Response Session

    Click Go Hunt → Initiate Live Response session.

  2. Isolate the Device

    In the Live Response console, enter:

    isolate

    To verify isolation status:

    isolationstatus
  3. (Optional) Release Isolation

    To reconnect the device:

    release

Steps to Isolate a Device Using Live Response in Microsoft Defender

  1. Start a Live Response Session:

    • On the device’s page, look for the ellipsis (...) in the top-right corner of the Response Actions section.

    • Select Initiate Live Response Session (you might need to expand "Advanced actions" depending on your UI version).

    • Confirm the action if prompted. Once the session starts, a command-line interface (CLI) will appear in the portal with a prompt like Connected to <DeviceName>.

  2. Execute Commands to Isolate the Device:

    • In the Live Response CLI, you’ll manually disable network connectivity to isolate the device. Since Live Response supports PowerShell, you can run a command to disable all active network adapters:

      run powershell.exe -Command "Get-NetAdapter | Where-Object { $_.Status -eq 'Up' } | Disable-NetAdapter -Confirm:$false"
      • What this does:

        • Get-NetAdapter: Lists all network adapters on the device.

        • Where-Object { $_.Status -eq 'Up' }: Filters for only active adapters.

        • Disable-NetAdapter -Confirm:$false: Disables them without prompting.

      • Result: The device loses network connectivity, but Defender’s cloud communication typically persists due to its low-level sensor exceptions.

  3. Verify the Isolation:

    • Check the network adapter status to confirm:

      run powershell.exe -Command "Get-NetAdapter | Select-Object Name, Status | Out-File C:\temp\netstatus.txt"
      • This saves the adapter status to a file on the device.

    • Retrieve the file to review:

      getfile C:\temp\netstatus.txt
      • The output should show all adapters as "Disabled" (except possibly virtual adapters used by Defender).

    • Alternatively, test connectivity:

      run cmd.exe -Command "ping 8.8.8.8"
      • If isolated, this should fail or timeout.

  4. End the Live Response Session:

    • Once you’ve confirmed isolation, type:

      exit
      • Or click Disconnect Session in the portal UI to close the session.

Optional: Use a Pre-Uploaded ScriptFor efficiency or reusability, you can upload a PowerShell script to the Live Response library beforehand:

  • Go to Settings > Endpoints > Live Response > Library > Upload File.

  • Upload this script (e.g., isolate_device.ps1):

    # Isolate device by disabling network adapters
    Get-NetAdapter | Where-Object { $_.Status -eq "Up" } | Disable-NetAdapter -Confirm:$false
    Write-Output "Device isolated - network adapters disabled."
  • In the Live Response session, run it:

    run isolate_device.ps1
New-NetFirewallRule -DisplayName "BlockC2" -RemoteAddress 203.0.113.5 -Action Block

PowerShell Function: Isolate-Devicepowershell

function Isolate-Device {
    param (
        [string]$DeviceName
    )

    try {
        Invoke-Command -ComputerName $DeviceName -ScriptBlock {
            # Get all active network adapters
            $adapters = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' }
            if ($adapters) {
                # Collect the names of the active adapters
                $adapterNames = $adapters | ForEach-Object { $_.Name }
                # Disable the active adapters without confirmation
                Disable-NetAdapter -Name $adapterNames -Confirm:$false -ErrorAction Stop
                # Log the isolation action in the event log
                Write-EventLog -LogName Application -Source "Windows PowerShell" -EventId 1000 -Message "Device isolated by disabling adapters: $($adapterNames -join ', ')"
            } else {
                # Log if no active adapters were found
                Write-EventLog -LogName Application -Source "Windows PowerShell" -EventId 1000 -Message "No active network adapters found to disable."
            }
        } -ErrorAction Stop
        Write-Host "Successfully isolated device: $DeviceName"
    } catch {
        Write-Error "Failed to isolate device: $DeviceName. Error: $_"
    }
}

How to Use the Script

  1. Run the Script: Ensure you have this function loaded in your PowerShell session (e.g., save it in a .ps1 file and dot-source it, or paste it directly into your session).

  2. Call the Function: Execute the function by providing the target device’s name, like this:powershell

    Isolate-Device -DeviceName "TargetComputerName"

    Replace "TargetComputerName" with the actual name of the device you want to isolate.


PowerShell Function: Enable-Devicepowershell

function Enable-Device {
    param (
        [string]$DeviceName
    )

    try {
        Invoke-Command -ComputerName $DeviceName -ScriptBlock {
            # Get all disabled network adapters
            $adapters = Get-NetAdapter | Where-Object { $_.Status -ne 'Up' }
            if ($adapters) {
                # Collect the names of the disabled adapters
                $adapterNames = $adapters | ForEach-Object { $_.Name }
                # Enable the disabled adapters without confirmation
                Enable-NetAdapter -Name $adapterNames -Confirm:$false -ErrorAction Stop
                # Log the re-enablement action in the event log
                Write-EventLog -LogName Application -Source "Windows PowerShell" -EventId 1001 -Message "Device re-enabled by enabling adapters: $($adapterNames -join ', ')"
            } else {
                # Log if no disabled adapters were found
                Write-EventLog -LogName Application -Source "Windows PowerShell" -EventId 1001 -Message "No disabled network adapters found to enable."
            }
        } -ErrorAction Stop
        Write-Host "Successfully re-enabled device: $DeviceName"
    } catch {
        Write-Error "Failed to re-enable device: $DeviceName. Error: $_"
    }
}

How to Use the Script

  1. Load the Function: Save this script in a .ps1 file (e.g., Enable-Device.ps1) and dot-source it in your PowerShell session (. .\Enable-Device.ps1), or paste it directly into your session.

  2. Run the Function: Execute it by providing the target device’s name:powershell

    Enable-Device -DeviceName "TargetComputerName"

    Replace "TargetComputerName" with the name of the device you want to re-enable.


System-Level Containment

This method assumes remote or local execution capability.

Script: Comprehensive Containment

# Check for admin privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Write-Warning "Run as Administrator required."
    exit
}

# Disable all active network adapters
$adapters = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' }
if ($adapters) {
    $adapterNames = $adapters | ForEach-Object { $_.Name }
    Disable-NetAdapter -Name $adapterNames -Confirm:$false -ErrorAction SilentlyContinue
    Write-Host "Network adapters disabled: $adapterNames"
} else {
    Write-Host "No active adapters found."
}

# Block all outbound and inbound traffic with Windows Firewall
New-NetFirewallRule -DisplayName "Block All Outbound" -Direction Outbound -Action Block -Enabled True
New-NetFirewallRule -DisplayName "Block All Inbound" -Direction Inbound -Action Block -Enabled True
Write-Host "Firewall rules applied to block all traffic."

# Optional: Stop non-essential services (e.g., file sharing)
Stop-Service -Name "Server" -Force -ErrorAction SilentlyContinue
Stop-Service -Name "Workstation" -Force -ErrorAction SilentlyContinue
Write-Host "Stopped non-essential services."

How It Works:

  • Network Adapters: Disables all active adapters, cutting physical network access.

  • Firewall Rules: Blocks all inbound and outbound traffic as a secondary layer, even if adapters are re-enabled.

  • Services: Stops services like "Server" (SMB sharing) and "Workstation" (SMB client) to limit local network interactions.

Usage:

  • Run locally: Save as Contain-System.ps1 and execute in an elevated PowerShell session.

  • Run remotely: Use Invoke-Command -ComputerName "TargetDevice" -ScriptBlock { <script above> } if remoting is still available.

Reversal:

# Re-enable adapters
Enable-NetAdapter -Name (Get-NetAdapter | Where-Object { $_.Status -ne 'Up' } | ForEach-Object { $_.Name }) -Confirm:$false
# Remove firewall rules
Remove-NetFirewallRule -DisplayName "Block All Outbound"
Remove-NetFirewallRule -DisplayName "Block All Inbound"
# Restart services
Start-Service -Name "Server"
Start-Service -Name "Workstation"

3. Windows Firewall for Network ContainmentIf physical adapter control isn’t desired, you can use the Windows Firewall to block all network traffic at the system level.

Steps (via PowerShell):

# Block all traffic
New-NetFirewallRule -DisplayName "Containment Outbound" -Direction Outbound -Action Block -Enabled True
New-NetFirewallRule -DisplayName "Containment Inbound" -Direction Inbound -Action Block -Enabled True

Why This Works:

  • Firewall rules apply system-wide, preventing all network communication regardless of adapter state.

  • Easier to reverse than disabling adapters, as it doesn’t require physical access if remoting is lost.

Reversal:

Remove-NetFirewallRule -DisplayName "Containment Outbound"
Remove-NetFirewallRule -DisplayName "Containment Inbound"

4. Defender Live Response for Containment

You can manually execute commands to isolate a device.

Steps:

  1. Start Live Response:

    Go to the device page in the Defender portal and select Initiate Live Response Session.

  2. Disable Adapters:

    Run:

    run cmd.exe -Command "for /f \"skip=1\" %%a in ('wmic path Win32_NetworkAdapter where \"DeviceEnabled=true\" get DeviceID') do (wmic path Win32_NetworkAdapter where \"DeviceID='%%a'\" call Disable)"
  3. Verify:

    Check status:

    run cmd.exe -Command "wmic path Win32_NetworkAdapter get DeviceID, DeviceEnabled"

Reversal:

Re-enable adapters:

run cmd.exe -Command "for /f \"skip=1\" %%a in ('wmic path Win32_NetworkAdapter get DeviceID') do (wmic path Win32_NetworkAdapter where \"DeviceID='%%a'\" call Enable)"

Command modifies a specific registry key on a Windows system to disable remote desktop (RDP) connections.

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 1

VerificationTo confirm the change:

Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections"

Look for fDenyTSConnections : 1 in the output.

Reversal

To re-enable Remote Desktop:

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0

To fully stop the service:

Stop-Service -Name TermService -Force

Enterprise-Wide Checks

Basic Check:

DeviceFileEvents
| where FileName contains "ransom"
DeviceFileEvents
| where FileName has "ransom" or InitiatingProcessFileName has "ransom"
| where ActionType in ("FileCreated", "FileModified", "FileDeleted", "FileRenamed")
| extend FilePath = tolower(strcat(FolderPath, "\\", FileName))
| summarize 
    EventCount = count(),
    FirstSeen = min(TimeGenerated),
    LastSeen = max(TimeGenerated),
    AffectedDevices = dcount(DeviceName),
    FilePaths = make_set(FilePath),
    InitiatingProcesses = make_set(InitiatingProcessFileName)
    by FileName, ActionType
| where EventCount > 1 or AffectedDevices > 1
| order by LastSeen desc

PreviousFirst Responder DFIR PlaybookNextEvidence Collection

Last updated 3 months ago