function GenerateNTResponse($challenge, $peerChallenge, $username, $password)
{
    $challengeHash = ChallengeHash($challenge, $peerChallenge, $username);
    $pwhash = NtPasswordHash($password);
    return ChallengeResponse($challengeHash, $pwhash);
}
Beispiel #2
0
    }
    if (!radius_put_attr($res, RADIUS_CHAP_CHALLENGE, $chall)) {
        echo 'RadiusError: RADIUS_CHAP_CHALLENGE:' . radius_strerror($res) . "<br>\n";
        exit;
    }
} else {
    if ($auth_type == 'mschapv1') {
        echo "MS-CHAPv1<br>\n";
        include_once 'mschap.php';
        $challenge = GenerateChallenge();
        printf("Challenge:%s\n", bin2hex($challenge));
        if (!radius_put_vendor_attr($res, RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_CHALLENGE, $challenge)) {
            echo 'RadiusError: RADIUS_MICROSOFT_MS_CHAP_CHALLENGE:' . radius_strerror($res) . "<br>\n";
            exit;
        }
        $ntresp = ChallengeResponse($challenge, NtPasswordHash($password));
        $lmresp = str_repeat("", 24);
        printf("NT Response:%s\n", bin2hex($ntresp));
        // Response: chapid, flags (1 = use NT Response), LM Response, NT Response
        $resp = pack('CCa48', 1, 1, $lmresp . $ntresp);
        printf("Response:%d %s\n", strlen($resp), bin2hex($resp));
        if (!radius_put_vendor_attr($res, RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_RESPONSE, $resp)) {
            echo 'RadiusError: RADIUS_MICROSOFT_MS_CHAP_RESPONSE:' . radius_strerror($res) . "<br>\n";
            exit;
        }
    } else {
        if ($auth_type == 'mschapv2') {
            echo "MS-CHAPv2<br>\n";
            include_once 'mschap.php';
            $authChallenge = GenerateChallenge(16);
            printf("Auth Challenge:%s\n", bin2hex($authChallenge));
This code cannot simply be copied and put under the GNU Public License or 
any other GPL-like (LGPL, GPL2) License.

    $Id: mschaptest.php,v 1.2 2003/01/26 20:31:11 mbretter Exp $
*/
include_once 'mschap.php';
echo "MS-CHAPv1 TEST\n";
$pass = '******';
$challenge = pack('H*', '102DB5DF085D3041');
printf("Test Challenge: %s\n", bin2hex($challenge));
$unipw = str2unicode($pass);
printf("Unicode PW: %s\nexpected  : 4d00790050007700\n", bin2hex($unipw));
$nthash = NtPasswordHash($pass);
printf("NT HASH   : %s\nexpected  : fc156af7edcd6c0edde3337d427f4eac\n", bin2hex($nthash));
$challresp = ChallengeResponse($challenge, $nthash);
printf("ChallResp : %s\nexpected  : 4e9d3c8f9cfd385d5bf4d3246791956ca4c351ab409a3d61\n", bin2hex($challresp));
echo "\n";
echo "MS-CHAPv2 TEST\n";
$user = '******';
$pass = '******';
printf("Username  : %s\nexpected  : 55736572\n", bin2hex($user));
$challenge = pack('H*', 'd02e4386bce91226');
printf("Challenge     : %s\n", bin2hex($challenge));
$authchallenge = pack('H*', '5b5d7c7d7b3f2f3e3c2c602132262628');
printf("Auth Challenge: %s\n", bin2hex($authchallenge));
$peerChallenge = pack('H*', '21402324255E262A28295F2B3A337C7E');
printf("Peer Challenge: %s\n", bin2hex($peerChallenge));
$nthash = NtPasswordHash($pass);
printf("NT HASH      : %s\nexpected     : 44ebba8d5312b8d611474411f56989ae\n", bin2hex($nthash));
$nthashhash = NtPasswordHashHash($nthash);