2

Delphi XE3 を使用して作成した Delphi アプリケーションのインストール中に、McAfee が「Generic BackDoor.add」を検出したという報告が顧客から寄せられています。私は、コンソール アプリケーションとして Delphi で作成した小さなユーティリティ EXE ファイルでこのウイルス陽性を返すVirus Totalを使用してこの結果を複製しました。

このユーティリティは、サービス コントロール マネージャー (SCM) を呼び出して、Innosetup の [実行] フェーズ中に「.sys」ファイルをインストールします。私は実際に、このユーティリティ EXE の 2 つのバージョンをデプロイします。1 つはコンソール アプリとして、もう 1 つは同じ Delphi SCM コード ユニットを持ちますが、ボタン付きの小さな GUI フォームを追加します。この後者のユーティリティはウイルス陽性として表示されず、コンソール アプリのみが表示されます。「{$R uac_manifest.res}」インクルージョンを使用してアプリを実行するには、昇格が必要です。私のユーティリティ アプリの DPR 部分を以下に示します。(サービス コントロール マネージャーの呼び出しは別のユニットにあるため、これには表示されないことに注意してください。ただし、この別のユニットは、ウイルス検出をトリガーしない GUI ユーティリティ バージョンで使用されているため、問題は DPR にあると結論付けます。おそらく? ):

    program ArtSCM;

uses
  SysUtils,
  Windows,
  UArtSysDriverInstaller;

{$APPTYPE CONSOLE}

{$R uac_manifest.res}
{$R *.res}

var
  sDriverName : string;


function CommandLineParamExistsWithArg(
     const ALookFor  : string;
     var   AArgument : string ) : boolean; overload;
{ Looks for the occurance of 'ALookFor' on the command line,
  of the form ALookFor=<AArgument>, where if found, AArgument returns
  the argument in upper case, AArgCaseAsIs returns the argument case as is. }
var
   I : integer;
   S : string;
begin
  Result := False;
  AArgument := '';

  For I := 1 to ParamCount do
    begin
    S := AnsiDequotedStr(ParamStr(I), '"');
    AArgument := UpperCase(S);
    Result := Pos( UpperCase(ALookFor)+'=', AArgument) = 1 ;
    If Result then
       begin
       Delete( AArgument, 1, Length(ALookFor)+1);
       Break;
       end;
    end;

  If not Result then
    AArgument := '';

end;




function PerformCommandLineAction : boolean;
var
  Installer : TArtSysDriverInstaller;

  procedure Install;
  begin
    Result := True;
    Installer := TArtSysDriverInstaller.Create( sDriverName );
    try
      Installer.InstallDriver;
    finally
      Installer.Free;
    end;
    Writeln( '  Driver installed OK.' );
  end;


  procedure Query;
  var
    S : string;
  begin
    Result := True;
    Installer := TArtSysDriverInstaller.Create( sDriverName );
    try
      If Installer.DriverIsInstalledAndRunning then
        begin
        S := Installer.DriverVersionString;
        S := Format('The driver is installed and running - Version %s.', [S] );
        end
       else
        S := 'The driver is *NOT* installed and running.';
    finally
      Installer.Free;
    end;
    Writeln( '  Status: ', S );
  end;

  procedure GetArtInfo;
  var
    S : string;
  begin
    Result := True;
    Installer := TArtSysDriverInstaller.Create( sDriverName );
    try
      If Installer.DriverIsInstalledAndRunning then
        begin
        S := Installer.ARTDriverInfoString;
        S := Format('Driver info string: %s', [S] );
        end
       else
        S := 'The driver is *NOT* installed and running.';
    finally
      Installer.Free;
    end;
    Writeln( '  Status: ', S );
  end;

  procedure Remove;
  begin
    Result := True;
    Installer := TArtSysDriverInstaller.Create( sDriverName );
    try
      Installer.RemoveDriver;
    finally
      Installer.Free;
    end;
    Writeln( '  Driver removed OK.' );
  end;



begin

  Result := False;

  try

    If not CommandLineParamExistsWithArg(
      '/DriverName',
      sDriverName )
       or (Length( sDriverName ) < 3) then
        Raise Exception.Create( 'Missing or invalid /DriverName=xxx parameter' );

    Writeln( '  Driver name: ', sDriverName );    

    If FindCmdLineSwitch(
      'QUERY' ) then
        Query
     else
    If FindCmdLineSwitch(
      'GETARTINFO' ) then
        GetArtInfo
     else
    If FindCmdLineSwitch(
      'REMOVE' ) then
        Remove
     else
    If FindCmdLineSwitch(
      'INSTALL' ) then
        Install
    else
      Raise Exception.Create( 'Missing command - QUERY, GETARTINFO, REMOVE or INSTALL required.' );

  except
    on E:Exception do
      begin
      Writeln( '  Error: ', E.Message );
      ExitCode := 1;
      end;
  end
end;


function IsRunningInDelphiIDE : boolean;
// Returns TRUE if the program is running in the IDE, FALSE otherwise.
begin
  Result := DebugHook <> 0;
end;








var
  dwVersion : DWORD;
begin
  dwVersion := GetFileVersion( ParamStr(0));

  Writeln( Format(
    'ArtDrvSC V%d.%d (c) Applied Relay Testing Ltd 2011',
    [HiWord(dwVersion), LoWord(dwVersion)] ));

  PerformCommandLineAction;

  If IsRunningInDelphiIDE then
    begin
    Writeln( 'Press a key ..' );
    Readln;
    end;
end.

ご覧のとおり、「{$R uac_manifest.res}」という行は、コマンド ラインから実行すると昇格を正しく要求します。マニフェストは次のとおりです。

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity type="win32" name="Applied Relay Testing Ltd" version="3.1.0.0" processorArchitecture="*"/> 
  <dependency> 
    <dependentAssembly> 
    </dependentAssembly> 
  </dependency> 
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
    <security> 
      <requestedPrivileges> 
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> 
        </requestedPrivileges> 
    </security> 
  </trustInfo> 
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
      <!--The ID below indicates application support for Windows Vista --> 
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
      <!--The ID below indicates application support for Windows 7 --> 
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> 
    </application> 
  </compatibility> 
</assembly> 

このウイルス検出を排除するために私が何をすべきかについて誰かコメントできますか?

4

0 に答える 0