經典 U 盤病毒 (如 `Runouce.exe`、`RavMon.exe`、`AutoRun` 類) 特徵:隱藏真實資料夾 (attrib +s+h+r)、釋出同名 `.exe` 偽裝程式、修改註冊表禁用工作管理員/註冊表編輯器/資料夾選項、寫入 `Autorun.inf` 實現雙擊傳播。本文提供經實戰驗證的批次腳本,涵蓋記憶體進程清理、磁碟檔案清除、註冊表修復、屬性恢復,並說明原理與使用注意事項。
@echo off
title U盤病毒專殺與系統修復
color 0A
setlocal enabledelayedexpansion
:: ========== 參數區 (請根據實際病毒特徵修改) ==========
set "VIRUS_EXE=Runouce.exe" :: 病毒主程式檔名
set "VIRUS_PATH=%SystemRoot%\System32\%VIRUS_EXE%" :: 病毒在系統盤路徑
:: 常見變種檔名:RavMon.exe, Kavo.exe, AutoRun.exe, setup.exe, folder.exe, video.exe, photo.exe
:: 如有多個請複製 :KILL_LOOP 區塊並修改變數
:: ========== 1. 終止記憶體殘留進程 ==========
echo [1/5] 正在掃描並終止記憶體中病毒進程 ...
:KILL_LOOP
tasklist /FI "IMAGENAME eq %VIRUS_EXE%" 2>nul | find /I "%VIRUS_EXE%" >nul
if %errorlevel% equ 0 (
taskkill /F /IM "%VIRUS_EXE%" /T >nul 2>&1
timeout /t 1 /nobreak >nul
goto KILL_LOOP
)
echo 病毒進程已清理乾淨。
:: ========== 2. 刪除系統盤病毒主程式 ==========
echo [2/5] 正在刪除系統盤病毒主程式 ...
if exist "%VIRUS_PATH%" (
attrib -R -S -H "%VIRUS_PATH%" 2>nul
del /F /A "%VIRUS_PATH%" 2>nul
if not exist "%VIRUS_PATH%" (echo 已刪除: %VIRUS_PATH%) else (echo 刪除失敗,請手動處理)
) else (
echo 系統盤未發現病毒主程式。
)
:: ========== 3. 清理常見垃圾郵件檔 (根據病毒特徵調整) ==========
echo [3/5] 正在清理病毒投放垃圾檔 ...
for %%f in (
"%ProgramFiles%\Common Files\Microsoft Shared\Stationery\README.EML"
"%ProgramFiles%\Common Files\System\ADO\README.EML"
"%ProgramFiles%\NetMeeting\README.EML"
) do (
if exist "%%f" (
attrib -R -S -H "%%f" 2>nul
del /F /A "%%f" 2>nul
echo 已刪除: %%f
)
)
:: ========== 4. 修復註冊表被禁用項 ==========
echo [4/5] 正在修復註冊表 (工作管理員、註冊表編輯器、資料夾選項) ...
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v DisableTaskMgr /f >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v DisableRegistryTools /f >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoFolderOptions /f >nul 2>&1
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v Runonce /f >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v Runonce /f >nul 2>&1
echo 註冊表修復完成。
:: ========== 5. 恢復 U 盤隱藏資料夾屬性 ==========
echo [5/5] 正在恢復所有可移動磁碟隱藏資料夾 ...
for %%d in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist "%%d:\" (
echo 處理 %%d: ...
attrib -S -H -R /S /D "%%d:\*.*" 2>nul
:: 刪除 Autorun.inf
if exist "%%d:\Autorun.inf" (
attrib -R -S -H "%%d:\Autorun.inf" 2>nul
del /F /A "%%d:\Autorun.inf" 2>nul
echo 已刪除 Autorun.inf
)
:: 免疫:建立唯讀 Autorun.inf 資料夾防止再感染
if not exist "%%d:\Autorun.inf\" (
mkdir "%%d:\Autorun.inf" 2>nul
attrib +R +S +H "%%d:\Autorun.inf" 2>nul
echo 已建立免疫 Autorun.inf 資料夾
)
)
)
echo.
echo ==========================================
echo 全部完成!請檢查 U 盤資料夾是否恢復顯示。
echo 若仍有異常,請進安全模式重執行或使用專殺工具。
echo ==========================================
pause
| 階段 | 關鍵指令 | 作用 |
|---|---|---|
| 殺進程 | tasklist + find + taskkill /F /IM /T | 遞迴終止病毒進程樹,防止檔案被鎖定無法刪除 |
| 刪主程式 | attrib -R -S -H + del /F /A | 移除系統/隱藏/唯讀屬性後強制刪除 |
| 清垃圾檔 | 遍歷已知路徑 del | 清除病毒投放的干擾檔案 |
| 修註冊表 | reg delete /f | 恢復工作管理員、註冊表編輯器、資料夾選項,刪除開機自啟鍵值 |
| 恢復屬性/免疫 | attrib -S -H -R /S /D + mkdir Autorun.inf + attrib +R+S+H | 遞迴恢復所有資料夾屬性,建立免疫資料夾阻擋 Autorun.inf 創建 |
# 需管理員權限執行
$virusExe = 'Runouce.exe'
$virusPath = "$env:SystemRoot\System32\$virusExe"
# 1. 殺進程
Get-Process -Name $virusExe.Replace('.exe','') -ErrorAction SilentlyContinue | Stop-Process -Force
# 2. 刪主程式
if (Test-Path $virusPath) { Remove-Item -Path $virusPath -Force -ErrorAction SilentlyContinue }
# 3. 清垃圾
@(
"${env:ProgramFiles}\Common Files\Microsoft Shared\Stationery\README.EML"
"${env:ProgramFiles}\Common Files\System\ADO\README.EML"
"${env:ProgramFiles}\NetMeeting\README.EML"
) | ForEach-Object { if (Test-Path $_) { Remove-Item -Path $_ -Force } }
# 4. 修註冊表
@(
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr'
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools'
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoFolderOptions'
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Runonce'
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run\Runonce'
) | ForEach-Object { if (Test-Path $_) { Remove-ItemProperty -Path (Split-Path $_ -Parent) -Name (Split-Path $_ -Leaf) -Force } }
# 5. 恢復可移動磁碟屬性 + 免疫
Get-PSDrive -PSProvider FileSystem | Where-Object { $_.DisplayRoot -match '^[D-Z]:$' } | ForEach-Object {
$drive = $_.Root
Write-Host "處理 $drive ..."
# 恢復屬性
Get-ChildItem -Path $drive -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object {
if ($_.Attributes -band [IO.FileAttributes]::Hidden -or $_.Attributes -band [IO.FileAttributes]::System -or $_.Attributes -band [IO.FileAttributes]::ReadOnly) {
$_.Attributes = [IO.FileAttributes]::Normal
}
}
# 刪除/免疫 Autorun.inf
$autorunFile = Join-Path $drive 'Autorun.inf'
$autorunDir = Join-Path $drive 'Autorun.inf\'
if (Test-Path $autorunFile) { Remove-Item -Path $autorunFile -Force }
if (-not (Test-Path $autorunDir)) { New-Item -Path $autorunDir -ItemType Directory -Force | Out-Null; (Get-Item $autorunDir).Attributes = 'ReadOnly,Hidden,System' }
}
Write-Host "完成!"
批次腳本輕量無依賴、兼容 XP 以上所有 Windows;PowerShell 版物件化、錯誤處理更優雅、支援遠程執行。視環境選擇,配合殺毒軟體,U 盤病毒不再是噩夢。