public Steam3Session(SteamUser.LogOnDetails details) { this.logonDetails = details; this.authenticatedUser = details.Username != null; this.credentials = new Credentials(); this.bConnected = false; this.bConnecting = false; this.bAborted = false; this.bExpectingDisconnectRemote = false; this.bDidDisconnect = false; this.bDidReceiveLoginKey = false; this.seq = 0; this.AppTickets = new Dictionary <uint, byte[]>(); this.AppTokens = new Dictionary <uint, ulong>(); this.DepotKeys = new Dictionary <uint, byte[]>(); this.CDNAuthTokens = new ConcurrentDictionary <string, SteamApps.CDNAuthTokenCallback>(); this.AppInfo = new Dictionary <uint, SteamApps.PICSProductInfoCallback.PICSProductInfo>(); this.PackageInfo = new Dictionary <uint, SteamApps.PICSProductInfoCallback.PICSProductInfo>(); this.AppBetaPasswords = new Dictionary <string, byte[]>(); this.steamClient = new SteamClient(); this.steamUser = this.steamClient.GetHandler <SteamUser>(); this.steamApps = this.steamClient.GetHandler <SteamApps>(); var steamUnifiedMessages = this.steamClient.GetHandler <SteamUnifiedMessages>(); this.steamPublishedFile = steamUnifiedMessages.CreateService <IPublishedFile>(); this.callbacks = new CallbackManager(this.steamClient); this.callbacks.Subscribe <SteamClient.ConnectedCallback>(ConnectedCallback); this.callbacks.Subscribe <SteamClient.DisconnectedCallback>(DisconnectedCallback); this.callbacks.Subscribe <SteamUser.LoggedOnCallback>(LogOnCallback); this.callbacks.Subscribe <SteamUser.SessionTokenCallback>(SessionTokenCallback); this.callbacks.Subscribe <SteamApps.LicenseListCallback>(LicenseListCallback); this.callbacks.Subscribe <SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback); this.callbacks.Subscribe <SteamUser.LoginKeyCallback>(LoginKeyCallback); Console.Write("Connecting to Steam3..."); if (authenticatedUser) { FileInfo fi = new FileInfo(String.Format("{0}.sentryFile", logonDetails.Username)); if (AccountSettingsStore.Instance.SentryData != null && AccountSettingsStore.Instance.SentryData.ContainsKey(logonDetails.Username)) { logonDetails.SentryFileHash = Util.SHAHash(AccountSettingsStore.Instance.SentryData[logonDetails.Username]); } else if (fi.Exists && fi.Length > 0) { var sentryData = File.ReadAllBytes(fi.FullName); logonDetails.SentryFileHash = Util.SHAHash(sentryData); AccountSettingsStore.Instance.SentryData[logonDetails.Username] = sentryData; AccountSettingsStore.Save(); } } Connect(); }
private void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth) { byte[] hash = Util.SHAHash(machineAuth.Data); Console.WriteLine("Got Machine Auth: {0} {1} {2} {3}", machineAuth.FileName, machineAuth.Offset, machineAuth.BytesToWrite, machineAuth.Data.Length, hash); AccountSettingsStore.Instance.SentryData[logonDetails.Username] = machineAuth.Data; AccountSettingsStore.Save(); var authResponse = new SteamUser.MachineAuthDetails { BytesWritten = machineAuth.BytesToWrite, FileName = machineAuth.FileName, FileSize = machineAuth.BytesToWrite, Offset = machineAuth.Offset, SentryFileHash = hash, // should be the sha1 hash of the sentry file we just wrote OneTimePassword = machineAuth.OneTimePassword, // not sure on this one yet, since we've had no examples of steam using OTPs LastError = 0, // result from win32 GetLastError Result = EResult.OK, // if everything went okay, otherwise ~who knows~ JobID = machineAuth.JobID, // so we respond to the correct server job }; // send off our response steamUser.SendMachineAuthResponse(authResponse); }
private void LoginKeyCallback(SteamUser.LoginKeyCallback loginKey) { Console.WriteLine("Accepted new login key for account {0}", logonDetails.Username); AccountSettingsStore.Instance.LoginKeys[logonDetails.Username] = loginKey.LoginKey; AccountSettingsStore.Save(); steamUser.AcceptNewLoginKey(loginKey); bDidReceiveLoginKey = true; }
private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn) { bool isSteamGuard = loggedOn.Result == EResult.AccountLogonDenied; bool is2FA = loggedOn.Result == EResult.AccountLoginDeniedNeedTwoFactor; bool isLoginKey = DepotDumper.Config.RememberPassword && logonDetails.LoginKey != null && loggedOn.Result == EResult.InvalidPassword; if (isSteamGuard || is2FA || isLoginKey) { bExpectingDisconnectRemote = true; Abort(false); if (!isLoginKey) { Console.WriteLine("This account is protected by Steam Guard."); } if (is2FA) { Console.Write("Please enter your 2 factor auth code from your authenticator app: "); logonDetails.TwoFactorCode = Console.ReadLine(); } else if (isLoginKey) { AccountSettingsStore.Instance.LoginKeys.Remove(logonDetails.Username); AccountSettingsStore.Save(); logonDetails.LoginKey = null; if (DepotDumper.Config.SuppliedPassword != null) { Console.WriteLine("Login key was expired. Connecting with supplied password."); logonDetails.Password = DepotDumper.Config.SuppliedPassword; } else { Console.WriteLine("Login key was expired. Please enter your password: "******"Please enter the authentication code sent to your email address: "); logonDetails.AuthCode = Console.ReadLine(); } Console.Write("Retrying Steam3 connection..."); Connect(); return; } else if (loggedOn.Result == EResult.ServiceUnavailable) { Console.WriteLine("Unable to login to Steam3: {0}", loggedOn.Result); Abort(false); return; } else if (loggedOn.Result != EResult.OK) { Console.WriteLine("Unable to login to Steam3: {0}", loggedOn.Result); Abort(); return; } Console.WriteLine(" Done!"); this.seq++; credentials.LoggedOn = true; }