Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/scanner/oracle/tnslsnr_version.rb
19715 views
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(
13
update_info(
14
info,
15
'Name' => 'Oracle TNS Listener Service Version Query',
16
'Description' => %q{
17
This module simply queries the tnslsnr service for the Oracle build.
18
},
19
'Author' => ['CG'],
20
'License' => MSF_LICENSE,
21
'DisclosureDate' => '2009-01-07',
22
'Notes' => {
23
'Reliability' => UNKNOWN_RELIABILITY,
24
'Stability' => UNKNOWN_STABILITY,
25
'SideEffects' => UNKNOWN_SIDE_EFFECTS
26
}
27
)
28
)
29
30
register_options(
31
[
32
Opt::RPORT(1521)
33
]
34
)
35
end
36
37
def run_host(ip)
38
begin
39
connect
40
41
pkt = tns_packet("(CONNECT_DATA=(COMMAND=VERSION))")
42
43
sock.put(pkt)
44
45
select(nil, nil, nil, 0.5)
46
47
data = sock.get_once
48
49
if (data && data =~ /\\*.TNSLSNR for (.*)/)
50
ora_version = data.match(/\\*.TNSLSNR for (.*)/)[1]
51
report_service(
52
:host => ip,
53
:port => datastore['RPORT'],
54
:name => "oracle",
55
:info => ora_version
56
)
57
print_good("#{ip}:#{datastore['RPORT']} Oracle - Version: " + ora_version)
58
elsif (data && data =~ /\(ERR=(\d+)\)/)
59
case $1.to_i
60
when 1189
61
print_error("#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown - Error code #{$1} - The listener could not authenticate the user")
62
else
63
print_error("#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown - Error code #{$1}")
64
end
65
else
66
print_error("#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown")
67
end
68
disconnect
69
rescue ::Rex::ConnectionError
70
rescue ::Errno::EPIPE
71
end
72
end
73
end
74
75