Class: NTLM::Message::Authenticate

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

Overview

MS-NLMP

2.2.1.3

Constant Summary collapse

TYPE =
3
ATTRIBUTES =
[:lm_response, :nt_response, :domain, :user, :workstation, :session_key, :version, :mic]
DEFAULT_FLAGS =
[NEGOTIATE_UNICODE, REQUEST_TARGET, NEGOTIATE_NTLM, NEGOTIATE_ALWAYS_SIGN, NEGOTIATE_EXTENDED_SECURITY].inject(:|)

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



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/ntlm/message.rb', line 305

def parse(string)
  super
  lm_response, nt_response, domain, user, workstation, session_key, @flag, version, mic = \
    string.unpack('x12a8a8a8a8a8a8Va8a16')

  @lm_response = fetch_payload(lm_response)
  @nt_response = fetch_payload(nt_response)
  @domain      = fetch_payload(domain)
  @user        = fetch_payload(user)
  @workstation = fetch_payload(workstation)
  @session_key = fetch_payload(session_key) if has_flag?(:NEGOTIATE_KEY_EXCH)
  @version     = decode_version(version) if has_flag?(:NEGOTIATE_VERSION)
  @mic         = mic

  if unicode?
    @domain      = decode_utf16(@domain)
    @user        = decode_utf16(@user)
    @workstation = decode_utf16(@workstation)
  end

  self
end

#serializeObject



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/ntlm/message.rb', line 328

def serialize
  @buffer = ''
  @offset = 88  # (8 + 4) + (8 * 6) + 4 + 8 + 16

  lm_response = append_payload(@lm_response)
  nt_response = append_payload(@nt_response)

  if unicode?
    domain      = append_payload(encode_utf16(@domain))
    user        = append_payload(encode_utf16(@user))
    workstation = append_payload(encode_utf16(@workstation))
  else
    domain      = append_payload(@domain)
    user        = append_payload(@user)
    workstation = append_payload(@workstation)
  end

  if @session_key
    set(:NEGOTIATE_KEY_EXCH)
    session_key = append_payload(@session_key)
  end

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

  [SSP_SIGNATURE, TYPE, lm_response, nt_response, domain, user, workstation, session_key, @flag, version, @mic].pack('a8Va8a8a8a8a8a8Va8a16') + @buffer
end