diff --git a/htdocs/password_checker.php b/htdocs/password_checker.php index 5ca2b68..c616e2e 100644 --- a/htdocs/password_checker.php +++ b/htdocs/password_checker.php @@ -18,6 +18,7 @@ $request['componentid'] = get_request('componentid','REQUEST'); $request['hash'] = get_request('hash','REQUEST'); $request['password'] = get_request('check_password','REQUEST'); $request['action'] = get_request('action','REQUEST'); +$request['attribute'] = get_request('attr','REQUEST'); if (get_request('base64','REQUEST')) { $request['hash'] = base64_decode($request['hash']); @@ -30,6 +31,7 @@ printf('

%s

',_('Password Checker Tool')); echo '
'; echo ''; +printf('',$request['attribute']); echo ''; @@ -53,7 +55,7 @@ echo '
'; if ($request['action'] == 'compare') { echo '    '; - if (password_check($request['hash'],$request['password'])) + if (password_check($request['hash'],$request['password'],$request['attribute'])) printf('%s',_('Passwords match!')); else printf('%s',_('Passwords do not match!')); diff --git a/lib/TemplateRender.php b/lib/TemplateRender.php index 379516e..774f6c9 100644 --- a/lib/TemplateRender.php +++ b/lib/TemplateRender.php @@ -2376,9 +2376,9 @@ function deleteAttribute(attrName,friendlyName,i) # Add the javascript so we can call check password later. echo ' '; @@ -2391,8 +2391,8 @@ function deleteAttribute(attrName,friendlyName,i) protected function drawCheckLinkPasswordAttribute($attribute,$component_id) { if (DEBUGTMP) printf('%s
',__METHOD__); - printf('%s...
', - $component_id,_('Check password')); + printf('%s...
', + $component_id,$attribute->getName(),_('Check password')); } /** RANDOM PASSWORD **/ diff --git a/lib/functions.php b/lib/functions.php index 08e4299..caf88ab 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -2198,10 +2198,30 @@ function password_hash($password_clear,$enc_type) { * @param String The password in clear text to test. * @return Boolean True if the clear password matches the hash, and false otherwise. */ -function password_check($cryptedpassword,$plainpassword) { +function password_check($cryptedpassword,$plainpassword,$attribute='userpassword') { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (in_array($attribute,array('sambalmpassword','sambantpassword'))) { + $smb = new smbHash; + + switch($attribute) { + case 'sambalmpassword': + if (strcmp($smb->lmhash($plainpassword),$cryptedpassword) == 0) + return true; + else + return false; + + case 'sambantpassword': + if (strcmp($smb->nthash($plainpassword),$cryptedpassword) == 0) + return true; + else + return false; + } + + return false; + } + if (preg_match('/{([^}]+)}(.*)/',$cryptedpassword,$matches)) { $cryptedpassword = $matches[2]; $cypher = strtolower($matches[1]);