会飞的鱼

FS - RM
谁能反抗生命随波逐流的离合
首页 » 源码代码 » QQ自动登录协议_QQ群验证授权_源码

QQ自动登录协议_QQ群验证授权_源码

制作QQ群验证程序:

1、我们访问任意QQ网站登录都会在本地产生Cookie

例如QQ会员登录:http://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=8000201&style=20&s_url=http%3A%2F%2Fvip.qq.com%2Floginsuccess.html&maskOpacity=60&daid=18&target=self" 

会在本地生成Cookie->pt_local_token

然后把Cookie->pt_local_token 请求至 localhost.ptlogin2.qq.com 就会得到QQ号·昵称·等一些信息!

具体代码如下:

public static bool VerifyQQGroupYesNo(string VerifyQQGroupNum)
{
            /// <summary>
            /// QQ群授权验证YesNo
            /// </summary>
            bool YesNo = false;
            ///随机数处理
            Random random = new Random();
            string randomstr = (Convert.ToDouble(random.Next(1, 99)) / Math.PI / 100).ToString();
            try
            {
                ///定义string类型pt_local_tk 、localhost_str 
                string pt_local_tk = string.Empty, localhost_str = string.Empty;
 
                //QQ会员中心Url
                string LoginUrl = "http://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=8000201&style=20&s_url=http%3A%2F%2Fvip.qq.com%2Floginsuccess.html&maskOpacity=60&daid=18&target=self";
 
                //Get方式Http1.1访问QQ会员中心
                Zmoli775.HTTP.GetHttp1_1(LoginUrl);
 
                //获取访问QQ会员中心生成Cookies->pt_local_tk值
                pt_local_tk = HTTP.Cookies.GetCookies(new Uri("http://ptlogin2.qq.com"))["pt_local_token"].Value;
          
                /*
                https://localhost.ptlogin2.qq.com:4301/pt_get_uins?callback=ptui_getuins_CB&r=0.22949112393586502&pt_local_tk=-2027291081
                */
 
                //自动登录[1]->返回QQ号、client_type、QQ头像代码face_index、性别、QQ昵称、uin、uin_flag
                localhost_str = Zmoli775.HTTP.Get("https://localhost.ptlogin2.qq.com:4301/pt_get_uins?callback=ptui_getuins_CB&r=" + randomstr + "&pt_local_tk=" + pt_local_tk + "", LoginUrl);
   
                //正则截取返回JSON字符串
                if (!string.IsNullOrEmpty(localhost_str = Regex.Match(localhost_str, "(?i)(?<=var_sso_uin_list=).*?(?=;)").Value))
                {
                    JArray JArray = (JArray)JsonConvert.DeserializeObject(localhost_str);
 
                    for (int i = 0; i < JArray.Count; i++)
                    {
   
                        //自动登录[2]->var_sso_get_st_uin登录失败返回:ptui_qlogin_CB('-1', 'http://qun.qzone.qq.com/group', '登录失败,请稍后再试。*');
 
                        string var_sso_get_st_uin = Zmoli775.HTTP.Get("http://localhost.ptlogin2.qq.com:4300/pt_get_st?clientuin=" + JArray[i]["account"] + "&callback=ptui_getst_CB&r=" + randomstr + "&pt_local_tk=" + pt_local_tk + "", LoginUrl);
 
                        //登录目标地址
                        string LoginDestinationAddress = "https://ssl.ptlogin2.qq.com/jump?clientuin=" + JArray[i]["account"] + "&keyindex=9&pt_aid=549000912&daid=5&u1=http%3A%2F%2Fqun.qzone.qq.com%2Fgroup&pt_local_tk=" + pt_local_tk + "&pt_3rd_aid=0&ptopt=1&style=40";
  
                        //登录目标地址Referer
                        string LoginDestinationAddressReferer = "https://ui.ptlogin2.qq.com/cgi-bin/login?appid=549000912&daid=5&style=12&s_url=http%3A%2F%2Fqun.qzone.qq.com%2Fgroup";
 
                        //LoginOK登录成功返回访问地址生成关键Cookies
                        string LoginOK = Zmoli775.HTTP.Get(LoginDestinationAddress, LoginDestinationAddressReferer);
                         
                        //正则截取Url
                        string skey = Regex.Match(LoginOK, "(?i)(?<=ptui_qlogin_CB\\('0', ').*?(?=',)").Value;
                    
                        if (!string.IsNullOrEmpty(skey))
                        {
                            //Get方式Http1.1访问截取Url
                            Zmoli775.HTTP.GetHttp1_1(skey);
                        }
                        ///获取QQ群页面产生的Cookies->skey
                        skey = HTTP.Cookies.GetCookies(new Uri("http://ptlogin2.qzone.qq.com"))["skey"].Value;
     
                        if (!string.IsNullOrEmpty(skey))///判断Cookies->skey
                        {
                            string QQGroupList = string.Empty, QQGroupListJson = string.Empty;
                            QQGroupList = Zmoli775.HTTP.Get("http://qun.qzone.qq.com/cgi-bin/get_group_list?uin=" + JArray[i]["account"] + "&ua=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20WOW64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F50.0.2661.102%20Safari%2F537.36&random=" + randomstr + "&g_tk=" + Convert.ToString(Zmoli775.HTTP.Getg_tk(skey)) + "", LoginDestinationAddressReferer);
                             
                            //正则取QQ群列表信息
                            QQGroupListJson = Regex.Match(QQGroupList, "(?i)(?<=_Callback\\().*?(?=\\);)").Value;
                  
                            if (!string.IsNullOrEmpty(QQGroupListJson))
                            {
                                JArray Jarray = (JArray)JsonConvert.DeserializeObject(Convert.ToString(((JObject)JsonConvert.DeserializeObject(QQGroupListJson))["data"]["group"]));
                                JArray JA = (JArray)JsonConvert.DeserializeObject(Convert.ToString(Jarray));
                                for (int y = 0; y < JA.Count; y++)
                                {
                                    if (JA[y]["groupid"].ToString() == VerifyQQGroupNum) YesNo = true;///如果获取到的QQ群号码和需要验证的QQ群号码一致则设置YesNo 值为true
                                }
                            }
                        }
                    }
                }
                if (YesNo)//如果值为true
                {
                    MessageBox.Show("QQ群验证成功!", "软件授权提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return true;
                }
                else
                {
                    MessageBox.Show("QQ群验证失败!", "软件授权提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("QQ群验证失败!", "软件授权提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
}


bool test = VerifyQQGroup.VerifyQQGroupYesNo("需要验证的QQ群号码");
Console.WriteLine("\r\n结果为“ture”验证成功!\r\n\r\n结果为“false”验证失败!\r\n\r\n当前程序验证结果->“{0}”!", test);
Console.ReadKey();

文章如无特别注明均为原创! 作者: 浮生若梦, 转载或复制请以 超链接形式 并注明出处 浮生若梦's Blog
原文地址《 QQ自动登录协议_QQ群验证授权_源码》发布于2017-12-17

分享到:
0 打赏

评论

  1. #1
    qq_avatar

    免费分享:空手套白狼,每30分钟赚18元,全新暴力正规项目,限时招真传弟子!
    当你还在思考的时候,你的对手早就已经开始操作了!
    赚钱最核心的秘密,那就是行动一定要快!狠!准!你只能从成功走向成功!
    空手套白狼定义:是指花费极小的代价,获取一个丰厚的回报!
    快速拜师渠道:威 sgvg6666  (写验证码126,加我必通过)

    匿名1年前 (2018-01-16)回复
切换注册

登录

您也可以使用第三方帐号快捷登录

Q Q 登 录
微 博 登 录
切换登录

注册