DepotDownloader: Cache Sentry File and send SentryFileHash with logondetails so we don't have to do SteamGuard auth every time

pull/8/head
Michael Busby 14 years ago
parent d7a8d9fe0a
commit 90b9051de3

@ -5,6 +5,7 @@ using System.Text;
using SteamKit2;
using System.Threading;
using System.Collections.ObjectModel;
using System.IO;
namespace DepotDownloader
{
@ -77,9 +78,16 @@ namespace DepotDownloader
this.callbacks.Register(new Callback<SteamUser.LoggedOnCallback>(LogOnCallback));
this.callbacks.Register(new Callback<SteamUser.SessionTokenCallback>(SessionTokenCallback));
this.callbacks.Register(new Callback<SteamApps.LicenseListCallback>(LicenseListCallback));
this.callbacks.Register(new JobCallback<SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback));
Console.Write( "Connecting to Steam3..." );
FileInfo fi = new FileInfo(String.Format("{0}.sentryFile", logonDetails.Username));
if(fi.Exists && fi.Length > 0)
{
logonDetails.SentryFileHash = Util.SHAHash(File.ReadAllBytes(fi.FullName));
}
Connect();
}
@ -285,5 +293,34 @@ namespace DepotDownloader
Licenses = licenseList.LicenseList;
}
private void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth, ulong jobId)
{
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);
File.WriteAllBytes( 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 = jobId, // so we respond to the correct server job
};
// send off our response
steamUser.SendMachineAuthResponse( authResponse );
}
}
}

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using Classless.Hasher;
namespace DepotDownloader
@ -158,5 +159,16 @@ namespace DepotDownloader
}
return BitConverter.GetBytes(a | (b << 16));
}
public static byte[] SHAHash( byte[] input )
{
SHA1Managed sha = new SHA1Managed();
byte[] output = sha.ComputeHash( input );
sha.Clear();
return output;
}
}
}

Loading…
Cancel
Save