Module: RubySMB::Dcerpc::Ndr::ConfStringPlugin
- Defined in:
- lib/ruby_smb/dcerpc/ndr.rb
Instance Attribute Summary collapse
-
#max_count ⇒ Object
Returns the value of attribute max_count.
Instance Method Summary collapse
- #assign(val) ⇒ Object
- #do_num_bytes ⇒ Object
- #do_read(io) ⇒ Object
- #do_write(io) ⇒ Object
- #get_max_count(val) ⇒ Object
- #initialize_instance ⇒ Object
- #set_max_count(val) ⇒ Object
- #should_process_max_count? ⇒ Boolean
Instance Attribute Details
#max_count ⇒ Object
Returns the value of attribute max_count.
511 512 513 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 511 def max_count @max_count end |
Instance Method Details
#assign(val) ⇒ Object
545 546 547 548 549 550 551 552 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 545 def assign(val) if val.is_a?(ConfStringPlugin) @max_count = val.max_count else set_max_count(get_max_count(val)) end super end |
#do_num_bytes ⇒ Object
554 555 556 557 558 559 560 561 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 554 def do_num_bytes sum = 0 if should_process_max_count? # add max_count size sum += 4 end sum + super end |
#do_read(io) ⇒ Object
534 535 536 537 538 539 540 541 542 543 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 534 def do_read(io) if should_process_max_count? max_count = io.readbytes(4).unpack1('L<') BinData. do |tracer| tracer.trace_obj("#{debug_name}.max_count", max_count.to_s) end set_max_count(max_count) end super end |
#do_write(io) ⇒ Object
527 528 529 530 531 532 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 527 def do_write(io) if should_process_max_count? io.writebytes([@max_count].pack('L<')) end super end |
#get_max_count(val) ⇒ Object
563 564 565 566 567 568 569 570 571 572 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 563 def get_max_count(val) if is_a?(BinData::Stringz) max_count = val.to_s.strip.length # Only count the terminating NULL byte if the string is not empty max_count += 1 if max_count > 0 return max_count else return val.to_s.length end end |
#initialize_instance ⇒ Object
513 514 515 516 517 518 519 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 513 def initialize_instance @max_count = 0 if has_parameter?(:initial_value) set_max_count(get_max_count(eval_parameter(:initial_value))) end super end |
#set_max_count(val) ⇒ Object
574 575 576 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 574 def set_max_count(val) @max_count = val end |
#should_process_max_count? ⇒ Boolean
521 522 523 524 525 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 521 def should_process_max_count? # :max_count has already been processed if the parent structure is an # NdrStruct, but this is not the case if we are dealing with a pointer !parent.is_a?(NdrStruct) || self.is_a?(PointerPlugin) end |