{"id":59334,"date":"2024-09-01T03:00:23","date_gmt":"2024-09-01T00:00:23","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180935\/tnspoison_checker.rb.txt"},"modified":"2024-09-01T03:00:23","modified_gmt":"2024-09-01T00:00:23","slug":"oracle-tns-listener-checker","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/oracle-tns-listener-checker\/","title":{"rendered":"Oracle TNS Listener Checker"},"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::Auxiliary<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<br \/>include Msf::Exploit::Remote::TNS<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Oracle TNS Listener Checker&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module checks the server for vulnerabilities like TNS Poison.<br \/>Module sends a server a packet with command to register new TNS Listener and checks<br \/>for a response indicating an error. If the registration is errored, the target is not<br \/>vulnerable. Otherwise, the target is vulnerable to malicious registrations.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [&#8216;ir0njaw (Nikita Kelesis) &lt;nikita.elkey[at]gmail.com&gt;&#8217;], # of Digital Security [http:\/\/dsec.ru]&#8216;References&#8217; =&gt;<br \/>[<br \/>[ &#8216;CVE&#8217;, &#8216;2012-1675&#8217;],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/seclists.org\/fulldisclosure\/2012\/Apr\/204&#8217; ],<br \/>],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2012-04-18&#8217;,<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE))<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(1521)<br \/>])<br \/>end<\/p>\n<p>def run_host(ip)<br \/>begin<br \/>connect<br \/>send_packet = tns_packet(&#8220;(CONNECT_DATA=(COMMAND=service_register_NSGR))&#8221;)<br \/>sock.put(send_packet)<br \/>packet = sock.read(100)<br \/>if packet<br \/>hex_packet = Rex::Text.to_hex(packet, &#8216;:&#8217;)<br \/>split_hex = hex_packet.split(&#8216;:&#8217;)<br \/>find_packet = \/\\(ERROR_STACK=\\(ERROR=\/ === packet<br \/>if find_packet == true #TNS Packet returned ERROR<br \/>print_error(&#8220;#{ip}:#{rport} is not vulnerable&#8221;)<br \/>elsif split_hex[5] == &#8217;02&#8217; #TNS Packet Type: ACCEPT<br \/>print_good(&#8220;#{ip}:#{rport} is vulnerable&#8221;)<br \/>elsif split_hex[5] == &#8217;04&#8217; #TNS Packet Type: REFUSE<br \/>print_error(&#8220;#{ip}:#{rport} is not vulnerable&#8221;)<br \/>else #All other TNS packet types or non-TNS packet type response cannot guarantee vulnerability<br \/>print_error(&#8220;#{ip}:#{rport} might not be vulnerable&#8221;)<br \/>end<br \/>else<br \/>print_error(&#8220;#{ip}:#{rport} is not vulnerable&#8221;)<br \/>end<br \/># TODO: Module should report_vuln if this finding is solid.<br \/>rescue ::Rex::ConnectionError, ::Errno::EPIPE<br \/>print_error(&#8220;#{ip}:#{rport} unable to connect to the server&#8221;)<br \/>end<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::Auxiliaryinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scannerinclude Msf::Exploit::Remote::TNS def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Oracle TNS Listener Checker&#8217;,&#8216;Description&#8217; =&gt; %q{This module checks the server for vulnerabilities like TNS Poison.Module sends a server a packet with command to register new TNS Listener and checksfor a response indicating an error. &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-59334","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59334","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=59334"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59334\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}