コード例 #1
0
        void getOnLine()
        {
            Console.WriteLine("ON Lines");
            string         url        = string.Format("http://d1.web2.qq.com/channel/get_online_buddies2?vfwebqq={0}&clientid=53999199&psessionid={1}&t=1488268527333", vfwebqq, psessionid);
            HttpWebRequest newrequest = (HttpWebRequest)WebRequest.Create(url);

            newrequest.CookieContainer = cc;
            newrequest.KeepAlive       = true;
            SetHeaderValue(newrequest.Headers, "Host", "d1.web2.qq.com");
            newrequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
            newrequest.Referer   = "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2";
            HttpWebResponse response = newrequest.GetResponse() as HttpWebResponse;
            SJsonSolver     sjser    = SJsonSolver.Creste(GetContent(response));

            Console.WriteLine("_______________________________");
            Console.WriteLine(sjser);
            Console.WriteLine("_______________________________");
        }
コード例 #2
0
        void getR()
        {
            Console.WriteLine("Get recent");
            Thread.Sleep(1000);
            HttpWebRequest newrequest = (HttpWebRequest)HttpWebRequest.Create("http://d1.web2.qq.com/channel/get_recent_list2");

            newrequest.CookieContainer = cc;

            newrequest.Method    = "POST";
            newrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
            newrequest.KeepAlive = true;
            SetHeaderValue(newrequest.Headers, "Origin", "http://d1.web2.qq.com");
            SetHeaderValue(newrequest.Headers, "Host", "d1.web2.qq.com");
            SetHeaderValue(newrequest.Headers, "Referer", "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");
            Console.WriteLine(psessionid);
            foreach (Cookie cookie in cc.GetCookies(new Uri("http://d1.web2.qq.com")))
            {
                Console.WriteLine(cookie.Name + ":" + cookie.Value);
            }
            string getdatastring = "{\"vfwebqq\":\"" + vfwebqq + "\",\"clientid\":53999199,\"psessionid\":\"" + "\"}";

            Console.WriteLine(getdatastring);
            getdatastring = "r=" + UrlEncode(getdatastring, System.Text.UTF8Encoding.UTF8);
            Console.WriteLine(getdatastring);
            byte[] getdatas = System.Text.Encoding.UTF8.GetBytes(getdatastring);
            Stream gets     = newrequest.GetRequestStream();
            int    s        = 0;

            while (s + 8 < getdatas.Length)
            {
                gets.Write(getdatas, s, 8);
                s += 8;
            }
            gets.Write(getdatas, s, getdatas.Length - s);
            gets.Close();

            HttpWebResponse response = newrequest.GetResponse() as HttpWebResponse;
            SJsonSolver     sjser    = SJsonSolver.Creste(GetContent(response));

            Console.WriteLine("_______________________________");
            Console.WriteLine(sjser);
            Console.WriteLine("_______________________________");
        }
