Module: RubySMB::Dcerpc::Ndr::VarStringPlugin
- Defined in:
- lib/ruby_smb/dcerpc/ndr.rb
Instance Attribute Summary collapse
-
#actual_count ⇒ Object
Returns the value of attribute actual_count.
-
#offset ⇒ Object
Returns the value of attribute offset.
Instance Method Summary collapse
- #assign(val) ⇒ Object
- #do_num_bytes ⇒ Object
- #do_read(io) ⇒ Object
- #do_write(io) ⇒ Object
- #initialize_instance ⇒ Object
- #update_actual_count(val) ⇒ Object
Instance Attribute Details
#actual_count ⇒ Object
Returns the value of attribute actual_count.
587 588 589 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 587 def actual_count @actual_count end |
#offset ⇒ Object
Returns the value of attribute offset.
587 588 589 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 587 def offset @offset end |
Instance Method Details
#assign(val) ⇒ Object
616 617 618 619 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 616 def assign(val) update_actual_count(val) super end |
#do_num_bytes ⇒ Object
621 622 623 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 621 def do_num_bytes @actual_count > 0 ? (8 + super) : 8 end |
#do_read(io) ⇒ Object
604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 604 def do_read(io) @offset = io.readbytes(4).unpack('L<').first BinData. do |tracer| tracer.trace_obj("#{debug_name}.offset", @offset.to_s) end @actual_count = io.readbytes(4).unpack('L<').first BinData. do |tracer| tracer.trace_obj("#{debug_name}.actual_count", @actual_count.to_s) end super if @actual_count > 0 end |
#do_write(io) ⇒ Object
598 599 600 601 602 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 598 def do_write(io) io.writebytes([@offset].pack('L<')) io.writebytes([@actual_count].pack('L<')) super if @actual_count > 0 end |
#initialize_instance ⇒ Object
589 590 591 592 593 594 595 596 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 589 def initialize_instance @offset = 0 @actual_count = 0 if has_parameter?(:initial_value) update_actual_count(eval_parameter(:initial_value)) end super end |
#update_actual_count(val) ⇒ Object
625 626 627 628 629 630 631 632 633 634 635 636 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 625 def update_actual_count(val) if is_a?(BinData::Stringz) @actual_count = val.to_s.strip.length # Add one to count the terminator. According to # https://pubs.opengroup.org/onlinepubs/9629399/chap14.htm#tagcjh_19_03_04, # the NDR String must contain at least one element, the terminator. So, # add one even if it is an empty string. @actual_count += 1 else @actual_count = val.to_s.length end end |