Due to the recent severe mass mailing of QQ junk information, the official team chose to detail the implementation of some WebQQ functions. The POST value obtained from friends has an additional hash parameter.
This hash is encrypted in js.
Below is the js source code
The code is as follows: |
Copy code |
<Script type = "text/javascript"> Function getHash (B, I ){ For (var a = I + "password error ", S = "", J = [];) if (s. length <= a. length ){ If (s + = B, s. length = a. length) break } Else { S = s. slice (0, a. length ); Break } For (var d = 0; d <s. length; d ++) j [d] = s. charCodeAt (d) ^ a. charCodeAt (d ); A = ["0", "1", "2", "3", "4", "5", "6", "7", "8 ", "9", "A", "B", "C", "D", "E", "F"]; S = ""; For (d = 0; d <j. length; d ++) s + = a [j [d]> 4 & 15], S + = a [j [d] & 15]; Return s; } </Script> |
Convert to PHP version for processing. The source code is as follows:
The code is as follows: |
Copy code |
<? Php /** * The POST parameter Hash algorithm when obtaining friends * * Public * @ Param string $ qq number * @ Param string $ ptwebqq in cookies * @ Return string */ Function get_hash ($ qq, $ ptwebqq) { For ($ a = $ ptwebqq. "password error", $ s = "", $ j = array ();;) { If (strlen ($ s) <= strlen ($ )) { $ S. = $ qq; If ($ s = strlen ($ a) break; } Else { $ S = substr ($ s, 0, strlen ($ )); Break; } } For ($ d = 0; $ d <strlen ($ s); $ d ++) { $ J [$ d] = uniord (substr ($ s, $ d) ^ uniord (substr ($ a, $ d )); } $ A = array ("0", "1", "2", "3", "4", "5", "6", "7 ", "8", "9", "A", "B", "C", "D", "E", "F "); $ S = ""; For ($ d = 0; $ d <count ($ j); $ d ++) { $ S. = $ a [$ j [$ d]> 4 & 15]; $ S. = $ a [$ j [$ d] & 15]; } Return $ s; } /** * Simulate the JavaScript charCodeAt function * * Protected * @ Param string $ str * @ Return int */ Function uniord ($ str) { List (, $ ord) = unpack ('N', mb_convert_encoding ($ str, 'ucs-4be ', 'utf-8 ')); Return |
$ Ord;
}
/* End of file commons. php */