public Constants.SignInStatus Authenticate(string encpass, string captxt, string emailstm, Gator2.Gator2Main gtmain) { if (status != Constants.SignInStatus.Authenticating) { gt = gtmain; transurl = string.Empty; webcookie = string.Empty; token = string.Empty; emailauth = emailstm; captchatxt = captxt; authdone.Reset(); encpwd = encpass; status = Constants.SignInStatus.Authenticating; Thread thAuth; ThreadStart thAuthStart; thAuthStart = new ThreadStart(AuthProc); thAuth = new Thread(thAuthStart); thAuth.IsBackground = true; thAuth.Start(); authdone.WaitOne(Timeout.Infinite); } else { //another auth in progress } return(status); }
public SteamAuth( ) { status = Constants.SignInStatus.LoggedOff; transurl = string.Empty; webcookie = string.Empty; captchaurl = string.Empty;//"https://steamcommunity.com/public/captcha.php?gid="; token = string.Empty; encpwd = string.Empty; kmod = string.Empty; kexp = string.Empty; krsatime = string.Empty; captchaid = string.Empty; captchatxt = string.Empty; emailcode = string.Empty; emailauth = string.Empty; emailsteamid = string.Empty; sessionid = string.Empty;; cookie = string.Empty;; steamid = string.Empty;; steamlogin = string.Empty;; uname = string.Empty;; pwd = string.Empty;; authdone = new ManualResetEvent(false); }
private void AuthProc() { gt.lblLoginStatus.Text = "AUTHENTICATING"; gt.lblLoginStatus.Refresh(); NameValueCollection formData = new NameValueCollection(); formData.Clear(); formData["username"] = uname; formData["password"] = encpwd; formData["emailauth"] = emailauth; formData["captchagid"] = captchaid; formData["captcha_text"] = captchatxt; formData["emailsteamid"] = emailsteamid; formData["rsatimestamp"] = krsatime; MyWeb.MyWeb web = new MyWeb.MyWeb(); string resp = string.Empty; while ((resp == string.Empty) || (resp.Contains("Error 503 Service Unavailable")) || (resp.Contains("The Steam Community is currently unavailable"))) { resp = web.PostPage("https://steamcommunity.com/login/dologin/", formData, 0, 0, ref cookie); if ((resp == string.Empty) || (resp.Contains("Error 503 Service Unavailable")) || (resp.Contains("The Steam Community is currently unavailable"))) { System.Threading.Thread.Sleep(3000); } } ; string sessid = GetSessionID(resp); if (sessid != string.Empty) { sessionid = sessid; } if (sessionid != string.Empty) { cookie = "sessionid=" + sessionid + ";"; } //sessionid=NTY4MjAzNjI3; Steam_Language=english; timezoneOffset=19800,0; steamLogin=76561198060247951%7C%7CB758FED3E08631A1A8468DCD27508C49E0CA4EBD MyUtils.MyUtils utils = new MyUtils.MyUtils(); if (resp.Contains("\"message\":\"Incorrect login\"")) { status = Constants.SignInStatus.Failed; } if (resp.Contains("login_complete\":true")) { //{"success":true,"login_complete":true,"transfer_url":"https:\/\/store.steampowered.com\/\/login\/transfer","transfer_parameters":{"steamid":"76561198060247951","token":"4A932916A0F2FC5D1E14EC141545E5758153BFD6"}} /////// // Cache-Control: no-cache //Pragma: no-cache //Set-Cookie: steamLogin=76561198060247951%7C%7CB758FED3E08631A1A8468DCD27508C49E0CA4EBD; path=/ //Set-Cookie: steamMachineAuth76561198060247951=DB9DA53AC036A06AC4D80E5409DADB21088D3991; expires=Fri, 15-Jul-2022 18:12:35 GMT; path=/; secure; httponly //Content-Length: 267 //Connection: close //Content-Type: application/json; charset=utf-8 //{"success":true,"login_complete":true,"transfer_url":"https:\/\/store.steampowered.com\/\/login\/transfer","transfer_parameters":{"steamid":"76561198060247951","token":"B758FED3E08631A1A8468DCD27508C49E0CA4EBD","webcookie":"DB9DA53AC036A06AC4D80E5409DADB21088D3991"}} // //////// transurl = utils.GetStrBetween(resp, "\"transfer_url\":\"", "\""); transurl = transurl.Replace("\\", string.Empty); steamid = utils.GetStrBetween(resp, "steamid\":\"", "\""); token = utils.GetStrBetween(resp, "token\":\"", "\""); webcookie = utils.GetStrBetween(resp, "webcookie\":\"", "\""); steamlogin = steamid + "%7C%7c" + token; //string tmpckie = string.Empty; if (sessionid == string.Empty) { //web.GetWebPage("http://steamcommunity.com/profiles/" + steamid + "/?xml=1", 3, 5000, ref tmpckie); resp = web.GetWebPage("http://steamcommunity.com/profiles/" + steamid + "/?xml=1", 3, 5000); sessid = string.Empty; sessid = GetSessionID(resp); if (sessid != string.Empty) { sessionid = sessid; } //int beg, end; //beg = end = -1; //if ((tmpckie != string.Empty) && (tmpckie != null)) // { // beg = tmpckie.IndexOf("sessionid="); // if (beg != -1) // { // beg += 10; // end = tmpckie.IndexOfAny(new char[] { ';', ',' }, beg); // if (end == -1) // sessionid = tmpckie.Substring(beg); // else // sessionid = tmpckie.Substring(beg, end - beg); // } // } } if (transurl != string.Empty) { if (sessionid == string.Empty) { TransferLogin(); } } if ((steamlogin != string.Empty) && (sessionid != string.Empty)) { cookie = "sessionid=" + sessionid + ";steamLogin="******"captcha_needed\":true")) { //{"success":false,"captcha_needed":false,"captcha_gid":-1,"message":"Incorrect login."} //{"success":false,"captcha_needed":true,"captcha_gid":"1317542928092269974","message":"Incorrect login."} captchaid = utils.GetStrBetween(resp, "captcha_gid\":\"", "\""); captchaurl = "https://steamcommunity.com/public/captcha.php?gid=" + captchaid; status = Constants.SignInStatus.CaptchaReqd; } //{"success":false,"message":"SteamGuard","emailauth_needed":true,"emaildomain":"yahoo.com","emailsteamid":"76561198060247951"} if (resp.Contains("emailauth_needed\":true")) { emailsteamid = utils.GetStrBetween(resp, "emailsteamid\":\"", "\""); status = Constants.SignInStatus.SGuardReqd; } authdone.Set(); }