Exemple #1
0
        private async Task <bool> CreateAccount(RSAccountForm account, RsWebHelper rsHelper)
        {
            if (account != null)
            {
                var captchaRes = await GetCaptchaSolveKey(account, rsHelper);

                if (captchaRes != string.Empty)
                {
                    account.CaptchaSolve = captchaRes;

                    StatusUpdate
                        (ServiceStatusCode.Updated, account, "Creating account...");

                    var response = await
                                   rsHelper.PostRequest(account);

                    var errorMessage = GetErrorMessage(response);
                    if (errorMessage != string.Empty)
                    {
                        StatusUpdate(ServiceStatusCode.Updated, account, errorMessage);
                    }

                    var success = IsCreateSuccess(response);
                    if (!success && errorMessage == string.Empty)
                    {
                        StatusUpdate(ServiceStatusCode.Updated, account, "An unknown error occured");
                        Util.Log(response);
                    }

                    return(success);
                }
            }

            return(false);
        }
Exemple #2
0
        private void Process(IRuneScapeForm reqForm)
        {
            StatusUpdate
                (ServiceStatusCode.Started, reqForm);

            var         result   = false;
            RsWebHelper rsHelper = null;

            if (AccountServiceType == AccountServiceType.Creation)
            {
                var accountForm = (reqForm as RSAccountForm);
                rsHelper = new RsWebHelper(accountForm.ProxyName);

                result = CreateAccount(accountForm, rsHelper).Result;
            }
            else
            {
                rsHelper = new RsWebHelper();
                result   = UnlockAccount(reqForm as RSRecoveryForm, rsHelper).Result;
            }

            if (result)
            {
                StatusUpdate(ServiceStatusCode.Success, reqForm);
            }

            // Request complete
            lock (reqFormsQueueLock)
            {
                runningRequests.Remove(reqForm.RequestId);
            }

            rsHelper?.Dispose();
        }
Exemple #3
0
        private async Task <string> GetCaptchaSolveKey(IRuneScapeForm form, RsWebHelper rsHelper)
        {
            var captchaResult = string.Empty;

            StatusUpdate(ServiceStatusCode.Updated, form, "Requesting captcha solve");

            var googleKey = await rsHelper.GrabGoogleKey(form.RequestUrl);

            if (googleKey == string.Empty ||
                googleKey == "NO_GOOGLE_KEY")
            {
                StatusUpdate(ServiceStatusCode.Updated, form, "Error obtaining Google Key from requested page");
                return(string.Empty);
            }

            var captchaId = await
                            CaptchaHelper.RequestSolveCaptcha(googleKey, form.RequestUrl);

            if (captchaId == string.Empty)
            {
                StatusUpdate(ServiceStatusCode.Updated, form, "An error occured requesting captcha solve");
                return(string.Empty);
            }

            for (int i = 0; i < 60; i++)
            {
                StatusUpdate
                    (ServiceStatusCode.Updated, form, "Waiting for captcha to be solved");

                var response = await CaptchaHelper.GetSolveResult(captchaId);

                if (response != string.Empty &&
                    !response.Contains("CAPCHA_NOT_READY") && !response.Contains("ERROR"))
                {
                    captchaResult = response;
                    break;
                }

                Thread.Sleep(5 * 1000);
            }

            return(captchaResult);
        }
Exemple #4
0
        private async Task <bool> UnlockAccount(RSRecoveryForm recovery, RsWebHelper rsHelper)
        {
            var captchaRes = await GetCaptchaSolveKey(recovery, rsHelper);

            if (captchaRes == string.Empty)
            {
                return(false);
            }

            recovery.CaptchaSolve = captchaRes;
            StatusUpdate(ServiceStatusCode.Updated, recovery, "Requesting account recovery");

            var response = await
                           rsHelper.PostRequest(recovery);

            if (!response.Contains("Account Identified"))
            {
                StatusUpdate(ServiceStatusCode.Updated, recovery, "An error occured requesting recovery page");
                return(false);
            }

            var requestTime = DateTime.Now;
            var redirectUrl = GetUnlockUrl(response);

            response = (await rsHelper.GetRequest(redirectUrl)).message;

            if (!response.Contains("Proceeded to e-mail confirmation screen"))
            {
                StatusUpdate(ServiceStatusCode.Updated, recovery, "An error occured requesting account recovery");
                return(false);
            }


            StatusUpdate(ServiceStatusCode.Updated, recovery, "Connecting to mail provider");

            var mail = new MailHelper(MailProvider.Gmail);

            if (!mail.Connect
                    (recovery.MasterEmail ?? recovery.Email, recovery.EmailPassword))
            {
                StatusUpdate(ServiceStatusCode.Updated, recovery, "Failed to connect to mail provider");
                return(false);
            }

            StatusUpdate
                (ServiceStatusCode.Updated, recovery, "Searching for activation mail");

            var messageContent = string.Empty;

            for (int i = 0; i < 30; i++)
            {
                messageContent = mail.FindMailBySubjToHtml("Reset your Jagex password", requestTime);
                if (messageContent != string.Empty)
                {
                    break;
                }

                Thread.Sleep(5 * 1000);
            }

            if (messageContent == string.Empty)
            {
                StatusUpdate(ServiceStatusCode.Updated, recovery, "Unable to find recovery mail");
                return(false);
            }

            var resetPassUrl = GetResetPassUrl(messageContent);

            if (resetPassUrl == string.Empty)
            {
                StatusUpdate(ServiceStatusCode.Updated, recovery, "Error obtaining Password Reset link from email");
                return(false);
            }

            var passResetRequest = await rsHelper.GetRequest(resetPassUrl);

            if (passResetRequest.response == null)
            {
                StatusUpdate(ServiceStatusCode.Updated, recovery, "Error obtaining Password Reset page");
                return(false);
            }

            var passResetPage = passResetRequest.response.RequestMessage.RequestUri;
            var accountId     = GetAccountId(passResetPage.AbsoluteUri);

            recovery.AccountId     = accountId;
            recovery.RequestUrl    = passResetPage.AbsoluteUri;
            recovery.RecoveryStage = AccRecoveryStage.Complete;

            response = await rsHelper.PostRequest(recovery);

            return(response.Contains("Successfully set a new password and completed the process"));
        }