Class: RubySMB::Dcerpc::Response

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/ruby_smb/dcerpc/response.rb

Overview

The Response PDU as defined in The response PDU

Constant Summary collapse

PTYPE =
PTypes::RESPONSE

Instance Method Summary collapse

Instance Method Details

#has_auth_verifier?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/ruby_smb/dcerpc/response.rb', line 34

def has_auth_verifier?
  self.pdu_header.auth_length > 0
end

#initialize_instanceObject



29
30
31
32
# File 'lib/ruby_smb/dcerpc/response.rb', line 29

def initialize_instance
  super
  pdu_header.ptype = PTYPE
end

#read(io) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ruby_smb/dcerpc/response.rb', line 49

def read(io)
  super
  if has_auth_verifier? && sec_trailer.auth_pad_length > 0
    # At this point, auth_pad is at the end of the stub. We need to move
    # it to the correct field. It is now possible since we know its
    # length from the sec_trailer auth_pad_length field.
    pad = stub[-(sec_trailer.auth_pad_length)..-1]
    stub.assign(stub[0...-(sec_trailer.auth_pad_length)])
    auth_pad.assign(pad)
  end
end

#stub_lengthObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/ruby_smb/dcerpc/response.rb', line 38

def stub_length
  stub_length = pdu_header.frag_length - stub.rel_offset
  if has_auth_verifier?
    # Note that the resulting stub length includes auth_pad. We will be
    # able to separate the auth_pad from the stub once the sec_trailer
    # structure is read.
    stub_length -= (sec_trailer.num_bytes + pdu_header.auth_length)
  end
  stub_length
end