Microsoft Visual Studio Team Foundation Server Detection (credentialed check)

2012-09-10T00:00:00
ID MICROSOFT_TEAM_FOUNDATION_SERVER_INSTALLED.NASL
Type nessus
Reporter Tenable
Modified 2019-01-15T00:00:00

Description

The remote host is running Microsoft Visual Studio Team Foundation Server. Team Foundation Server is a suite of tools for collaborative software development.

                                        
                                            #
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(62033);
  script_version("1.9");
  script_cvs_date("Date: 2019/01/15 17:11:58");

  script_name(english:"Microsoft Visual Studio Team Foundation Server Detection (credentialed check)");
  script_summary(english:"Checks for Microsoft Visual Studio Team Foundation Server install");

  script_set_attribute(
    attribute:"synopsis",
    value:
"The remote host is running a suite of tools for collaborative software
development."
  );
  script_set_attribute(
    attribute:"description",
    value:
"The remote host is running Microsoft Visual Studio Team Foundation
Server.  Team Foundation Server is a suite of tools for collaborative
software development."
  );
  script_set_attribute(attribute:"solution", value:"n/a");
  script_set_attribute(attribute:"risk_factor", value:"None");

  script_set_attribute(attribute:"plugin_publication_date", value:"2012/09/10");

  script_set_attribute(attribute:"plugin_type", value:"local");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:microsoft:visual_studio_team_foundation_server");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Windows");

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

  script_dependencies("smb_hotfixes.nasl");
  script_require_keys("SMB/Registry/Enumerated");
  script_require_ports(139, 445);

  exit(0);
}

include("audit.inc");
include("smb_func.inc");
include("smb_hotfixes.inc");
include("smb_hotfixes_fcheck.inc");
include("smb_reg_query.inc");
include("misc_func.inc");
include("install_func.inc");

# List of arrays, because indexed
update_vers = {"^15\.":[ {'ver' : '15.105.25910.0', 'update' : '0',   'name' : 'RTW'},
                         {'ver' : '15.112.26301.0', 'update' : '1',   'name' : 'Update 1'},
                         {'ver' : '15.117.26714.0', 'update' : '2',   'name' : 'Update 2'},
                         {'ver' : '15.117.27024.0', 'update' : '3',   'name' : 'Update 3'},
                         {'ver' : '15.117.27414.0', 'update' : '3.1', 'name' : 'Update 3.1'}
                       ],
               "^16\.":[ {'ver' : '16.122.27102.1', 'update' : '0',   'name' : 'RTW'},
                         {'ver' : '16.122.27409.2', 'update' : '1',   'name' : 'Update 1'},
                         {'ver' : '16.122.28028.4', 'update' : '1.1', 'name' : 'Update 1.1'},
                         {'ver' : '16.122.28313.3', 'update' : '1.2', 'name' : 'Update 1.2'},
                         {'ver' : '16.131.27701.1', 'update' : '2',   'name' : 'Update 2'},
                         {'ver' : '16.131.28106.2', 'update' : '3',   'name' : 'Update 3'},
                         {'ver' : '16.131.28226.3', 'update' : '3.1', 'name' : 'Update 3.1'},
                         {'ver' : '16.131.28507.4', 'update' : '3.2', 'name' : 'Update 3.2'}
                       ]
};

rel_map = { "^15\." : '2017',
            "^16\." : '2018'
          };

port = kb_smb_transport();
appname = 'Microsoft Team Foundation Server';
kb_base = "SMB/Microsoft_Team_Foundation_Server/";

install_num = 0;

registry_init();
hklm = registry_hive_connect(hive:HKEY_LOCAL_MACHINE, exit_on_fail:TRUE);
key = "SOFTWARE\Microsoft\TeamFoundationServer";
subkeys = get_registry_subkeys(handle:hklm, key:key);

paths = make_list();

foreach subkey (subkeys)
{
  if (subkey !~ "^[0-9.]+$") continue;

  entry = key + "\" + subkey + "\InstallPath";
  path = get_registry_value(handle:hklm, item:entry);

  if (isnull(path)) continue;
    paths = make_list(paths, path);
}

RegCloseKey(handle:hklm);

if (max_index(paths) == 0)
{
  close_registry();
  audit(AUDIT_NOT_INST, appname);
}
else
  close_registry(close:FALSE);

installs = make_array();

foreach path (paths)
{
  # this DLL is always updated between versions
  exe = path + "\Tools\Microsoft.TeamFoundation.Framework.Server.dll";
  ver = hotfix_get_fversion(path:exe);

  version = '';
  rel = '';
  update_ver = '';
  friendly_update = '';
  if (isnull(ver['value'])) continue;

  version = join(ver['value'], sep:'.');

  # Find update version
  foreach maj_ver (keys(update_vers))
  {
    if (version =~ maj_ver)
    {
      rel = rel_map[maj_ver];
      for (i=0; i<max_index(update_vers[maj_ver]); i++)
      {
        update_ver = update_vers[maj_ver][i];
        if (ver_compare(ver:version, fix:update_ver.ver) >= 0)
        {
          update = update_ver.update;
          friendly_update = update_ver.name;
        }
        else
          break;
      }
    }
  }

  set_kb_item(name: kb_base + install_num + "/Path", value: path);
  set_kb_item(name: kb_base + install_num + "/Version", value: version);

  if (rel && friendly_update && !empty_or_null(update))
  {
    register_install(
      app_name:appname,
      path:path,
      version:version,
      display_version: version + " (" + rel + " " + friendly_update + ")",
      extra_no_report: {'Update' : update, 'Release' : rel, "Friendly Update" : friendly_update},
      cpe:"cpe:/a:microsoft:visual_studio_team_foundation_server");

    install_num++;
  }
  else
  {
    register_install(
      app_name:appname,
      path:path,
      version:version,
      cpe:"cpe:/a:microsoft:visual_studio_team_foundation_server");
    install_num++;
  }
}

hotfix_check_fversion_end();

if (install_num == 0) audit(AUDIT_UNINST, appname);

set_kb_item(name:kb_base + 'NumInstalled', value:install_num);
set_kb_item(name:kb_base + 'Installed', value:TRUE);

report_installs(app_name:appname, port:port);