Class: Rex::Proto::DCERPC::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/dcerpc/handle.rb

Constant Summary collapse

@@protocols =
['ncacn_ip_tcp', 'ncacn_ip_udp', 'ncacn_np', 'ncacn_http']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid, protocol, address, options) ⇒ Handle

instantiate a handle object, akin to Microsoft’s string binding handle by values

Raises:



13
14
15
16
17
18
19
20
21
# File 'lib/rex/proto/dcerpc/handle.rb', line 13

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

Instance Attribute Details

#addressObject

Returns the value of attribute address.



10
11
12
# File 'lib/rex/proto/dcerpc/handle.rb', line 10

def address
  @address
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/rex/proto/dcerpc/handle.rb', line 10

def options
  @options
end

#protocolObject

Returns the value of attribute protocol.



10
11
12
# File 'lib/rex/proto/dcerpc/handle.rb', line 10

def protocol
  @protocol
end

#uuidObject

Returns the value of attribute uuid.



10
11
12
# File 'lib/rex/proto/dcerpc/handle.rb', line 10

def uuid
  @uuid
end

Class Method Details

.parse(handle) ⇒ Object

instantiate a handle object, by parsing a string binding handle

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rex/proto/dcerpc/handle.rb', line 24

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

Instance Method Details

#to_sObject

stringify a handle



41
42
43
# File 'lib/rex/proto/dcerpc/handle.rb', line 41

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