Sha256: 254089c344cef3589e370e9b7d25104e53414579ab879c11691129e0235c689b

Contents?: true

Size: 1.33 KB

Versions: 43

Compression:

Stored size: 1.33 KB

Contents

module Rex
module Proto
module DCERPC
class Handle

	require 'rex/proto/dcerpc/uuid'

	@@protocols = ['ncacn_ip_tcp', 'ncacn_ip_udp', 'ncacn_np', 'ncacn_http']
	attr_accessor :uuid, :protocol, :address, :options

	# instantiate a handle object, akin to Microsoft's string binding handle by values
	def initialize(uuid, protocol, address, options)
		raise ArgumentError if !Rex::Proto
		raise ArgumentError if !Rex::Proto::DCERPC::UUID.is?(uuid[0])
		raise ArgumentError if !@@protocols.include?(protocol)
		self.uuid = uuid
		self.protocol = protocol
		self.address = address
		self.options = options
	end

	# instantiate a handle object, by parsing a string binding handle
	def self.parse (handle)
		uuid_re = '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
		rev_re = '\d+.\d+'
		proto_re = '(?:' + @@protocols.join('|') + ')'
		re = Regexp.new("(#{uuid_re}):(#{rev_re})\@(#{proto_re}):(.*?)\\[(.*)\\]$", true, 'n')
		match = re.match(handle)
		raise ArgumentError if !match

		uuid = [match[1], match[2]]
		protocol = match[3]
		address = match[4]
		options = match[5].split(',')
		i = Rex::Proto::DCERPC::Handle.new(uuid, protocol, address, options)
		return i
	end

	# stringify a handle
	def to_s
		self.uuid.join(':') + '@' + self.protocol + ':' + self.address + '[' + self.options.join(', ') + ']'
	end

end
end
end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/proto/dcerpc/handle.rb
librex-0.0.63 lib/rex/proto/dcerpc/handle.rb
librex-0.0.54 lib/rex/proto/dcerpc/handle.rb
librex-0.0.53 lib/rex/proto/dcerpc/handle.rb
librex-0.0.52 lib/rex/proto/dcerpc/handle.rb
librex-0.0.51 lib/rex/proto/dcerpc/handle.rb
librex-0.0.50 lib/rex/proto/dcerpc/handle.rb
librex-0.0.49 lib/rex/proto/dcerpc/handle.rb
librex-0.0.48 lib/rex/proto/dcerpc/handle.rb
librex-0.0.47 lib/rex/proto/dcerpc/handle.rb
librex-0.0.46 lib/rex/proto/dcerpc/handle.rb
librex-0.0.44 lib/rex/proto/dcerpc/handle.rb
librex-0.0.43 lib/rex/proto/dcerpc/handle.rb
librex-0.0.42 lib/rex/proto/dcerpc/handle.rb
librex-0.0.41 lib/rex/proto/dcerpc/handle.rb
librex-0.0.40 lib/rex/proto/dcerpc/handle.rb
librex-0.0.39 lib/rex/proto/dcerpc/handle.rb
librex-0.0.38 lib/rex/proto/dcerpc/handle.rb
librex-0.0.37 lib/rex/proto/dcerpc/handle.rb
librex-0.0.36 lib/rex/proto/dcerpc/handle.rb