Exemplo n.º 1
0
        public static void AddBot(string email)
        {
            var futAccount = FUTAccountsDatabase.GetFUTAccountByEMail(email);

            if (futAccount != null && _futClients != null)
            {
                var futClient = new FUTClient(futAccount);
                _futClients.Add(futClient);
            }
        }
Exemplo n.º 2
0
        public static void Initialize()
        {
            _futClients = new List <FUTClient>();
            var futAccounts = FUTAccountsDatabase.GetFUTAccounts();

            foreach (var account in futAccounts)
            {
                var futClient = new FUTClient(account);
                _futClients.Add(futClient);
            }
        }
Exemplo n.º 3
0
 public void SaveChanges()
 {
     using (var ctx = new FUTAccountsDatabase())
     {
         var pre = ctx.FUTAccounts.FirstOrDefault(x => x.EMail.ToLower() == EMail.ToLower());
         if (pre != null)
         {
             ctx.Entry(pre).CurrentValues.SetValues(this);
             ctx.SaveChanges();
         }
     }
 }
Exemplo n.º 4
0
        public Index()
        {
            this.RequiresAuthentication();
            Get("/", args =>
            {
                var mod = new IndexModel();
                #region Coins & Accounts
                var coinsPerAccount = 0;
                var accounts        = FUTAccountsDatabase.GetFUTAccounts();
                var coins           = FUTLogsDatabase.GetFUTCoins();

                var totalCoins = accounts.Select(acc => coins.FirstOrDefault(x => x.EMail.ToLower() == acc.EMail.ToLower())).Where(coinsFromAcc => coinsFromAcc != null).Sum(coinsFromAcc => coinsFromAcc.Coins);
                if (totalCoins > 0 && accounts.Count > 0)
                {
                    coinsPerAccount = totalCoins / accounts.Count;
                }

                mod.TotalCoins         = totalCoins;
                mod.AvgCoinsPerAccount = coinsPerAccount;
                mod.TotalAccounts      = accounts.Count;


                var allTpItems = Fifa.Managers.BotManager.GetTradepileItems();
                var tpValue    = (int)(allTpItems.Sum(x => x.buyNowPrice) * 0.95);

                mod.TotalOverallValue   = tpValue + totalCoins;
                mod.TotalTradepileValue = tpValue;
                mod.TotalTradepileItems = allTpItems.Count;
                #endregion

                #region Logs
                mod.TotalBuys  = FUTLogsDatabase.GetFUTBuysCount();
                mod.TotalSells = FUTLogsDatabase.GetFUTSellsCount();
                mod.TotalLogs  = mod.TotalBuys + mod.TotalSells;
                #endregion

                if (!string.IsNullOrEmpty(HttpUtility.ParseQueryString(Request.Url.Query).Get("forbidden")))
                {
                    mod.DisplayError = true;
                    mod.ErrorMessage = "You do not have permissions to view this page!";
                }

                return(View["Index", mod]);
            });
        }
Exemplo n.º 5
0
        public ExportData()
        {
            this.RequiresAuthentication();

            Get("/export/accounts", args =>
            {
                var exportText = "";
                var accs       = FUTAccountsDatabase.GetFUTAccounts();

                foreach (var futAccount in accs)
                {
                    exportText +=
                        $"{futAccount.EMail};{futAccount.Password};{futAccount.SecurityAnswer};{futAccount.GoogleAuthCode};{futAccount.EMailPassword}{Environment.NewLine}";
                }

                return(Response.AsText(exportText));
            });

            Get("/export/proxies", args =>
            {
                using (var ctx = new FUTSettingsDatabase())
                {
                    var proxys     = ctx.FUTProxys.ToList();
                    var exportText = "";
                    foreach (var proxy in proxys)
                    {
                        exportText +=
                            $"{proxy.Host}:{proxy.Port}:{proxy.Username}:{proxy.Password}{Environment.NewLine}";
                    }

                    return(Response.AsText(exportText));
                }
            });

            Get("/export/actionscheduler", args =>
            {
                return(Response.AsText(FUTSettings.Instance.ActionSchedulerJson));
            });
        }
