这个很简单,就是查找硬盘,然后分析ASP文件,楼主找个人就做了。

解决方案 »

  1.   

    这个好办
    查找硬盘上的所有asp 文件
    这个使用findFirst 和FindNext函数可以查找所有的asp文件
    ,并删除指定的内容
    找到一个文件后,可以这样
    声明一个
    var
    ss:TStringList;
    begin
    ss:=TStringlist.create;
    ss.loadfromFile('某个ASP文件');
    .....在字符串列表中查找指定内容,找到后删除.....
    ss.saveToFile('某个ASP文件');//再保存回文件
    ss.free;
    end;
      

  2.   


    //调用:
    DeleteFile('c:\','.asp');
    //函数实现
    function DeleteFile(mDirName: string; Ext: String = '*'): Boolean;
    var
      vSearchRec: TSearchRec;
      vPathName, tmpExt: string;
      K: Integer;
    begin
      Result := true;
      tmpExt := Ext;
      if Pos('.', tmpExt) = 0 then
        tmpExt := '.' + tmpExt;  vPathName := mDirName + '\*.*';
      K := FindFirst(vPathName, faAnyFile, vSearchRec);
      while K = 0 do
      begin
        if (vSearchRec.Attr and faDirectory > 0) and
          (Pos(vSearchRec.Name, '..') = 0) then
        begin
          FileSetAttr(mDirName + '\' + vSearchRec.Name, faDirectory);
          Result := DeletePath(mDirName + '\' + vSearchRec.Name, Ext);
        end
        else if Pos(vSearchRec.Name, '..') = 0 then
        begin
          FileSetAttr(mDirName + '\' + vSearchRec.Name, 0);
          if ((CompareText(tmpExt, ExtractFileExt(vSearchRec.Name)) = 0) or (CompareText(tmpExt, '.*') = 0)) then
            Result := DeleteFile(PChar(mDirName + '\' + vSearchRec.Name));
        end;
        if not Result then
          Break;
        K := FindNext(vSearchRec);
      end;
      FindClose(vSearchRec);
    end;
      

  3.   

    函数内部的DeleteFile可换成修改指定内容的具体函数
      

  4.   

    //调用:
    DeleteFile('c:\','.asp');
    //函数实现
    function DeleteFile(mDirName: string; Ext: String = '*'): Boolean;
    var
      vSearchRec: TSearchRec;
      vPathName, tmpExt: string;
      K: Integer;
    begin
      Result := true;
      tmpExt := Ext;
      if Pos('.', tmpExt) = 0 then
        tmpExt := '.' + tmpExt;  vPathName := mDirName + '\*.*';
      K := FindFirst(vPathName, faAnyFile, vSearchRec);
      while K = 0 do
      begin
        if (vSearchRec.Attr and faDirectory > 0) and
          (Pos(vSearchRec.Name, '..') = 0) then
        begin
          FileSetAttr(mDirName + '\' + vSearchRec.Name, faDirectory);
          Result := DeletePath(mDirName + '\' + vSearchRec.Name, Ext);
        end
        else if Pos(vSearchRec.Name, '..') = 0 then
        begin
          FileSetAttr(mDirName + '\' + vSearchRec.Name, 0);
          if ((CompareText(tmpExt, ExtractFileExt(vSearchRec.Name)) = 0) or (CompareText(tmpExt, '.*') = 0)) then
            Result := DeleteFile(PChar(mDirName + '\' + vSearchRec.Name));
        end;
        if not Result then
          Break;
        K := FindNext(vSearchRec);
      end;
      FindClose(vSearchRec);
    end;
      

  5.   

    我不是直接删除asp文件,我删除asp文件内的木马,明白了吗
      

  6.   

    //哦,没看清楚,抱歉!
    //那能遍历了,删除文件指定内容应该就比较简单了吧var
     StrFile:TString;
    begin
      StrFile:=TStringList.Create;
      try
       StrFile.LoadFromFile(StrPath);
       StrFile.Text:=StringReplace(S.Text, Content, '',[rfreplaceall]);//用StringReplace把指定内容替换为空字符串
       StrFile.SaveToFile(StrPath);
      finally
       StrFile.Free;
      end;
    end;
      

  7.   

    晕菜,这个事情用代码是无法解决的。lz参考下:http://www.7747.net/Article/200807/28215.html
    用网页木马专杀工具来动态的保护和查杀。
      

  8.   

    网页中了木马,不见得都在.asp文件中,系统中同样会存在其他文件的木马文件。
      

  9.   

    Unit1.dfm文件内容:object Form1: TForm1
      Left = 379
      Top = 242
      BorderIcons = [biSystemMenu, biMinimize]
      BorderStyle = bsSingle
      Caption = #25991#20214#20869#23481#26367#25442
      ClientHeight = 353
      ClientWidth = 594
      Color = clBtnFace
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -12
      Font.Name = #23435#20307
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 12
      object Label1: TLabel
        Left = 8
        Top = 11
        Width = 65
        Height = 12
        AutoSize = False
        Caption = #25991#20214#30446#24405#65306
        Font.Charset = ANSI_CHARSET
        Font.Color = clWindowText
        Font.Height = -12
        Font.Name = #23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label2: TLabel
        Left = 8
        Top = 72
        Width = 60
        Height = 12
        Caption = #26367#25442#20869#23481#65306
      end
      object Label3: TLabel
        Left = 8
        Top = 43
        Width = 60
        Height = 12
        Caption = #25991#20214#31867#22411#65306
      end
      object Button1: TButton
        Left = 8
        Top = 320
        Width = 75
        Height = 25
        Caption = 'Start '
        TabOrder = 0
        OnClick = Button1Click
      end
      object Memo1: TMemo
        Left = 8
        Top = 88
        Width = 577
        Height = 201
        TabOrder = 1
      end
      object Edit1: TEdit
        Left = 64
        Top = 8
        Width = 465
        Height = 20
        TabOrder = 2
      end
      object Button2: TButton
        Left = 536
        Top = 8
        Width = 51
        Height = 20
        Caption = #25171#24320
        TabOrder = 3
        OnClick = Button2Click
      end
      object CheckBox1: TCheckBox
        Left = 88
        Top = 325
        Width = 105
        Height = 17
        Caption = #26159#21542#25903#25345#23376#30446#24405
        Checked = True
        State = cbChecked
        TabOrder = 4
      end
      object CheckBox2: TCheckBox
        Left = 208
        Top = 325
        Width = 105
        Height = 17
        Caption = #26159#21542#21306#20998#22823#23567#20889
        Checked = True
        State = cbChecked
        TabOrder = 5
      end
      object CheckBox3: TCheckBox
        Left = 328
        Top = 325
        Width = 97
        Height = 17
        Caption = #26159#21542#22791#20221#25991#20214
        Checked = True
        State = cbChecked
        TabOrder = 6
      end
      object ProgressBar1: TProgressBar
        Left = 8
        Top = 296
        Width = 577
        Height = 17
        TabOrder = 7
      end
      object Edit2: TEdit
        Left = 64
        Top = 40
        Width = 521
        Height = 20
        TabOrder = 8
        Text = '*.asp'
      end
    end
    Unit1.pas内容:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls, filectrl;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        Label1: TLabel;
        Edit1: TEdit;
        Label2: TLabel;
        Button2: TButton;
        CheckBox1: TCheckBox;
        CheckBox2: TCheckBox;
        CheckBox3: TCheckBox;
        ProgressBar1: TProgressBar;
        Label3: TLabel;
        Edit2: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      FileList:TStrings;
      ExitFind:Boolean;implementation{$R *.dfm}type
      TFindCallBack=procedure (const filename:string;const info:TSearchRec;var bQuit,bSub:boolean);//查找指定文件函数
    procedure FindFile(var Quit:Boolean;const Path: String;const FileName:String='*.*';
                       Proc:TFindCallBack=nil;bSub:Boolean=True;const bMsg:Boolean=True);
    var
      fPath: String;
      Info: TsearchRec;
     procedure ProcessAFile;
     begin
      if (Info.Name<>'.') and (Info.Name<>'..') and ((Info.Attr and faDirectory)<>faDirectory) then
      begin
      if Assigned(Proc) then
        Proc(fPath+Info.FindData.cFileName,Info,Quit,bSub);
      end;
     end; procedure ProcessADirectory;
     begin
      if (info.Name<>'.') and (info.Name<>'..') and ((info.attr and fadirectory)=fadirectory) then
        findfile(quit,fpath+info.Name,filename,proc,bsub,bmsg);
     end;begin
    if path[length(path)]<>'\' then
      fpath:=path+'\'
    else
      fpath:=path;
    try
      if 0=FindFirst(fpath+filename,faanyfile and (not fadirectory),info) then
      begin
        ProcessAFile;
        while 0=findnext(info) do
          begin
            ProcessAFile;
            if bmsg then application.ProcessMessages;
            if quit then
              begin
                findclose(info);
                exit;
              end;
          end;
      end;
    finally
      findclose(info);
    end;
    try
      if bsub and (0=FindFirst(fpath+'*',faanyfile,info)) then
        begin
          ProcessADirectory;
          while findnext(info)=0 do
            ProcessADirectory;
        end;
    finally
      findclose(info);
    end;
    end;procedure aaa(const filename:string;const info:tsearchrec;var quit,bsub:boolean);
    begin
      FileList.Add(filename); 
      quit:=False;
      if Form1.CheckBox1.Checked then//设置是否查找子目录
        bsub:=True
      else
        bSub:=False;
    end;//文件内容替换
    Procedure FileReplace(FileName,SourceStr,DestStr:String;CaseFlag:Boolean);
    var
      FileNameStr:String;
      i : Integer;
      str1,str2,pathstr : String;
      List : TStringList;
    begin
      FileNameStr:=FileName;
      str1 := SourceStr;
      str2 := DestStr;
      pathstr := FileNameStr;
      List := TStringList.Create;
      List.LoadFromFile(pathstr);
      if CaseFlag=True then
        List.Text:=StringReplace(List.Text,Str1,Str2,[rfReplaceAll])
      else
        List.Text:=StringReplace(List.Text,Str1,Str2,[rfReplaceAll,rfIgnoreCase]);//忽略大小写
      List.SaveToFile( Pathstr );
      List.free;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer;
      CaseFlag:Boolean;
    begin
      ExitFind:=False;
      FileList:=TStringList.Create;
      //查找文件
       findfile(ExitFind,Edit1.text,Edit2.Text,aaa,False,False);  if CheckBox2.Checked then
        CaseFlag:=True
      else
        CaseFlag:=False;
      ProgressBar1.Max:=FileList.Count;
      for i:=0 to FileList.Count-1 do//循环替换所有文件
        begin
          APPlication.ProcessMessages;
          if CheckBox3.Checked then
            begin
              if not FileExists(FileList[i]) then
                CopyFile(PChar(FileList[i]),PChar(FileList[i]+'.bak'),False);
            end;
          FileReplace(FileList[i],Memo1.Text,'',CaseFlag);//把指定内容更换成空
          ProgressBar1.Position:=ProgressBar1.Position+1;
        end;
      if ProgressBar1.Position= FileList.Count then
      begin
        MessageBox(Handle,'指定的文件内容已经更换完成!','提示',MB_OK+MB_ICONINFORMATION);
        ProgressBar1.Position:=0;
      end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
     DirStr:String ;
    begin
      if SelectDirectory('请选择目录','我的电脑',DirStr) then
        Edit1.Text:=DirStr;
    end;end.
    Project1.dpr内容:program Project1;uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.
      

  10.   

    你仔细看看楼主说的吧[ote=引用 7 楼 myloveq 的回复:}]
    不是直接删除asp文件,我删除asp文件内的木马,明白了吗[/Quote]
      

  11.   

    删除asp文件,或者是删除asp文件内的某段病毒代码,都非常容易实现。可以做成无界面的,也可以做成有处理进度条提示的有界面程序。你QQ多少,加一下,请你提供asp样本及标明病毒代码,我马上给你搞定!
      

  12.   

    这种活不用python干白瞎这机会了
      

  13.   

    贴的代码是不能满足你的要求还是其它什么的?
    我写的时候大概测试了一下可以替换掉ASP里面指定代码。
      

  14.   

    ksaiy ,阳光总在风雨后 已经给出了可用的代码.
      

  15.   

    我想问一下lz,你删除那些内容后,就不中马了吗?
    是不是还要考虑一下将asp文件变成只读,加个木马专杀什么的?
      

  16.   

    建议不要用ASP了,很容易被挂马
      

  17.   

    我dephi写过一个类似的。用正则表达来匹配特征码。加我qq吧。传给你!1881191
      

  18.   

    这个不值得写代码,有现成的工具“Search and Replace”,这个工具我用着感觉非常好,功能强大,你去下载吧,保证比上面那些代码强百倍