Class: NTLM::Message::Challenge

Inherits:
NTLM::Message show all
Defined in:
lib/ntlm/message.rb

Overview

MS-NLMP

2.2.1.2

Constant Summary collapse

TYPE =
2
ATTRIBUTES =
[:target_name, :challenge, :target_info, :version]
DEFAULT_FLAGS =
0

Constants inherited from NTLM::Message

AV_PAIRS, AV_PAIR_NAMES, FLAGS, SSP_SIGNATURE

Constants included from Util

Util::LM_MAGIC_TEXT

Instance Attribute Summary

Attributes inherited from NTLM::Message

#flag

Instance Method Summary collapse

Methods inherited from NTLM::Message

#clear, #has_flag?, #initialize, #inspect, #inspect_flags, parse, #serialize_to_base64, #set, #to_s, #unicode?

Methods included from Util

create_des_keys, #decode_utf16, #encode_utf16, encrypt, lm_v1_hash, nt_v1_hash, nt_v2_hash, ntlm_v1_response, ntlm_v2_response

Constructor Details

This class inherits a constructor from NTLM::Message

Instance Method Details

#parse(string) ⇒ Object



252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/ntlm/message.rb', line 252

def parse(string)
  super
  target_name, @flag, @challenge, target_info, version = string.unpack('x12a8Va8x8a8a8')
  @target_name = fetch_payload(target_name) if has_flag?(:REQUEST_TARGET)
  @target_info = fetch_payload(target_info) if has_flag?(:NEGOTIATE_TARGET_INFO)
  @version     = decode_version(version)  if has_flag?(:NEGOTIATE_VERSION)

  @target_name &&= decode_utf16(@target_name) if unicode?
  @target_info &&= decode_av_pair(@target_info)

  self
end

#serializeObject



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/ntlm/message.rb', line 265

def serialize
  @buffer = ''
  @offset = 56  # (8 + 4) + 8 + 4 + (8 * 4)

  @challenge ||= OpenSSL::Random.random_bytes(8)

  if @target_name
    set(:REQUEST_TARGET)
    if unicode?
      target_name = append_payload(encode_utf16(@target_name))
    else
      target_name = append_payload(@target_name)
    end
  end

  if @target_info
    set(:NEGOTIATE_TARGET_INFO)
    target_info = append_payload(encode_av_pair(@target_info))
  end

  if @version
    set(:NEGOTIATE_VERSION)
    version = encode_version(@version)
  end

  [SSP_SIGNATURE, TYPE, target_name, @flag, @challenge, target_info, version].pack('a8Va8Va8x8a8a8') + @buffer
end