Exemplo n.º 6
0
        public async Task <LoginResponse> PerformRequestAsync()
        {
            try
            {
                var resp = new LoginResponse();
                if (_mailClient == null && String.IsNullOrEmpty(FUTAccount.BackupCode1) && String.IsNullOrEmpty(FUTAccount.BackupCode2) && String.IsNullOrEmpty(FUTAccount.BackupCode3) && String.IsNullOrEmpty(FUTAccount.GoogleAuthCode))
                {
                    resp.Code    = FUTErrorCode.UnknownEMailProvider;
                    resp.Message = "Unknown EMailprovider";
                    return(resp);
                }
                HttpClient.RemoveRequestHeader(NonStandardHttpHeaders.PhishingToken);
                HttpClient.RemoveRequestHeader(NonStandardHttpHeaders.SessionId);
                UpdateStatistic("Loading Cookies and Enviromentvariables...");
                HttpClient.SetCookieContainer(CookieManager.GetCookieContainer(FUTAccount, false));
                UpdateStatistic("Grabbing Loginpage...");
                var loggedIn = await GetLoginPageAsync().ConfigureAwait(false);

                var loggedInString = await loggedIn.Content.ReadAsStringAsync().ConfigureAwait(false);

                if (!loggedIn.RequestMessage.RequestUri.AbsoluteUri.Contains("companion/auth.html"))
                {
                    await Task.Delay(2000).ConfigureAwait(false);

                    UpdateStatistic("Loging in to Origin...");
                    loggedIn = await LoginAsync(loggedIn.RequestMessage.RequestUri.AbsoluteUri).ConfigureAwait(false);

                    loggedInString = await loggedIn.Content.ReadAsStringAsync().ConfigureAwait(false);
                }


                var codeSentTimestamp = DateTime.Now.Subtract(new TimeSpan(0, 2, 0));
                if (loggedInString.Contains("var redirectUri = 'https://signin.ea.com:443/p/web2/login?execution="))
                {
                    var redirect = Regex.Match(loggedInString, "'(.*?)';").Groups[1].Value;
                    var red2     = Regex.Match(loggedInString, "redirectUri \\+ \"(.*?)\";").Groups[1].Value;
                    loggedIn = await HttpClient.GetAsync(redirect + red2).ConfigureAwait(false);

                    loggedInString = await loggedIn.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                if (loggedInString.Contains("general-error") && !loggedInString.Contains("panel-profile-upgrade"))
                {
                    resp.Code = Models.FUTErrorCode.WrongLoginData;
                    return(resp);
                }
                if (loggedInString.Contains("tfa-login-link") && loggedInString.Contains("btnSendCode"))
                {
                    if (!String.IsNullOrEmpty(FUTAccount.GoogleAuthCode))
                    {
                        loggedIn = await SelectGoogleAuthenticatorAsync(loggedIn.RequestMessage.RequestUri.AbsoluteUri).ConfigureAwait(false);

                        loggedInString = await loggedIn.Content.ReadAsStringAsync().ConfigureAwait(false);
                    }
                    else
                    {
                        loggedIn = await SelectEMailTwoFactorAsync(loggedIn.RequestMessage.RequestUri.AbsoluteUri).ConfigureAwait(false);

                        loggedInString = await loggedIn.Content.ReadAsStringAsync().ConfigureAwait(false);
                    }
                }
                var twoFactorCode = "";
                if (loggedInString.Contains("tfa-login-panel-container-style") && loggedInString.Contains("oneTimeCode"))
                {
                    if (!String.IsNullOrEmpty(FUTAccount.BackupCode1))
                    {
                        twoFactorCode          = FUTAccount.BackupCode1;
                        FUTAccount.BackupCode1 = "";
                        FUTAccount.UpdateBackupCodes();
                    }
                    else if (!String.IsNullOrEmpty(FUTAccount.BackupCode2))
                    {
                        twoFactorCode          = FUTAccount.BackupCode2;
                        FUTAccount.BackupCode2 = "";
                        FUTAccount.UpdateBackupCodes();
                    }
                    else if (!String.IsNullOrEmpty(FUTAccount.BackupCode2))
                    {
                        twoFactorCode          = FUTAccount.BackupCode2;
                        FUTAccount.BackupCode3 = "";
                        FUTAccount.UpdateBackupCodes();
                    }
                    else if (!string.IsNullOrEmpty(FUTAccount.GoogleAuthCode))
                    {
                        twoFactorCode = QuickEAAuthenticator.GenerateAuthCode(FUTAccount.GoogleAuthCode);
                    }
                    else
                    {
                        var resendUri  = loggedIn.RequestMessage.RequestUri.AbsoluteUri + "&_eventId=resend";
                        var resendUri2 = "https://signin.ea.com" + loggedInString.GetRegexBetween(" < a id=\"resend_code_link\" href=\"", "\"");
                        UpdateStatistic("Waiting for TwoFactor Code...");
                        twoFactorCode = await WaitForTwoFactorCode(codeSentTimestamp, resendUri).ConfigureAwait(false);
                    }
                    if (twoFactorCode == "WrongUserPassword")
                    {
                        resp.Code = Models.FUTErrorCode.WrongEMailPassword;
                        return(resp);
                    }
                    if (twoFactorCode == "GMXBlocked")
                    {
                        resp.Code = Models.FUTErrorCode.GMXBlocked;
                        return(resp);
                    }
                    if (twoFactorCode.StartsWith("EXC"))
                    {
                        resp.Code    = Models.FUTErrorCode.TwoFactorFailed;
                        resp.Message = twoFactorCode.Remove(0, 3);
                        return(resp);
                    }
                    if (twoFactorCode == "000000" || twoFactorCode == "")
                    {
                        resp.Code    = Models.FUTErrorCode.TwoFactorFailed;
                        resp.Message = "Couldn't get twoFactorCode";
                        return(resp);
                    }
                    await Task.Delay(2000).ConfigureAwait(false);

                    loggedIn = await FillInTwoFactorAsync(loggedIn.RequestMessage.RequestUri.AbsoluteUri, twoFactorCode).ConfigureAwait(false);

                    loggedInString = await loggedIn.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                if (loggedInString.Contains("Eingegebener Code nicht korrekt"))
                {
                    resp.Code    = FUTErrorCode.WrongEMailCode;
                    resp.Message = "Wrong email code!";
                    return(resp);
                }
                if (!loggedIn.RequestMessage.RequestUri.AbsoluteUri.Contains("auth.html"))
                {
                    resp.Code    = Models.FUTErrorCode.NoRedirectToWebApp;
                    resp.Message = "No redirect to mobile-app";
                    return(resp);
                }
                UpdateStatistic("Grabbing EASW ID...");

                var authCode  = loggedIn.RequestMessage.RequestUri.Query.Remove(0, 6);
                var tmpBearer = await GetBearerAuthCodeAsync(authCode);

                var bearer = Regex.Match(tmpBearer, "\"access_token\" : \"(.*?)\",").Groups[1].Value;
                var easw   = await GetEaswAsync(bearer);

                var easwID = easw.pid.pidId.ToString();
                if (string.IsNullOrEmpty(easwID))
                {
                    FUTAccountsDatabase.RemoveFUTCookiesByEMail(FUTAccount.EMail);
                    CookieManager.DeleteCookieContainer(FUTAccount, false);
                    resp.Code    = Models.FUTErrorCode.NoEaswID;
                    resp.Message = "No easwID";
                    return(resp);
                }
                FUTSession.NucleusID = easwID;
                FUTSession.Update();
                resp.NucleusID = easwID;

                HttpClient.AddRequestHeader(NonStandardHttpHeaders.NucleusId, FUTSession.NucleusID);
                HttpClient.AddRequestHeader(NonStandardHttpHeaders.EmbedError, "true");
                UpdateStatistic("Grabbing Shards...");
                var shards = await IsServerOnline();

                if (!shards)
                {
                    resp.Code    = Models.FUTErrorCode.ServerMaintenance;;
                    resp.Message = "Server offline";
                    return(resp);
                }


                HttpClient.AddRequestHeader(NonStandardHttpHeaders.Route, FUTPlatform.Route);
                UpdateStatistic("Grabbing UserAccounts...");
                var userAccounts = await GetUserAccountsAsync().ConfigureAwait(false);

                if (userAccounts == null || userAccounts.userAccountInfo == null || userAccounts.userAccountInfo.personas == null || userAccounts.userAccountInfo.personas.FirstOrDefault() == null)
                {
                    resp.Code    = Models.FUTErrorCode.NoUserAccounts;
                    resp.Message = "No userAccounts";
                    return(resp);
                }
                FUTSession.NucleusName = userAccounts.userAccountInfo.personas.FirstOrDefault().personaName;
                FUTSession.PersonaID   = userAccounts.userAccountInfo.personas.FirstOrDefault().personaId.ToString();
                FUTSession.Update();
                resp.NucleusName = FUTSession.NucleusName;
                resp.PersonaID   = FUTSession.PersonaID;

                authCode = await GetAuthCodeAsync(bearer);

                authCode = Regex.Match(authCode, "{\"code\":\"(.*?)\"}").Groups[1].Value;
                if (string.IsNullOrEmpty(authCode))
                {
                    resp.Code    = Models.FUTErrorCode.NoSessionID;
                    resp.Message = "No authCode";
                    return(resp);
                }
                UpdateStatistic("Authing on Utas...");
                var authed = await AuthAsync(authCode).ConfigureAwait(false);

                if (authed == null || string.IsNullOrEmpty(authed.sid))
                {
                    resp.Code    = Models.FUTErrorCode.NoSessionID;
                    resp.Message = "No sid";
                    return(resp);
                }
                FUTSession.SessionID = authed.sid;
                FUTSession.Update();
                resp.SessionID = authed.sid;
                HttpClient.AddRequestHeader(NonStandardHttpHeaders.SessionId, FUTSession.SessionID);
                await Task.Delay(3000).ConfigureAwait(false);

                UpdateStatistic("Grabbing SecurityQuestion...");
                var question = await QuestionAsync().ConfigureAwait(false);

                if (question.Code == FUTErrorCode.CaptchaTriggered || question.Code == FUTErrorCode.CaptchaTriggered2)
                {
                    var futproxy = FUTAccount.GetFUTProxy();
                    var solver   = new CaptchaSolver(futproxy);
                    var result   = await solver.DoAntiCaptcha();

                    if (result.errorId == 0)
                    {
                        await SolveCaptchaAsync(result.solution.token);

                        question = await QuestionAsync().ConfigureAwait(false);
                    }
                    else
                    {
                        resp.Code    = Models.FUTErrorCode.CaptchaException;
                        resp.Message = "Captcha failed!";
                        return(resp);
                    }
                }
                if (!string.IsNullOrEmpty(question.token))
                {
                    FUTSession.PhishingToken = question.token;
                    FUTSession.Update();
                    HttpClient.AddRequestHeader(NonStandardHttpHeaders.PhishingToken, FUTSession.PhishingToken);
                    resp.PhishingToken = question.token;

                    HttpClient.RemoveRequestHeader(NonStandardHttpHeaders.NucleusId);
                    HttpClient.RemoveRequestHeader(NonStandardHttpHeaders.Route);
                    CollectAllCookies();
                    return(resp);
                }
                UpdateStatistic("Validating SecurityQuestion...");
                var validate = await ValidateAsync().ConfigureAwait(false);

                if (string.IsNullOrEmpty(validate?.token))
                {
                    if (validate.code == "461")
                    {
                        resp.Code    = Models.FUTErrorCode.WrongSecurityAnswer;
                        resp.Message = "Wrong SecurityAnswer";
                        return(resp);
                    }
                    resp.Code    = Models.FUTErrorCode.NoPhishingToken;
                    resp.Message = "No phishingtoken";
                    return(resp);
                }
                //await QuestionAsync().ConfigureAwait(false);

                UpdateStatistic("Login success...");
                FUTSession.PhishingToken = validate.token;

                FUTSession.Update();
                HttpClient.AddRequestHeader(NonStandardHttpHeaders.PhishingToken, FUTSession.PhishingToken);
                resp.PhishingToken = validate.token;

                HttpClient.RemoveRequestHeader(NonStandardHttpHeaders.Route);
                CollectAllCookies();
                return(resp);
            }
            catch (Exception e)
            {
                var resp = new LoginResponse();
                resp.Message = e.ToString();
                resp.Code    = FUTErrorCode.BadRequest;
                return(resp);
            }
        }
Exemplo n.º 7
0
        public AccountManager()
        {
            this.RequiresAuthentication();
            Get("/accountmanager", args =>
            {
                var mod = new AccountManagerModel();

                var accounts = FUTAccountsDatabase.GetFUTAccounts();
                mod.Accounts = accounts;
                return(View["AccountManager", mod]);
            });

            Post("/accountmanager", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);

                var accounts = parameters["accounts"].Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
                foreach (var accString in accounts)
                {
                    if (accString.Split(';').Count() < 5)
                    {
                        continue;
                    }
                    var email          = accString.Split(';')[0];
                    var password       = accString.Split(';')[1];
                    var securityAnswer = accString.Split(';')[2];
                    var appAuth        = accString.Split(';')[3];
                    var emailPassword  = accString.Split(';')[4];
                    if (FUTAccountsDatabase.GetFUTAccountByEMail(email) == null)
                    {
                        var futAccount            = new FUTAccount();
                        futAccount.EMail          = email;
                        futAccount.Password       = password;
                        futAccount.SecurityAnswer = securityAnswer;
                        futAccount.GoogleAuthCode = appAuth;
                        futAccount.EMailPassword  = emailPassword;
                        futAccount.FUTPlatform    = new FUTPlatform();
                        FUTAccountsDatabase.AddFUTAccount(futAccount);
                        Fifa.Managers.BotManager.AddBot(email);
                    }
                }
                return(Response.AsRedirect("/accountmanager"));
            });

            Post("/deleteaccountarray", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);

                var accounts = parameters["account"].Split(',');

                foreach (var acc in accounts)
                {
                    FUTAccountsDatabase.RemoveFUTAccountByEMail(acc);
                    Fifa.Managers.BotManager.RemoveBot(acc);
                }
                return("true");
            });

            Post("/deleteaccount", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);
                var acc        = parameters["account"];

                FUTAccountsDatabase.RemoveFUTAccountByEMail(acc);
                Fifa.Managers.BotManager.RemoveBot(acc);
                return("true");
            });
        }
