徐亞非
【摘 要】本文對批處理查殺Autorun病毒這一問題進行了分析闡述。
【關(guān)鍵詞】批處理 查殺 Autorun病毒
Autorun病毒又名U盤病毒。U盤病毒主要依賴于U盤等移動存儲設(shè)備生存,當用戶從網(wǎng)上下載文件并拷貝到U盤時便可能中了U盤病毒,當用戶雙擊U盤盤符時,便啟動了隱藏了的Autorun.inf等系統(tǒng)文件,能在U盤和電腦的各個分區(qū)下生成病毒本體和Autorun.inf,并向系統(tǒng)和注冊表寫入監(jiān)控、免殺等主體文件。Autorun.inf是一個安裝信息文件,通過它可以實現(xiàn)移動設(shè)備的自動運行。
其文檔大約格式為:
[autorun]
Open=病毒.exe?
Shellexecute=病毒.exe?
Shell\Open\command=病毒.exe?
Shell\Explore\command=病毒.exe?
原理:Autorun病毒能夠通過自動播放而達到傳播自身的目的,但目前符合要求的可執(zhí)行文件后綴有.pif .com .exe .bat .vbs;病毒為了達到隱藏自己的目的,通常給Autorun.inf和病毒主體文件添加隱藏屬性(H)、只讀屬性(R)、系統(tǒng)屬性(S)中的幾種,并且通過修改注冊表讓用戶無法查看隱藏文件,即使在文件夾選項里選擇“顯示隱藏的文件和文件夾”和取消“隱藏受保護的操作系統(tǒng)文件(推薦)”也不能看到隱藏的文件即使看到了也刪除不掉,因為帶有多重屬性,必須在命令下查看和操作。因此根據(jù)以上信息可以編寫殺毒用的批處理,如下所示:
@echo off
ping 127.0.0.1 -n 6
::這里起到延遲的效果,目的是等待用戶的移動設(shè)備被電腦完全識別。
dir d:
if %errorlevel%==0 (goto a) else goto b
:a
d:
call :shadu&&call :help&&call :sos
:b
dir e:
if %errorlevel%==0 (goto c) else goto d
:c
e:
call :shadu&&call :help&&call :sos
:d
dir f:
if %errorlevel%==0 (goto e) else goto f
:e
f:
call :shadu&&call :help&&call :sos
:f
dir g:
if %errorlevel%==0 (goto g) else goto h
:g
g:
call :shadu&&call :help&&call :sos
:h
dir h:
if %errorlevel%==0 (goto i) else goto j
:i
h:
call :shadu&&call :help&&call :sos
:j
pause
exit
goto :one
:shadu
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=*" %%a in ('dir/a-d/b/oe') do set/a c+=1&set a!c!=%%a&set b!c!=%%~za&set c!c!=%%~xa
for /l %%a in (1,1,%c%) do set/a d=%%a+1&for /l %%b in (!d!,1,%c%) do if not !b%%a!.==. call :1 %%a %%b
goto :eof
:1
if !b%1!==!b%2! if !c%1!==!c%2! set b%2=&attrib "!a%2!" -r -h -s &attrib "!a%1!" -r -h -s &del "!a%2!" "!a%1!"
goto :eof
goto :one
goto :eof
:help
del *.exe/a:shr&&del *.exe/a:sh&&del *.exe/a:hr&&del *.exe/a:sr del *.exe/a:h&&del *.pif/a:shr&&del *.pif/a:sh&&del *.pif/a:hr&&del *.pif/a:sr&&del *.pif/a:h&&del *.com/a:shr&&del *.com/a:sh&&del *.com/a:hr&&del *.com/a:sr&&del *.com/a:h&&del *.bat/a:shr&&del *.bat/a:sh&&del *.bat/a:hr&&del *.bat/a:sr&&del *.bat/a:h&&del *.vbs/a:shr&&del *.vbs/a:sh&&del *.vbs/a:hr&&del *.vbs/a:sr&&del *.vbs/a:h&&del *.scr/a:shr&&del *.scr/a:sh&&del *.scr/a:hr&&del *.scr/a:sr&&del *.scr/a:h&&Rd RECYCLER/s/q
goto :eof
goto :eof
:sos
if exist autorun.inf if not exist autorun.inf\nul ( for /f "usebackq tokens=1* delims==" %%j in ("autorun.inf") do if not "%%k"=="" ( del /f /a "%%k" )) &&attrib autorun.inf -s -h -r&&del autorun.inf
goto :eof
保存為:U盤病毒專殺.bat,當U盤插入后在電腦上完全識別了就雙擊這個批處理,它就會自動執(zhí)行刪除病毒文件。程序只列舉到H盤,用戶可根據(jù)自己需要按規(guī)律自行添加多余的盤符。當用戶U盤里中了文件夾類的病毒后,病毒就會把所有的文件夾都隱藏掉,上面的批處理雖然能查殺這類病毒但是沒有解決病毒留下的后遺癥:用戶無法找到自己以前的文件夾了!所以下面的這個配套批處理能夠很好的做到這一點:
@echo off
Echo請輸入所需顯示被隱藏文件的盤符:&&Set /p panfu=請輸入盤符,如(D):
dir %panfu%:\&&if %errorlevel%==0 (goto 1) else goto 2
:1
%panfu%:&&echo正在顯示所有文件,請稍等...&&attrib *.* /s /d -s -h -r&&cls&&echo %panfu%盤文件已全部顯示.
:2
Pause
保存為:顯示隱藏文件.bat,當遇到自己的文件或者文件夾找不到的時候,只要是被隱藏了就可以執(zhí)行這個批處理來顯示所有東西。
(作者單位:許昌學(xué)院05級電氣本科一班)