| Write-Host "`n--- 1) Kiểm tra hosts file (tìm 'kms') ---" -ForegroundColor Cyan | |
| $hosts = Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -ErrorAction SilentlyContinue | |
| if ($hosts -match 'kms') { | |
| $hosts | Select-String -Pattern 'kms' | |
| } else { | |
| Write-Host "No kms entries in hosts file." | |
| } | |
| Write-Host "`n--- 2) Kiểm tra scheduled tasks có chứa 'activate|aio|office|kms' ---" -ForegroundColor Cyan | |
| $tasks = Get-ScheduledTask | Where-Object { $_.TaskName -match 'activate|aio|office|kms' -or $_.TaskPath -match 'activate|aio|office|kms' } | |
| if ($tasks) { | |
| $tasks | Format-Table TaskName, @{n='Path';e={$_.TaskPath}}, State -AutoSize | |
| } else { | |
| Write-Host "No suspicious scheduled tasks found." | |
| } | |
| Write-Host "`n--- 3) Kiểm tra service sppsvc (Software Protection) ---" -ForegroundColor Cyan | |
| Get-Service -Name sppsvc -ErrorAction SilentlyContinue | Format-List Name, Status, StartType | |
| Write-Host "`n--- 4) Tìm file OSPP.VBS trong hệ thống (report only) ---" -ForegroundColor Cyan | |
| Get-ChildItem -Path "C:\Users\*" -Filter OSPP.VBS -Recurse -ErrorAction SilentlyContinue | Select-Object FullName | |
| Get-ChildItem -Path "C:\Program Files*" -Filter OSPP.VBS -Recurse -ErrorAction SilentlyContinue | Select-Object FullName | |
| Write-Host "`n--- 5) Tìm chuỗi 'kms' trong registry (chỉ các chỗ phổ biến) ---" -ForegroundColor Cyan | |
| $pathsToCheck = @( | |
| "HKLM:\SOFTWARE", | |
| "HKLM:\SOFTWARE\WOW6432Node", | |
| "HKLM:\SYSTEM\CurrentControlSet\Services" | |
| ) | |
| foreach ($p in $pathsToCheck) { | |
| try { | |
| Get-ChildItem -Path $p -Recurse -ErrorAction SilentlyContinue | ForEach-Object { | |
| $props = Get-ItemProperty -Path $_.PSPath -ErrorAction SilentlyContinue | |
| if ($props) { | |
| foreach ($prop in $props.PSObject.Properties) { | |
| $val = $prop.Value | |
| if ($val -and ($val -is [string]) -and ($val -match 'kms|kms\.srv|crsoo')) { | |
| Write-Output "Found in Registry Path: $($_.PSPath) | Property: $($prop.Name) | Value: $val" | |
| } | |
| } | |
| } | |
| } | |
| } catch { | |
| # ignore permission errors | |
| } | |
| } | |
| Write-Host "`n--- 6) Kiểm tra trạng thái Office (nếu có OSPP.VBS) ---" -ForegroundColor Cyan | |
| $ospp = Get-ChildItem -Path "C:\Program Files","C:\Program Files (x86)" -Filter OSPP.VBS -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 | |
| if ($ospp) { | |
| Write-Host "Found OSPP.VBS at: $($ospp.FullName)" | |
| Write-Host "Nếu muốn kiểm tra trạng thái: cd tới thư mục đó rồi chạy `cscript OSPP.VBS /dstatus`" | |
| } else { | |
| Write-Host "No OSPP.VBS found in Program Files (official location)." | |
| } | |
| Write-Host "`n--- End of report ---" -ForegroundColor Green | |