Class: FunctionTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/rex/proto/ntlm.rb.ut.rb

Overview

FunctionTest by Minero Aoki

Instance Method Summary collapse

Instance Method Details

#setupObject

:nodoc:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 77

def setup
  @passwd = "SecREt01"
  @user   = "user"
  @domain = "domain"
  @challenge = ["0123456789abcdef"].pack("H*")
  @client_ch = ["ffffff0011223344"].pack("H*")
  @timestamp = 1055844000
  @trgt_info = [
    "02000c0044004f004d00410049004e00" +
    "01000c00530045005200560045005200" +
    "0400140064006f006d00610069006e00" +
    "2e0063006f006d000300220073006500" +
    "72007600650072002e0064006f006d00" +
    "610069006e002e0063006f006d000000" +
    "0000"
  ].pack("H*")
end

#test_lm_hashObject



95
96
97
98
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 95

def test_lm_hash
  ahash = ["ff3750bcc2b22412c2265b23734e0dac"].pack("H*")
  assert_equal ahash, Rex::Proto::NTLM::Crypt::lm_hash(@passwd)
end

#test_lm_responseObject



110
111
112
113
114
115
116
117
118
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 110

def test_lm_response
  ares = ["c337cd5cbd44fc9782a667af6d427c6de67c20c2d3e77c56"].pack("H*")
  assert_equal ares, Rex::Proto::NTLM::Crypt::lm_response(
    {
    :lm_hash => Rex::Proto::NTLM::Crypt::lm_hash(@passwd),
    :challenge => @challenge
  }
  )
end

#test_lmv2_responseObject



131
132
133
134
135
136
137
138
139
140
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 131

def test_lmv2_response
  ares = ["d6e6152ea25d03b7c6ba6629c2d6aaf0ffffff0011223344"].pack("H*")
  assert_equal ares, Rex::Proto::NTLM::Crypt::lmv2_response(
    {
    :ntlmv2_hash => Rex::Proto::NTLM::Crypt::ntlmv2_hash(@user, @passwd, @domain),
    :challenge => @challenge
  },
    { :client_challenge => @client_ch }
  )
end

#test_ntlm2_sessionObject



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 168

def test_ntlm2_session
  acha = ["ffffff001122334400000000000000000000000000000000"].pack("H*")
  ares = ["10d550832d12b2ccb79d5ad1f4eed3df82aca4c3681dd455"].pack("H*")
  session = Rex::Proto::NTLM::Crypt::ntlm2_session(
    {
    :ntlm_hash => Rex::Proto::NTLM::Crypt::ntlm_hash(@passwd),
    :challenge => @challenge
  },
    { :client_challenge => @client_ch }
  )
  assert_equal acha, session[0]
  assert_equal ares, session[1]
end

#test_ntlm_hashObject



100
101
102
103
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 100

def test_ntlm_hash
  ahash = ["cd06ca7c7e10c99b1d33b7485a2ed808"].pack("H*")
  assert_equal ahash, Rex::Proto::NTLM::Crypt::ntlm_hash(@passwd)
end

#test_ntlm_responseObject



120
121
122
123
124
125
126
127
128
129
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 120

def test_ntlm_response
  ares = ["25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6"].pack("H*")
  ntlm_hash = Rex::Proto::NTLM::Crypt::ntlm_hash(@passwd)
  assert_equal ares, Rex::Proto::NTLM::Crypt::ntlm_response(
    {
    :ntlm_hash => ntlm_hash,
    :challenge => @challenge
  }
  )
end

#test_ntlmv2_hashObject



105
106
107
108
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 105

def test_ntlmv2_hash
  ahash = ["04b8e0ba74289cc540826bab1dee63ae"].pack("H*")
  assert_equal ahash, Rex::Proto::NTLM::Crypt::ntlmv2_hash(@user, @passwd, @domain)
end

#test_ntlmv2_responseObject



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/rex/proto/ntlm.rb.ut.rb', line 142

def test_ntlmv2_response
  ares = [
    "cbabbca713eb795d04c97abc01ee4983" +
    "01010000000000000090d336b734c301" +
    "ffffff00112233440000000002000c00" +
    "44004f004d00410049004e0001000c00" +
    "53004500520056004500520004001400" +
    "64006f006d00610069006e002e006300" +
    "6f006d00030022007300650072007600" +
    "650072002e0064006f006d0061006900" +
    "6e002e0063006f006d00000000000000" +
    "0000"
  ].pack("H*")
  assert_equal ares, Rex::Proto::NTLM::Crypt::ntlmv2_response(
    {
    :ntlmv2_hash => Rex::Proto::NTLM::Crypt::ntlmv2_hash(@user, @passwd, @domain),
    :challenge => @challenge,
    :target_info => @trgt_info
  },
    {
    :timestamp => @timestamp,
    :client_challenge => @client_ch
  }
  )
end