Class: RubySMB::Dcerpc::Ndr::NdrStruct

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

Direct Known Subclasses

Drsr::Attr, Drsr::Attrblock, Drsr::Attrval, Drsr::Attrvalblock, Drsr::DrsCompressedBlob, Drsr::DrsExtensions, Drsr::DrsExtensionsInt, Drsr::DrsMsgCrackreply, Drsr::DrsMsgCrackreplyV1, Drsr::DrsMsgCrackreq, Drsr::DrsMsgCrackreqV1, Drsr::DrsMsgDcinforeply, Drsr::DrsMsgDcinforeplyV1, Drsr::DrsMsgDcinforeplyV2, Drsr::DrsMsgDcinforeplyV3, Drsr::DrsMsgDcinforeplyVffffffff, Drsr::DrsMsgDcinforeq, Drsr::DrsMsgDcinforeqV1, Drsr::DrsMsgGetchgreply, Drsr::DrsMsgGetchgreplyV1, Drsr::DrsMsgGetchgreplyV2, Drsr::DrsMsgGetchgreplyV6, Drsr::DrsMsgGetchgreplyV7, Drsr::DrsMsgGetchgreplyV9, Drsr::DrsMsgGetchgreq, Drsr::DrsMsgGetchgreqV3, Drsr::DrsMsgGetchgreqV4, Drsr::DrsMsgGetchgreqV5, Drsr::DsDomainControllerInfo1w, Drsr::DsDomainControllerInfo2w, Drsr::DsDomainControllerInfo3w, Drsr::DsDomainControllerInfoFfffffffw, Drsr::DsName, Drsr::DsNameResultItemw, Drsr::DsNameResultw, Drsr::Entinf, Drsr::MtxAddr, Drsr::OidT, Drsr::PartialAttrVectorV1Ext, Drsr::PrefixTableEntry, Drsr::PropertyMetaDataExt, Drsr::PropertyMetaDataExtVector, Drsr::ReplentinflistPtr, Drsr::ReplvalinfV1, Drsr::ReplvalinfV3, Drsr::SchemaPrefixTable, Drsr::UptodateCursorV1, Drsr::UptodateCursorV2, Drsr::UptodateVectorV1Ext, Drsr::UptodateVectorV2Ext, Drsr::UsnVector, Drsr::ValueMetaDataExtV1, Drsr::ValueMetaDataExtV3, Drsr::VarSizeBufferWithVersion, Efsrpc::EfsHashBlob, Efsrpc::EncryptionCertificateHash, Epm::EpmDecodedTowerOctetString, Epm::EpmFloorHostOrAddr, Epm::EpmFloorInterfaceOrDataIdentifier, Epm::EpmFloorPipeOrHost, Epm::EpmFloorPipeOrPort, Epm::EpmFloorProtocolIdentifier, Epm::EpmIpxSpxAddress, Epm::EpmTwrt, Icpr::CertTransBlob, RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator, PContElemT, PContListT, PResultListT, PResultT, PSyntaxIdT, PortAnyT, PrintSystem::DriverContainer, PrintSystem::DriverInfo2, RpcSecurityAttributes, RpcSecurityDescriptor, RpcUnicodeString, RrpUnicodeString, Samr::GroupMembership, Samr::RpcSid, Samr::SamprEnumerationBuffer, Samr::SamprGetGroupsBuffer, Samr::SamprPsidArray, Samr::SamprRidEnumeration, Samr::SamprSidInformation, Samr::SamprUlongArray, SecTrailer, Srvsvc::LpshareEnumStruct, Srvsvc::ShareInfo1Container, Srvsvc::ShareInfo1Element, Svcctl::QueryServiceConfigW, Svcctl::ServiceStatus, Winreg::Regsam, Wkssvc::LpwkstaInfo, Wkssvc::WkstaInfo100, Wkssvc::WkstaInfo101, Wkssvc::WkstaInfo102

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.has_conformant_arrayObject (readonly)

Returns the value of attribute has_conformant_array.



827
828
829
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 827

def has_conformant_array
  @has_conformant_array
end

Class Method Details

.method_missing(symbol, *args, &block) ⇒ Object



844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 844

def self.method_missing(symbol, *args, &block)
  field = super
  if field.is_a?(::Array) && field.last.is_a?(BinData::SanitizedField)
    unless field.last.has_parameter?(:byte_align) || field.last.instantiate.bit_aligned?
      raise ArgumentError.new(
        "NDR Structures must only include elements with the `:byte_align` "\
        "parameter set. This makes sure the whole structure is correctly "\
        "aligned. Use a predefined NDR element instead, or provide the "\
        "`:byte_align` parameter when defining the structure "\
        "(Faulty element: #{field.last.name})"
      )
    end
    validate_conformant_array(field)
  end
  field
end

.validate_conformant_array(field) ⇒ Object



829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 829

def self.validate_conformant_array(field)
  if @has_conformant_array
    raise ArgumentError.new(
      "Invalid structure #{self}: Conformant array or embedded structure "\
      "with Conformant array must be the last member of the structure"
    )
  end
  obj_proto = field.last.prototype
  obj_class = obj_proto.instance_variable_get(:@obj_class)
  @has_conformant_array = true if obj_class < NdrStruct && obj_class.has_conformant_array
  if obj_class.is_a?(ConfClassPlugin) && !obj_class.is_a?(PointerClassPlugin)
    @has_conformant_array = true
  end
end

Instance Method Details

#initialize_shared_instanceObject



861
862
863
864
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 861

def initialize_shared_instance
  super
  extend StructPlugin
end