Sha256: 3fedcafa1585c32485c96d11466f56740aa4b0918649537cf4e8c9f37f974654

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

# -*- coding: binary -*-
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

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/proto/dcerpc/handle.rb
rex-2.0.12 lib/rex/proto/dcerpc/handle.rb
rex-2.0.11 lib/rex/proto/dcerpc/handle.rb
rex-2.0.10 lib/rex/proto/dcerpc/handle.rb
rex-2.0.9 lib/rex/proto/dcerpc/handle.rb
rex-2.0.8 lib/rex/proto/dcerpc/handle.rb
rex-2.0.7 lib/rex/proto/dcerpc/handle.rb
rex-2.0.5 lib/rex/proto/dcerpc/handle.rb
rex-2.0.4 lib/rex/proto/dcerpc/handle.rb
dstruct-0.0.1 lib/rex/proto/dcerpc/handle.rb
rex-2.0.3 lib/rex/proto/dcerpc/handle.rb
librex-0.0.999 lib/rex/proto/dcerpc/handle.rb
rex-2.0.2 lib/rex/proto/dcerpc/handle.rb
librex-0.0.71 lib/rex/proto/dcerpc/handle.rb
librex-0.0.70 lib/rex/proto/dcerpc/handle.rb