this method will work for External Database (i.e. Mysql).
I was using openfire with external Mysql database and forgot the admin password
then I followed these steps to successfully reset my passwrod:
- used OpenFire Blowfish Class for password encryption (also attaching the code below)
- go to your openfire mysql database (in phpmyadmin)
- in Db go to "ofProperty" table and look for passwordKey->value (copy past this key for later use
- also updated "admin.authorizedJIDs" with admin@vps.server.com (i.e: username@domain) in "ofProperty" table
- recover now with OpenFire Blowfish Class:
======================OpenFire Blowfish.php===========================
<?php
/**
* Emulate OpenFire Blowfish Class
*/
class OpenFireBlowfish
{
private $key;
private $cipher;
public $enckey = "acE1v7A2L0MdjuS"; //Hidden Encryption Key of Openfire BlowFish
public $enciv = '';
function __construct($pass)
{
$this->cipher = mcrypt_module_open('blowfish','','cbc','');
$ks = mcrypt_enc_get_key_size($this->cipher);
$this->key = pack('H*',sha1($pass));
}
function encryptString($plaintext, $iv = '')
{
if ($iv == '') {
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->cipher));
}
else {
$iv = pack("H*", $iv);
}
mcrypt_generic_init($this->cipher, $this->key, $iv);
$bs = mcrypt_enc_get_block_size($this->cipher); // get block size
$plaintext = mb_convert_encoding($plaintext,'UTF-16BE'); // set to 2 byte, network order
$pkcs = $bs - (strlen($plaintext) % $bs); // get pkcs5 pad length
$pkcs = str_repeat(chr($pkcs), $pkcs); // create padding string
$plaintext = $plaintext.$pkcs; // append pkcs5 padding to the data
$result = mcrypt_generic($this->cipher, $plaintext);
mcrypt_generic_deinit($this->cipher);
return $iv.$result;
}
function decryptString($ciphertext)
{
$bs = mcrypt_enc_get_block_size($this->cipher); // get block size
$iv_size = mcrypt_enc_get_iv_size($this->cipher);
if ((strlen($ciphertext) % $bs) != 0) { // check string is proper size
exit(1);
}
$iv = substr($ciphertext, 0, $iv_size); // retrieve IV
$ciphertext = substr($ciphertext, $iv_size);
mcrypt_generic_init($this->cipher, $this->key, $iv);
$result = mdecrypt_generic($this->cipher, $ciphertext); // decrypt
//echo var_dump(unpack('c*',$iv))."\n";
$padding = ord(substr($result,-1)); // retrieve padding
$result = substr($result,0,$padding * -1); // and remove it
mcrypt_generic_deinit($this->cipher);
return $result;
}
function __destruct()
{
mcrypt_module_close($this->cipher);
}
}
// Test OpenFire Blowfish Class
$enckey = "paste your openfire passwordKey"; //paste your openfire Db passwordKey copied in poin# 3
$enciv = '';
$a = new OpenFireBlowfish($enckey);
$encstring = bin2hex($a->encryptString('password',$enciv)); //enter your password string to encrypt it
echo "Encrypted Password string:".$encstring . "<br>";
echo "Original Password string:".$a->decryptString(pack("H*", $encstring)) . "<br>";
?>
=========================================================
6. now run this file on your local webserver and copy the encryptedPassword string
7. now go to "ofUser" table in openfire database and replace the encryptedPassword string in your "ofUser" Table against your admin username.
Note:
8. restart your server that can be done from WHM (forcerestart/graceful restart)
9. after restarting server refresh your openfire page (http://xxx.xxx.xxx.xxx:9090/ or http://domain.com:9090 ) and login using username and password that you used for encryption
this method will work for External Database Mysql.