Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Reset Modx Evolution Administrator's Password from Database - UNCRYPT Encryption

Ever since Modx changed their password from MD5 all websites that describe resetting admin password from the database stopped working. This has kept me on a particular issue for more than a week, trying to fix the admin login issue. I eventually hit a goldmine while searching the web. I saw someone who has created a function that can helps generate the hash password password you can replace in your database to login with. You can find the link here https://rextester.com/TBVI30009 or you can save below code and run it locally.

I hope this helps someone. Drop a comment if it is useful for you.


<?php

    echo genHash('password!', 1);
	
	function genHash($password, $seed='1')
	{ 
		// $seed is user_id basically
		$algorithm = 'UNCRYPT';
		
		$salt = md5($password . $seed);
		
		switch($algorithm)
		{
			case 'BLOWFISH_Y':
				$salt = '$2y$07$' . substr($salt,0,22);
				break;
			case 'BLOWFISH_A':
				$salt = '$2a$07$' . substr($salt,0,22);
				break;
			case 'SHA512':
				$salt = '$6$' . substr($salt,0,16);
				break;
			case 'SHA256':
				$salt = '$5$' . substr($salt,0,16);
				break;
			case 'MD5':
				$salt = '$1$' . substr($salt,0,8);
				break;
		}
		
		if($algorithm!=='UNCRYPT')
		{
			$password = sha1($password) . crypt($password,$salt);
		}
		else $password = sha1($salt.$password);
		
		$result = strtolower($algorithm) . '>' . md5($salt.$password) . substr(md5($salt),0,8);
		
		return $result;
	}
	


comments powered by Disqus