Beispiel #1
0
 /**
  */
 protected function _changePassword($user, $oldpass, $newpass)
 {
     parent::_changePassword($user, $oldpass, $newpass);
     // Get existing user information.
     $entry = $this->_ldap->getEntry($this->_userdn);
     // Return if the user is not a Samba user.
     if (!in_array($this->_params['smb_objectclass'], $entry->getValue('objectClass', 'all'))) {
         return;
     }
     // Crypt_CHAP is not PSR-0 compatible.
     require_once 'Crypt/CHAP.php';
     $hash = new Crypt_CHAP_MSv2();
     $hash->password = $newpass;
     $lmpasswd = Horde_String::upper(bin2hex($hash->lmPasswordHash()));
     $ntpasswd = Horde_String::upper(bin2hex($hash->ntPasswordHash()));
     $settime = time();
     if (!is_null($this->_params['pw_expire_time'])) {
         // 24 hours/day * 60 min/hour * 60 secs/min = 86400 seconds/day
         $expiretime = $settime + $this->_params['pw_expire_time'] * 86400;
     } else {
         // This is NT's version of infinity time:
         // http://lists.samba.org/archive/samba/2004-January/078175.html
         $expiretime = 2147483647;
     }
     // All changes must succeed or fail together.  Attributes with
     // null name are not updated.
     $changes = array();
     if (!is_null($this->_params['lm_attribute'])) {
         $changes[$this->_params['lm_attribute']] = $lmpasswd;
     }
     if (!is_null($this->_params['nt_attribute'])) {
         $changes[$this->_params['nt_attribute']] = $ntpasswd;
     }
     if (!is_null($this->_params['pw_set_attribute'])) {
         $changes[$this->_params['pw_set_attribute']] = $settime;
     }
     if (!is_null($this->_params['pw_expire_attribute'])) {
         $changes[$this->_params['pw_expire_attribute']] = $expiretime;
     }
     if (count($changes) > 0) {
         try {
             $entry->replace($changes, true);
             $entry->update();
         } catch (Horde_Ldap_Exception $e) {
             throw new Passwd_Exception($e);
         }
     }
 }
Beispiel #2
0
printf("ChallResp : %s\nexpected  : d39bfaf5d6855a948c8c81a85947502c\n", bin2hex($crpt->challengeResponse()));
echo "\n";
echo "MS-CHAPv1 str2unicode\n";
$crpt = new Crypt_CHAP_MSv1();
printf("Passed 123 as Number:%s\n", bin2hex($crpt->str2unicode(123)));
printf("Passed 123 as String:%s\n", bin2hex($crpt->str2unicode('123')));
echo "MS-CHAPv1 TEST\n";
$crpt->password = '******';
$crpt->challenge = pack('H*', '102DB5DF085D3041');
$unipw = $crpt->str2unicode($pass);
printf("Unicode PW: %s\nexpected  : 4d00790050007700\n", bin2hex($unipw));
printf("NT HASH   : %s\nexpected  : fc156af7edcd6c0edde3337d427f4eac\n", bin2hex($crpt->ntPasswordHash()));
printf("NT Resp   : %s\nexpected  : 4e9d3c8f9cfd385d5bf4d3246791956ca4c351ab409a3d61\n", bin2hex($crpt->challengeResponse()));
printf("LM HASH   : %s\nexpected  : 75ba30198e6d1975aad3b435b51404ee\n", bin2hex($crpt->lmPasswordHash()));
printf("LM Resp   : %s\nexpected  : 91881d0152ab0c33c524135ec24a95ee64e23cdc2d33347d\n", bin2hex($crpt->lmChallengeResponse()));
//printf ("Response  : %s\nexpected  : unknown\n", bin2hex($crpt->response()));
echo "\n";
echo "MS-CHAPv2 TEST\n";
$crpt = new Crypt_CHAP_MSv2();
$crpt->username = '******';
$crpt->password = '******';
printf("Username  : %s\nexpected  : 55736572\n", bin2hex($crpt->username));
$crpt->authChallenge = pack('H*', '5b5d7c7d7b3f2f3e3c2c602132262628');
$crpt->peerChallenge = pack('H*', '21402324255E262A28295F2B3A337C7E');
$nthash = $crpt->ntPasswordHash();
printf("NT HASH      : %s\nexpected     : 44ebba8d5312b8d611474411f56989ae\n", bin2hex($nthash));
$nthashhash = $crpt->ntPasswordHashHash($nthash);
printf("NT HASH-HASH : %s\nexpected     : 41c00c584bd2d91c4017a2a12fa59f3f\n", bin2hex($nthashhash));
printf("ChallResp    : %s\nexpected     : 82309ecd8d708b5ea08faa3981cd83544233114a3d85d6df\n", bin2hex($crpt->challengeResponse()));
printf("Challenge    : %s\nexpected     : d02e4386bce91226\n", bin2hex($crpt->challenge));
echo "\n";
 /**
  * Returns the content object of the attribute.
  *
  * @param mixed $contentObjectAttribute Class eZContentObjectAttribute.
  *
  * @return array
  */
 public function objectAttributeContent($contentObjectAttribute)
 {
     $data = $contentObjectAttribute->attribute('data_text');
     if ($data != '') {
         require_once 'Crypt/CHAP.php';
         $crypt = new Crypt_CHAP_MSv2();
         $crypt->password = $data;
         $ntPass = bin2hex($crypt->ntPasswordHash());
         $lmPass = bin2hex($crypt->lmPasswordHash());
         $result = array('plain' => $data, 'nt' => $ntPass, 'nt_prefix' => '0x' . $ntPass, 'lm' => $lmPass, 'lm_prefix' => '0x' . $lmPass);
     } else {
         $result = array('plain' => '', 'nt' => '', 'nt_prefix' => '', 'lm' => '', 'lm_prefix' => '');
     }
     return $result;
 }