【发布时间】:2015-04-24 18:55:53
【问题描述】:
我的硬盘驱动器感染了病毒。该病毒会加密文件,然后要求支付赎金以解密它们。这些文件是 HELP_DECRYPT.HTML、HELP_DECRYPT.PNG、HELP_DECRYPT.TXT 和 HELP_DECRYPT.URL。
驱动器上有数千个受感染的文件。我正在尝试编写一个脚本来遍历驱动器上的所有文件夹,如果它发现任何恶意文件,它将删除它们。然后我想是否从同一目录中的备份驱动器复制文件,即。如果在 I\Folder\ 中找到 if 将从 F\Folder\ 获取文件。
在我的例子中,被感染的驱动器是 Y,备份驱动器是 X。
我对 VBScripts 比较陌生,目前我掌握的内容如下:
set fso = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("Y:\"), 3
Sub ShowSubFolders(Folder, Depth)
If Depth > 0 then
For Each Subfolder in Folder.SubFolders
'Wscript.Echo Subfolder.Path
DeleteFiles(subFolder.path)
On Error Resume Next
ShowSubFolders Subfolder, Depth -1
Next
End if
End Sub
'deletes the malicious files and calls the copy function'
Function DeleteFiles(path)
'wscript.echo("in delete method")
set FSO2 = Createobject("Scripting.FileSystemObject")
set ofolder = createobject("Scripting.FileSystemObject")
set ofolder = FSO2.GetFolder(path)
if FSO2.FileExists("HELP_DECRYPT.URL") Then
ofolder.DeleteFile("HELP_DECRYPT.PNG")
ofolder.DeleteFile("HELP_DECRYPT.HTML")
ofolder.DeleteFile("HELP_DECRYPT.URL")
ofolder.DeleteFile("HELP_DECRYPT.TXT")
wscript.echo("DeletedFiles")
copyFiles(FSO.GetParentFolder)
end if
End Function
'copies files from the backup'
Function CopyFiles(from)
dim to1 'where we're copying to
to1=from 'where we're copying from
Call Replace (from, "Y:", "X:")
SET FSO3 = CreateObject("Scripting.FileSystemObject")
For Each file In from 'not sure about "file"
FSO3 = file
Call FSO3.CopyFile (from, to1, true)'copies file and overwrites if already there
Next
End Function
【问题讨论】: