Class: Rex::Proto::NTLM::Base::FieldSet

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

Overview

base class of data structure

Direct Known Subclasses

Message

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFieldSet

self


234
235
236
# File 'lib/rex/proto/ntlm/base.rb', line 234

def initialize
  @alist = self.class.prototypes.map{ |n, t, o| [n, t.new(o)] }
end

Class Method Details

.define(&block) ⇒ Object


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/rex/proto/ntlm/base.rb', line 162

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


182
183
184
# File 'lib/rex/proto/ntlm/base.rb', line 182

def int16LE(name, opts)
  add_field(name, Int16LE, opts)
end

.int32LE(name, opts) ⇒ Object


186
187
188
# File 'lib/rex/proto/ntlm/base.rb', line 186

def int32LE(name, opts)
  add_field(name, Int32LE, opts)
end

.int64LE(name, opts) ⇒ Object


190
191
192
# File 'lib/rex/proto/ntlm/base.rb', line 190

def int64LE(name, opts)
  add_field(name, Int64LE, opts)
end

.namesObject


202
203
204
# File 'lib/rex/proto/ntlm/base.rb', line 202

def names
  @proto.map{|n, t, o| n}
end

.optsObject


210
211
212
# File 'lib/rex/proto/ntlm/base.rb', line 210

def opts
  @proto.map{|n, t, o| o}
end

.prototypesObject


198
199
200
# File 'lib/rex/proto/ntlm/base.rb', line 198

def prototypes
  @proto
end

.security_buffer(name, opts) ⇒ Object


194
195
196
# File 'lib/rex/proto/ntlm/base.rb', line 194

def security_buffer(name, opts)
  add_field(name, SecurityBuffer, opts)
end

.string(name, opts) ⇒ Object


178
179
180
# File 'lib/rex/proto/ntlm/base.rb', line 178

def string(name, opts)
  add_field(name, String, opts)
end

.typesObject


206
207
208
# File 'lib/rex/proto/ntlm/base.rb', line 206

def types
  @proto.map{|n, t, o| t}
end

Instance Method Details

#[](name) ⇒ Object

Raises:


250
251
252
253
254
# File 'lib/rex/proto/ntlm/base.rb', line 250

def [](name)
  a = @alist.assoc(name.to_s.intern)
  raise ArgumentError, "no such field: #{name}" unless a
  a[1]
end

#[]=(name, val) ⇒ Object

Raises:


256
257
258
259
260
# File 'lib/rex/proto/ntlm/base.rb', line 256

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


266
267
268
# File 'lib/rex/proto/ntlm/base.rb', line 266

def disable(name)
  self[name].active = false
end

#enable(name) ⇒ Object


262
263
264
# File 'lib/rex/proto/ntlm/base.rb', line 262

def enable(name)
  self[name].active = true
end

#parse(str, offset = 0) ⇒ Object


242
243
244
# File 'lib/rex/proto/ntlm/base.rb', line 242

def parse(str, offset=0)
  @alist.inject(offset){|cur, a|  cur += a[1].parse(str, cur)}
end

#serializeObject


238
239
240
# File 'lib/rex/proto/ntlm/base.rb', line 238

def serialize
  @alist.map{|n, f| f.serialize }.join
end

#sizeObject


246
247
248
# File 'lib/rex/proto/ntlm/base.rb', line 246

def size
  @alist.inject(0){|sum, a| sum += a[1].size}
end