예제 #1
0
        //登录
        private static bool Login(ClassHttpPostEx objHttp, string strUser, string strPwd)
        {
            string strLoginUrl = "http://www.google.com/accounts/Logout?continue=https%3A%2F%2Fwww.google.com%2Faccounts%2FServiceLoginAuth%3Fcontinue%3Dhttp%253A%252F%252Fwww.google.com.hk%252Flanguage_tools%253Fhl%253Dzh-CN%26hl%3Dzh-cn&il=true&zx=8pife4w3cezu";
            string strRet      = objHttp.GetHttpPage(strLoginUrl, "utf-8", "get", "", "", "http://www.google.com.hk", "*/*", "");

            //找到标识,证明此页面获取无误
            if (strRet.IndexOf("保持登录状态") < 0)
            {
                return(false);
            }
            string strData = "";
            string strDsh  = "";
            string strGALX = "";

            string strTempRet = "";

            strTempRet = strRet.Substring(strRet.IndexOf("id=\"dsh\""));
            strDsh     = GetKeyString(strTempRet, "value=\"", "\"");

            strTempRet = strRet.Substring(strRet.IndexOf("name=\"GALX\""));
            strGALX    = GetKeyString(strTempRet, "value=\"", "\"");
            strData    = string.Format("continue=http%3A%2F%2Fwww.google.com.hk%2Flanguage_tools%3Fhl%3Dzh-CN&dsh={0}&hl=zh-cn&timeStmp=&secTok=&GALX={1}" +
                                       "&Email={2}&Passwd={3}&rmShown=1&signIn=%E7%99%BB%E5%BD%95&asts=",
                                       strDsh,
                                       strGALX,
                                       strUser,
                                       strPwd
                                       );

            strRet = objHttp.GetHttpPage("https://www.google.com/accounts/ServiceLoginAuth", "utf-8", "post", "", strData, "https://www.google.com/accounts/ServiceLoginAuth?continue=http%3A%2F%2Fwww.google.com.hk%2F&hl=zh-cn", "*/*", "");
            if (strRet.IndexOf("转接") < 0)
            {
                return(false);
            }
            //得到跳转的链接
            string strUrl = GetKeyString(strRet, "&#39;", "&#39;");

            strUrl = strUrl.Replace("&amp;", "&");
            strRet = objHttp.GetHttpPage(strUrl, "utf-8", "get", "", "", "http://www.google.com.hk", "*/*", "");
            if (strRet.IndexOf("退出</a>") < 0)
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
        public static bool ChangePassWord(string strUser, string strOldPwd, string strNewPwd)
        {
            ClassHttpPostEx objHttp = new ClassHttpPostEx();
            bool            bRet    = Login(objHttp, strUser, strOldPwd);

            if (!bRet)
            {
                return(false);
            }
            //获取密码编辑页面
            string strRet = objHttp.GetHttpPage("https://www.google.com/accounts/EditPasswd?hl=zh-cn", "utf-8", "get", "", "", "http://www.google.com.hk", "*/*", "");

            if (strRet.IndexOf("请提供您目前的密码") < 0)
            {
                return(false);
            }
            string strData     = "";
            string strtimeStmp = "";
            string strsecTok   = ""; //URLENCODE

            string strTempRet = "";

            strTempRet  = strRet.Substring(strRet.IndexOf("id=\"timeStmp\""));
            strtimeStmp = GetKeyString(strTempRet, "value='", "'");

            strTempRet = strRet.Substring(strRet.IndexOf("id=\"secTok\""));
            strsecTok  = GetKeyString(strTempRet, "value='", "'");

            strsecTok = System.Web.HttpUtility.UrlEncode(strsecTok, System.Text.Encoding.GetEncoding("gb2312"));
            strData   = string.Format("hl=zh-cn&timeStmp={0}&secTok={1}&group1=OldPasswd&OldPasswd={2}" +
                                      "&Passwd={3}&PasswdAgain={4}&p=&save=%E4%BF%9D%E5%AD%98",
                                      strtimeStmp,
                                      strsecTok,
                                      strOldPwd,
                                      strNewPwd,
                                      strNewPwd
                                      );
            strRet = objHttp.GetHttpPage("https://www.google.com/accounts/UpdatePasswd", "utf-8", "post", "", strData, "https://www.google.com/accounts/EditPasswd?hl=zh-cn", "*/*", "");
            if (strRet.IndexOf("新密码已保存") < 0)
            {
                return(false);
            }
            return(true);
        }
        //登录
        private static bool Login(ClassHttpPostEx objHttp,string strUser, string strPwd)
        {
            string strLoginUrl = "http://www.google.com/accounts/Logout?continue=https%3A%2F%2Fwww.google.com%2Faccounts%2FServiceLoginAuth%3Fcontinue%3Dhttp%253A%252F%252Fwww.google.com.hk%252Flanguage_tools%253Fhl%253Dzh-CN%26hl%3Dzh-cn&il=true&zx=8pife4w3cezu";
            string strRet = objHttp.GetHttpPage(strLoginUrl, "utf-8", "get", "", "", "http://www.google.com.hk", "*/*", "");

            //找到标识,证明此页面获取无误
            if (strRet.IndexOf("保持登录状态")<0)
            {
                return false;
            }
            string strData = "";
            string strDsh = "";
            string strGALX = "";

            string strTempRet = "";
            strTempRet = strRet.Substring(strRet.IndexOf("id=\"dsh\""));
            strDsh = GetKeyString(strTempRet, "value=\"", "\"");

            strTempRet = strRet.Substring(strRet.IndexOf("name=\"GALX\""));
            strGALX = GetKeyString(strTempRet, "value=\"", "\"");
            strData = string.Format("continue=http%3A%2F%2Fwww.google.com.hk%2Flanguage_tools%3Fhl%3Dzh-CN&dsh={0}&hl=zh-cn&timeStmp=&secTok=&GALX={1}" +
                "&Email={2}&Passwd={3}&rmShown=1&signIn=%E7%99%BB%E5%BD%95&asts=",
            strDsh,
            strGALX,
            strUser,
            strPwd
            );

            strRet = objHttp.GetHttpPage("https://www.google.com/accounts/ServiceLoginAuth", "utf-8", "post", "", strData, "https://www.google.com/accounts/ServiceLoginAuth?continue=http%3A%2F%2Fwww.google.com.hk%2F&hl=zh-cn", "*/*", "");
            if (strRet.IndexOf("转接")<0)
            {
                return false;
            }
            //得到跳转的链接
            string strUrl = GetKeyString(strRet, "&#39;", "&#39;");
            strUrl = strUrl.Replace("&amp;", "&");
            strRet = objHttp.GetHttpPage(strUrl, "utf-8", "get", "", "", "http://www.google.com.hk", "*/*", "");
            if (strRet.IndexOf("退出</a>")<0)
            {
                return false;
            }
            return true;
        }
예제 #4
0
        /// <summary>
        /// 查询失败返回空字符串
        /// </summary>
        /// <param name="strUser"></param>
        /// <param name="strPwd"></param>
        /// <returns></returns>
        public static string QueryBalance(string strUser, string strPwd)
        {
            //<form method="post" name="login_form" action="https://www.paypal.com/c2/cgi-bin/webscr?cmd=_login-submit&amp;dispatch=5885d80a13c0db1f8e263663d3faee8d61ec37c409b56235bed2ddf64505aee9">
            ClassHttpPostEx objHttp = new ClassHttpPostEx();
            string          strRet  = objHttp.GetHttpPage("https://www.paypal.com/c2", "gb2312", "get", "", "", "http://www.bai.com", "*/*", "");

            strRet = System.Web.HttpUtility.HtmlDecode(strRet);
            if (strRet.IndexOf("Welcome - PayPal") < 0 && strRet.IndexOf("欢迎 - PayPal") < 0)
            {
                return("");
            }
            string strData = string.Format("login_email={0}&login_password={1}&target_page=0&submit.x=%E7%99%BB%E5%BD%95" +
                                           "&form_charset=UTF-8&browser_name=Microsoft+Internet+Explorer&browser_version=8&operating_system=Windows",
                                           strUser,
                                           strPwd
                                           );
            ///c2/cgi-bin/webscr?cmd=_login-submit&dispatch=5885d80a13c0db1f8e263663d3faee8d61ec37c409b56235bed2ddf64505aee9
            string strLoginUrl = GetKeyString(strRet, "<form method=\"post\" name=\"login_form\" action=\"", "\">");

            strLoginUrl = strLoginUrl.Replace("&amp;", "&");
            strRet      = objHttp.GetHttpPage(strLoginUrl, "gb2312", "post", "", strData, "https://www.paypal.com/c2/cgi-bin/webscr?cmd=_logout", "*/*", "");
            strRet      = System.Web.HttpUtility.HtmlDecode(strRet);

            //&#27491;&#22312;&#30331;&#24405;
            if (strRet.IndexOf("<title>正在登录 - PayPal</title>") < 0)
            {
                return("");
            }
            //<p class="note">如果此页面的显示时间超过5秒钟,请<a href="https://www.paypal.com/c2/cgi-bin/webscr?cmd=_login-done&amp;login_access=1297172353">点击此处</a>重新加载。</p>
            strLoginUrl = GetKeyString(strRet, "如果此页面的显示时间超过5秒钟,请<a href=\"", "\">点击此处");
            strLoginUrl = strLoginUrl.Replace("&amp;", "&");
            strRet      = objHttp.GetHttpPage(strLoginUrl, "utf-8", "get", "", "", "", "*/*", "");
            strRet      = System.Web.HttpUtility.HtmlDecode(strRet);
            if (strRet.IndexOf("PayPal余额:") < 0)
            {
                return("");
            }
            string strTempRet = strRet.Substring(strRet.IndexOf("PayPal余额:"));
            string strBalance = GetKeyString(strTempRet, "<strong>", "</strong>");

            return(strBalance);
        }
        public static bool ChangePassWord(string strUser,string strOldPwd,string strNewPwd)
        {
            ClassHttpPostEx objHttp = new ClassHttpPostEx();
            bool bRet = Login(objHttp, strUser, strOldPwd);
            if (!bRet)
            {
                return false;
            }
            //获取密码编辑页面
            string strRet = objHttp.GetHttpPage("https://www.google.com/accounts/EditPasswd?hl=zh-cn", "utf-8", "get", "", "", "http://www.google.com.hk", "*/*", "");
            if (strRet.IndexOf("请提供您目前的密码")<0)
            {
                return false;
            }
            string strData = "";
            string strtimeStmp = "";
            string strsecTok = "";  //URLENCODE

            string strTempRet = "";
            strTempRet = strRet.Substring(strRet.IndexOf("id=\"timeStmp\""));
            strtimeStmp = GetKeyString(strTempRet, "value='", "'");

            strTempRet = strRet.Substring(strRet.IndexOf("id=\"secTok\""));
            strsecTok = GetKeyString(strTempRet, "value='", "'");

            strsecTok = System.Web.HttpUtility.UrlEncode(strsecTok, System.Text.Encoding.GetEncoding("gb2312"));
            strData = string.Format("hl=zh-cn&timeStmp={0}&secTok={1}&group1=OldPasswd&OldPasswd={2}" +
                "&Passwd={3}&PasswdAgain={4}&p=&save=%E4%BF%9D%E5%AD%98",
                strtimeStmp,
                strsecTok,
                strOldPwd,
                strNewPwd,
                strNewPwd
                );
            strRet = objHttp.GetHttpPage("https://www.google.com/accounts/UpdatePasswd", "utf-8", "post", "", strData, "https://www.google.com/accounts/EditPasswd?hl=zh-cn", "*/*", "");
            if (strRet.IndexOf("新密码已保存")<0)
            {
                return false;
            }
            return true;
        }
예제 #6
0
        public static bool PayMoney(string strAcc, string strPwd, string strRecver, float fMoney, out string strError)
        {
            strError = "";
            ClassHttpPostEx objHttp = new ClassHttpPostEx();
            string          strRet  = objHttp.GetHttpPage("https://www.paypal.com/c2", "gb2312", "get", "", "", "http://www.bai.com", "*/*", "");

            strRet = System.Web.HttpUtility.HtmlDecode(strRet);
            if (strRet.IndexOf("Welcome - PayPal") < 0 && strRet.IndexOf("欢迎 - PayPal") < 0)
            {
                strError = "获取登录页面失败";
                return(false);
            }
            string strData = string.Format("login_email={0}&login_password={1}&target_page=0&submit.x=%E7%99%BB%E5%BD%95" +
                                           "&form_charset=UTF-8&browser_name=Microsoft+Internet+Explorer&browser_version=8&operating_system=Windows",
                                           strAcc,
                                           strPwd
                                           );
            string strLoginUrl = GetKeyString(strRet, "<form method=\"post\" name=\"login_form\" action=\"", "\">");

            strLoginUrl = strLoginUrl.Replace("&amp;", "&");
            strRet      = objHttp.GetHttpPage(strLoginUrl, "gb2312", "post", "", strData, "https://www.paypal.com/c2/cgi-bin/webscr?cmd=_logout", "*/*", "");
            strRet      = System.Web.HttpUtility.HtmlDecode(strRet);

            if (strRet.IndexOf("<title>正在登录 - PayPal</title>") < 0)
            {
                strError = "登录失败";
                return(false);
            }

            string strLoginAccess = GetKeyString(strRet, "如果此页面的显示时间超过5秒钟,请<a href=\"https://www.paypal.com/c2/cgi-bin/webscr?cmd=_login-done&login_access=", "\"");
            string strUrl         = "https://www.paypal.com/c2/cgi-bin/webscr?cmd=_send-money&nav=1";
            string strReffer      = string.Format("https://www.paypal.com/c2/cgi-bin/webscr?cmd=_login-done&login_access={0}", strLoginAccess);

            strRet = objHttp.GetHttpPage(strUrl, "gb2312", "get", "", strData, strReffer, "*/*", "");   //1299341733
            strRet = System.Web.HttpUtility.HtmlDecode(strRet);
            if (strRet.IndexOf("您可以为购买和服务付款") < 0 && strRet.IndexOf("您可以为购买的物品和服务付款") < 0)
            {
                strError = "打开付款页面失败";
                return(false);
            }
            string strContext = GetKeyString(strRet, "id=\"CONTEXT_CGI_VAR\" name=\"CONTEXT\" value=\"", "\"");
            string strAuth    = GetKeyString(strRet, "name=\"auth\" type=\"hidden\" value=\"", "\"");

            strData = "";
            //
            string strPostUrl = GetKeyString(strRet, "<form method=\"post\" id=\"rosetta\" class=\"rosetta\" action=\"", "\"");

            //https://www.paypal.com/c2/cgi-bin/webscr?cmd=_flow&SESSION=lZS9WYNF9O_e9u3oSF8jeGCAvKxKfU-WtkSiAPPVH4SmnGVeY-so_Ju7sOC&dispatch=5885d80a13c0db1f8e263663d3faee8d61ec37c409b56235bed2ddf64505aee9
            strReffer = strPostUrl;// +"&cmd=_flow";
            strData   = string.Format("CONTEXT={0}&cmd=_flow&sender_email={1}&currency_out=USD&email_acInput={2}&email={2}&emailPrevValue={2}&amount={3}&amount_ccode=USD&payment_type=G&submit.x=%E7%BB%A7%E7%BB%AD&auth={4}&form_charset=UTF-8",
                                      strContext,
                                      strAcc,
                                      strRecver,
                                      fMoney,
                                      strAuth);
            strRet = objHttp.GetHttpPage(strPostUrl, "gb2312", "post", "", strData, strReffer, "*/*", "");
            strRet = System.Web.HttpUtility.HtmlDecode(strRet);
            if (strRet.IndexOf("查看您的付款并发送") < 0)
            {
                strError = "尝试付款失败";
                return(false);
            }
            string strAddr = GetKeyString(strRet, "<input type=\"radio\" class=\"radio\" id=\"adr-", "\"");

            strData = string.Format("CONTEXT={0}&myAllTextSubmitID=&cmd=_flow&pie_code_manual=&no_adr_required=%E6%97%A0%E9%9C%80%E9%80%81%E8%B4%A7&address=" +
                                    "{1}&shipping_state=&shipping_city=&shipping_address1=&shipping_address2=&shipping_zip=&shipping_country_name=C2&subject=%E6%82%A8%E6%94%B6%E5%88%B0%E4%BB%98%E6%AC%BE%E4%BA%86&enterPersonalMessage=%E8%BE%93%E5%85%A5%E7%BB%99%E6%8E%A5%E6%94%B6%E4%BA%BA%E7%9A%84%E4%B8%AA%E4%BA%BA%E6%B6%88%E6%81%AF%E3%80%82&perMsg=%E8%BE%93%E5%85%A5%E7%BB%99%E6%8E%A5%E6%94%B6%E4%BA%BA%E7%9A%84%E4%B8%AA%E4%BA%BA%E6%B6%88%E6%81%AF%E3%80%82&note=&DefaultSubject=%E6%82%A8%E6%94%B6%E5%88%B0%E4%BB%98%E6%AC%BE%E4%BA%86&FlagSubjectChanged=false&submit.x=%E4%BB%98%E6%AC%BE&auth=" +
                                    "{2}&form_charset=UTF-8",
                                    strContext,
                                    strAddr,
                                    strAuth);
            strPostUrl = GetKeyString(strRet, "class=\"safeSubmit\" id=\"reviewForm\" name=\"main\" action=\"", "\"");
            strRet     = objHttp.GetHttpPage(strPostUrl, "utf-8", "post", "", strData, strReffer, "*/*", "");
            strRet     = System.Web.HttpUtility.HtmlDecode(strRet);
            if (strRet.IndexOf("钱款已发送") > 0)
            {
                strError = "付款成功";
                return(true);
            }
            strError = "付款失败";
            return(false);
        }