Class: Rex::Proto::NTLM::Base::String

Inherits:
Field
  • Object
show all
Defined in:
lib/rex/proto/ntlm/base.rb

Instance Attribute Summary

Attributes inherited from Field

#active, #value

Instance Method Summary collapse

Methods inherited from Field

#size

Constructor Details

#initialize(opts) ⇒ String

Returns a new instance of String.



72
73
74
75
# File 'lib/rex/proto/ntlm/base.rb', line 72

def initialize(opts)
	super(opts)
	@size = opts[:size]
end

Instance Method Details

#parse(str, offset = 0) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/rex/proto/ntlm/base.rb', line 77

def parse(str, offset=0)
	if @active and str.size >= offset + @size
		@value = str[offset, @size]
		@size
	else
		0
	end
end

#serializeObject



86
87
88
89
90
91
92
# File 'lib/rex/proto/ntlm/base.rb', line 86

def serialize
	if @active
		@value
	else
		""
	end
end

#value=(val) ⇒ Object



94
95
96
97
98
# File 'lib/rex/proto/ntlm/base.rb', line 94

def value=(val)
	@value = val
	@size = @value.nil? ? 0 : @value.size
	@active = (@size > 0)
end