我想做一个redlof病毒的专杀工具。
现在有两个关键技术问题请教大家。
1.如何检测内存中的病毒代码,以及如何清除内存中的病毒代码。
2.如何遍历某个驱动器下的所有文件(深度优先,广度优先,各举一例最好)病毒分析:
http://expert.csdn.net/Expert/topic/1773/1773517.xml?temp=.1025049

解决方案 »

  1.   

    shadowfish,呵呵,别卖关子了。快说呀。
      

  2.   

    这个函数遍历某个文件夹中的文件,遍历整个驱动器的一时找不到:(,这个你改改应该也能用吧:)function tdm.isdelete():boolean;
    var
    sr: TSearchRec;
    strdeltime,dirpath:string;
    deltime:array[1..50] of char;
    begin
    {****************
      读ini,取得要删除的文件夹名称
    //  备份的时候写ini文件
      删除的时候取得最老的文件夹
      读取ini文件,判断是否删除。
    ******************}
    //取得文件夹路径
    dirpath:= backupath+'\old\';//取得最早的文件夹
    dirname:='';
    if FindFirst(dirpath+'*.*', faDirectory, sr) = 0 then
        begin
          repeat
            if (sr.Attr and faDirectory) = sr.Attr then
            begin
             if (sr.Name <> '.') and (sr.Name <> '..') then
             begin
              if dirname = '' then
                dirname:=sr.Name
              else
                begin
                  if strtodate(dirname)> strtodate(sr.Name) then
                    dirname:= sr.Name;
                end;
             end;
            end;
          until FindNext(sr) <> 0;
          FindClose(sr);
        end;
    // edit1.Text:=dirname;取得要删除的文件夹名称
    //读取该文件夹内ini文件,返回数值
          GetPrivateProfileString(
        //从.INI文件中获取路径信息
            'backupInfo',//[]中节的名称
            'deltime', //=保存路径
            '2003-1-1', //如果没有找到字符串时,返回c:\
            @deltime,//存放取得字符串
            25,//取得字符的允许最大长度
            pchar(dirpath+'\'+dirname+'\detail.ini') //.INI文件名
            );
            strdeltime:=deltime;
            strdeltime:=string(strdeltime);
            strdeltime:=strpas(pchar(strdeltime));
         if strdeltime <= datetostr(date) then
           result:=true
         else
           result:=false;
         dirname:=dirpath+dirname;
    end;
      

  3.   

    自己找到一个,先放到这里,关于第二个问题的答案。(没有验证,是搜出来的。)来自http://expert.csdn.net/Expert/topic/1647/1647891.xml?temp=.9627954
    至于遍历操作,先取得所有硬盘
    procedure GetAvailableDriver(var ADriverList: TStringList);
    var
      drives: set of 0..25;
      DrivePath, _Drive: string;
      I: integer;
    begin
      ADriverList.Clear;
      DWORD(drives) := windows.GetLogicalDrives;
      for I := 0 to 25 do
        if I in drives then //如果驱动器存在
        begin
          DrivePath := Char(Ord('A') + i) + ':\';
          _Drive := Char(Ord('A') + i);
          case GetDriveType(pchar(DrivePath)) of
            DRIVE_FIXED, DRIVE_REMOTE: ADriverList.Add(trim(_Drive)); //如果是硬盘
          end;
        end;
    end;遍历查找文件
    代码如下:1. 从搜索记录中判断是否是子目录。 function IsValidDir(SearchRec:TSearchRec):Boolean;begin
    if (SearchRec.Attr=16) and(SearchRec.Name<>'.') and(SearchRec.Name<>'..') thenResult:=TrueelseResult:=False;end;2. 这是查询主体函数。参数介绍:Mainpath: 指定的查询目录。Filename: 欲查询的文件。Foundresult: 返回的含完整路径的匹配文件(可能有多个)。如果有匹配文件,函数返回True,否则,返回False; function SearchFile(mainpath:string;filename:string;var foundresult:TStrings):Boolean;vari:integer;Found:Boolean;subdir1:TStrings;searchRec:TsearchRec;beginfound:=false;if Trim(filename)<>'' thenbeginsubdir1:=TStringList.Create;//字符串列表必须动态生成//找出所有下级子目录。if (FindFirst(mainpath+'*.*', faDirectory, SearchRec)=0) thenbeginif IsValidDir(SearchRec) thensubdir1.Add(SearchRec.Name);while (FindNext(SearchRec) = 0) dobeginif IsValidDir(SearchRec) thensubdir1.Add(SearchRec.Name);end;end;FindClose(SearchRec);//查找当前目录。if FileExists(mainpath+filename) thenbeginfound:=true;foundresult.Add(mainpath+filename);end;//这是递归部分,查找各子目录。for i:=0 to subdir1.Count-1 dofound:=Searchfile(mainpath+subdir1.Strings[i]+'\',Filename,foundresult)or found;//资源释放并返回结果。subdir1.Free;end;result:=found;end;
      

  4.   

    对于第一个问题,我的想法是:穷举所有内存中的进程,得到进程的内存地址,然后进行扫描分析,最后进行修改或者kill进程穷举进程我已经能够实现,关键问题是如何得到进程占用的内存地址,并且得到内存的读写权限。
      

  5.   

    是否应该Kill进程呢,不用吧!如果很多文件被感染,岂不是全部Kill掉,或者是系统进程无法Kill的情况又如何解决?
      

  6.   

    不是kill,能修改的就修改,不能修改的实在没办法,就不负责任地kill掉。呵呵,别说我偷懒呀。
      

  7.   

    就用delhpi,我相信delphi完全可以做出来。(不是迷信)
      

  8.   

    Win32好像不能访问其他进程的地址空间吧
      

  9.   

    ReadProcessMemory和WriteProcessMemory
    不是可以访问其他程序的内存空间么