CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/scanner/oracle/tnslsnr_version.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Auxiliary::Report
8
include Msf::Auxiliary::Scanner
9
include Msf::Exploit::Remote::TNS
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Oracle TNS Listener Service Version Query',
14
'Description' => %q{
15
This module simply queries the tnslsnr service for the Oracle build.
16
},
17
'Author' => ['CG'],
18
'License' => MSF_LICENSE,
19
'DisclosureDate' => '2009-01-07'))
20
21
register_options(
22
[
23
Opt::RPORT(1521)
24
])
25
end
26
27
def run_host(ip)
28
begin
29
connect
30
31
pkt = tns_packet("(CONNECT_DATA=(COMMAND=VERSION))")
32
33
sock.put(pkt)
34
35
select(nil,nil,nil,0.5)
36
37
data = sock.get_once
38
39
if ( data && data =~ /\\*.TNSLSNR for (.*)/ )
40
ora_version = data.match(/\\*.TNSLSNR for (.*)/)[1]
41
report_service(
42
:host => ip,
43
:port => datastore['RPORT'],
44
:name => "oracle",
45
:info => ora_version
46
)
47
print_good("#{ip}:#{datastore['RPORT']} Oracle - Version: " + ora_version)
48
elsif ( data && data =~ /\(ERR=(\d+)\)/ )
49
case $1.to_i
50
when 1189
51
print_error( "#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown - Error code #{$1} - The listener could not authenticate the user")
52
else
53
print_error( "#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown - Error code #{$1}")
54
end
55
else
56
print_error( "#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown")
57
end
58
disconnect
59
rescue ::Rex::ConnectionError
60
rescue ::Errno::EPIPE
61
end
62
end
63
end
64
65