postfixadmin忘記密碼後的修改密碼方法詳解_php執行個體

來源:互聯網
上載者:User
本文執行個體講述了postfixadmin忘記密碼後的修改密碼方法。分享給大家供大家參考,具體如下:

Postfix Admin 是一個基於Web的 Postfix 郵件發送伺服器的管理工具,可以直接管理 Postfix 的虛擬網域名稱和使用者。

由於有一段時間沒使用postfixadmin增刪使用者了, 突然需使用時忘記了管理密碼, 使用老外的方式直接在資料庫裡修改密碼, 後登入成功

php源碼:

<?phpecho md5crypt("新密碼");// md5crypt// Action: Creates MD5 encrypted password// Call: md5crypt (string cleartextpassword)function md5crypt($pw, $salt = "", $magic = ""){  $MAGIC = "$1$";  if ($magic == "")  {    $magic = $MAGIC;  }  if ($salt == "")  {    $salt = create_salt();  }  $slist = explode("$", $salt);  if (isset($slist[0]) && $slist[0] == "1")  {    $salt = $slist[1];  }  $salt = substr($salt, 0, 8);  $ctx = $pw.$magic.$salt;  $final = hex2bin(md5($pw.$salt.$pw));  for ($i = strlen($pw); $i > 0; $i -= 16)  {    if ($i > 16)    {      $ctx .= substr($final,0,16);    }    else    {      $ctx .= substr($final,0,$i);    }  }  $i = strlen($pw);  while ($i > 0)  {    if ($i & 1)    {      $ctx .= chr(0);    }    else    {      $ctx .= $pw[0];    }    $i = $i >> 1;  }  $final = hex2bin(md5($ctx));  for ($i=0; $i<1000; $i++)  {    $ctx1 = "";    if ($i & 1)    {      $ctx1 .= $pw;    }    else    {      $ctx1 .= substr($final,0,16);    }    if ($i % 3)    {      $ctx1 .= $salt;    }    if ($i % 7)    {      $ctx1 .= $pw;    }    if ($i & 1)    {      $ctx1 .= substr($final, 0, 16);    }    else    {      $ctx1 .= $pw;    }    $final = hex2bin(md5($ctx1));  }  $passwd = "";  $passwd .= to64(((ord($final[0]) << 16) | (ord($final[6]) << 8) | (ord($final[12]))), 4);  $passwd .= to64(((ord($final[1]) << 16) | (ord($final[7]) << 8) | (ord($final[13]))), 4);  $passwd .= to64(((ord($final[2]) << 16) | (ord($final[8]) << 8) | (ord($final[14]))), 4);  $passwd .= to64(((ord($final[3]) << 16) | (ord($final[9]) << 8) | (ord($final[15]))), 4);  $passwd .= to64(((ord($final[4]) << 16) | (ord($final[10]) << 8) | (ord($final[5]))), 4);  $passwd .= to64(ord($final[11]), 2);  return $magic.$salt.'$'.$passwd;}function create_salt(){  srand((double) microtime() * 1000000);  return substr(md5(rand(0,9999999)), 0, 8);}// PHP around 5.3.8 includes hex2bin as native function - http://php.net/hex2binfunction hex2bin($str){    $len = strlen($str);    $nstr = "";    for ($i = 0; $i < $len; $i += 2)    {      $num = sscanf(substr($str, $i, 2), "%x");      $nstr .= chr($num[0]);    }    return $nstr;}function to64($v, $n){  $ITOA64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";  $ret = "";  while (($n - 1) >= 0)  {    $n--;    $ret .= $ITOA64[$v & 0x3f];    $v = $v >> 6;  }  return $ret;}

更多關於PHP相關內容感興趣的讀者可查看本站專題:《php加密方法總結》、《PHP編碼與轉碼操作技巧匯總》、《php物件導向程式設計入門教程》、《PHP數學運算技巧總結》、《PHP數組(Array)操作技巧大全》、《php字串(string)用法總結》、《PHP資料結構與演算法教程》、《php程式設計演算法總結》、《phpRegex用法總結》、及《php常見資料庫操作技巧匯總》

希望本文所述對大家PHP程式設計有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.