rubyntlm 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/net/ntlm/client.rb +4 -0
- data/lib/net/ntlm/client/session.rb +16 -16
- data/lib/net/ntlm/message/type2.rb +4 -2
- data/lib/net/ntlm/version.rb +1 -1
- data/spec/lib/net/ntlm/client/session_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0f0a253f64eaf9c8dc94df34a8f2ca3e92cc43f
|
4
|
+
data.tar.gz: 85e3ac2289f6ed8cd265429280e2be7c1187d05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a87594be04e9d3cd5630e0ad3ed19f8d069daf4c39c78b33f5c19487fdc97960e40bc2f62b689c5f4004895befc5cb1ab38d4a781d630bcda4b50aa098d1112
|
7
|
+
data.tar.gz: 7697d3619ceef486dcde7461eabc8ba9f0a7e60f9315088e01f23285b029e506b80c6f509f3aa3964fb593b6a3842a6669e96e115ad11b69d47f3c988bddea12
|
data/lib/net/ntlm/client.rb
CHANGED
@@ -38,13 +38,24 @@ module Net
|
|
38
38
|
rc4 = OpenSSL::Cipher::Cipher.new("rc4")
|
39
39
|
rc4.encrypt
|
40
40
|
rc4.key = user_session_key
|
41
|
-
sk = rc4.update
|
41
|
+
sk = rc4.update exported_session_key
|
42
42
|
sk << rc4.final
|
43
43
|
t3.session_key = sk
|
44
44
|
end
|
45
45
|
t3
|
46
46
|
end
|
47
47
|
|
48
|
+
def exported_session_key
|
49
|
+
@exported_session_key ||=
|
50
|
+
begin
|
51
|
+
if negotiate_key_exchange?
|
52
|
+
OpenSSL::Cipher.new("rc4").random_key
|
53
|
+
else
|
54
|
+
user_session_key
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
48
59
|
def sign_message(message)
|
49
60
|
seq = sequence
|
50
61
|
sig = OpenSSL::HMAC.digest(OpenSSL::Digest::MD5.new, client_sign_key, "#{seq}#{message}")[0..7]
|
@@ -75,7 +86,6 @@ module Net
|
|
75
86
|
message + server_cipher.final
|
76
87
|
end
|
77
88
|
|
78
|
-
|
79
89
|
private
|
80
90
|
|
81
91
|
|
@@ -83,16 +93,6 @@ module Net
|
|
83
93
|
@user_session_key ||= nil
|
84
94
|
end
|
85
95
|
|
86
|
-
def master_key
|
87
|
-
@master_key ||= begin
|
88
|
-
if negotiate_key_exchange?
|
89
|
-
OpenSSL::Cipher.new("rc4").random_key
|
90
|
-
else
|
91
|
-
user_session_key
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
96
|
def sequence
|
97
97
|
[raw_sequence].pack("V*")
|
98
98
|
end
|
@@ -106,19 +106,19 @@ module Net
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def client_sign_key
|
109
|
-
@client_sign_key ||= OpenSSL::Digest::MD5.digest "#{
|
109
|
+
@client_sign_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{CLIENT_TO_SERVER_SIGNING}"
|
110
110
|
end
|
111
111
|
|
112
112
|
def server_sign_key
|
113
|
-
@server_sign_key ||= OpenSSL::Digest::MD5.digest "#{
|
113
|
+
@server_sign_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{SERVER_TO_CLIENT_SIGNING}"
|
114
114
|
end
|
115
115
|
|
116
116
|
def client_seal_key
|
117
|
-
@client_seal_key ||= OpenSSL::Digest::MD5.digest "#{
|
117
|
+
@client_seal_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{CLIENT_TO_SERVER_SEALING}"
|
118
118
|
end
|
119
119
|
|
120
120
|
def server_seal_key
|
121
|
-
@server_seal_key ||= OpenSSL::Digest::MD5.digest "#{
|
121
|
+
@server_seal_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{SERVER_TO_CLIENT_SEALING}"
|
122
122
|
end
|
123
123
|
|
124
124
|
def client_cipher
|
@@ -77,8 +77,10 @@ module Net
|
|
77
77
|
ar = {:ntlm_hash => NTLM::ntlm_hash(pwd, opt), :challenge => chal}
|
78
78
|
lm_res, ntlm_res = NTLM::ntlm2_session(ar, opt)
|
79
79
|
else
|
80
|
-
|
81
|
-
|
80
|
+
ar = {:lm_hash => NTLM::lm_hash(pwd), :challenge => chal}
|
81
|
+
lm_res = NTLM::lm_response(ar)
|
82
|
+
ar = {:ntlm_hash => NTLM::ntlm_hash(pwd, opt), :challenge => chal}
|
83
|
+
ntlm_res = NTLM::ntlm_response(ar)
|
82
84
|
end
|
83
85
|
|
84
86
|
Type3.create({
|
data/lib/net/ntlm/version.rb
CHANGED
@@ -51,17 +51,17 @@ describe Net::NTLM::Client::Session do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe "#
|
54
|
+
describe "#exported_session_key" do
|
55
55
|
it "returns a random 16-byte key when negotiate_key_exchange? is true" do
|
56
56
|
expect(inst).to receive(:negotiate_key_exchange?).and_return(true)
|
57
57
|
expect(inst).not_to receive(:user_session_key)
|
58
|
-
inst.
|
58
|
+
inst.exported_session_key
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns the user_session_key when negotiate_key_exchange? is false" do
|
62
62
|
expect(inst).to receive(:negotiate_key_exchange?).and_return(false)
|
63
63
|
expect(inst).to receive(:user_session_key).and_return(user_session_key)
|
64
|
-
inst.
|
64
|
+
inst.exported_session_key
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyntlm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Kajimoto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.4.
|
152
|
+
rubygems_version: 2.4.7
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Ruby/NTLM library.
|