| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
Copyright (c) 2003, Michael Bretterklieber <michael@bretterklieber.com>
|
|
|
4 |
All rights reserved.
|
|
|
5 |
|
|
|
6 |
Redistribution and use in source and binary forms, with or without
|
|
|
7 |
modification, are permitted provided that the following conditions
|
|
|
8 |
are met:
|
|
|
9 |
|
|
|
10 |
1. Redistributions of source code must retain the above copyright
|
|
|
11 |
notice, this list of conditions and the following disclaimer.
|
|
|
12 |
2. Redistributions in binary form must reproduce the above copyright
|
|
|
13 |
notice, this list of conditions and the following disclaimer in the
|
|
|
14 |
documentation and/or other materials provided with the distribution.
|
|
|
15 |
3. The names of the authors may not be used to endorse or promote products
|
|
|
16 |
derived from this software without specific prior written permission.
|
|
|
17 |
|
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
|
|
|
29 |
This code cannot simply be copied and put under the GNU Public License or
|
|
|
30 |
any other GPL-like (LGPL, GPL2) License.
|
|
|
31 |
|
|
|
32 |
$Id: mschaptest.php,v 1.2 2003/01/26 20:31:11 mbretter Exp $
|
|
|
33 |
*/
|
|
|
34 |
|
|
|
35 |
include_once('mschap.php');
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
echo "MS-CHAPv1 TEST\n";
|
|
|
39 |
$pass = 'MyPw';
|
|
|
40 |
$challenge = pack('H*', '102DB5DF085D3041');
|
|
|
41 |
printf ("Test Challenge: %s\n", bin2hex($challenge));
|
|
|
42 |
$unipw = str2unicode($pass);
|
|
|
43 |
printf ("Unicode PW: %s\nexpected : 4d00790050007700\n", bin2hex($unipw));
|
|
|
44 |
$nthash = NtPasswordHash($pass);
|
|
|
45 |
printf ("NT HASH : %s\nexpected : fc156af7edcd6c0edde3337d427f4eac\n", bin2hex($nthash));
|
|
|
46 |
$challresp = ChallengeResponse($challenge, $nthash);
|
|
|
47 |
printf ("ChallResp : %s\nexpected : 4e9d3c8f9cfd385d5bf4d3246791956ca4c351ab409a3d61\n", bin2hex($challresp));
|
|
|
48 |
echo "\n";
|
|
|
49 |
|
|
|
50 |
echo "MS-CHAPv2 TEST\n";
|
|
|
51 |
$user = 'User';
|
|
|
52 |
$pass = 'clientPass';
|
|
|
53 |
printf ("Username : %s\nexpected : 55736572\n", bin2hex($user));
|
|
|
54 |
$challenge = pack('H*', 'd02e4386bce91226');
|
|
|
55 |
printf ("Challenge : %s\n", bin2hex($challenge));
|
|
|
56 |
$authchallenge = pack('H*', '5b5d7c7d7b3f2f3e3c2c602132262628');
|
|
|
57 |
printf ("Auth Challenge: %s\n", bin2hex($authchallenge));
|
|
|
58 |
$peerChallenge = pack('H*', '21402324255E262A28295F2B3A337C7E');
|
|
|
59 |
printf ("Peer Challenge: %s\n", bin2hex($peerChallenge));
|
|
|
60 |
$nthash = NtPasswordHash($pass);
|
|
|
61 |
printf ("NT HASH : %s\nexpected : 44ebba8d5312b8d611474411f56989ae\n", bin2hex($nthash));
|
|
|
62 |
$nthashhash = NtPasswordHashHash($nthash);
|
|
|
63 |
printf ("NT HASH-HASH : %s\nexpected : 41c00c584bd2d91c4017a2a12fa59f3f\n", bin2hex($nthashhash));
|
|
|
64 |
$resp = GenerateNtResponse($authchallenge, $peerChallenge, $user, $pass);
|
|
|
65 |
printf ("ChallResp : %s\nexpected : 82309ecd8d708b5ea08faa3981cd83544233114a3d85d6df\n", bin2hex($resp));
|
|
|
66 |
echo "\n";
|
|
|
67 |
|
|
|
68 |
?>
|