MD-102 Giai đoạn 2 – Defender Module 16
16

Microsoft Defender for Endpoint (MDE)

EDR • Device Onboarding • Threat Hunting • Live Response • Automated Investigation • Security Score

Defender for Endpoint Microsoft Intune MD-102 GĐ2

01 · Lý thuyết

MDE là gì? – EDR vs AV

Microsoft Defender for Endpoint (MDE) là giải pháp EDR (Endpoint Detection and Response) — vượt xa Antivirus truyền thống. Trong khi AV chỉ phát hiện malware đã biết (signature-based), MDE phân tích hành vi để phát hiện tấn công nâng cao (APT).

Tính năngAntivirus (Defender AV)MDE (EDR)
Phát hiện malware✓ Signature-based✓ Signature + Behavioral
Zero-day threatsGiới hạn (cloud protection)✓ ML + behavior analysis
Timeline & investigation✓ 180 ngày device timeline
Threat hunting✓ Advanced Hunting (KQL)
Live Response✓ Remote shell vào thiết bị
Automated Investigation✓ AI tự điều tra & remediate
Vulnerability Management✓ Phát hiện CVE trên thiết bị

MDE Licensing – Plan 1 vs Plan 2

Tính năngMDE Plan 1MDE Plan 2
Next-gen AV
Attack Surface Reduction
EDR (timeline, alerts)
Advanced Hunting
Threat Intelligence
Vulnerability Management✓ (add-on)
Included inM365 Business Premium, A3M365 E5, E5 Security, A5

Onboarding Methods – Cách deploy MDE sensor

Phương phápPhù hợp vớiCơ chế
Intune (recommended)Cloud-managed devicesEndpoint Security policy → MDE onboarding package
Group Policy (GPO)On-premises AD joinedDeploy onboarding script qua GPO
SCCM/ConfigMgrCo-managed environmentsDeploy package qua ConfigMgr
Local scriptOnboard thủ công (lab, test)Chạy WindowsDefenderATPOnboardingScript.cmd trực tiếp
VDI onboardingNon-persistent VDIScript đặc biệt cho VDI environments

Advanced Hunting – Threat Hunting với KQL

Advanced Hunting cho phép security team chủ động tìm kiếm mối đe dọa trong 30 ngày dữ liệu từ tất cả thiết bị, sử dụng ngôn ngữ truy vấn KQL (Kusto Query Language).

Intune + MDE Integration: Khi enable MDE connector trong Intune, device risk level từ MDE tự động trở thành điều kiện trong Compliance Policy. Thiết bị bị MDE phát hiện threat → tự động non-compliant → Conditional Access block truy cập.

02 · Thực hành

Lab A: Onboard thiết bị vào MDE qua Intune

Thực hành tại: intune.microsoft.com → Endpoint security → Microsoft Defender for Endpoint

  1. Vào intune.microsoft.comEndpoint securityMicrosoft Defender for Endpoint
  2. Enable Connect Windows devices... to Microsoft Defender for Endpoint → Save
  3. Tạo Endpoint Security profile: Endpoint detection and response
    Platform: Windows 10 and later → Profile: Endpoint detection and response
  4. Name: MDE-Onboarding-All-Windows
  5. Microsoft Defender for Endpoint client configuration package type: Auto from connector
  6. Sample sharing: All (gửi suspicious files lên Microsoft cloud để phân tích)
  7. Telemetry reporting frequency: Normal
  8. Assign to All Devices → Create
  9. Sau 15–30 phút: thiết bị xuất hiện trong security.microsoft.com → Devices

Lab B: Kết nối MDE với Intune Compliance

Connect-MgGraph -Scopes "DeviceManagementConfiguration.ReadWrite.All" # Tạo Compliance Policy có điều kiện MDE device risk $compliancePolicy = @{ "@odata.type" = "#microsoft.graph.windows10CompliancePolicy" displayName = "Compliance-MDE-RiskBased" description = "Block high-risk devices detected by MDE" deviceThreatProtectionEnabled = $true deviceThreatProtectionRequiredSecurityLevel = "medium" # medium = block nếu MDE phát hiện risk level >= Medium # low = strict hơn, chỉ cho phép thiết bị Low risk } | ConvertTo-Json -Depth 5 $policy = Invoke-MgGraphRequest -Method POST ` -Uri "https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies" ` -Body $compliancePolicy -ContentType "application/json" Write-Host "Policy created: $($policy.id)"
Policy created: compliance-abc123-def456 # Kết quả: # Thiết bị nhận policy → check MDE risk level # MDE risk = None / Low → Compliant → access granted # MDE risk = Medium / High / Critical → Non-compliant → CA block access # IT nhận alert qua security.microsoft.com → investigate → remediate → compliant restored

