void OnUpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth) { byte[] hash = SHAHash (machineAuth.Data); Directory.CreateDirectory(Path.Combine(Application.StartupPath, "sentryfiles")); File.WriteAllBytes (Path.Combine("sentryfiles", String.Format("{0}.sentryfile", logOnDetails.Username)), machineAuth.Data); 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); }
public virtual void OnMachineAuth(SteamUser.UpdateMachineAuthCallback e) { VersatileIO.Debug("Updating sentry file..."); int fileSize; byte[] sentryHash; using (FileStream fs = File.Open(SentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { fs.Seek(e.Offset, SeekOrigin.Begin); fs.Write(e.Data, 0, e.BytesToWrite); fileSize = (int)fs.Length; fs.Seek(0, SeekOrigin.Begin); using (SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider()) { sentryHash = sha.ComputeHash(fs); } } SteamUser.MachineAuthDetails details = new SteamUser.MachineAuthDetails(); details.JobID = e.JobID; details.FileName = e.FileName; details.BytesWritten = e.BytesToWrite; details.FileSize = fileSize; details.Offset = e.Offset; details.Result = EResult.OK; details.LastError = 0; details.OneTimePassword = e.OneTimePassword; details.SentryFileHash = sentryHash; User.SendMachineAuthResponse(details); VersatileIO.Success("Machine Authentication Complete!"); }
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); ConfigStore.TheConfig.SentryData[logonDetails.Username] = machineAuth.Data; ConfigStore.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 ); }
void OnUpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth, JobID jobId) { byte[] hash = SHAHash (machineAuth.Data); StringBuilder sb = new StringBuilder(); for (int count = 0; count < hash.Length; count++) { sb.Append(hash[count]); } MachineAuthData = sb.ToString(); Directory.CreateDirectory(Application.StartupPath + "/sentryfiles/"); File.WriteAllBytes (String.Format ("{0}/sentryfiles/{1}.sentryfile", Application.StartupPath, logOnDetails.Username), machineAuth.Data); 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 = jobId, // so we respond to the correct server job }; // send off our response SteamUser.SendMachineAuthResponse (authResponse); }