Exemplo n.º 8
0
        public ProxyManager()
        {
            this.RequiresAuthentication();
            Get("/proxymanager", args =>
            {
                var mod = new ProxyManagerModel();

                var proxies = new List <FUTProxy>();
                using (var ctx = new FUTSettingsDatabase())
                {
                    proxies = ctx.FUTProxys.ToList();
                }
                mod.Proxies = proxies;
                return(View["ProxyManager", mod]);
            });

            Post("/proxymanager", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);

                var proxies = parameters["proxies"].Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);

                foreach (var proxyString in proxies)
                {
                    if (proxyString.Split(':').Count() < 4)
                    {
                        continue;
                    }
                    var host          = proxyString.Split(':')[0];
                    var port          = int.Parse(proxyString.Split(':')[1]);
                    var username      = proxyString.Split(':')[2];
                    var password      = proxyString.Split(':')[3];
                    var futProxy      = new FUTProxy();
                    futProxy.Host     = host;
                    futProxy.Port     = port;
                    futProxy.Username = username;
                    futProxy.Password = password;
                    using (var ctx = new FUTSettingsDatabase())
                    {
                        ctx.FUTProxys.Add(futProxy);
                        ctx.SaveChanges();
                    }
                    Fifa.Managers.ProxyManager.AddFUTProxy(futProxy);
                }
                return(Response.AsRedirect("/proxymanager"));
            });

            Post("/deleteproxyarray", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);

                var proxies = parameters["proxy"].Split(',');

                foreach (var p in proxies)
                {
                    FUTProxy proxy = null;
                    var id         = int.Parse(p);
                    using (var ctx = new FUTSettingsDatabase())
                    {
                        proxy = ctx.FUTProxys.FirstOrDefault(x => x.ID == id);
                        if (proxy != null)
                        {
                            var accounts = FUTAccountsDatabase.GetFUTAccounts()
                                           .Where(x => x.FUTProxyID == proxy.ID).ToList();
                            foreach (var futAccount in accounts)
                            {
                                futAccount.FUTProxyID = -1;
                                futAccount.SaveChanges();
                            }
                            ctx.FUTProxys.Remove(proxy);
                            ctx.SaveChanges();
                        }
                    }
                    Fifa.Managers.ProxyManager.RemoveFUTProxy(proxy);
                }
                return("true");
            });

            Post("/deleteproxy", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);
                var id         = int.Parse(parameters["proxy"]);
                FUTProxy proxy = null;
                using (var ctx = new FUTSettingsDatabase())
                {
                    proxy = ctx.FUTProxys.FirstOrDefault(x => x.ID == id);
                    if (proxy != null)
                    {
                        var accounts = FUTAccountsDatabase.GetFUTAccounts()
                                       .Where(x => x.FUTProxyID == proxy.ID).ToList();
                        foreach (var futAccount in accounts)
                        {
                            futAccount.FUTProxyID = -1;
                            futAccount.SaveChanges();
                        }
                        ctx.FUTProxys.Remove(proxy);
                        ctx.SaveChanges();
                    }
                }
                Fifa.Managers.ProxyManager.RemoveFUTProxy(proxy);
                return("true");
            });

            Post("/allocateproxies", args =>
            {
                var body       = new StreamReader(Request.Body).ReadToEnd();
                body           = HttpUtility.UrlDecode(body);
                var parameters = HttpUtility.ParseQueryString(body);
                var action     = parameters["action"];
                if (action == "allocate")
                {
                    Fifa.Managers.BotManager.AllocateProxies();
                }
                else
                {
                    Fifa.Managers.BotManager.DeallocateProxies();
                    Fifa.Managers.ProxyManager.ResetProxyCounter();
                }
                return("true");
            });
        }