Lab C: Advanced Hunting – Tìm PowerShell đáng ngờ

// Advanced Hunting query trong security.microsoft.com // Tìm PowerShell processes chạy encoded commands (dấu hiệu obfuscation) DeviceProcessEvents | where Timestamp > ago(7d) | where FileName =~ "powershell.exe" or FileName =~ "pwsh.exe" | where ProcessCommandLine has_any ("-enc", "-encodedcommand", "-e ", "base64") | project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine | order by Timestamp desc | limit 100 // Tìm lateral movement (PsExec, WMI remote execution) DeviceNetworkEvents | where Timestamp > ago(7d) | where RemotePort in (445, 135, 5985, 5986) // SMB, RPC, WinRM | where InitiatingProcessFileName in~ ("psexec.exe","wmic.exe","winrm.cmd") | summarize count() by DeviceName, RemoteIP, InitiatingProcessFileName | order by count_ desc
// Kết quả PowerShell encoded command: Timestamp DeviceName AccountName ProcessCommandLine ------------------- ----------- ----------- ----------------- 2024-03-15 14:22:00 LAPTOP-VT001 nguyen.a powershell.exe -enc JABzACAAPQ... 2024-03-14 09:15:00 LAPTOP-KT005 tran.b pwsh.exe -e SQBuAHYAbwBrAGUA... # ALERT: Đây là dấu hiệu của malware hoặc pentest # Action: Isolate device → Live Response investigation

Lab D: Live Response – Điều tra thiết bị từ xa

// Trong security.microsoft.com → Devices → chọn device → Initiate Live Response // Live Response là remote shell vào thiết bị, chạy command mà không cần RDP // Các lệnh Live Response hữu ích: // Xem processes đang chạy processes // Xem network connections connections // Thu thập file đáng ngờ về để analyze getfile "C:\Users\nguyen.a\AppData\Roaming\Temp\suspicious.exe" // Chạy PowerShell script phân tích run PSScript.ps1 // Quarantine file ngay lập tức remediate file "C:\Users\nguyen.a\AppData\Roaming\Temp\suspicious.exe" // Isolate device khỏi mạng (giữ kết nối MDE) // Trong portal: Device actions → Isolate device
Connected to LAPTOP-VT001 via Live Response User: nguyen.a | OS: Windows 11 22H2 > processes PID Name CPU Memory User ---- ----- --- ------ ----- 4284 suspicious.exe 45% 128MB nguyen.a ← ALERT! ... > getfile "C:\Users\nguyen.a\AppData\Roaming\Temp\suspicious.exe" File collected successfully. Available in Evidence files. > remediate file "C:\...\suspicious.exe" File quarantined successfully. Process terminated.

03 · Tình huống thực tế

Tổng công ty Điện lực EVN – Phát hiện tấn công APT vào hạ tầng quan trọng

EVN phát hiện bất thường: một số máy tính ở trung tâm điều độ có traffic kỳ lạ ban đêm. Không có AV alert nào — malware này bypass signature detection. Đây là điển hình APT (Advanced Persistent Threat) nhắm vào cơ sở hạ tầng quan trọng.

Quy trình điều tra với MDE:

  • Alert triage: MDE alert "Suspicious PowerShell execution" trên 3 máy — medium severity
  • Device Timeline: Trace lại 7 ngày — thấy Excel file mở → macro chạy → PowerShell encoded → C2 connection đêm
  • Advanced Hunting: Tìm tất cả máy có cùng pattern C2 IP → phát hiện 5 máy thêm đã bị compromise
  • Isolate: Immediate isolation 8 máy khỏi mạng (vẫn giữ MDE connection để điều tra)
  • Live Response: Thu thập malware sample, xóa persistence mechanisms (scheduled tasks, registry keys)
  • Root cause: Phishing email với macro-enabled Excel → nâng cấp ASR rules block Office macros toàn hệ thống

Kết quả:

  • • Phát hiện và ngăn chặn APT trong 4 giờ (vs. trung bình 197 ngày theo Ponemon Institute)
  • • Không có hệ thống OT (điều độ điện) nào bị ảnh hưởng — isolation kịp thời
  • • MDE Automated Investigation: tự clean 6/8 máy, chỉ 2 máy cần manual intervention