2009-07-14 16:48:56 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-07-14 16:48:56 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::TNS
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2010-11-24 19:43:49 +00:00
|
|
|
'Name' => 'Oracle TNS Listener Command Issuer',
|
2009-07-14 16:48:56 +00:00
|
|
|
'Description' => %q{
|
2009-12-05 14:30:22 +00:00
|
|
|
This module allows for the sending of arbitrary TNS commands in order
|
|
|
|
to gather information.
|
2009-07-14 16:48:56 +00:00
|
|
|
Inspired from tnscmd.pl from www.jammed.com/~jwa/hacks/security/tnscmd/tnscmd
|
|
|
|
},
|
|
|
|
'Author' => ['MC'],
|
|
|
|
'License' => MSF_LICENSE,
|
2010-09-20 08:06:27 +00:00
|
|
|
'DisclosureDate' => 'Feb 1 2009'
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(1521),
|
|
|
|
OptString.new('CMD', [ false, 'Something like ping, version, status, etc..', '(CONNECT_DATA=(COMMAND=VERSION))']),
|
|
|
|
], self.class)
|
2009-07-14 16:48:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
|
2011-05-19 19:02:58 +00:00
|
|
|
begin
|
|
|
|
connect
|
2009-07-14 16:48:56 +00:00
|
|
|
|
2011-05-19 19:02:58 +00:00
|
|
|
command = datastore['CMD']
|
2009-07-14 16:48:56 +00:00
|
|
|
|
2011-05-19 19:02:58 +00:00
|
|
|
pkt = tns_packet(command)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2011-05-19 19:02:58 +00:00
|
|
|
print_status("Sending '#{command}' to #{rhost}:#{rport}")
|
|
|
|
sock.put(pkt)
|
|
|
|
print_status("writing #{pkt.length} bytes.")
|
2009-07-14 16:48:56 +00:00
|
|
|
|
2011-05-19 19:02:58 +00:00
|
|
|
select(nil,nil,nil,0.5)
|
2009-07-14 16:48:56 +00:00
|
|
|
|
2011-05-19 19:02:58 +00:00
|
|
|
print_status("reading")
|
2012-06-04 20:31:10 +00:00
|
|
|
res = sock.get_once(-1,5) || ''
|
2011-05-19 19:02:58 +00:00
|
|
|
res = res.tr("[\200-\377]","[\000-\177]")
|
|
|
|
res = res.tr("[\000-\027\]",".")
|
|
|
|
res = res.tr("\177",".")
|
2011-09-11 02:42:39 +00:00
|
|
|
print_status(res)
|
2011-05-19 19:02:58 +00:00
|
|
|
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
|
2011-10-17 02:42:01 +00:00
|
|
|
print_error e.message
|
2011-05-19 19:02:58 +00:00
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE,Errno::ECONNRESET => e
|
|
|
|
print_error e.message
|
2009-07-14 16:48:56 +00:00
|
|
|
end
|
|
|
|
end
|