Class: RubySMB::NTLM::Client::Session

Inherits:
Net::NTLM::Client::Session
  • Object
show all
Defined in:
lib/ruby_smb/ntlm/client.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby_smb/ntlm/client.rb', line 19

def authenticate!
  calculate_user_session_key!
  type3_opts = {
    :lm_response   => is_anonymous? ? "\x00".b : lmv2_resp,
    :ntlm_response => is_anonymous? ? '' : ntlmv2_resp,
    :domain        => domain,
    :user          => username,
    :workstation   => workstation,
    :flag          => (challenge_message.flag & client.flags)
  }
  t3 = Net::NTLM::Message::Type3.create type3_opts
  t3.extend(Message)
  if negotiate_key_exchange?
    t3.enable(:session_key)
    rc4 = OpenSSL::Cipher.new("rc4")
    rc4.encrypt
    rc4.key = user_session_key
    sk = rc4.update exported_session_key
    sk << rc4.final
    t3.session_key = sk
  end
  t3
end

#is_anonymous?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ruby_smb/ntlm/client.rb', line 43

def is_anonymous?
  username == '' && password == ''
end