zoukankan      html  css  js  c++  java
  • QQ空间g_tk、bkn加密参数算法

    g_tk是腾讯在QQ空间这一领域使用的密文,有写数据包或者url参数中需要加入你计算出的g_tk才能成功!

    下面是通过浏览器抓包工具抓取

    访问该js内容找出 QZONE.FrontPage.getACSRFToken() 函数

    QZONE.FrontPage.getACSRFToken = function(url){
        url = QZFL.util.URI(url);
        var skey;
        if(url){
          if(url.host && url.host.indexOf(“qzone.qq.com”)> 0){
            skey = QZFL.cookie.get(“p_skey”);
          } else {
            if(url.host && url.host.indexOf(“qq.com”)> 0){
              skey = QZFL.cookie.get(“skey”);
            }}
          }}
        }}
        if(!skey){
          尝试{
            skey = parent.QZFL.cookie.get(“p_skey”)|| “”;
          } catch(err){
            skey = QZFL.cookie.get(“p_skey”)|| “”;
          }}
        }}
        if(!skey){
          skey = QZFL.cookie.get(“skey”)|| QZFL.cookie.get(“rv2”);
        }}
        var hash = 5381;
        forvar i = 0,len = skey.length; i <len; ++ i){
          hash + =(hash << 5)+ skey.charAt(i).charCodeAt();
        }}
        return hash&2147483647;
      };

    得到p_skey后,循环取单字符的二进制并取左值.累加之后就得到后面的g_tk值了

    转为C#代码

           string p_skey = pskey;
                long hash = 5381;
                for (int i = 0; i < p_skey.Length; i++)
                {
                    hash += (hash << 5) + p_skey[i];
                }
                long g_tk = hash & 0x7fffffff;

    bkn加密算法:

         public long GetBkn(string skey)
            {
                var hash = 5381;
                for (int i = 0, len = skey.Length; i < len; ++i)
                {
                    hash += (hash << 5) + (int)skey[i];
                }
                return hash & 2147483647;
            }
  • 相关阅读:
    oracle EXP导出一张表时使用query参数指定where条件
    Centos7-安装Apache2.4+PHP5.6
    VMWare 14 Workstation Pro 下载与安装
    Mysql的视图、存储过程、函数、索引全解析
    Eclipse Java注释模板设置详解
    Tomcat 80端口 配置及域名访问步骤
    LeetCode——merge-k-sorted-lists
    LeetCode——rotate-list
    LeetCode——jump-game-ii
    LeetCode——jump-game
  • 原文地址:https://www.cnblogs.com/a849788087/p/6440264.html
Copyright © 2011-2022 走看看