예제 #1
0
        private void GetCitys()
        {
            string url      = @"http://passport2.chaoxing.com/org/allcity";
            string header   = @"
                Accept: */*
                Accept-Encoding: gzip, deflate
                Accept-Language: zh-CN,zh;q=0.9
                Cache-Control: no-cache
                Connection: keep-alive
                Content-Length: 13
                Content-Type: application/x-www-form-urlencoded; charset=UTF-8
                Cookie: source=""; JSESSIONID=BF20476348793503112CFD992E4EF272; route=6cf035fa58a23c9bbcbce99d20a53f7a
                Host: passport2.chaoxing.com
                Origin: http://passport2.chaoxing.com
                Pragma: no-cache
                Referer: http://passport2.chaoxing.com/login
                User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
                X-Requested-With: XMLHttpRequest
            ";
            string response = "";

            response = http.httpPost(url, header, "pid=undefined", Encoding.UTF8);
            if (string.IsNullOrEmpty(response))
            {
                return;
            }
            //JObject json = (JObject)JsonConvert.DeserializeObject(response);
            JObject json = JObject.Parse(response);

            citys = json.GetValue("citys");
            //foreach(object item in citys)
            //{
            //    Console.Write(item);
            //}
            gridViewRegion.DataSource = null;
            gridViewRegion.DataSource = citys;
            //gridViewRegion.Rows.Add()
            foreach (DataGridViewRow item in gridViewRegion.SelectedRows)
            {
                item.Selected = false;
            }
        }
예제 #2
0
        private bool Login()
        {
            bool flag = false;

            if (string.IsNullOrEmpty(textBoxAccount.Text))
            {
                MessageBox.Show("请输入账号", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (string.IsNullOrEmpty(textBoxPassword.Text))
            {
                MessageBox.Show("请输入密码", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (string.IsNullOrEmpty(textBoxCode.Text))
            {
                MessageBox.Show("请输入验证码", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                string fid = "-1", fidName = "", allowJoin = "0";
                if (!string.IsNullOrEmpty(school))
                {
                    JObject json = JObject.Parse(school);
                    fid       = json.Value <string>("id");
                    fidName   = json.Value <string>("name");
                    allowJoin = json.Value <string>("allowJoin");
                }

                string uname    = textBoxAccount.Text,
                       password = textBoxPassword.Text,
                       numcode  = textBoxCode.Text;
                password = Utility.EncodeBase64("utf-8", password);

                string url      = @"http://passport2.chaoxing.com/login?refer=http%3A%2F%2Fi.mooc.chaoxing.com";
                string header   = @"
                    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
                    Accept-Encoding: gzip, deflate
                    Accept-Language: zh-CN,zh;q=0.9
                    Cache-Control: no-cache
                    Connection: keep-alive
                    Content-Length: 282
                    Content-Type: application/x-www-form-urlencoded
                    Host: passport2.chaoxing.com
                    Origin: http://passport2.chaoxing.com
                    Pragma: no-cache
                    Referer: http://passport2.chaoxing.com/login?refer=http%3A%2F%2Fi.mooc.chaoxing.com
                    Upgrade-Insecure-Requests: 1
                    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
                ";
                string response = "";
                response = http.httpPost(url, header, "refer_0x001=http%3A%2F%2Fi.mooc.chaoxing.com&pid=-1&pidName=&fid=" + fid + "&fidName=" + fidName + "&allowJoin=" + allowJoin + "&isCheckNumCode=1&f=0&productid=&t=true&uname=" + uname + "&password="******"&numcode=" + numcode + "&verCode=", Encoding.UTF8);

                string startStr, endStr, errorStr;
                Regex  pattern;
                startStr = "<td class=\"show_error\" id=\"show_error\">";
                endStr   = "&nbsp;</td>";
                pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                errorStr = pattern.Match(response).Value;
                if (string.IsNullOrEmpty(errorStr))
                {
                    if (response.IndexOf("RegisterNew.dll") > 0)
                    {
                        flag = true;

                        string schoolid = "", username = "", userpwd = "", encryptPwd = "", urls = "", urld = "", proc = "";

                        startStr = "<input type=\"hidden\" name=\"SchoolID\" value=\"";
                        endStr   = "\" />";
                        pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        schoolid = pattern.Match(response).Value;

                        startStr = "<input type=\"hidden\" name=\"UserName\" value=\"";
                        endStr   = "\" />";
                        pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        username = pattern.Match(response).Value;

                        startStr = "<input type=\"hidden\" name=\"UserPwd\" value=\"";
                        endStr   = "\"/>";
                        pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        userpwd  = pattern.Match(response).Value;

                        startStr   = "<input type=\"hidden\" name=\"encryptPwd\" value=\"";
                        endStr     = "\"/>";
                        pattern    = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        encryptPwd = pattern.Match(response).Value;

                        startStr = "<input type=\"hidden\" name=\"Urls\" value=\"";
                        endStr   = "\"/>";
                        pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        urls     = pattern.Match(response).Value;

                        startStr = "<input type=\"hidden\" name=\"Urld\" value=\"";
                        endStr   = "\"/>";
                        pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        urld     = pattern.Match(response).Value;

                        startStr = "<input type=\"hidden\" name=\"Proc\" value=\"";
                        endStr   = "\"/>";
                        pattern  = new Regex("(?<=(" + startStr + "))[.\\s\\S]*?(?=(" + endStr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                        proc     = pattern.Match(response).Value;


                        url      = @"https://reg.chaoxing.com/reg/RegisterNew.dll";
                        header   = @"
                            Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
                            Accept-Encoding: gzip, deflate, br
                            Accept-Language: zh-CN,zh;q=0.9
                            Cache-Control: no-cache
                            Connection: keep-alive
                            Content-Length: 367
                            Content-Type: application/x-www-form-urlencoded
                            Host: reg.chaoxing.com
                            Origin: http://passport2.chaoxing.com
                            Pragma: no-cache
                            Referer: http://passport2.chaoxing.com/login?refer=http%3A%2F%2Fi.mooc.chaoxing.com
                            Sec-Fetch-Mode: navigate
                            Sec-Fetch-Site: cross-site
                            Upgrade-Insecure-Requests: 1
                            User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
                        ";
                        response = "";
                        response = http.httpPost(url, header, "SchoolID = " + schoolid + " & UserName = "******" & UserPwd = " + userpwd + " & encryptPwd = " + encryptPwd + " & Hddinfo = 1583399121 & Urls = " + urls + " & Urld = " + urld + " & Proc = " + proc + " & SSVer = 4.1.1.0003", Encoding.Default);


                        Console.Write(response);

                        url = @"http://passport2.chaoxing.com/tochaoxing?refer=http%3A%2F%2Fi.mooc.chaoxing.com&username="******"&Result=0&RegCode=384358e7c764b92d56cd9dc19813def18234b1a99330ea90c1b00fdaadd2b9dd22d7fe42cdd17e283077e363b2fcd49a&hddid=172052239&EncryptNo=9ecd82a32c6c58daf90744d7a8e50b3e";

                        http.httpGet(url);
                    }
                    else
                    {
                        MessageBox.Show("服务器未知错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                else
                {
                    MessageBox.Show(errorStr, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }


                GetPic();
            }
            return(flag);
        }