Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/ruby_smb/dcerpc/samr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,25 @@ class UserProperty < BinData::Record
# [2.2.10.1 USER_PROPERTIES](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/8263e7ab-aba9-43d2-8a36-3a9cb2dd3dad)
class UserProperties < BinData::Record
endian :little
hide :bytes_remaining

uint32 :reserved1
uint32 :struct_length, initial_value: -> { num_bytes - 12 }
# Length, in bytes, of the entire structure, starting from the :reserved4 field (offset 12):
uint32 :struct_length, value: -> { num_bytes - 12}
uint16 :reserved2
uint16 :reserved3
string :reserved4, length: 96
uint16 :property_signature, initial_value: 0x50
uint16 :property_count, initial_value: -> { user_properties.size }, onlyif: -> { struct_length > 111 }
array :user_properties, type: :user_property, initial_length: :property_count, onlyif: :property_count?
count_bytes_remaining :bytes_remaining
# When there are zero `user_property` elements in the `:user_properties` field, this field MUST be omitted;
# the resultant `UserProperties` structure has a constant size of 0x6F bytes.
uint16 :property_count, value: -> { user_properties.size }, onlyif: :display_user_properties?
array :user_properties, type: :user_property, read_until: -> { array.size == property_count }, onlyif: :display_user_properties?
uint8 :reserved5

def display_user_properties?
(bytes_remaining > 1 && reading?) || user_properties.size > 0
end
end

# [2.2.10.7 KERB_KEY_DATA_NEW](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/447520a5-e1cc-48cc-8fdc-b90db57f7eac)
Expand Down
Loading