Пример #1
0
 public function testCanGetChallengeMessage()
 {
     $testMethod = new ReflectionMethod('\\InterExperts\\NTLM\\NTLM', 'get_challenge_msg');
     $testMethod->setAccessible(true);
     $this->assertSame('4e544c4d5353500002000000140014003000000001028100313233340000000000000000680068004400000074006500730074005400610072006700650074000200000001001800740065007300740043006f006d007000750074006500720004001a00740065007300740044004e00530044006f006d00610069006e0003001e00740065007300740044004e00530043006f006d00700075007400650072000000000000000000', bin2hex($testMethod->invoke(new \InterExperts\NTLM\NTLM(), \InterExperts\NTLM\NTLM::UTF8ToUTF16le('testMessage'), '1234', 'testTarget', 'testDomain', 'testComputer', 'testDNSDomain', 'testDNSComputer')));
     $this->assertSame('4e544c4d53535000020000001600160030000000010281003536373800000000000000006e006e0046000000740065007300740054006100720067006500740032000200000001001a00740065007300740043006f006d0070007500740065007200320004001c00740065007300740044004e00530044006f006d00610069006e00320003002000740065007300740044004e00530043006f006d007000750074006500720032000000000000000000', bin2hex($testMethod->invoke(new \InterExperts\NTLM\NTLM(), \InterExperts\NTLM\NTLM::UTF8ToUTF16le('testMessage2'), '5678', 'testTarget2', 'testDomain2', 'testComputer2', 'testDNSDomain2', 'testDNSComputer2')));
 }
Пример #2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once dirname(__FILE__) . "/../vendor/autoload.php";
use InterExperts\NTLM\NTLM;
$ntlm = new NTLM();
$get_user_hash = function ($user) {
    $userdb = array('user1' => 'examplePassword', 'user2' => 'aDifferentPassword');
    if (!isset($userdb[strtolower($user)])) {
        return false;
    }
    return NTLM::toMD4(NTLM::UTF8ToUTF16le($userdb[strtolower($user)]));
};
session_start();
//$ntlm->setVerifyHashMethod($verify_hash);
$ntlm->setGetUserHashMethod($get_user_hash);
$auth = $ntlm->prompt("testwebsite", "testdomain", "mycomputer", "testdomain.local", "mycomputer.local");
if ($ntlm->is_authenticated) {
    print "You are authenticated as user `{$ntlm->user->username}` from `{$ntlm->user->domain}/{$ntlm->user->workstation}`.";
} else {
    print "You are not authenticated.";
}
$ntlm->ntlm_unset_auth();