Class: Net::NTLM::Message::Type3

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Net::NTLM::Message

#data_edge, #data_size, decode64, #decode64, #deflag, #dump_flags, #encode64, #has_flag?, #head_size, parse, #parse, #security_buffers, #serialize, #set_flag, #size

Methods inherited from FieldSet

#[], #[]=, #disable, #enable, #has_disabled_fields?, #initialize, int16LE, int32LE, int64LE, names, opts, #parse, prototypes, security_buffer, #serialize, #size, string, types

Constructor Details

This class inherits a constructor from Net::NTLM::FieldSet

Class Method Details

.create(arg, opt = {}) ⇒ Type3

Note:

All options must be properly encoded with either unicode or oem encoding

Builds a Type 3 packet

Parameters:

  • arg (Hash)

    a customizable set of options

Options Hash (arg):

  • :lm_response (String)

    The LM hash

  • :ntlm_response (String)

    The NTLM hash

  • :domain (String)

    The domain to authenticate to

  • :workstation (String)

    The name of the calling workstation

  • :session_key (String)

    The session key

  • :flag (Integer)

    Flags for the packet

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/net/ntlm/message/type3.rb', line 29

def create(arg, opt ={})
  t = new
  t.lm_response = arg[:lm_response]
  t.ntlm_response = arg[:ntlm_response]
  t.domain = arg[:domain]
  t.user = arg[:user]

  if arg[:workstation]
    t.workstation = arg[:workstation]
  end

  if arg[:session_key]
    t.enable(:session_key)
    t.session_key = arg[:session_key]
  end

  if arg[:flag]
    t.enable(:session_key)
    t.enable(:flag)
    t.flag = arg[:flag]
  end
  t
end

Instance Method Details

#blank_password?(server_challenge) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


55
56
57
# File 'lib/net/ntlm/message/type3.rb', line 55

def blank_password?(server_challenge)
  password?('', server_challenge)
end

#domainSecurityBuffer

Returns:



12
# File 'lib/net/ntlm/message/type3.rb', line 12

security_buffer :domain,        {:value => ""}

#domain=SecurityBuffer

Returns:



12
# File 'lib/net/ntlm/message/type3.rb', line 12

security_buffer :domain,        {:value => ""}

#flagInt32LE

Returns:



16
# File 'lib/net/ntlm/message/type3.rb', line 16

int32LE         :flag,          {:value => 0, :active => false }

#flag=Int32LE

Returns:



16
# File 'lib/net/ntlm/message/type3.rb', line 16

int32LE         :flag,          {:value => 0, :active => false }

#lm_responseSecurityBuffer

Returns:



10
# File 'lib/net/ntlm/message/type3.rb', line 10

security_buffer :lm_response,   {:value => ""}

#lm_response=SecurityBuffer

Returns:



10
# File 'lib/net/ntlm/message/type3.rb', line 10

security_buffer :lm_response,   {:value => ""}

#ntlm_responseSecurityBuffer

Returns:



11
# File 'lib/net/ntlm/message/type3.rb', line 11

security_buffer :ntlm_response, {:value => ""}

#ntlm_response=SecurityBuffer

Returns:



11
# File 'lib/net/ntlm/message/type3.rb', line 11

security_buffer :ntlm_response, {:value => ""}

#ntlm_versionSymbol

Returns:

  • (Symbol)


77
78
79
80
81
82
83
84
85
# File 'lib/net/ntlm/message/type3.rb', line 77

def ntlm_version
  if ntlm_response.size == 24 && lm_response[0,8] != "\x00"*8 && lm_response[8,16] == "\x00"*16
    :ntlm2_session
  elsif ntlm_response.size == 24
    :ntlmv1
  elsif ntlm_response.size > 24
    :ntlmv2
  end
end

#os_versionString

Returns:



17
# File 'lib/net/ntlm/message/type3.rb', line 17

string          :os_version,    {:size => 8, :active => false }

#os_version=String

Returns:



17
# File 'lib/net/ntlm/message/type3.rb', line 17

string          :os_version,    {:size => 8, :active => false }

#password?(password, server_challenge) ⇒ true, false

Parameters:

Returns:



65
66
67
68
69
70
71
72
73
74
# File 'lib/net/ntlm/message/type3.rb', line 65

def password?(password, server_challenge)
  case ntlm_version
  when :ntlm2_session
    ntlm2_session_password?(password, server_challenge)
  when :ntlmv2
    ntlmv2_password?(password, server_challenge)
  else
    raise
  end
end

#session_keySecurityBuffer

Returns:



15
# File 'lib/net/ntlm/message/type3.rb', line 15

security_buffer :session_key,   {:value => "", :active => false }

#session_key=SecurityBuffer

Returns:



15
# File 'lib/net/ntlm/message/type3.rb', line 15

security_buffer :session_key,   {:value => "", :active => false }

#signString

Returns:



8
# File 'lib/net/ntlm/message/type3.rb', line 8

string          :sign,          {:size => 8, :value => SSP_SIGN}

#sign=String

Returns:



8
# File 'lib/net/ntlm/message/type3.rb', line 8

string          :sign,          {:size => 8, :value => SSP_SIGN}

#typeInt32LE

Returns:



9
# File 'lib/net/ntlm/message/type3.rb', line 9

int32LE         :type,          {:value => 3}

#type=Int32LE

Returns:



9
# File 'lib/net/ntlm/message/type3.rb', line 9

int32LE         :type,          {:value => 3}

#userSecurityBuffer

Returns:



13
# File 'lib/net/ntlm/message/type3.rb', line 13

security_buffer :user,          {:value => ""}

#user=SecurityBuffer

Returns:



13
# File 'lib/net/ntlm/message/type3.rb', line 13

security_buffer :user,          {:value => ""}

#workstationSecurityBuffer

Returns:



14
# File 'lib/net/ntlm/message/type3.rb', line 14

security_buffer :workstation,   {:value => ""}

#workstation=SecurityBuffer

Returns:



14
# File 'lib/net/ntlm/message/type3.rb', line 14

security_buffer :workstation,   {:value => ""}