{"id":59333,"date":"2024-09-01T03:00:22","date_gmt":"2024-09-01T00:00:22","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180936\/sid_enum.rb.txt"},"modified":"2024-09-01T03:00:22","modified_gmt":"2024-09-01T00:00:22","slug":"oracle-tns-listener-sid-enumeration","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/oracle-tns-listener-sid-enumeration\/","title":{"rendered":"Oracle TNS Listener SID Enumeration"},"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::Exploit::Remote::TNS<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Oracle TNS Listener SID Enumeration&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module simply queries the TNS listener for the Oracle SID.<br \/>With Oracle 9.2.0.8 and above the listener will be protected and<br \/>the SID will have to be bruteforced or guessed.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [ &#8216;CG&#8217;, &#8216;MC&#8217; ],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2009-01-07&#8217;<br \/>))<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(1521)<br \/>])<br \/>end<\/p>\n<p>def run_host(ip)<br \/>begin<br \/>connect<\/p>\n<p>pkt = tns_packet(&#8220;(CONNECT_DATA=(COMMAND=STATUS))&#8221;)<\/p>\n<p>sock.put(pkt)<\/p>\n<p>select(nil,nil,nil,0.5)<\/p>\n<p>data = sock.get_once<\/p>\n<p>if ( data and data =~ \/ERROR_STACK\/ )<br \/>print_error(&#8220;TNS listener protected for #{ip}&#8230;&#8221;)<br \/>else<br \/>if(not data)<br \/>print_error(&#8220;#{ip} Connection but no data&#8221;)<br \/>else<br \/>sid = data.scan(\/INSTANCE_NAME=([^\\)]+)\/)<br \/>sid.uniq.each do |s|<br \/>report_note(<br \/>:host =&gt; ip,<br \/>:port =&gt; rport,<br \/>:type =&gt; &#8220;oracle_sid&#8221;,<br \/>:data =&gt; &#8220;PORT=#{rport}, SID=#{s}&#8221;,<br \/>:update =&gt; :unique_data<br \/>)<br \/>print_good(&#8220;Identified SID for #{ip}:#{rport} #{s}&#8221;)<br \/>end<br \/>service_name = data.scan(\/SERVICE_NAME=([^\\)]+)\/)<br \/>service_name.uniq.each do |s|<br \/>report_note(<br \/>:host =&gt; ip,<br \/>:port =&gt; rport,<br \/>:type =&gt; &#8220;oracle_service_name&#8221;,<br \/>:data =&gt; &#8220;PORT=#{rport}, SERVICE_NAME=#{s}&#8221;,<br \/>:update =&gt; :unique_data<br \/>)<br \/>print_status(&#8220;Identified SERVICE_NAME for #{ip}:#{rport} #{s}&#8221;)<br \/>end<br \/>end<br \/>end<br \/>disconnect<br \/>rescue ::Rex::ConnectionError<br \/>rescue ::Errno::EPIPE<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::Exploit::Remote::TNSinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scanner def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Oracle TNS Listener SID Enumeration&#8217;,&#8216;Description&#8217; =&gt; %q{This module simply queries the TNS listener for the Oracle SID.With Oracle 9.2.0.8 and above the listener will be protected andthe SID will have to be bruteforced or &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-59333","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59333","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=59333"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59333\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}