{"id":226,"date":"2018-04-01T01:15:46","date_gmt":"2018-03-31T17:15:46","guid":{"rendered":"http:\/\/www.brofive.org\/?p=226"},"modified":"2018-05-05T21:25:08","modified_gmt":"2018-05-05T13:25:08","slug":"wordpress-%e7%94%a8%e6%88%b7%e5%af%86%e7%a0%81%e9%87%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/www.brofive.net\/?p=226","title":{"rendered":"wordpress \u7528\u6237\u5bc6\u7801\u91cd\u7f6e"},"content":{"rendered":"<p>\u7533\u8bf7\u4e86\u4e00\u4e2aWordPress\u7a7a\u95f4\uff0c\u6ca1\u6599\u5230\u628a\u7528\u6237\u5bc6\u7801\u5fd8\u8bb0\u4e86\uff0c\u4e0d\u77e5\u9053\u4ec0\u4e48\u539f\u56e0\uff0cWordPress\u7684\u3010\u5fd8\u8bb0\u5bc6\u7801\u3011\u529f\u80fd\u5931\u7075\u4e86\uff0c\u53ea\u597d\u7528\u7ba1\u7406\u5458\u767b\u5f55\u4e0a\u53bb\uff0c\u5c1d\u8bd5\u4ece\u6570\u636e\u5e93\u91cc\u9762\u91cd\u7f6e\u4e00\u4e0b\uff0c\u767b\u4e0a\u53bb\u4e00\u770b\uff0c\u5bc6\u7801\u662f\u52a0\u5bc6\u7684\uff0c\u8fd9\u662f\u96be\u4e0d\u4f4f\u6211\u4eec\u7684\uff0c\u5f53\u5e74\u641e\u5b9aJIRA\u7684\u5bc6\u7801\u4e5f\u5c31\u90a3\u4e48\u56de\u4e8b\u3002<\/p>\n<p><a href=\"http:\/\/144.202.107.67\/wp-content\/uploads\/2018\/04\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" src=\"http:\/\/144.202.107.67\/wp-content\/uploads\/2018\/04\/image_thumb.png\" alt=\"image\" width=\"544\" height=\"166\" border=\"0\" \/><\/a><\/p>\n<p>\u4f30\u8ba1wordpress\u4e0d\u4f1a\u5f31\u5230\u4f7f\u7528MySQL\u7684\u52a0\u5bc6\u51fd\u6570\uff0c\u4e8e\u662f\u5148\u767e\u5ea6\u4e86\u4e00\u4e0b\uff0c\u627e\u5230\u4e00\u7bc7\u6587\u7ae0\u3010wordpress\u7528\u6237\u5bc6\u7801\u52a0\u5bc6\u539f\u7406\u53ca\u5176\u7b97\u6cd5\u5206\u6790\u3011\uff08<a title=\"https:\/\/blog.csdn.net\/HK_JH\/article\/details\/27368279\" href=\"https:\/\/blog.csdn.net\/HK_JH\/article\/details\/27368279\">https:\/\/blog.csdn.net\/HK_JH\/article\/details\/27368279<\/a>\uff09\uff0c\u4e0b\u8f7d\u4e86\u4f5c\u8005\u5199\u7684c\u8bed\u8a00\u7a0b\u5e8f\uff0c\u7528VS 15\u7f16\u8bd1\u4e86\u4e00\u4e0b\uff0c\u679c\u7136\u5c31\u53ef\u4ee5\u7b97\u51fa\u4e00\u4e2ahash\u4ee5\u540e\u7684\u5bc6\u7801\uff0cupdata\u4e00\u4e0b\uff0c\u7136\u540e\u53d1\u73b0\u4e0d\u5bf9\uff01\uff01\uff01<\/p>\n<p>\u4e0b\u8f7d<a title=\"https:\/\/wordpress.org\/download\/\" href=\"https:\/\/wordpress.org\/download\/\">https:\/\/wordpress.org\/download\/<\/a>\u7684\u6700\u65b0\u7248\u672c\uff08<a title=\"https:\/\/wordpress.org\/latest.tar.gz\" href=\"https:\/\/wordpress.org\/latest.tar.gz\">https:\/\/wordpress.org\/latest.tar.gz<\/a>\uff09\uff0c\u76ee\u524d\u662f4.9.4\uff0c\u627e\u5230\u7528\u6237\u5bc6\u7801\u4ee3\u7801class-phpass.php\u6587\u4ef6\uff0c\u6253\u5f00\u4e00\u770b\uff0c\u662f\u4e00\u4e2ahash\u7c7b\uff0c\u6839\u636e\u914d\u7f6e\u91c7\u7528\u4e0d\u540c\u7684hash\u7b97\u6cd5\u3002\u5199\u4e86\u4e00\u4e2a3\u884c\u7684\u5c0f\u7a0b\u5e8f\uff1a<\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<td>require_once &#8216;\/class-phpass.php&#8217;;<br \/>\n$hasher = new PasswordHash( 8, true );<br \/>\necho $hasher-&gt;HashPassword(&#8220;mypassword&#8221;);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7136\u540e\u5c31\u5f97\u5230\u4e86\u4e00\u4e2a\u53ef\u7528\u7684\u5bc6\u7801\uff0c\u641e\u5b9a\uff01<\/p>\n<p>\u4f30\u8ba1\u6b64\u524d\u7684\u4f5c\u8005\u662f\u4e2aC\u7231\u597d\u8005\uff0c\u4ece\u7f51\u4e0a\u5f04\u4e86\u4e00\u4e9b\u4ee3\u7801\uff0c\u90a3\u4e2aMD5\u660e\u663e\u662f\u5f00\u6e90\u4ee3\u7801\uff0c\u8fd8\u8bf4\u662f\u81ea\u5df1\u4ee5\u524d\u5199\u7684\uff0c<!--StartFragment--> \u770b\u6765\u6c34\u5e73\u4e0d\u548b\u5730\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<br \/>\n\/**<br \/>\n* Portable PHP password hashing framework.<br \/>\n* @package phpass<br \/>\n* @since 2.5.0<br \/>\n* @version 0.3 \/ WordPress<br \/>\n* @link <a href=\"http:\/\/www.openwall.com\/phpass\/\">http:\/\/www.openwall.com\/phpass\/<\/a><br \/>\n*\/<\/p>\n<p>#<br \/>\n# Written by Solar Designer &lt;solar at openwall.com&gt; in 2004-2006 and placed in<br \/>\n# the public domain.\u00a0 Revised in subsequent years, still public domain.<br \/>\n#<br \/>\n# There&#8217;s absolutely no warranty.<br \/>\n#<br \/>\n# Please be sure to update the Version line if you edit this file in any way.<br \/>\n# It is suggested that you leave the main version number intact, but indicate<br \/>\n# your project name (after the slash) and add your own revision information.<br \/>\n#<br \/>\n# Please do not change the &#8220;private&#8221; password hashing method implemented in<br \/>\n# here, thereby making your hashes incompatible.\u00a0 However, if you must, please<br \/>\n# change the hash type identifier (the &#8220;$P$&#8221;) to something different.<br \/>\n#<br \/>\n# Obviously, since this code is in the public domain, the above are not<br \/>\n# requirements (there can be none), but merely suggestions.<br \/>\n#<\/p>\n<p>\/**<br \/>\n* Portable PHP password hashing framework.<br \/>\n*<br \/>\n* @package phpass<br \/>\n* @version 0.3 \/ WordPress<br \/>\n* @link <a href=\"http:\/\/www.openwall.com\/phpass\/\">http:\/\/www.openwall.com\/phpass\/<\/a><br \/>\n* @since 2.5.0<br \/>\n*\/<br \/>\nclass PasswordHash {<br \/>\nvar $itoa64;<br \/>\nvar $iteration_count_log2;<br \/>\nvar $portable_hashes;<br \/>\nvar $random_state;<\/p>\n<p>\/**<br \/>\n* PHP5 constructor.<br \/>\n*\/<br \/>\nfunction __construct( $iteration_count_log2, $portable_hashes )<br \/>\n{<br \/>\n$this-&gt;itoa64 = &#8216;.\/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#8217;;<\/p>\n<p>if ($iteration_count_log2 &lt; 4 || $iteration_count_log2 &gt; 31)<br \/>\n$iteration_count_log2 = 8;<br \/>\n$this-&gt;iteration_count_log2 = $iteration_count_log2;<\/p>\n<p>$this-&gt;portable_hashes = $portable_hashes;<\/p>\n<p>$this-&gt;random_state = microtime() . uniqid(rand(), TRUE); \/\/ removed getmypid() for compatibility reasons<br \/>\n}<\/p>\n<p>\/**<br \/>\n* PHP4 constructor.<br \/>\n*\/<br \/>\npublic function PasswordHash( $iteration_count_log2, $portable_hashes ) {<br \/>\nself::__construct( $iteration_count_log2, $portable_hashes );<br \/>\n}<\/p>\n<p>function get_random_bytes($count)<br \/>\n{<br \/>\n$output = &#8221;;<br \/>\nif ( @is_readable(&#8216;\/dev\/urandom&#8217;) &amp;&amp;<br \/>\n($fh = @fopen(&#8216;\/dev\/urandom&#8217;, &#8216;rb&#8217;))) {<br \/>\n$output = fread($fh, $count);<br \/>\nfclose($fh);<br \/>\n}<\/p>\n<p>if (strlen($output) &lt; $count) {<br \/>\n$output = &#8221;;<br \/>\nfor ($i = 0; $i &lt; $count; $i += 16) {<br \/>\n$this-&gt;random_state =<br \/>\nmd5(microtime() . $this-&gt;random_state);<br \/>\n$output .=<br \/>\npack(&#8216;H*&#8217;, md5($this-&gt;random_state));<br \/>\n}<br \/>\n$output = substr($output, 0, $count);<br \/>\n}<\/p>\n<p>return $output;<br \/>\n}<\/p>\n<p>function encode64($input, $count)<br \/>\n{<br \/>\n$output = &#8221;;<br \/>\n$i = 0;<br \/>\ndo {<br \/>\n$value = ord($input[$i++]);<br \/>\n$output .= $this-&gt;itoa64[$value &amp; 0x3f];<br \/>\nif ($i &lt; $count)<br \/>\n$value |= ord($input[$i]) &lt;&lt; 8;<br \/>\n$output .= $this-&gt;itoa64[($value &gt;&gt; 6) &amp; 0x3f];<br \/>\nif ($i++ &gt;= $count)<br \/>\nbreak;<br \/>\nif ($i &lt; $count)<br \/>\n$value |= ord($input[$i]) &lt;&lt; 16;<br \/>\n$output .= $this-&gt;itoa64[($value &gt;&gt; 12) &amp; 0x3f];<br \/>\nif ($i++ &gt;= $count)<br \/>\nbreak;<br \/>\n$output .= $this-&gt;itoa64[($value &gt;&gt; 18) &amp; 0x3f];<br \/>\n} while ($i &lt; $count);<\/p>\n<p>return $output;<br \/>\n}<\/p>\n<p>function gensalt_private($input)<br \/>\n{<br \/>\n$output = &#8216;$P$&#8217;;<br \/>\n$output .= $this-&gt;itoa64[min($this-&gt;iteration_count_log2 +<br \/>\n((PHP_VERSION &gt;= &#8216;5&#8217;) ? 5 : 3), 30)];<br \/>\n$output .= $this-&gt;encode64($input, 6);<\/p>\n<p>return $output;<br \/>\n}<\/p>\n<p>function crypt_private($password, $setting)<br \/>\n{<br \/>\n$output = &#8216;*0&#8217;;<br \/>\nif (substr($setting, 0, 2) == $output)<br \/>\n$output = &#8216;*1&#8217;;<\/p>\n<p>$id = substr($setting, 0, 3);<br \/>\n# We use &#8220;$P$&#8221;, phpBB3 uses &#8220;$H$&#8221; for the same thing<br \/>\nif ($id != &#8216;$P$&#8217; &amp;&amp; $id != &#8216;$H$&#8217;)<br \/>\nreturn $output;<\/p>\n<p>$count_log2 = strpos($this-&gt;itoa64, $setting[3]);<br \/>\nif ($count_log2 &lt; 7 || $count_log2 &gt; 30)<br \/>\nreturn $output;<\/p>\n<p>$count = 1 &lt;&lt; $count_log2;<\/p>\n<p>$salt = substr($setting, 4, 8);<br \/>\nif (strlen($salt) != 8)<br \/>\nreturn $output;<\/p>\n<p># We&#8217;re kind of forced to use MD5 here since it&#8217;s the only<br \/>\n# cryptographic primitive available in all versions of PHP<br \/>\n# currently in use.\u00a0 To implement our own low-level crypto<br \/>\n# in PHP would result in much worse performance and<br \/>\n# consequently in lower iteration counts and hashes that are<br \/>\n# quicker to crack (by non-PHP code).<br \/>\nif (PHP_VERSION &gt;= &#8216;5&#8217;) {<br \/>\n$hash = md5($salt . $password, TRUE);<br \/>\ndo {<br \/>\n$hash = md5($hash . $password, TRUE);<br \/>\n} while (&#8211;$count);<br \/>\n} else {<br \/>\n$hash = pack(&#8216;H*&#8217;, md5($salt . $password));<br \/>\ndo {<br \/>\n$hash = pack(&#8216;H*&#8217;, md5($hash . $password));<br \/>\n} while (&#8211;$count);<br \/>\n}<\/p>\n<p>$output = substr($setting, 0, 12);<br \/>\n$output .= $this-&gt;encode64($hash, 16);<\/p>\n<p>return $output;<br \/>\n}<\/p>\n<p>function gensalt_extended($input)<br \/>\n{<br \/>\n$count_log2 = min($this-&gt;iteration_count_log2 + 8, 24);<br \/>\n# This should be odd to not reveal weak DES keys, and the<br \/>\n# maximum valid value is (2**24 &#8211; 1) which is odd anyway.<br \/>\n$count = (1 &lt;&lt; $count_log2) &#8211; 1;<\/p>\n<p>$output = &#8216;_&#8217;;<br \/>\n$output .= $this-&gt;itoa64[$count &amp; 0x3f];<br \/>\n$output .= $this-&gt;itoa64[($count &gt;&gt; 6) &amp; 0x3f];<br \/>\n$output .= $this-&gt;itoa64[($count &gt;&gt; 12) &amp; 0x3f];<br \/>\n$output .= $this-&gt;itoa64[($count &gt;&gt; 18) &amp; 0x3f];<\/p>\n<p>$output .= $this-&gt;encode64($input, 3);<\/p>\n<p>return $output;<br \/>\n}<\/p>\n<p>function gensalt_blowfish($input)<br \/>\n{<br \/>\n# This one needs to use a different order of characters and a<br \/>\n# different encoding scheme from the one in encode64() above.<br \/>\n# We care because the last character in our encoded string will<br \/>\n# only represent 2 bits.\u00a0 While two known implementations of<br \/>\n# bcrypt will happily accept and correct a salt string which<br \/>\n# has the 4 unused bits set to non-zero, we do not want to take<br \/>\n# chances and we also do not want to waste an additional byte<br \/>\n# of entropy.<br \/>\n$itoa64 = &#8216;.\/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&#8217;;<\/p>\n<p>$output = &#8216;$2a$&#8217;;<br \/>\n$output .= chr(ord(&#8216;0&#8217;) + $this-&gt;iteration_count_log2 \/ 10);<br \/>\n$output .= chr(ord(&#8216;0&#8217;) + $this-&gt;iteration_count_log2 % 10);<br \/>\n$output .= &#8216;$&#8217;;<\/p>\n<p>$i = 0;<br \/>\ndo {<br \/>\n$c1 = ord($input[$i++]);<br \/>\n$output .= $itoa64[$c1 &gt;&gt; 2];<br \/>\n$c1 = ($c1 &amp; 0x03) &lt;&lt; 4;<br \/>\nif ($i &gt;= 16) {<br \/>\n$output .= $itoa64[$c1];<br \/>\nbreak;<br \/>\n}<\/p>\n<p>$c2 = ord($input[$i++]);<br \/>\n$c1 |= $c2 &gt;&gt; 4;<br \/>\n$output .= $itoa64[$c1];<br \/>\n$c1 = ($c2 &amp; 0x0f) &lt;&lt; 2;<\/p>\n<p>$c2 = ord($input[$i++]);<br \/>\n$c1 |= $c2 &gt;&gt; 6;<br \/>\n$output .= $itoa64[$c1];<br \/>\n$output .= $itoa64[$c2 &amp; 0x3f];<br \/>\n} while (1);<\/p>\n<p>return $output;<br \/>\n}<\/p>\n<p>function HashPassword($password)<br \/>\n{<br \/>\nif ( strlen( $password ) &gt; 4096 ) {<br \/>\nreturn &#8216;*&#8217;;<br \/>\n}<\/p>\n<p>$random = &#8221;;<\/p>\n<p>if (CRYPT_BLOWFISH == 1 &amp;&amp; !$this-&gt;portable_hashes) {<br \/>\n$random = $this-&gt;get_random_bytes(16);<br \/>\n$hash =<br \/>\ncrypt($password, $this-&gt;gensalt_blowfish($random));<br \/>\nif (strlen($hash) == 60)<br \/>\nreturn $hash;<br \/>\n}<\/p>\n<p>if (CRYPT_EXT_DES == 1 &amp;&amp; !$this-&gt;portable_hashes) {<br \/>\nif (strlen($random) &lt; 3)<br \/>\n$random = $this-&gt;get_random_bytes(3);<br \/>\n$hash =<br \/>\ncrypt($password, $this-&gt;gensalt_extended($random));<br \/>\nif (strlen($hash) == 20)<br \/>\nreturn $hash;<br \/>\n}<\/p>\n<p>if (strlen($random) &lt; 6)<br \/>\n$random = $this-&gt;get_random_bytes(6);<br \/>\n$hash =<br \/>\n$this-&gt;crypt_private($password,<br \/>\n$this-&gt;gensalt_private($random));<br \/>\nif (strlen($hash) == 34)<br \/>\nreturn $hash;<\/p>\n<p># Returning &#8216;*&#8217; on error is safe here, but would _not_ be safe<br \/>\n# in a crypt(3)-like function used _both_ for generating new<br \/>\n# hashes and for validating passwords against existing hashes.<br \/>\nreturn &#8216;*&#8217;;<br \/>\n}<\/p>\n<p>function CheckPassword($password, $stored_hash)<br \/>\n{<br \/>\nif ( strlen( $password ) &gt; 4096 ) {<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>$hash = $this-&gt;crypt_private($password, $stored_hash);<br \/>\nif ($hash[0] == &#8216;*&#8217;)<br \/>\n$hash = crypt($password, $stored_hash);<\/p>\n<p>return $hash === $stored_hash;<br \/>\n}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7533\u8bf7\u4e86\u4e00\u4e2aWordPress\u7a7a\u95f4\uff0c\u6ca1\u6599\u5230\u628a\u7528\u6237\u5bc6\u7801\u5fd8\u8bb0\u4e86\uff0c\u4e0d\u77e5\u9053\u4ec0\u4e48\u539f\u56e0\uff0cWordPress\u7684\u3010\u5fd8\u8bb0\u5bc6\u7801\u3011\u529f\u80fd&#8230;<\/p>\n","protected":false},"author":1,"featured_media":494,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[279,20],"tags":[24],"views":4824,"_links":{"self":[{"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/posts\/226"}],"collection":[{"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.brofive.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=226"}],"version-history":[{"count":2,"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":898,"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions\/898"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.brofive.net\/index.php?rest_route=\/wp\/v2\/media\/494"}],"wp:attachment":[{"href":"http:\/\/www.brofive.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.brofive.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.brofive.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}