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" -NoTypeInformationGet-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" -NoTypeInformationDeviceNetworkEvents
| where TimeGenerated > ago(30d)
| summarize ConnectedIPs = make_set(RemoteIP), Protocols = make_set(Protocol), EventCount = count() by DeviceName, LocalIP
| project DeviceName, LocalIP, ConnectedIPs, Protocols, EventCountDeviceNetworkEvents
| where TimeGenerated > ago(30d)
| summarize ConnectedIPs = make_set(RemoteIP), Protocols = make_set(Protocol), ConnectionCount = count() by DeviceName, LocalIP
| project DeviceName, LocalIP, ConnectedIPs, Protocols, ConnectionCountIncident 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 descindex=windows sourcetype="WinEventLog:Security" EventCode IN (4624, 4625, 4672, 4688)
| table _time, user, EventCode, action, host, src_ip
| sort - _timeScope Assessment
DeviceProcessEvents
| where FileName == "svch0st.exe"
| summarize AffectedHosts = dcount(DeviceName), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), ProcessCount = count(), AffectedHostsList = make_set(DeviceName) by FileNameindex=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_nameContainment (Short-Term)
Network-Level Containment
Steps to Isolate a Device Using Live Response in Microsoft Defender
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>.
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:
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.
Verify the Isolation:
Check the network adapter status to confirm:
This saves the adapter status to a file on the device.
Retrieve the file to review:
The output should show all adapters as "Disabled" (except possibly virtual adapters used by Defender).
Alternatively, test connectivity:
If isolated, this should fail or timeout.
End the Live Response Session:
Once you’ve confirmed isolation, type:
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):
In the Live Response session, run it:
PowerShell Function: Isolate-Devicepowershell
How to Use the Script
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).
Call the Function: Execute the function by providing the target device’s name, like this:powershell
Replace "TargetComputerName" with the actual name of the device you want to isolate.
PowerShell Function: Enable-Devicepowershell
How to Use the Script
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.
Run the Function: Execute it by providing the target device’s name:powershell
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
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:
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):
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:
4. Defender Live Response for Containment
You can manually execute commands to isolate a device.
Steps:
Start Live Response:
Go to the device page in the Defender portal and select Initiate Live Response Session.
Disable Adapters:
Run:
Verify:
Check status:
Reversal:
Re-enable adapters:
Command modifies a specific registry key on a Windows system to disable remote desktop (RDP) connections.
VerificationTo confirm the change:
Look for fDenyTSConnections : 1 in the output.
Reversal
To re-enable Remote Desktop:
To fully stop the service:
Enterprise-Wide Checks
Basic Check:
Last updated