Quarantine and Remediation Procedures
Quarantine and Remediation Procedures
Effective malware response requires proper quarantine and remediation procedures preventing spread while preserving evidence for analysis. Automated remediation must balance aggressive threat removal with avoiding system damage from false positives. Establish clear procedures for different threat severity levels.
Windows Defender quarantine management through PowerShell enables centralized control:
# Review quarantined items
Get-MpThreatDetection | Where-Object {$_.ThreatStatusID -eq 2}
# Restore false positives
$threat = Get-MpThreat | Where-Object {$_.ThreatName -eq "FalsePositive"}
Remove-MpThreat -ThreatID $threat.ThreatID
# Export quarantine for analysis
$quarantinePath = "$env:ProgramData\Microsoft\Windows Defender\Quarantine"
Copy-Item -Path $quarantinePath -Destination "\\forensics\quarantine" -Recurse
Linux quarantine procedures vary by antivirus solution. Implement custom quarantine with proper permissions:
#!/bin/bash
# Custom quarantine script
QUARANTINE_DIR="/var/quarantine"
mkdir -p "$QUARANTINE_DIR"
chmod 700 "$QUARANTINE_DIR"
quarantine_file() {
local infected_file="$1"
local timestamp=$(date +%Y%m%d_%H%M%S)
local quarantine_name="${timestamp}_$(basename "$infected_file").infected"
# Preserve metadata
getfacl "$infected_file" > "$QUARANTINE_DIR/${quarantine_name}.acl"
stat "$infected_file" > "$QUARANTINE_DIR/${quarantine_name}.stat"
# Move with restricted permissions
mv "$infected_file" "$QUARANTINE_DIR/$quarantine_name"
chmod 000 "$QUARANTINE_DIR/$quarantine_name"
echo "Quarantined: $infected_file -> $QUARANTINE_DIR/$quarantine_name" | logger
}
Remediation strategies depend on threat type and system criticality. For ransomware, immediate isolation prevents spread:
# Automated ransomware response
$ransomwareIndicators = @("*.encrypted", "*.locked", "HELP_DECRYPT.*")
$suspiciousProcesses = Get-Process | Where-Object {$_.Path -match "AppData\\Local\\Temp"}
foreach ($process in $suspiciousProcesses) {
Stop-Process -Id $process.Id -Force
Disable-NetAdapter -Name * -Confirm:$false # Network isolation
Send-MailMessage -To "[email protected]" -Subject "Ransomware Alert" -Body "Potential ransomware detected on $env:COMPUTERNAME"
}