2009-01-07 03:07:01 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This module exposes methods for querying a remote TNS service
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module Exploit::Remote::TNS
|
2011-11-20 01:32:06 +00:00
|
|
|
|
2009-01-07 03:07:01 +00:00
|
|
|
include Exploit::Remote::Tcp
|
2011-11-20 01:32:06 +00:00
|
|
|
|
2009-01-07 03:07:01 +00:00
|
|
|
#
|
|
|
|
# Creates an instance of a TNS exploit module.
|
|
|
|
#
|
|
|
|
def initialize(info = {})
|
|
|
|
super
|
|
|
|
|
|
|
|
# Register the options that all TNS exploits may make use of.
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RHOST,
|
|
|
|
Opt::RPORT(1521),
|
|
|
|
], Msf::Exploit::Remote::TNS)
|
|
|
|
end
|
|
|
|
|
|
|
|
def tns_packet(connect_data)
|
|
|
|
|
|
|
|
packet_length = [58 + connect_data.length].pack('n')
|
2011-11-20 01:32:06 +00:00
|
|
|
|
2009-01-07 03:07:01 +00:00
|
|
|
# Packet length
|
|
|
|
pkt = packet_length
|
|
|
|
# Checksum
|
|
|
|
pkt << "\x00\x00"
|
|
|
|
# Packet Type: Connect(1)
|
|
|
|
pkt << "\x01"
|
|
|
|
# Reserved
|
|
|
|
pkt << "\x00"
|
|
|
|
# Header Checksum
|
|
|
|
pkt << "\x00\x00"
|
|
|
|
# Version
|
|
|
|
pkt << "\x01\x36"
|
|
|
|
# Version (Compatible)
|
|
|
|
pkt << "\x01\x2C"
|
|
|
|
pkt << "\x00\x00\x08\x00"
|
|
|
|
pkt << "\x7F\xFF"
|
|
|
|
pkt << "\x7F\x08"
|
|
|
|
pkt << "\x00\x00"
|
|
|
|
pkt << "\x00\x01"
|
|
|
|
pkt << [connect_data.length].pack('n')
|
|
|
|
pkt << "\x00\x3A"
|
|
|
|
pkt << "\x00\x00\x00\x00"
|
|
|
|
pkt << "\x00\x00\x00\x00"
|
|
|
|
pkt << "\x00"
|
|
|
|
pkt << "\x00"
|
|
|
|
pkt << "\x00\x00\x00\x00"
|
|
|
|
# Unique Connection ID
|
|
|
|
pkt << "\x00\x00\x34\xE6\x00\x00\x00\x01"
|
|
|
|
# Connect Data
|
|
|
|
pkt << "\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
pkt << connect_data
|
|
|
|
|
|
|
|
return pkt
|
|
|
|
|
|
|
|
end
|
2009-08-05 00:46:35 +00:00
|
|
|
|
|
|
|
def tns_packet10g(connect_data)
|
|
|
|
|
|
|
|
packet_length = [58 + connect_data.length].pack('n')
|
|
|
|
|
|
|
|
# Packet length
|
|
|
|
pkt = packet_length
|
|
|
|
# Checksum
|
|
|
|
pkt << "\x00\x00"
|
|
|
|
# Packet Type: Connect(1)
|
|
|
|
pkt << "\x01"
|
|
|
|
# Reserved
|
|
|
|
pkt << "\x00"
|
|
|
|
# Header Checksum
|
|
|
|
pkt << "\x00\x00"
|
|
|
|
# Version
|
|
|
|
pkt << "\x01\x39"
|
|
|
|
# Version (Compatible)
|
2010-09-26 21:02:00 +00:00
|
|
|
pkt << "\x01\x2C"
|
2009-08-05 00:46:35 +00:00
|
|
|
pkt << "\x00\x81\x08\x00"
|
|
|
|
pkt << "\x7F\xFF"
|
|
|
|
pkt << "\x7F\x08"
|
|
|
|
pkt << "\x00\x00"
|
|
|
|
pkt << "\x00\x01"
|
|
|
|
pkt << [connect_data.length].pack('n')
|
|
|
|
pkt << "\x00\x3A"
|
|
|
|
pkt << "\x00\x00\x07\xf8"
|
|
|
|
pkt << "\x0c\x0c\x00\x00"
|
|
|
|
pkt << "\x00" * 22
|
|
|
|
pkt << connect_data
|
|
|
|
|
|
|
|
return pkt
|
|
|
|
|
|
|
|
end
|
2011-11-20 01:32:06 +00:00
|
|
|
|
2009-01-07 03:07:01 +00:00
|
|
|
end
|
|
|
|
end
|