Lucene search
+L

SMB Network Service Reporter

🗓️ 12 Oct 2026 00:00:00Reported by TenableType 
nessus
 nessus
🔗 www.tenable.com👁 12 Views

SMB Network Service Reporter reports SMB network service settings as host tags.

Code
#%NASL_MIN_LEVEL 80900
##
# (C) Tenable, Inc.
##

include('compat.inc');

if (description)
{
  script_id(364700);
  script_version("1.1");
  script_set_attribute(attribute:"plugin_modification_date", value:"2026/10/12");

  script_name(english:"SMB Network Service Reporter");
  script_set_attribute(attribute:"synopsis", value:
"Reports SMB network service settings as internal host tags.");
  script_set_attribute(attribute:"description", value:
"This plugin aggregates SMB network service settings collected by individual detection plugins and reports the result
as a structured internal host tag. The structured data object is reported even when only a subset of the source
plugins ran.");
  script_set_attribute(attribute:"solution", value:"n/a");
  script_set_attribute(attribute:"plugin_publication_date", value:"2026/10/12");
  script_set_attribute(attribute:"plugin_type", value:"summary");
  script_set_attribute(attribute:"always_run", value:TRUE);
  script_end_attributes();

  script_category(ACT_END);
  script_family(english:"General");

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

  script_require_keys("Host/TCP/scanned");

  exit(0);
}

include('debug.inc');
include('ports.inc');
include("smb_func.inc");
include('structured_data_network_services.inc');

var trigger = get_kb_item('trigger/smb_network_service_reporter');
var smb_v1_supported = get_kb_item('SMB/SMBv1_is_supported');
var smb_v2_supported = get_kb_item('SMB/SMBv2_is_supported');
var smb_v2_dialect_detection_attempted = get_kb_item('SMB/SMBv2_dialect_detection_attempted');
var smb_v2_dialects = get_kb_list('SMB/smb_dialect/*');

# core reporting procedure
function check_and_report_smb()
{
  # decide if SMB is enabled or not
  if (smb_v1_supported == 1 || smb_v2_supported == 1 || !empty_or_null(smb_v2_dialects))
  {
    structured_data_network_services.set('state', 'enabled');
  }
  else if (!empty_or_null(smb_v1_supported) && smb_v1_supported == 0 && 
          ((!empty_or_null(smb_v2_supported) && smb_v2_supported == 0) || (smb_v2_dialect_detection_attempted == 1 && empty_or_null(smb_v2_dialects))))
  {
    structured_data_network_services.set('state', 'disabled');
  }

  # only assemble the list of SMB versions if the detection of both SMBv1 and SMBv2+ executed.
  # otherwise we would be reporting partial data, with potential implications for downstream consumers.
  if (!empty_or_null(smb_v1_supported) && !empty_or_null(smb_v2_dialect_detection_attempted))
  {
    var smb_versions = [];
    if (smb_v1_supported == 1)
      smb_versions = ['1.0'];

    var dialect_num, dialect_enabled;
    for (var key in smb_v2_dialects)
    {
      dialect_num = str_replace(string:key, find:'SMB/smb_dialect/', replace:'');
      dialect_enabled = smb_v2_dialects[key];
      if (dialect_enabled == '1')
      {
        append_element(var:smb_versions, value:dialect_num);
      }
    }

    structured_data_network_services.set('supported_protocol_versions', sort(smb_versions));
  }

  # if state was determined, report the rest
  if (!empty_or_null(structured_data_network_services.data.state))
  {
    if (structured_data_network_services.data.state == 'enabled')
    {
      structured_data_network_services.set('listening_port', kb_smb_transport());
    }

    structured_data_network_services.set('application_protocol', 'smb');
    structured_data_network_services.report_internal();
  }
}

function is_port_open(port)
{
  var state = get_kb_item('Ports/tcp/' + string(port));
  return state == 1;
}

function log_sd_object()
{
  # for testing purposes only
  var FLATLINE_TEST = !isnull(get_kb_item("flatline/TEST"));
  if (FLATLINE_TEST)
  {
    dbg::enable();
    dbg::set_log_level(1);

    var sd_data = structured_data_network_services.data;
    var output = strcat(
      'application_protocol: ', string(sd_data["application_protocol"]), '\n',
      'state: ', string(sd_data["state"]), '\n',
      'supported_protocol_versions: ', string(sd_data["supported_protocol_versions"]), '\n',
      'listening_port: ', string(sd_data["listening_port"]), '\n'
    );

    dbg::detailed_log(lvl:1, src:SCRIPT_NAME, msg:output);
  }
}

# at least one of the source plugins executed
if (!empty_or_null(trigger))
{
  check_and_report_smb();
}
# none of the source plugins executed. we need to establish if that's because the ports were not scanned, or scanned but closed
else
{
  var port_range = ports::scan::get_port_range();
  var scanned_port_count = 0;

  for (var port of port_range)
  {
    if (port == 139 || port == 445)
      scanned_port_count++;
  }

  # both ports scanned and closed
  if (scanned_port_count == 2 && !is_port_open(port:139) && !is_port_open(port:445))
  {
    structured_data_network_services.set('state', 'disabled');
    structured_data_network_services.set('application_protocol', 'smb');
    structured_data_network_services.report_internal();
  }
}

log_sd_object();

exit(0, "This plugin does not produce output.");

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

12 Oct 2026 00:00Current
5.9Medium risk
Vulners AI Score5.9
12