/// <summary> /// Method to get the encrypted Password after RSA encryption. /// </summary> /// <param name="input">The RSA object out of the JSON response.</param> /// <returns>The encrypted password.</returns> private string getEncryptedBase64Password(GetRsaKey input) { //RSA Encryption RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); RSAParameters rsaParameters = new RSAParameters(); rsaParameters.Exponent = HexToByte(input.publickey_exp); rsaParameters.Modulus = HexToByte(input.publickey_mod); rsa.ImportParameters(rsaParameters); byte[] bytePassword = Encoding.ASCII.GetBytes(this.password); byte[] encodedPassword = rsa.Encrypt(bytePassword, false); string encryptedBase64Password = Convert.ToBase64String(encodedPassword); return(encryptedBase64Password); }
//Login methods /// <summary> /// Method to start the login without gmail email handler. /// </summary> /// <param name="username">Username of your steam account.</param> /// <param name="password">Password of your steam account.</param> public void doLogin(string username, string password) { this.username = username; this.password = password; this.getOpenidLogin(); GetRsaKey temp = this.getRSAKey(); this.loginDoLogin(temp, ""); temp = this.getRSAKey(); string steamGuardText = ""; Console.WriteLine("Type Steam Guard: "); steamGuardText = Uri.EscapeDataString(Console.ReadLine()); this.setSteamCredentials(JsonConvert.DeserializeObject <DoLoginRootObject>( this.getResponseMessage(this.loginDoLogin(temp, steamGuardText)))); this.postTransfer(); this.getCookiesOnD2L(this.postOpenIDLogin2(this.postOpenIDLogin())); }
/// <summary> /// Do the login with the RSA encrypted password. /// </summary> /// <param name="inputResponse">This is the JSON-Deserialized Object out of the RSA Response of Steam. /// In this object is the RSA key to encrypt the password.</param> /// <param name="guardText">This is an parameter if steam guard is activated, steam will send a key /// to your Email to check and paste in.</param> /// <returns>THis request returns a response which will be parsed, if the login was correct.</returns> private HttpWebResponse loginDoLogin(GetRsaKey inputResponse, string guardText) { var data = new NameValueCollection(); data.Add("remember_login", "false"); data.Add("captchagid", "-1"); data.Add("password", this.getEncryptedBase64Password(inputResponse)); data.Add("twofactorcode", ""); data.Add("captcha_text", ""); data.Add("username", this.username); if (inputResponse.timestamp != null) { data.Add("rsatimestamp", inputResponse.timestamp.ToString()); } else { data.Add("rsatimestamp", ""); } if (guardText == "") { data.Add("emailauth", ""); data.Add("emailsteamid", ""); data.Add("loginfriendlyname", ""); } else { data.Add("emailauth", guardText); data.Add("emailsteamid", inputResponse.steamid); data.Add("loginfriendlyname", guardText + "a"); } string referer = "https://steamcommunity.com/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=https%3A%2F%2Fdota2lounge.com%2Flogin&openid.realm=https%3A%2F%2Fdota2lounge.com&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select"; string url = "https://steamcommunity.com/login/dologin/"; string host = "steamcommunity.com"; string accept = "text/javascript, text/html, application/xml, text/xml, */*"; HttpWebResponse response = this.request(url, "POST", referer, host, accept, data, "XMLHttpRequest", "1.7", "", "", false); this.updateCookieContainer(response); return(response); }
/// <summary> /// Method to start the login with gmail email handler. /// This method will only work if your steam account is registered with an gmail /// account. If you have another Email provider, then use: /// doLogin(string username, string password); /// </summary> /// <param name="username">Username of your steam account.</param> /// <param name="password">Password of your steam account.</param> /// <param name="emailAddress">Email address of your gmail account.</param> /// <param name="emailPassword">Password of your gmail account.</param> public void doLogin(string username, string password, string emailAddress, string emailPassword) { this.username = username; this.password = password; this.getOpenidLogin(); GetRsaKey temp = this.getRSAKey(); this.loginDoLogin(temp, ""); temp = this.getRSAKey(); string steamGuardText = ""; EMailHandler e = new EMailHandler(emailAddress, emailPassword); steamGuardText = e.getGuardText(); System.Threading.Thread.Sleep(2500); this.setSteamCredentials(JsonConvert.DeserializeObject <DoLoginRootObject>( this.getResponseMessage(this.loginDoLogin(temp, steamGuardText)))); this.postTransfer(); this.getCookiesOnD2L(this.postOpenIDLogin2(this.postOpenIDLogin())); }