Nessus Product Information

2015-06-02T00:00:00
ID NESSUS_PRODUCT_SETUP.NASL
Type nessus
Reporter This script is Copyright (C) 2015-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
Modified 2020-04-02T00:00:00

Description

Set up Nessus product information to help facilitate some plugins to detect what platform they are running on.

                                        
                                            #TRUSTED 5f098b4679740bbb90fb0e90a322e03bca3cbb01b2da1118f12b15d827d6ba02e52da0dee5fa8678a88fd0eb78b3520ca1c3df05897a6b3aa33b1733d8d36b59eaec86c46a1494c1a97cd60821e629f0e2999d9a777c41b105592ef98a0db568ade28791f458b30b25f646b16e11aa98ab404c75686a8cb2ee45467865ce11363bac79cd08eec7cb24fda4e9887c4641c64fb12509836ade17968c0f06a0315823911cf2cf70d6669e65efa7dae477121ad99e5b230dc6747d7c93721d9a1abff6f9ff4bf68a004e9289df4ac275216c58bad7e6a4369e862c67243d016c1e1c3d27c5c4578744a0fa421a892b3573ae5f27f1b537c7315b18ec789f90f235554e89e5de1b8a8357d1acee948133676c07b42b0aea30f15bdba66fc5fe413afff85accdc32076312a108eac832591f9671b688c79e622bc5724b05f7e1903475fa5496df6c21399a61391d0b97162c942c101eb6ab6bc768afbabbc23479ce052ded799c7e21dd8f7cfb2cdffb1236e4111e58245460c5bd5630b3ecb5b3ba145d1976386b260d10758cbaa9c51eb629697911b6e30c1d85799b4ab9137d071f2b1fb6e4e8b350e7f78df794d5005ac088fd78685a88f82809f8894a8319f7b58bb10d476371ce5c0f5addbc9d120d0153ed38f9d647357ec47bf0607898a98b5bfac1d796df05f18f3ef59f057e03c2000e674f0ac2ff4982443d5851d78035
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
 script_id(83955);
 script_version("1.9");
 script_cvs_date("Date: 2019/12/13");

 script_name(english:"Nessus Product Information");
 script_summary(english:"Initializes information used in Nessus product detection.");

 script_set_attribute(attribute:"synopsis", value:
"Set up information about which Nessus product is running.");
 script_set_attribute(attribute:"description", value:
"Set up Nessus product information to help facilitate some plugins to
detect what platform they are running on.");
 script_set_attribute(attribute:"solution", value:"n/a");
 script_set_attribute(attribute:"risk_factor", value:"None");

 script_set_attribute(attribute:"plugin_publication_date", value:"2015/06/02");

 script_set_attribute(attribute:"plugin_type", value:"summary");
 script_set_attribute(attribute:"agent", value:"all");
 script_end_attributes();

 script_category(ACT_INIT);

 script_copyright(english:"This script is Copyright (C) 2015-2019 and is owned by Tenable, Inc. or an Affiliate thereof.");
 script_family(english:"Settings");

 exit(0);
}
include("global_settings.inc");
include("misc_func.inc");
include("nessusd_product_info.inc");

report = "Nessus product is ";

# nessus environment
env = nessusd_env();

if (!isnull(env['product']))
{
  if (env['product'] == PRODUCT_WIN_AGENT) report += 'Windows Agent.\n';
  else if (env['product'] == PRODUCT_UNIX_AGENT)
  {
    if (env['os'] == 'DARWIN')
    {
      env['product'] = PRODUCT_MAC_AGENT;
      report += 'Mac Agent.\n';
    }
    else
      report += 'Unix Agent.\n';
  }
  else if (env['product'] == PRODUCT_NESSUSD) report += 'Nessus Scanner.\n';
  else if (env['product'] == PRODUCT_NESSUSD_NSX) report += 'Nessus NSX Scanner.\n';

  else report += 'undetermined.\n';
}
else
{
  report = 'No Nessus Product information available.\n';
}

set_kb_item(name:"nessus/product", value:env['product']);
set_kb_item(name:"nessus/os", value:env['os']);

# Agent bool set
if (nessusd_is_agent()) set_kb_item(name:"nessus/product/agent", value:TRUE);

# local scan set
if (nessusd_is_local()) set_kb_item(name:"nessus/product/local", value:TRUE);

##
# Returns whether or not the scanner machine is a Nessus Enterprise Cloud system
#
# @return 1 if the Nessus msp_scanner file exists, or the Nessus msp file exists and its MD5 is a specific string
#         else 0 (&& FALSE)
##
function is_nec()
{
  local_var separator, path;
  if (platform() == 'WINDOWS')
    separator = '\\';
  else
    separator = '/';

  path = nessus_get_dir(N_STATE_DIR) + separator + 'msp_scanner';
  if ( file_stat(path) > 0 ) return 1;

  path = nessus_get_dir(N_STATE_DIR) + separator + 'msp';
  return file_stat(path) > 0 &&  hexstr(MD5(fread(path))) == 'bcc7b34f215f46e783987c5f2e6199e5';
}

if (is_nec())
{
  replace_kb_item(name:"Host/msp_scanner", value:TRUE);
}

exit(0, report);