###############################################################################
# OpenVAS Vulnerability Test
# $Id: gb_clamav_detect_win.nasl 1466 2009-04-15 16:42:37Z apr $
#
# ClamAV Version Detection (Win)
#
# Authors:
# Nikita MR <rnikita@secpod.com>
#
# Modified By: Antu sanadi <santu@secpod.com> on 2010-04-09
# Modified to detect version of latest products also
#
# Copyright:
# Copyright (c) 2009 Intevation GmbH, http://www.intevation.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# (or any later version), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
###############################################################################

if(description)
{
  script_id(800555);
  script_version("$Revision$: 1.2");
  script_tag(name:"risk_factor", value:"None");
  script_name("ClamAV Version Detection (Win)");
  desc = "
  Overview : This script retrieves ClamAV Version for Windows and saves the
  result in KB.

  Risk factor : None";

  script_description(desc);
  script_family("Service detection");
  script_category(ACT_GATHER_INFO);
  script_copyright("Copyright (C) 2009 Intevation GmbH");
  script_summary("Set Version of ClamAV in KB for Windows");
  script_dependencies("secpod_reg_enum.nasl");
  script_require_keys("SMB/WindowsVersion");
  script_require_ports(139, 445);
  exit(0);
}


include("smb_nt.inc");
include("secpod_smb_func.inc");

if(!get_kb_item("SMB/WindowsVersion")){
  exit(0);
}

key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\";
foreach item (registry_enum_keys(key:key))
{
  clamName = registry_get_sz(key:key + item, item:"DisplayName");
  if("ClamWin" >< clamName)
  {
    clamVer = eregmatch(pattern:"ClamWin Free Antivirus ([0-9.]+)", string:clamName);
    if(clamVer[1] != NULL)
    {
      set_kb_item(name:"ClamAV/Win/Ver", value:clamVer[1]);
      security_note(data:"Clam Anti Virus version " + clamVer[1] + " was detected" + 
                         " on the host");
      exit(0);
    }
  }
}

key = key + "Immunet Protect\";
clamname = registry_get_sz(key:key , item:"DisplayName");
if("ClamAV for Windows"  >< clamname)
{
  clamVer = registry_get_sz(key:key , item:"DisplayVersion");
  if(clamVer)
  {
    set_kb_item(name:"ClamAV/Win/Ver", value:clamVer);
    security_note(data:"Clam Anti Virus version " + clamVer + " was detected" + 
                         " on the host"); 
  }
}
