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/tnspoison_checker.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 Checker',
14
'Description' => %q{
15
This module checks the server for vulnerabilities like TNS Poison.
16
Module sends a server a packet with command to register new TNS Listener and checks
17
for a response indicating an error. If the registration is errored, the target is not
18
vulnerable. Otherwise, the target is vulnerable to malicious registrations.
19
},
20
'Author' => ['ir0njaw (Nikita Kelesis) <nikita.elkey[at]gmail.com>'], # of Digital Security [http://dsec.ru]
21
'References' =>
22
[
23
[ 'CVE', '2012-1675'],
24
[ 'URL', 'https://seclists.org/fulldisclosure/2012/Apr/204' ],
25
],
26
'DisclosureDate' => '2012-04-18',
27
'License' => MSF_LICENSE))
28
29
register_options(
30
[
31
Opt::RPORT(1521)
32
])
33
end
34
35
def run_host(ip)
36
begin
37
connect
38
send_packet = tns_packet("(CONNECT_DATA=(COMMAND=service_register_NSGR))")
39
sock.put(send_packet)
40
packet = sock.read(100)
41
if packet
42
hex_packet = Rex::Text.to_hex(packet, ':')
43
split_hex = hex_packet.split(':')
44
find_packet = /\(ERROR_STACK=\(ERROR=/ === packet
45
if find_packet == true #TNS Packet returned ERROR
46
print_error("#{ip}:#{rport} is not vulnerable")
47
elsif split_hex[5] == '02' #TNS Packet Type: ACCEPT
48
print_good("#{ip}:#{rport} is vulnerable")
49
elsif split_hex[5] == '04' #TNS Packet Type: REFUSE
50
print_error("#{ip}:#{rport} is not vulnerable")
51
else #All other TNS packet types or non-TNS packet type response cannot guarantee vulnerability
52
print_error("#{ip}:#{rport} might not be vulnerable")
53
end
54
else
55
print_error("#{ip}:#{rport} is not vulnerable")
56
end
57
# TODO: Module should report_vuln if this finding is solid.
58
rescue ::Rex::ConnectionError, ::Errno::EPIPE
59
print_error("#{ip}:#{rport} unable to connect to the server")
60
end
61
end
62
end
63
64