コード例 #1
0
        public bool SendCaptchaResponse(string captchaResponse, ref string captchaUrl)
        {
            var getParams = new Dictionary <string, string> {
                { "action", "PiracyScreen" },
                { "function", "capture" },
                { "buildingLevel", buildingLevel },
                { "view", "pirateFortress" },
                { "cityId", cityID },
                { "position", position },
                { "captcha", captchaResponse },
                { "backgroundView", "city" },
                { "currentCityId", cityID },
                { "templateView", "pirateFortress" },
                { "currentTab", "tabBootyQuest" },
                { "actionRequest", token },
                { "ajax", "1" }
            };

            string           html = "";
            CookieCollection t    = new CookieCollection();

            if (HTTP.Request("http://" + ServersUrls[(int)m_Server] + "/index.php",
                             cookies, getParams, null, ref t, ref html, Proxy == null ? null : Proxy))
            {
                token = getNewToken(html);
                //is captcha solved?
                string src = getCaptchaURL(html);
                if (src != null)
                {
                    Log("Captcha nicht korrekt");
                    captchaUrl = src;
                    return(false);
                }

                if (isSessionExpired(html))
                {
                    Log("Sesison expired");
                    return(false);
                }
                else
                {
                    Log("Captcha korrekt");
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public bool Login()
        {
            var getParams = new Dictionary <string, string> {
                { "action", "loginAvatar" },
                { "function", "login" }
            };

            var postParams = new Dictionary <string, string> {
                { "uni_url", ServersUrls[(int)m_Server] },
                { "name", m_user },
                { "password", m_pass },
                { "kid", "" },
                { "pwat_uid", "" },
                { "pwat_checksum", "" },
                { "startPageShown", "1" },
                { "detectedDevice", "1" }
            };

            string html = "";

            if (HTTP.Request("http://" + ServersUrls[(int)m_Server] + "/index.php", null, getParams, postParams, ref cookies, ref html, Proxy == null ? null : Proxy))
            {
                if (cookies.Count < 2)
                {
                    return(false);
                }

                if (parse(html))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public bool StartMission(ref string response)
        {
            if (!isfirst)
            {
                var randomDelay = rnd.Next(Math.Min(min, max), Math.Max(min, max) + 1);
                //0s - 2min 30s = 150s
                Thread.Sleep((150 + randomDelay) * 1000);
            }
            isfirst = false;

            var getParams = new Dictionary <string, string> {
                { "action", "PiracyScreen" },
                { "function", "capture" },
                { "buildingLevel", buildingLevel },
                { "view", "pirateFortress" },
                { "cityId", cityID },
                { "position", position },
                { "backgroundView", "city" },
                { "currentCityId", cityID },
                { "templateView", "pirateFortress" },
                { "currentTab", "tabBootyQuest" },
                { "actionRequest", token },
                { "ajax", "1" }
            };

            string           html = "";
            CookieCollection t    = new CookieCollection();

            if (HTTP.Request("http://" + ServersUrls[(int)m_Server] + "/index.php",
                             cookies, getParams, null, ref t, ref html, Proxy == null ? null : Proxy))
            {
                response = html;
                token    = getNewToken(html);

                //we have a captcha to solve
                string src = getCaptchaURL(html);
                if (src != null)
                {
                    Log("Captcha muss gelöst werden: " + src);

                    if (_9kw.isServerOnline())
                    {
                        int guthaben = int.Parse(_9kw.guthaben());
                        if (guthaben < 10)
                        {
                            Log("Zu wenig Guthaben: " + guthaben);
                            return(false);
                        }
                        else
                        {
                            CookieCollection tempCookie = null;
                            Image            img        = null;
                            if (HTTP.RequestImage(src, cookies, null, null, ref tempCookie, ref img, Proxy))
                            {
                                saveImage(img);
                                string id = _9kw.captchaEinsenden("captcha.png");
                                //wait 60sec until captcha is solved by someone
                                //Thread.Sleep(30 * 1000);

                                string sol = _9kw.getCaptchaSolution(id);
                                Log("Uebermittelte Captcha Loesung: " + sol);
                                int attempts = 1;
                                while (attempts < 5)
                                {
                                    if (SendCaptchaResponse(sol, ref src))
                                    {
                                        _9kw.captchaIsCorrect(id);
                                        isfirst = true;
                                        return(true);
                                    }
                                    else
                                    {
                                        _9kw.captchaInCorrect(id);
                                        if (HTTP.RequestImage(src, cookies, null, null, ref tempCookie, ref img, Proxy))
                                        {
                                            saveImage(img);
                                        }
                                        else
                                        {
                                            Log("Konnte Captcha nicht runterladen");
                                            isfirst = true;
                                            return(false);
                                        }
                                    }

                                    id = _9kw.captchaEinsenden("captcha.png");
                                    //Thread.Sleep(30 * 1000);
                                    sol = _9kw.getCaptchaSolution(id);
                                    Log("Uebermittelte Captcha Loesung: " + sol);
                                    attempts++;
                                }
                                Log("Captcha wurde nach 5 Versuchen nicht gelöst. Hole neues Captcha");
                                isfirst = true;
                                return(false);
                            }
                            else
                            {
                                Log("Konnte Captcha nicht runterladen");
                                isfirst = true;
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        Log("9kw Server ist down");
                        isfirst = true;
                        return(false);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }