Class: Rex::Proto::NTLM::Base::FieldSet
- Inherits:
-
Object
- Object
- Rex::Proto::NTLM::Base::FieldSet
- Defined in:
- lib/rex/proto/ntlm/base.rb
Overview
base class of data structure
Direct Known Subclasses
Class Method Summary collapse
- .define(&block) ⇒ Object
- .int16LE(name, opts) ⇒ Object
- .int32LE(name, opts) ⇒ Object
- .int64LE(name, opts) ⇒ Object
- .names ⇒ Object
- .opts ⇒ Object
- .prototypes ⇒ Object
- .security_buffer(name, opts) ⇒ Object
- .string(name, opts) ⇒ Object
- .types ⇒ Object
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, val) ⇒ Object
- #disable(name) ⇒ Object
- #enable(name) ⇒ Object
-
#initialize ⇒ FieldSet
constructor
self.
- #parse(str, offset = 0) ⇒ Object
- #serialize ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ FieldSet
self
233 234 235 |
# File 'lib/rex/proto/ntlm/base.rb', line 233 def initialize @alist = self.class.prototypes.map{ |n, t, o| [n, t.new(o)] } end |
Class Method Details
.define(&block) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/rex/proto/ntlm/base.rb', line 161 def define(&block) klass = Class.new(self) do def self.inherited(subclass) proto = @proto subclass.instance_eval do @proto = proto end end end klass.module_eval(&block) klass end |
.int16LE(name, opts) ⇒ Object
181 182 183 |
# File 'lib/rex/proto/ntlm/base.rb', line 181 def int16LE(name, opts) add_field(name, Int16LE, opts) end |
.int32LE(name, opts) ⇒ Object
185 186 187 |
# File 'lib/rex/proto/ntlm/base.rb', line 185 def int32LE(name, opts) add_field(name, Int32LE, opts) end |
.int64LE(name, opts) ⇒ Object
189 190 191 |
# File 'lib/rex/proto/ntlm/base.rb', line 189 def int64LE(name, opts) add_field(name, Int64LE, opts) end |
.names ⇒ Object
201 202 203 |
# File 'lib/rex/proto/ntlm/base.rb', line 201 def names @proto.map{|n, t, o| n} end |
.opts ⇒ Object
209 210 211 |
# File 'lib/rex/proto/ntlm/base.rb', line 209 def opts @proto.map{|n, t, o| o} end |
.prototypes ⇒ Object
197 198 199 |
# File 'lib/rex/proto/ntlm/base.rb', line 197 def prototypes @proto end |
.security_buffer(name, opts) ⇒ Object
193 194 195 |
# File 'lib/rex/proto/ntlm/base.rb', line 193 def security_buffer(name, opts) add_field(name, SecurityBuffer, opts) end |
.string(name, opts) ⇒ Object
177 178 179 |
# File 'lib/rex/proto/ntlm/base.rb', line 177 def string(name, opts) add_field(name, String, opts) end |
.types ⇒ Object
205 206 207 |
# File 'lib/rex/proto/ntlm/base.rb', line 205 def types @proto.map{|n, t, o| t} end |
Instance Method Details
#[](name) ⇒ Object
249 250 251 252 253 |
# File 'lib/rex/proto/ntlm/base.rb', line 249 def [](name) a = @alist.assoc(name.to_s.intern) raise ArgumentError, "no such field: #{name}" unless a a[1] end |
#[]=(name, val) ⇒ Object
255 256 257 258 259 |
# File 'lib/rex/proto/ntlm/base.rb', line 255 def []=(name, val) a = @alist.assoc(name.to_s.intern) raise ArgumentError, "no such field: #{name}" unless a a[1] = val end |
#disable(name) ⇒ Object
265 266 267 |
# File 'lib/rex/proto/ntlm/base.rb', line 265 def disable(name) self[name].active = false end |
#enable(name) ⇒ Object
261 262 263 |
# File 'lib/rex/proto/ntlm/base.rb', line 261 def enable(name) self[name].active = true end |
#parse(str, offset = 0) ⇒ Object
241 242 243 |
# File 'lib/rex/proto/ntlm/base.rb', line 241 def parse(str, offset=0) @alist.inject(offset){|cur, a| cur += a[1].parse(str, cur)} end |
#serialize ⇒ Object
237 238 239 |
# File 'lib/rex/proto/ntlm/base.rb', line 237 def serialize @alist.map{|n, f| f.serialize }.join end |
#size ⇒ Object
245 246 247 |
# File 'lib/rex/proto/ntlm/base.rb', line 245 def size @alist.inject(0){|sum, a| sum += a[1].size} end |