Ejemplo n.º 1
0
        /// <summary>
        /// 允许登录
        /// </summary>
        public void Waitinglogin(string s)
        {
            for (int i = 0; i < 1;)
            {
                s   = HttpHelps.Get(Encoding.UTF8, "https://wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=" + uuid + "&tip=0&r=-757158328&_=1491110788887", ref cookie);
                uri = function.middlestring(s.ToString(), "redirect_uri=\"", "\"");
                if (uri.IndexOf("qq.com") != -1)
                {
                    domain    = "http://wx2.qq.com";
                    heartbeat = "https://webpush.wx2.";
                    file      = "https://file.wx2.qq.com";
                    Err       = "https://wx2.qq.com";
                    if (uri.IndexOf("https://wx.qq.com") != -1)
                    {
                        domain    = "http://wx.qq.com";
                        heartbeat = "https://webpush.wx.";
                        file      = "https://file.wx.qq.com";
                        Err       = "https://wx.qq.com";
                    }
                    i = i + 1;
                }
                Thread.Sleep(500);
            }
            //开始获取登陆秘钥

            Thread th = new Thread(new ThreadStart(delegate { GetKey(uri); }));

            th.IsBackground = true;
            th.Start();
            //手机确认登陆事件
            if (cl != null)
            {
                cl();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 扫二维码
        /// </summary>
        public void Scanning()
        {
            while (true)
            {
                /// MessageBox.Show("https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=" + uuid + "&tip=0&r=-755502095&_=1491109138225");
                s = HttpHelps.Get(Encoding.Default, "http://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=" + uuid + "&tip=0&r=-755502095&_=1491109138225", ref cookie);

                if (function.middlestring(s, "code=", ";") == "201")
                {
                    HeadImageBase64 = function.middlestring(s, "base64,", "'");
                    if (HeadImageBase64 != "")
                    {
                        HeadImage = function.Base64ToImage(HeadImageBase64);
                    }
                    if (SetImage != null)
                    {
                        SetImage(HeadImage);
                    }
                    Waitinglogin(s);
                    return;
                }
                if (function.middlestring(s, "code=", ";") == "200")
                {
                    Waitinglogin(s);
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化参数
        /// </summary>
        public void GetKey(string ur)
        {
            string s = HttpHelps.Get(Encoding.UTF8, ur.Replace("https", "http"), ref cookie);

            if (s.IndexOf("<error><ret>1203</ret>") != -1)
            {
                MessageBox.Show(function.middlestring(s, "<message>", "</message>"));
                return;
            }
            skey        = function.middlestring(s.ToString(), "<skey>", "</skey>");
            wxsid       = function.middlestring(s.ToString(), "<wxsid>", "</wxsid>");
            wxuin       = function.middlestring(s.ToString(), "<wxuin>", "</wxuin>");
            pass_ticket = function.middlestring(s.ToString(), "<pass_ticket>", "</pass_ticket>");
            OfflineMessage();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 登录状态
        /// </summary>
        public static bool login(string url, string username, string userpass, CookieContainer webCookie, out string postUrl)
        {
            if (username.Length == 0 || userpass.Length == 0)
            {
                postUrl = "";
                return(false);
            }


            bool   loginSuccess = false;
            string formPost     = "";

            postUrl = "";
            string hidden_verificationToken  = "";
            string hidden_VIEWSTATE          = "";
            string hidden_VIEWSTATEGENERATOR = "";

            //登录获取Cookie

            //

            for (int i = 0; i < 3; i++)
            {
                string frameUrl = "";
                for (int j = 0; j < 2; j++)
                {
                    string resultMain = HttpHelps.Get(url, webCookie, Encoding.Default, 3000);

                    //string resultMain = HttpHelps.Post("", url, webCookie, Encoding.Default);

                    frameUrl = function.middlestring(resultMain, "<iframe src=\"", "\" width=\"100%\"");
                    if (!string.IsNullOrWhiteSpace(frameUrl))
                    {
                        function.log("实际地址" + frameUrl);
                        break;
                    }
                }
                if (frameUrl.Length > 0)
                {
                    Uri    frameUri    = new Uri(frameUrl);
                    string resultFrame = HttpHelps.Get(frameUrl, webCookie, Encoding.UTF8);

                    formPost = function.middlestring(resultFrame, "<form name=\"form1\" method=\"post\" action=\"./?", "\" id=");
                    if (formPost.Length == 0)
                    {
                        formPost = function.middlestring(resultFrame, "<form name=\"form1\" method=\"post\" action=\"?", "\" id=");
                    }
                    hidden_verificationToken  = function.middlestring(resultFrame, "__RequestVerificationToken\" type=\"hidden\" value=\"", "\" />");
                    hidden_VIEWSTATE          = function.middlestring(resultFrame, "__VIEWSTATE\" value=\"", "\" />");
                    hidden_VIEWSTATEGENERATOR = function.middlestring(resultFrame, "__VIEWSTATEGENERATOR\" value=\"", "\" />");
                    postUrl = "http://" + frameUri.Host;
                    if (hidden_verificationToken.Length > 0)
                    {
                        if (hidden_VIEWSTATEGENERATOR.Length > 0)
                        {
                        }
                        break;
                    }

                    string jsCookie = HttpHelps.Post("", postUrl + "/cp2-dfgj-mb/bk.aspx/GetCookie", webCookie, Encoding.Default);
                }
                Thread.Sleep(100);
            }


            int tryCount = 0;

            while (true)
            {
                if (string.IsNullOrWhiteSpace(postUrl))
                {
                    loginSuccess = false;
                    break;
                }

                #region 获取验证码

                //图像验证码
                string validateCode = "";
                Bitmap bitmap;
                validateCode = ServerCommon.GetValidateCode(postUrl + "/cp2-dfgj-mb/checknum.aspx?ts=" + DateTime.Now.Ticks,
                                                            webCookie, out bitmap);



                #endregion 获取验证码

                #region 登录

                if (validateCode.Length == 4)
                {
                    string resultCredits = HttpHelps.Post("txt_U_name=" + username + "&txt_U_Password="******"&txt_validate=" + validateCode
                                                          + "&__VIEWSTATE=" + hidden_VIEWSTATE + "&__VIEWSTATEGENERATOR=" + hidden_VIEWSTATEGENERATOR + "&__RequestVerificationToken=" + hidden_verificationToken,
                                                          postUrl + "/cp2-dfgj-mb/" + "?" + formPost, webCookie, Encoding.UTF8);

                    string resultLeft = HttpHelps.Post("", postUrl + "/cp2-dfgj-mb/ch/left.aspx", webCookie, Encoding.UTF8);

                    if (resultLeft.Length > 2000)
                    {
                        loginSuccess = true;
                        function.log("永利登录成功");
                        break;
                    }
                    else
                    {
                        tryCount++;
                        loginSuccess = false;
                    }

                    function.log("永利登录失败,重新尝试");
                    Thread.Sleep(500);
                }

                #endregion 登录

                if (tryCount > 10)
                {
                    function.log("尝试登录次数过多");
                    break;
                }
            }

            return(loginSuccess);
        }