private static void Main() { Console.Title = "Exchange Bot by sne4kyFox"; Console.WriteLine("Welcome to the exchange bot!"); Console.WriteLine( "By using this software you agree to the terms in \"license.txt\"."); _config = ConfigHandler.Reload(_config); ConfigErrorResult errors = _config.CheckForErrors(); if (!errors.Valid) { Console.WriteLine(errors.ErrorMessage); Console.ReadLine(); Environment.Exit(-1); } Console.WriteLine("Attempting web login..."); _account = Web.RetryDoLogin(TimeSpan.FromSeconds(5), 10, _config.Username, _config.Password, _config.SteamMachineAuth); if (!string.IsNullOrEmpty(_account.SteamMachineAuth)) { _config.SteamMachineAuth = _account.SteamMachineAuth; ConfigHandler.WriteChanges(_config); } Console.WriteLine("Login was successful!"); PollOffers(); }
private static void Main() { Console.Title = "Confirmer by sne4kyFox"; Console.WriteLine("This program will accept any and ALL mobile auth confirmations, use with extreme caution."); Console.WriteLine( "By using this software you agree to the terms in \"license.txt\"."); _config = ConfigHandler.Reload(_config); Console.WriteLine("Attempting web login..."); _account = Web.RetryDoLogin(TimeSpan.FromSeconds(5), 10, _config.Username, _config.Password, _config.SteamMachineAuth); if (!string.IsNullOrEmpty(_account.SteamMachineAuth)) { _config.SteamMachineAuth = _account.SteamMachineAuth; ConfigHandler.WriteChanges(_config); } Console.WriteLine("Login was successful!"); while (!File.Exists("account.maFile")) SteamAuthLogin(); var sgAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText("account.maFile")); AcceptConfirmationsLoop(sgAccount); }
public FriendsListWindow(Account account, string apiKey) { _account = account; #region activate apis ChatHandler = new SteamChatHandler(_account); SteamUserHandler = new SteamUserHandler(apiKey); #endregion InitializeComponent(); }
/// <summary> /// Creates a new SteamChatHandler. Generates a random jQueryId to use. /// </summary> /// <param name="account">Account object of the account to use.</param> public SteamChatHandler(Account account) { _account = account; var rand = new Random(); var jQueryId = (long)(((rand.NextDouble() * 2.0 - 1.0) * long.MaxValue) % 99999999999); //might be able to be larger, haven't checked if (jQueryId < 0) jQueryId = -jQueryId; _basejQuery = "jQuery" + jQueryId + _account.SteamId + "_{0}"; _auth = Logon(); }
//login static void Login() { Console.WriteLine("Attempting web login..."); _account = Web.RetryDoLogin(TimeSpan.FromSeconds(5), 10, _config.Username, _config.Password, _config.SteamMachineAuth); if (!string.IsNullOrEmpty(_account.SteamMachineAuth)) { _config.SteamMachineAuth = _account.SteamMachineAuth; ConfigHandler.WriteChanges(_config); } Console.WriteLine("Login was successful!"); }
/// <summary> /// Creates a new SteamChatHandler. Generates a random jQueryId to use. /// </summary> /// <param name="account">Account object of the account to use.</param> public SteamChatHandler(Account account) { _account = account; //sloppy way to do it, but couldn't get Regex to love me _accessToken = GetAccessToken(); var rand = new Random(); var jQueryId = (long)(((rand.NextDouble() * 2.0 - 1.0) * long.MaxValue) % 99999999999); //might be able to be larger, haven't checked if (jQueryId < 0) jQueryId = -jQueryId; _basejQuery = "jQuery" + jQueryId + _account.SteamId + "_{0}"; _auth = Logon(); }
private static void Main() { Console.Title = "Donation Bot by sne4kyFox"; Console.WriteLine("Welcome to the donation bot!"); Console.WriteLine( "By using this software you agree to the terms in \"license.txt\"."); _config = ConfigHandler.Reload(_config); if (string.IsNullOrEmpty(_config.ApiKey)) { Console.WriteLine("Fatal error: API key is missing. Please fill in the API key field in \"configuration.xml\""); Console.ReadLine(); Environment.Exit(-1); } _apiKey = _config.ApiKey; if (string.IsNullOrEmpty(_config.Username) || string.IsNullOrEmpty(_config.Password)) { Console.WriteLine("Please input your username and password."); Console.Write("Username: "******"Password: "******"Attempting web login..."); _account = Web.RetryDoLogin(TimeSpan.FromSeconds(5), 10, _user, _pass, _config.SteamMachineAuth); if (!string.IsNullOrEmpty(_account.SteamMachineAuth)) { _config.SteamMachineAuth = _account.SteamMachineAuth; ConfigHandler.WriteChanges(_config); } Console.WriteLine("Login was successful!"); PollOffers(); }
/// <summary> /// Creates a new SteamChatHandler. Generates a random jQueryId to use. /// </summary> /// <param name="account">Account object of the account to use.</param> public SteamChatHandler(Account account) { _account = account; //sloppy way to do it, but couldn't get Regex to love me _accessToken = GetAccessToken(); if (string.IsNullOrEmpty(_accessToken)) { throw new ChatException( "Error fetching access token, the account specified is not authorized to use this feature."); } var rand = new Random(); var jQueryId = (long) (((rand.NextDouble()*2.0 - 1.0)*long.MaxValue)%9999999999999999999); jQueryId = Math.Abs(jQueryId); _basejQuery = "jQuery" + jQueryId + "_{0}"; _auth = Logon(); }
/// <summary> /// Sets the privacy settings of the account. /// </summary> /// <param name="settings">Settings to set.</param> /// <param name="account">Account of settings to change.</param> public void SetPrivacySettings(PrivacySettings settings, Account account) //implement settings as an interface later! { string url = "https://steamcommunity.com/profiles/" + account.SteamId + "/edit/settings"; string sessionid = (from Cookie cookie in _account.AuthContainer.GetCookies(new Uri("https://steamcommunity.com")) where cookie.Name == "sessionid" select cookie.Value).FirstOrDefault(); var data = new Dictionary<string, string> { {"sessionID", sessionid}, {"type", PrivacySettings.Type}, {"privacySetting", ((int) settings.PrivacySetting).ToString()}, {"commentSetting", PrivacySettings.EPrivacySettingToCommentSetting(settings.CommentSetting)}, {"inventoryPrivacySetting", ((int) settings.InventoryPrivacySetting).ToString()}, {"inventoryGiftPrivacy", settings.InventoryGiftPrivacy.IntValue().ToString()}, {"tradeConfirmationSetting", settings.TradeConfirmationSetting.IntValue().ToString()}, {"marketConfirmationSetting", settings.MarketConfirmationSetting.IntValue().ToString()} }; _web.Fetch(url, "POST", data, _account.AuthContainer); }
/// <summary> /// Sets the user's public profile settings to the exact settings specified in /// the Profile object. /// </summary> /// <param name="profile">The object to specify the new profile data.</param> /// <param name="account">The account of the profile to modify.</param> /// <returns>Bool depending on the success of the request.</returns> public bool SetProfile(Profile profile, Account account) //implement Settings as an interface! { string url = "https://steamcommunity.com/profiles/" + account.SteamId + "/edit"; string sessionid = (from Cookie cookie in _account.AuthContainer.GetCookies(new Uri("https://steamcommunity.com")) where cookie.Name == "sessionid" select cookie.Value).FirstOrDefault(); var data = new Dictionary<string, string> { {"sessionID", sessionid}, {"type", Profile.Type}, {"weblink_1_title", profile.Weblink1Title}, {"weblink_1_url", profile.Weblink1Url}, {"weblink_2_title", profile.Weblink2Title}, {"weblink_2_url", profile.Weblink2Url}, {"weblink_3_title", profile.Weblink3Title}, {"weblink_3_url", profile.Weblink3Url}, {"personaName", profile.PersonaName}, {"real_name", profile.RealName}, {"country", profile.Country}, {"state", profile.State}, {"city", profile.City}, {"customURL", profile.CustomUrl}, {"summary", profile.Summary}, {"favorite_badge_badgeid", profile.FavoriteBadgeBadgeId.ToString()}, {"favorite_badge_communityitemid", profile.FavoriteBadgeCommunityItemId.ToString()}, {"primary_group_steamid", profile.PrimaryGroupSteamId.ToString()} }; string response = _web.Fetch(url, "POST", data, _account.AuthContainer).ReadStream(); return response.Contains("<div class=\"saved_changes_msg\">"); }
public CommunityHandler(Account account) { _account = account; }
/// <summary> /// Executes the web login using the Steam website. /// </summary> /// <param name="username">Username to use</param> /// <param name="password">Password to use</param> /// <param name="machineAuth">Steam machine auth string. /// You should save Web.SteamMachineAuth after the code has been entered and the request has /// been successful and pass it to DoLogin in future attempts to login. /// This field can be left blank, but if the account is SteamGuard protected /// it will ask you for a new code every time.</param> /// <returns>An Account object to that contains the SteamId and AuthContainer.</returns> public Account DoLogin(string username, string password, string machineAuth = "") { Thread.Sleep(2000); var rsaHelper = new RsaHelper(password); var loginDetails = new Dictionary<string, string> {{"username", username}}; IResponse response = Fetch("https://steamcommunity.com/login/getrsakey", "POST", loginDetails); string encryptedBase64Password = rsaHelper.EncryptPassword(response); if (encryptedBase64Password == null) return null; LoginResult loginJson = null; CookieCollection cookieCollection; string steamGuardText = string.Empty; string steamGuardId = string.Empty; string twoFactorText = string.Empty; do { bool captcha = loginJson != null && loginJson.CaptchaNeeded; bool steamGuard = loginJson != null && loginJson.EmailAuthNeeded; bool twoFactor = loginJson != null && loginJson.RequiresTwofactor; var time = Uri.EscapeDataString(rsaHelper.RsaJson.TimeStamp); var capGid = "-1"; if (loginJson != null && loginJson.CaptchaNeeded) capGid = Uri.EscapeDataString(loginJson.CaptchaGid); var data = new Dictionary<string, string> { {"password", encryptedBase64Password}, {"username", username}, {"loginfriendlyname", string.Empty}, {"rememberlogin", "false"} }; // Captcha string capText = string.Empty; if (captcha) { Process.Start("https://steamcommunity.com/public/captcha.php?gid=" + loginJson.CaptchaGid); Console.WriteLine( "Please note, if you enter in your captcha correctly and it still opens up new captchas, double check your username and password."); Console.Write("Please enter the numbers/letters from the picture that opened up: "); capText = Console.ReadLine(); } data.Add("captchagid", captcha ? capGid : string.Empty); data.Add("captcha_text", captcha ? capText : string.Empty); // Captcha end // SteamGuard if (steamGuard) { Console.Write("SteamGuard code required: "); steamGuardText = Console.ReadLine(); steamGuardId = loginJson.EmailSteamId; } data.Add("emailauth", steamGuardText); data.Add("emailsteamid", steamGuardId); // SteamGuard end //TwoFactor if (twoFactor && !loginJson.Success) { Console.Write("TwoFactor code required: "); twoFactorText = Console.ReadLine(); } data.Add("twofactorcode", twoFactor ? twoFactorText : string.Empty); data.Add("rsatimestamp", time); CookieContainer cc = null; if (!string.IsNullOrEmpty(machineAuth)) { SteamMachineAuth = machineAuth; cc = new CookieContainer(); var split = machineAuth.Split('='); var machineCookie = new Cookie(split[0], split[1]); cc.Add(new Uri("https://steamcommunity.com/login/dologin/"), machineCookie); } using (IResponse webResponse = Fetch("https://steamcommunity.com/login/dologin/", "POST", data, cc)) { //var steamStream = webResponse.GetResponseStream(); string json = webResponse.ReadStream(); loginJson = JsonConvert.DeserializeObject<LoginResult>(json); cookieCollection = webResponse.Cookies; } } while (loginJson.CaptchaNeeded || loginJson.EmailAuthNeeded || (loginJson.RequiresTwofactor && !loginJson.Success)); Account account; if (loginJson.EmailSteamId != null) account = new Account(Convert.ToUInt64(loginJson.EmailSteamId)); else if (loginJson.TransferParameters?.Steamid != null) account = new Account(Convert.ToUInt64(loginJson.TransferParameters.Steamid)); else return null; if (loginJson.Success) { _cookies = new CookieContainer(); foreach (Cookie cookie in cookieCollection) { _cookies.Add(cookie); switch (cookie.Name) { case "steamLogin": account.AuthContainer.Add(cookie); SteamLogin = cookie.Value; break; case "steamLoginSecure": account.AuthContainer.Add(cookie); SteamLoginSecure = cookie.Value; break; case "timezoneOffset": account.AuthContainer.Add(cookie); TimezoneOffset = cookie.Value; break; } if (!cookie.Name.StartsWith("steamMachineAuth")) continue; SteamMachineAuth = cookie.Name + "=" + cookie.Value; } if (!string.IsNullOrEmpty(SteamMachineAuth)) account.AddMachineAuthCookies(SteamMachineAuth); SubmitCookies(_cookies); account.AuthContainer.Add(_cookies.GetCookies(new Uri("https://steamcommunity.com"))["sessionid"]); SessionId = _cookies.GetCookies(new Uri("https://steamcommunity.com"))["sessionid"]?.Value; return account; } Console.WriteLine("SteamWeb Error: " + loginJson.Message); return null; }