@@ -131,7 +131,7 @@ sub doInventory {
131131 } elsif ($antivirus -> {NAME } =~ / F-Secure/i ) {
132132 _setFSecureInfos($antivirus );
133133 } elsif ($antivirus -> {NAME } =~ / Bitdefender/i ) {
134- _setBitdefenderInfos($antivirus ,$logger );
134+ _setBitdefenderInfos($antivirus , $logger , " C: \\ Program Files \\ Bitdefender \\ Endpoint Security \\ product.console.exe " );
135135 } elsif ($antivirus -> {NAME } =~ / Norton|Symantec/i ) {
136136 _setNortonInfos($antivirus );
137137 } elsif ($antivirus -> {NAME } =~ / Trend Micro Security Agent/i ) {
@@ -162,6 +162,12 @@ sub doInventory {
162162 service => " cyserver" ,
163163 command => " C:\\ Program Files\\ Palo Alto Networks\\ Traps\\ cytool.exe" ,
164164 func => \&_setCortexInfos,
165+ }, {
166+ # BitDefender support
167+ name => " Bitdefender Endpoint Security" ,
168+ service => " EPSecurityService" ,
169+ command => " C:\\ Program Files\\ Bitdefender\\ Endpoint Security\\ product.console.exe" ,
170+ func => \&_setBitdefenderInfos,
165171 }) {
166172 my $antivirus ;
167173 my $service = $services -> {$support -> {service }}
@@ -402,7 +408,52 @@ sub _setFSecureInfos {
402408}
403409
404410sub _setBitdefenderInfos {
405- my ($antivirus ) = @_ ;
411+ my ($antivirus , $logger , $command ) = @_ ;
412+
413+ # Use given default command, but try to find it if installation path is not the default one
414+ my $command_found = canRun($command );
415+ unless ($command_found ) {
416+ my $installpath = _getSoftwareRegistryKeys(
417+ ' BitDefender/Endpoint Security' ,
418+ [ ' InstallPath' ],
419+ sub {
420+ my ($reg ) = @_ ;
421+ foreach my $key (keys (%{$reg })) {
422+ next unless $key =~ / ^\{ [0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\}\/ $ /is ;
423+ next unless $reg -> {$key }-> {" Install/" } && $reg -> {$key }-> {" Install/" }-> {" /InstallPath" };
424+ return $reg -> {$key }-> {" Install/" }-> {" /InstallPath" };
425+ }
426+ }
427+ );
428+ if ($installpath ) {
429+ $command = $installpath . ($installpath =~ / \\ $ / ? " " : " \\ " ) ." product.console.exe" ;
430+ $command_found = canRun($command );
431+ }
432+ }
433+
434+ # Don't check datas in registry if Bitdefender Endpoint Security Tools is found
435+ if ($command_found ) {
436+ my $version = getFirstLine(command => " \" $command \" /c GetVersion product" , logger => $logger );
437+ $antivirus -> {VERSION } = $version if $version ;
438+ my $base_version = getFirstLine(command => " \" $command \" /c GetVersion antivirus" , logger => $logger );
439+ $antivirus -> {BASE_VERSION } = $base_version if $base_version ;
440+ # Don't check if up-to-date with command if still reported by WMI on Windows Desktop
441+ unless (defined ($antivirus -> {UPTODATE })) {
442+ my @update_status = getAllLines(command => " \" $command \" /c GetUpdateStatus product" , logger => $logger );
443+ my ($attempt_time ) = map { / ^lastAttemptedTime: (\d +)$ / } grep { / ^lastAttemptedTime:/ } @update_status ;
444+ my ($success_time ) = map { / ^lastSucceededTime: (\d +)$ / } grep { / ^lastSucceededTime:/ } @update_status ;
445+ my $uptodate = $attempt_time && $success_time && int ($attempt_time ) == int ($success_time ) ? 1 : 0;
446+ if ($uptodate ) {
447+ @update_status = getAllLines(command => " \" $command \" /c GetUpdateStatus antivirus" , logger => $logger );
448+ ($attempt_time ) = map { / ^lastAttemptedTime: (\d +)$ / } grep { / ^lastAttemptedTime:/ } @update_status ;
449+ ($success_time ) = map { / ^lastSucceededTime: (\d +)$ / } grep { / ^lastSucceededTime:/ } @update_status ;
450+ $uptodate += 1 if $attempt_time && $success_time && int ($attempt_time ) == int ($success_time );
451+ }
452+ $antivirus -> {UPTODATE } = $uptodate > 1 ? 1 : 0;
453+ }
454+ $antivirus -> {COMPANY } = " Bitdefender" unless $antivirus -> {COMPANY };
455+ return ;
456+ }
406457
407458 my $bitdefenderReg = _getSoftwareRegistryKeys(
408459 ' BitDefender/About' ,
@@ -552,7 +603,7 @@ sub _getSoftwareRegistryKeys {
552603 my $reg ;
553604 if (is64bit()) {
554605 $reg = getRegistryKey(
555- path => ' HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/' .$base ,
606+ path => ' HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/' .$base ,
556607 # Important for remote inventory optimization
557608 required => $values ,
558609 );
0 commit comments