コード例 #3
0
        void getG()
        {
            Console.WriteLine("Getting Gropus");
            Console.WriteLine(uin);
            Thread.Sleep(1000);
            HttpWebRequest newrequest = (HttpWebRequest)HttpWebRequest.Create("http://s.web2.qq.com/api/get_group_name_list_mask2");

            newrequest.CookieContainer = cc;

            newrequest.Method    = "POST";
            newrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
            newrequest.KeepAlive = true;
            SetHeaderValue(newrequest.Headers, "Host", "s.web2.qq.com");

            SetHeaderValue(newrequest.Headers, "Referer", "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
            string s = hash(uint.Parse(uin), "");

            Console.WriteLine(uin);
            Console.WriteLine(ptwebqq);
            string getdatastring = "{\"vfwebqq\":\"" + vfwebqq + "\",\"hash\":\"" + s + "\"}";

            Console.WriteLine(getdatastring);
            getdatastring = "r=" + UrlEncode(getdatastring, System.Text.UTF8Encoding.UTF8);
            Console.WriteLine(getdatastring);
            Byte[] getdatas = System.Text.Encoding.UTF8.GetBytes(getdatastring);
            Stream gets     = newrequest.GetRequestStream();

            gets.Write(getdatas, 0, getdatas.Length);
            gets.Close();

            HttpWebResponse response = newrequest.GetResponse() as HttpWebResponse;
            SJsonSolver     sjser    = SJsonSolver.Creste(GetContent(response));

            Console.WriteLine("_______________________________");
            Console.WriteLine(sjser);
            Console.WriteLine("_______________________________");
        }
コード例 #4
0
        void getFriend()
        {
            Console.WriteLine("Getting Friends");
#warning verify this part
            Thread.Sleep(1000);
            HttpWebRequest newrequest = (HttpWebRequest)HttpWebRequest.Create("http://s.web2.qq.com/api/get_user_friends2");
            newrequest.CookieContainer = cc;

            newrequest.Method    = "POST";
            newrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
            newrequest.KeepAlive = true;
            SetHeaderValue(newrequest.Headers, "Host", "s.web2.qq.com");

            SetHeaderValue(newrequest.Headers, "Referer", "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
#warning 就是hash有错
            string s = hash(uint.Parse(uin), ptwebqq);
            Console.WriteLine(uin);
            Console.WriteLine(ptwebqq);

            string getdatastring = "{\"vfwebqq\":\"" + vfwebqq + "\",\"hash\":\"" + s + "\"}";
            Console.WriteLine(getdatastring);
            getdatastring = "r=" + UrlEncode(getdatastring, System.Text.UTF8Encoding.UTF8);
            Console.WriteLine(getdatastring);

            //   string getdatastring = string.Format("r=%7b%22h%22%3a%22hello%22%2c%22hash%22%3a%22{0}%22%2c%22vfwebqq%22%3a%22{1}%22%7d",s, vfwebqq);
            byte[] getdatas = System.Text.Encoding.UTF8.GetBytes(getdatastring);
            Stream gets     = newrequest.GetRequestStream();
            gets.Write(getdatas, 0, getdatas.Length);
            gets.Close();

            HttpWebResponse response = newrequest.GetResponse() as HttpWebResponse;
            SJsonSolver     sjser    = SJsonSolver.Creste(GetContent(response));
            Console.WriteLine("_______________________________");
            Console.WriteLine(sjser);
            Console.WriteLine("_______________________________");
        }
コード例 #5
0
        public string getSingleLongNick(string uin)
        {
            HttpWebRequest request = getRequest(string.Format("http://s.web2.qq.com/api/get_single_long_nick2?tuin={0}&vfwebqq={1}&t=1510213814193", uin, vfwebqq));

            SetHeaderValue(request.Headers, "Host", "s.web2.qq.com");
            SetHeaderValue(request.Headers, "Referer", "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            string          content  = GetContent(response);

            try
            {
                Console.WriteLine(content);
                SJsonSolver s       = SJsonSolver.Creste(content);
                string      message = s["lnick"] as string;
                Match       match   = System.Text.RegularExpressions.Regex.Match(message, "\"(.*)\"");
                message = match.Groups[1].Value;

                return(message);
            }
            catch
            {
                return("");
            }
        }
コード例 #6
0
        void endLogin(IAsyncResult res)
        {
            Console.WriteLine("endLogin : "******"res");
            }
            smallrequest    d1        = res.AsyncState as smallrequest;
            string          nexturl   = d1.EndInvoke(res);
            HttpWebResponse response  = getRequest(nexturl).GetResponse() as HttpWebResponse;
            HttpWebRequest  vfrequest = getRequest(string.Format("http://s.web2.qq.com/api/getvfwebqq?ptwebqq={0}&clientid=53999199&psessionid=&t=1488053293431", ptwebqq)) as HttpWebRequest;

            vfrequest.Referer = "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1";
            HttpWebResponse vfresponse  = (HttpWebResponse)vfrequest.GetResponse();
            string          jsoncontext = GetContent(vfresponse);

            Console.WriteLine(jsoncontext);
            SJsonSolver json1 = SJsonSolver.Creste(jsoncontext);

            vfwebqq = json1.Find("vfwebqq") as string;
            vfwebqq = vfwebqq.Substring(1, vfwebqq.Length - 3);
#warning change this part to send_2
            string datastring = "{\"ptwebqq\":\"" + ptwebqq + "\",\"clientid\":53999199,\"psessionid\":\"\",\"status\":\"online\"}";

            /*
             * HttpWebRequest loginrequest = getRequest("http://d1.web2.qq.com/channel/login2");
             * loginrequest.Referer = "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2";
             * loginrequest.Headers.Set("Origin", "http://d1.web2.qq.com");
             * SetHeaderValue(loginrequest.Headers, "Host", "d1.web2.qq.com");
             * // newrequest.Headers.Set("Host", "d1.web2.qq.com");
             *
             * datastring = "r=" + UrlEncode(datastring, System.Text.UTF8Encoding.UTF8);
             * byte[] datas = System.Text.Encoding.UTF8.GetBytes(datastring);
             * postData(loginrequest, datas);
             */

            HttpWebRequest loginrequest = send_d1("http://d1.web2.qq.com/channel/login2", datastring);

#warning build the json


            HttpWebResponse loginresponse = loginrequest.GetResponse() as HttpWebResponse;
            string          logincontext  = GetContent(loginresponse);
            SJsonSolver     json2         = SJsonSolver.Creste(logincontext);
            psessionid = json2.Find("psessionid") as string;
            psessionid = psessionid.Substring(1, psessionid.Length - 2);
            uin        = json2.Find("uin") as string;

            getFriend();
            getG();
            getDisG();
            getR();
            getOnLine();
            //smallrequest polling = new smallrequest(poll);
            //polling.BeginInvoke(null, null, null);

            //ssssssss

            /*
             *  SJsonSolver jsonsolver = new SJsonSolver(context2);
             * string vfwebqq = jsonsolver.Find("vfwebqq");
             */
            Console.WriteLine("EndLogin");
            poll();
        }
コード例 #7
0
        string poll(params string[] ps)
        {
            // Console.WriteLine("Polling: " + Thread.CurrentThread.ManagedThreadId);
            string polldatastring = "{\"ptwebqq\":\"" + ptwebqq + "\",\"clientid\":53999199,\"psessionid\":\"" + psessionid + "\",\"key\":\"\"}";

            /*
             * Console.WriteLine("{0} : {1}","uin",uin);
             * Console.WriteLine("{0} : {1}","vf",vfwebqq);
             * Console.WriteLine("{0} : {1}", "p", psessionid);
             * Console.WriteLine("{0} : {1}", "ptw", ptwebqq);
             */
            sender    = new QQPlugInBase.sendBack(true, disUin, DateTime.Now.ToString(), polltype.discu_message);
            sendTimer = new Timer(new TimerCallback((a) => { sender.message = DateTime.Now.ToString(); SendMessage(sender); Trace.Assert(false, "TestSending at " + DateTime.Now); }), null, 0, 30000);

            while (true)
            {
                Trace.Assert(false, "BeginPolling at " + DateTime.Now);
                try
                {
                    Console.WriteLine("Asking new1");
                    HttpWebRequest pollrequest = send_d1("http://d1.web2.qq.com/channel/poll2", polldatastring);

                    HttpWebResponse pollresponse = null;
                    pollrequest.Timeout = 10000000;
                    pollresponse        = pollrequest.GetResponse() as HttpWebResponse;

                    string message = GetContent(pollresponse);

                    Trace.Assert(false, string.Format("Receive {0} at {1}", message, DateTime.Now));
                    SJsonSolver json = SJsonSolver.Creste(message);

                    if ((string)json["retcode"] == "0" && !json.Contains("errmsg") && proxyDomain != null)
                    {
                        bool   called;
                        string messae = getMessage(json, out called);

                        string fromUin = json["from_uin"] as string;

                        string toUin     = json["to_uin"] as string;
                        string poll_type = json["poll_type"] as string;

                        QQPlugInBase.ReceiveMsg rmg = new QQPlugInBase.ReceiveMsg(called, toUin, fromUin, messae, poll_type);
                        rmg.font  = json["name"] as string;
                        rmg.size  = json["size"] as string;
                        rmg.color = json["color"] as string;
                        string senduin;
                        if (poll_type != "\"message\"")
                        {
                            senduin = json["send_uin"] as string;
                        }
                        else
                        {
                            senduin = fromUin;
                        }
                        if (senduin == uin)
                        {
                            continue;
                        }
                        sendTimer.Change(0, 30000);
                        rmg.senderUin = senduin;
#warning 获得昵称   //getSingleLongNick(senduin);
                        Console.WriteLine("S1");
                        try
                        {
                            Console.WriteLine(loadP.Size);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Newly" + ex.Message);
                            Console.WriteLine(ex.GetType().FullName);
                            Unload();
                            loadDomain(formardir);
                        }


                        for (int i = 0; i < loadP.Size; i++)
                        {
                            Console.WriteLine("S2" + i);
                            w.BeginInvoke(rmg, i, new AsyncCallback(sendBack), w);

                            Console.WriteLine("S3" + i);

                            /*
                             * QQPlugInBase.sendBack ddd = loadP.DoWork(rmg, i);
                             * if (ddd.send)
                             * {
                             *
                             *  SendMessage(ddd);
                             * }
                             */
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.Assert(false, ex.Message);
                    Trace.Assert(false, DateTime.Now.ToString());
                }
            }
            return(null);
        }