一位客户报告说,在安装我使用 Delphi XE3 编写的 Delphi 应用程序期间,McAfee 检测到“通用 BackDoor.add”。我已经通过使用Virus Total复制了这个结果,它在我用 Delphi 作为控制台应用程序编写的一个小型实用程序 EXE 文件上返回了这个病毒阳性,并认为这是导致报告的文件(不是主应用程序 EXE)。
该实用程序调用服务控制管理器 (SCM) 在 Innosetup 的 [运行] 阶段安装“.sys”文件。我实际上部署了这个实用程序 EXE 的两个版本,一个作为控制台应用程序,另一个具有相同的 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>
任何人都可以评论我应该做些什么来消除这种病毒检测吗?