CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/oracle/tnscmd.rb
Views: 11783
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::Exploit::Remote::TNS
8
9
def initialize(info = {})
10
super(update_info(info,
11
'Name' => 'Oracle TNS Listener Command Issuer',
12
'Description' => %q{
13
This module allows for the sending of arbitrary TNS commands in order
14
to gather information.
15
Inspired from tnscmd.pl from www.jammed.com/~jwa/hacks/security/tnscmd/tnscmd
16
},
17
'Author' => ['MC'],
18
'License' => MSF_LICENSE,
19
'DisclosureDate' => '2009-02-01'
20
))
21
22
register_options(
23
[
24
Opt::RPORT(1521),
25
OptString.new('CMD', [ false, 'Something like ping, version, status, etc..', '(CONNECT_DATA=(COMMAND=VERSION))']),
26
])
27
end
28
29
def run
30
31
begin
32
connect
33
34
command = datastore['CMD']
35
36
pkt = tns_packet(command)
37
38
print_status("Sending '#{command}' to #{rhost}:#{rport}")
39
sock.put(pkt)
40
print_status("writing #{pkt.length} bytes.")
41
42
select(nil,nil,nil,0.5)
43
44
print_status("reading")
45
res = sock.get_once(-1,5) || ''
46
res = res.tr("[\200-\377]","[\000-\177]")
47
res = res.tr("[\000-\027\]",".")
48
res = res.tr("\177",".")
49
print_status(res)
50
51
disconnect
52
end
53
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
54
print_error e.message
55
rescue ::Timeout::Error, ::Errno::EPIPE,Errno::ECONNRESET => e
56
print_error e.message
57
end
58
end
59
60