Ejemplo n.º 1
0
 public SteamProcessor(
     IWebDriver driver,
     SteamAccount account)
     : base(driver)
 {
     this.account = account;
 }
Ejemplo n.º 2
0
        private void OpenSteamAccount(SteamAccount steamAccount)
        {
            string saveDataPath = Path.Combine(SteamUtility.GetMhwSaveDir(steamAccount) !, "SAVEDATA1000");

            MainWindowViewModel.Instance.SetActiveViewModel(new SaveDataViewModel(saveDataPath)
            {
                SteamAccount = steamAccount
            });
        }
        SteamAccountResponse CreateResponse(User user, SteamAccount steamAccount)
        {
            SteamAccountResponse response = new SteamAccountResponse();

            response.Username  = steamAccount.Username;
            response.Password  = steamAccount.Password;
            response.HmacToken = responseHmacEncoder.GenerateToken(response, user.SharedSecretKey);

            return(response);
        }
Ejemplo n.º 4
0
        internal static SteamAccount ToServiceModel(this SteamAccountEntity dataObject)
        {
            SteamAccount serviceModel = new SteamAccount();

            serviceModel.Id       = dataObject.Id;
            serviceModel.Username = dataObject.Username;
            serviceModel.Password = dataObject.Password;

            return(serviceModel);
        }
        public SteamAccountResponse GetAccount(SteamAccountRequest request)
        {
            User user = userRepository.Get(request.Username).ToServiceModel();

            ValidateRequest(request, user);

            SteamAccount         assignedAccount = GetAssignedAccount(user, request.GiveawaysProvider);
            SteamAccountResponse response        = CreateResponse(user, assignedAccount);

            return(response);
        }
