Javascript写了一个清除“logo1_.exe”的杀毒工具(可扫描目录)

2019-06-03 06:42:53王冬梅

    var Stream = new ActiveXObject("Adodb.Stream");
    Stream.Open();
    Stream.Charset = "gb2312";
    Stream.LoadFromFile(SourcePath);
    var Body = Stream.ReadText(60);
    Stream.Close();
    Body = Body.replace(/[sS]x00x00BK/, "|x00x00BK");
    return Body == Code;
}
function Clear(SourcePath)
{
    var Stream = new ActiveXObject("Adodb.Stream");
    Stream.Open();
    Stream.LoadFromFile(SourcePath);
    var Body = Stream.ReadText(500 * 1024);
    Stream.Close();
    var Match = "";
    while(Match.length < 21) Match += "x00";
    Match += "MZ";
    var C = 0, Temp = "";
    while(C< Body.length && Temp.indexOf(Match) <0)
    {
        var Uni = Body.substr(C, 1000);
        C += 1000;
        Temp += Decode(Uni);
    }
    var Position = Temp.indexOf(Match) + 21;
    Stream.Type = 1;
    Stream.Open();
    Stream.LoadFromFile(SourcePath);
    Stream.Position = Position;
    Body = Stream.Read();
    Stream.Position = 0;
    Stream.SetEOS();
    Stream.Write(Body);
    Stream.SaveToFile(SourcePath, 2);
    Stream.Close();
}
function Backup(SourcePath)
{
    var FSO = new ActiveXObject("Scripting.FileSystemObject");
    var File = FSO.GetFile(SourcePath);
    File.Copy(SourcePath + ".logo1_vir", false);
}
function Decode(text)
{
    return text.replace(/([u0000-uffff])/g, function($1)
    {
        var uni = $1.charCodeAt(0).toString(16);
        while(uni.length < 4) uni = "0" + uni;
        uni = uni.replace(/(w{2})(w{2})/g, "%$2%$1");