Ejemplo n.º 6
0
 private void button_add_Click(object sender, RoutedEventArgs e)
 {
     if (TestString(tb_username.Text) && TestString(passwordBox.Password.ToString()))
     {
         SteamAccount Account = new SteamAccount(tb_username.Text, passwordBox.SecurePassword);
         ((MainWindow)Application.Current.MainWindow).NewAccount(Account);
         this.Close();
     }
     else
     {
         MessageBox.Show("Please enter a valid username and password.");
     }
 }
        internal static SteamAccount ToServiceModel(this SteamAccountEntity dataObject)
        {
            SteamAccount serviceModel = new SteamAccount();

            serviceModel.Id       = dataObject.Id;
            serviceModel.Username = dataObject.Username;
            serviceModel.Password = dataObject.Password;
            serviceModel.IsSteamGiftsSuspended = dataObject.IsSteamGiftsSuspended;

            serviceModel.CreationTime   = DateTime.ParseExact(dataObject.CreationTimestamp, DateTimeFormat, CultureInfo.InvariantCulture);
            serviceModel.LastUpdateTime = DateTime.ParseExact(dataObject.LastUpdateTimestamp, DateTimeFormat, CultureInfo.InvariantCulture);

            return(serviceModel);
        }
        internal static SteamAccountEntity ToDataObject(this SteamAccount serviceModel)
        {
            SteamAccountEntity dataObject = new SteamAccountEntity();

            dataObject.Id       = serviceModel.Id;
            dataObject.Username = serviceModel.Username;
            dataObject.Password = serviceModel.Password;
            dataObject.IsSteamGiftsSuspended = serviceModel.IsSteamGiftsSuspended;

            dataObject.CreationTimestamp   = serviceModel.CreationTime.ToString(DateTimeFormat);
            dataObject.LastUpdateTimestamp = serviceModel.LastUpdateTime.ToString(DateTimeFormat);

            return(dataObject);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Instantiates SteamProfileModel object from
 /// steam api response model.
 /// </summary>
 /// <param name="account">steam api response model</param>
 public SteamProfileModel(SteamAccount account)
 {
     Id64            = ulong.Parse(account.Id);
     PersonaName     = account.PersonaName;
     AvatarFullUrl   = account.AvatarFullURL;
     AvatarMediumUrl = account.AvatarMediumURL;
     AvatarSmallUrl  = account.AvatarURL;
     CountryCode     = account.LocCountryCode;
     VisibilityState = account.CommunityVisibilityState;
     TimeCreated     = account.TimeCreated;
     LastLogOff      = account.LastLogOff;
     PersonaState    = account.PersonaState;
     ProfileState    = account.ProfileState;
 }
        SteamAccount FindAccountToAssign(string gaProvider)
        {
            IEnumerable <User>         users         = userRepository.GetAll().ToServiceModels();
            IEnumerable <SteamAccount> steamAccounts = steamAccountRepository.GetAll().ToServiceModels();

            steamAccounts = steamAccounts.Where(x => users.All(y => y.AssignedSteamAccount != x.Username));

            if (gaProvider.Equals("SteamGifts", StringComparison.InvariantCultureIgnoreCase))
            {
                steamAccounts = steamAccounts.Where(x => !x.IsSteamGiftsSuspended);
            }

            SteamAccount randomAccount = steamAccounts.GetRandomElement();

            return(randomAccount);
        }
        bool DoesItNeedReuser(User user, string gaProvider)
        {
            if (string.IsNullOrWhiteSpace(user.AssignedSteamAccount))
            {
                return(true);
            }

            SteamAccount account = steamAccountRepository.Get(user.AssignedSteamAccount).ToServiceModel();

            if (gaProvider.Equals("SteamGifts", StringComparison.InvariantCultureIgnoreCase) &&
                account.IsSteamGiftsSuspended)
            {
                return(true);
            }

            return(false);
        }
        void CreateAccount(SteamAccount account)
        {
            IWebDriver driver = SetupDriver();

            try
            {
                LogInToSteam(driver, account);
                RegisterOnGameCode(driver, account);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                driver.Quit();
            }
        }
Ejemplo n.º 13
0
        public static string?GetMhwSaveDir(SteamAccount user)
        {
            string?steamRoot = GetSteamRoot();

            if (steamRoot == null)
            {
                return(null);
            }

            string userDataPath = Path.Combine(steamRoot, "userdata", user.SteamId3.ToString());

            if (Directory.GetDirectories(userDataPath).FirstOrDefault(x => x.Contains(MONSTER_HUNTER_WORLD_APPID)) != null)
            {
                return(Path.Combine(userDataPath, MONSTER_HUNTER_WORLD_APPID, "remote"));
            }

            return(null);
        }
        void LogInToSteam(IWebDriver driver, SteamAccount account)
        {
            logger.Info(MyOperation.SteamLogIn, OperationStatus.Started, new LogInfo(MyLogInfoKey.Username, account.Username));

            try
            {
                ISteamProcessor steamProcessor = new SteamProcessor(driver, account);
                steamProcessor.LogIn();
                steamProcessor.Dispose();

                logger.Debug(MyOperation.SteamLogIn, OperationStatus.Success, new LogInfo(MyLogInfoKey.Username, account.Username));
            }
            catch (Exception ex)
            {
                logger.Error(MyOperation.SteamLogIn, OperationStatus.Failure, ex, new LogInfo(MyLogInfoKey.Username, account.Username));
                throw;
            }
        }
Ejemplo n.º 15
0
        static void RunSteam(SteamAccount steamAccount)
        {
            try
            {
                HttpWebRequest w = WebRequest.Create("http://localhost:8088/steam/" + Environment.UserName.ToLower() + "/stop") as HttpWebRequest;

                var response = w.GetResponse();

                using (Stream s = response.GetResponseStream())
                    using (StreamReader readStream = new StreamReader(s, Encoding.UTF8))
                    {
                        string responsestring = readStream.ReadToEnd();
                        if (responsestring.StartsWith("steam stopped") || responsestring.ToLower() == "steam not running")
                        {
                            ProcessStartInfo info = new ProcessStartInfo();
                            info.FileName               = steamAccount.SteamFolder;
                            info.CreateNoWindow         = true;
                            info.UseShellExecute        = false;
                            info.RedirectStandardError  = true;
                            info.RedirectStandardInput  = true;
                            info.RedirectStandardOutput = true;
                            var decryptedPassword = CryptoProvider.Decrypt(steamAccount.Password, steamAccount.Key);
                            info.Arguments = "-login " + steamAccount.Username + " " + decryptedPassword;
                            Process.Start(info);
                        }
                        else
                        {
                            ProcessStartInfo info = new ProcessStartInfo();
                            info.FileName               = steamAccount.SteamFolder;
                            info.CreateNoWindow         = true;
                            info.UseShellExecute        = false;
                            info.RedirectStandardError  = true;
                            info.RedirectStandardInput  = true;
                            info.RedirectStandardOutput = true;
                            Process.Start(info);
                        }
                    }
            }

            catch (Exception e)
            {
                MessageBox.Show("Unable to launch steam, check if the SteamStopperService is running. The unfriendly error message is: " + e.Message);
            }
        }
Ejemplo n.º 16
0
        static void RunSteam(SteamAccount steamAccount)
        {
            try
            {
                HttpWebRequest w = WebRequest.Create("http://localhost:8088/steam/" + Environment.UserName.ToLower() + "/stop") as HttpWebRequest;

                var response = w.GetResponse();

                using (Stream s = response.GetResponseStream())
                using (StreamReader readStream = new StreamReader(s, Encoding.UTF8))
                {
                    string responsestring = readStream.ReadToEnd();
                    if (responsestring.StartsWith("steam stopped") || responsestring.ToLower() == "steam not running")
                    {
                        ProcessStartInfo info = new ProcessStartInfo();
                        info.FileName = steamAccount.SteamFolder;
                        info.CreateNoWindow = true;
                        info.UseShellExecute = false;
                        info.RedirectStandardError = true;
                        info.RedirectStandardInput = true;
                        info.RedirectStandardOutput = true;
                        var decryptedPassword = CryptoProvider.Decrypt(steamAccount.Password, steamAccount.Key);
                        info.Arguments = "-login " + steamAccount.Username + " " + decryptedPassword;
                        Process.Start(info);
                    }
                    else
                    {
                        ProcessStartInfo info = new ProcessStartInfo();
                        info.FileName = steamAccount.SteamFolder;
                        info.CreateNoWindow = true;
                        info.UseShellExecute = false;
                        info.RedirectStandardError = true;
                        info.RedirectStandardInput = true;
                        info.RedirectStandardOutput = true;
                        Process.Start(info);
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show("Unable to launch steam, check if the SteamStopperService is running. The unfriendly error message is: " + e.Message);
            }
        }
        void RegisterOnGameCode(IWebDriver driver, SteamAccount account)
        {
            logger.Info(MyOperation.GameCodeRegistration, OperationStatus.Started, new LogInfo(MyLogInfoKey.Username, account.Username));

            try
            {
                IGameCodeProcessor gameCodeProcessor = new GameCodeProcessor(driver, account);
                gameCodeProcessor.Register();
                gameCodeProcessor.LinkSteamAccount();
                gameCodeProcessor.Dispose();

                logger.Debug(MyOperation.GameCodeRegistration, OperationStatus.Success, new LogInfo(MyLogInfoKey.Username, account.Username));
            }
            catch (Exception ex)
            {
                logger.Error(MyOperation.GameCodeRegistration, OperationStatus.Failure, ex.StackTrace, ex, new LogInfo(MyLogInfoKey.Username, account.Username));
                throw;
            }
        }
Ejemplo n.º 18
0
        public static List <SteamAccount> GetSteamUsersWithMhw()
        {
            string?steamRoot = GetSteamRoot();
            List <SteamAccount> steamUsers = new List <SteamAccount>();

            if (steamRoot == null)
            {
                return(steamUsers); // Empty list
            }
            string configPath = Path.Combine(steamRoot, "config", "loginusers.vdf");

            try
            {
                // Yikes, dynamic data warning. We JavaScript now.
                // This throws an error when you enable "catch all errors" in the debugger, but this does actually work.
                string configText = File.ReadAllText(configPath);
                var    vdf        = VdfConvert.Deserialize(configText);
                foreach (dynamic user in vdf.Value)
                {
                    SteamAccount account = new SteamAccount
                    {
                        SteamId64   = long.Parse(user.Key),
                        AccountName = user.Value.AccountName.Value,
                        PersonaName = user.Value.PersonaName.Value,
                        //RememberPassword = user.Value.RememberPassword.Value == "1",
                        //MostRecent = user.Value.mostrecent.Value == "1",
                        //Timestamp = long.Parse(user.Value.Timestamp.Value)
                    };

                    // Check if user has MHW saves
                    if (GetMhwSaveDir(account) != null)
                    {
                        steamUsers.Add(account);
                    }
                }
            }
            catch (Exception ex)
            {
                CtxLog.Error(ex, ex.Message);
            }

            return(steamUsers);
        }
Ejemplo n.º 19
0
        public void EditAccount(SteamAccount account)
        {
            account.EncryptedPassword = Crypto.EncryptString(account.SecurePassword, account.Iv);
            Connection.Update(account);

            /**
             * Modify Accounts collection.
             * Reason: ObservableCollection triggers notification to the listeners only when the collection object is modified.
             * */
            foreach (var acc in Accounts)
            {
                if (acc.Id == account.Id)
                {
                    Accounts.Remove(acc);
                    Accounts.Add(account);
                    break;
                }
            }
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            Person pDominikWiesend  = new Person("Dominik", "Wiesend");
            Person pBenediktWiesend = new Person("Benedikt", "Wiesend");

            SteamAccount saDominikWiesend  = new SteamAccount("STEAM:0:05642354");
            SteamAccount saBenediktWiesend = new SteamAccount("STEAM:0:213124354");
            Player       plDominikWiesend  = new Player()
            {
                Person        = pDominikWiesend,
                SteamAccounts = new List <SteamAccount>()
                {
                    saDominikWiesend
                }
            };
            Player plBenediktWiesend = new Player()
            {
                Person        = pBenediktWiesend,
                SteamAccounts = new List <SteamAccount>()
                {
                    saBenediktWiesend
                }
            };

            // <summary>
            // Create Team #1
            // </summary>
            Team team1 = new Team();

            team1.TeamFlag = "DE";
            team1.TeamName = "DominikWiesend";
            team1.TeamTag  = "DW";
            team1.Logo     = string.Empty;
            team1.Players  = new List <Player>()
            {
                plDominikWiesend
            };

            // <summary>
            // Create Team #2
            // </summary>
            Team team2 = new Team();

            team2.TeamFlag = "DE";
            team2.TeamName = "BenediktWiesend";
            team2.TeamTag  = "BW";
            team2.Logo     = string.Empty;
            team2.Players  = new List <Player>()
            {
                plBenediktWiesend
            };

            // <summary>
            // Create a new spectators team.
            // </summary>
            Spectators spectators = new Spectators()
            {
                Players = new List <Player>()
                {
                    plDominikWiesend,
                    plBenediktWiesend
                }
            };

            // <summary>
            // Create a new Match
            // </summary>
            Match match = new Match();

            match.Team1      = team1;
            match.Team2      = team2;
            match.Spectators = spectators;
            match.MatchName  = "Dominik [vs] Benedikt";

            // <summary>
            // Save the Match to the database.
            // </summary>
            using (CSGOServerDatabase dbContext = new CSGOServerDatabase())
            {
                dbContext.Persons.Add(pDominikWiesend);
                dbContext.Persons.Add(pBenediktWiesend);
                dbContext.SteamAccounts.Add(saDominikWiesend);
                dbContext.SteamAccounts.Add(saBenediktWiesend);
                dbContext.Players.Add(plDominikWiesend);
                dbContext.Players.Add(plBenediktWiesend);
                dbContext.Spectators.Add(spectators);
                dbContext.Teams.Add(team1);
                dbContext.Teams.Add(team2);
                dbContext.Matches.Add(match);
                dbContext.SaveChanges();
            }

            // <summary>
            // Get all match config(s) from Database.
            // </summary>
            #region
            // <summary>
            // Create a new database context connection.
            // </summary>
            using (CSGOServerDatabase dbContext = new CSGOServerDatabase())
            {
                List <Match> matches = dbContext.Matches.ToList();
                foreach (Match myMatch in matches)
                {
                    string json = JsonConvert.SerializeObject(myMatch, Formatting.Indented);
                    Console.WriteLine(json);
                    Console.ReadKey();
                }
            }
            #endregion
        }
Ejemplo n.º 21
0
 public void EditAccount(SteamAccount account)
 {
     account.EncryptedPassword = Crypto.EncryptString(account.SecurePassword, account.Iv);
     Connection.Update(account);
 }
Ejemplo n.º 22
0
 public void NewAccount(SteamAccount account)
 {
     AccountList.Add(account);
     Listbox_Accounts.Items.Add(account.Name);
 }
Ejemplo n.º 23
0
        private async Task BuyItemAsync(ItemConfiguration itemConfig, List <ItemData> currentInfo)
        {
            if (currentInfo?.Count > 0)
            {
                var buyFunction = _buyModeFunctions[itemConfig.Mode];
                var itemsToBuy  = buyFunction(itemConfig, currentInfo);

                foreach (var itemToBuy in itemsToBuy)
                {
                    InventoryMonitor inventoryMonitor = null;
                    SteamAccount     altAccount       = null;
                    if (itemConfig.AltAccounts?.Count > 0)
                    {
                        altAccount = itemConfig.AltAccounts.FirstOrDefault(c =>
                        {
                            var monitor = _inventoryMonitor[c.SteamID64];
                            if ((monitor.InventorySize + itemsToBuy.Count()) < InventoryMonitor.MaxCSGOInventorySize)
                            {
                                inventoryMonitor = monitor;
                                return(true);
                            }
                            return(false);
                        });

                        if (altAccount == null)
                        {
                            WriteLog(LogType.Warning, "Skipping purchase, as no alt account with enough space was found.", false);
                            return;
                        }
                    }
                    else
                    {
                        inventoryMonitor = _inventoryMonitor[_steamID64];
                    }


                    if (inventoryMonitor.InventorySize >= InventoryMonitor.MaxCSGOInventorySize)
                    {
                        WriteLog(LogType.Warning, "Skipping purchase, as the main account has not enough space.", false);
                        return;
                    }

                    if (_marketBalance < itemToBuy.Price)
                    {
                        WriteLog(LogType.Warning, "Skipping purchase, as the balance is not sufficient.", false);
                        continue;
                    }

                    BuyItemResponse response;

                    if (altAccount == null)
                    {
                        response = await _service.BuyItemAsync(itemToBuy.ID, itemToBuy.Price);
                    }
                    else
                    {
                        response = await _service.BuyItemForAsync(itemToBuy.ID, itemToBuy.Price, altAccount.SteamID32, altAccount.Token);
                    }

                    if (response?.IsSuccessfully ?? false)
                    {
                        string quantityLeftString = "";
                        if (itemConfig?.MaxQuantity > 0)
                        {
                            itemConfig.MaxQuantity = itemConfig.MaxQuantity - 1;
                            quantityLeftString     = ". (" + itemConfig.MaxQuantity + " left)";
                            if (itemConfig.MaxQuantity == 0)
                            {
                                itemConfig.IsActive = false;
                            }

                            // Update new Quantity/IsActive settings to config file
                            ConfigService.Instance.SaveConfig();
                        }

                        inventoryMonitor.InventorySize++;
                        WriteLog(LogType.Information, "Bought '" + itemConfig.HashName + "' at " + (response?.Price ?? 0) + " " + _service.Currency + quantityLeftString, false);
                    }
                }
            }
        }
Ejemplo n.º 24
0
 public void RemoveAccount(SteamAccount account)
 {
     Connection.Delete(account);
     Accounts.Remove(account);
 }
Ejemplo n.º 25
0
 public void AddAccount(SteamAccount account)
 {
     account.EncryptedPassword = Crypto.EncryptString(account.SecurePassword, account.Iv);
     Connection.Insert(account);
     Accounts.Add(account);
 }
Ejemplo n.º 26
0
        private void AttemptLogin()
        {
            if(_account == null)
                _account = _loginProvider.GetAccount();

            if (_loginAttemps++ > MaxLoginAttemps)
            {
                Abort();
                return;
            }

            _user.LogOn((SteamUser.LogOnDetails)_account);
        }