From 6c715c821490d1d69f58d10fa0723e3cd39a7246 Mon Sep 17 00:00:00 2001 From: oureveryday Date: Tue, 26 Jul 2022 20:30:11 +0800 Subject: [PATCH] Update Custom Machine Auth --- DepotDownloaderMod/ContentDownloader.cs | 28 +++++++++++++++++-- DepotDownloaderMod/Program.cs | 8 +++++- .../Properties/launchSettings.json | 7 +++++ DepotDownloaderMod/Steam3Session.cs | 23 ++++++--------- 4 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 DepotDownloaderMod/Properties/launchSettings.json diff --git a/DepotDownloaderMod/ContentDownloader.cs b/DepotDownloaderMod/ContentDownloader.cs index 9bb84a035..c5de9c21d 100644 --- a/DepotDownloaderMod/ContentDownloader.cs +++ b/DepotDownloaderMod/ContentDownloader.cs @@ -362,16 +362,40 @@ public static bool InitializeSteam3(string username, string password) _ = AccountSettingsStore.Instance.LoginKeys.TryGetValue(username, out loginKey); } - steam3 = new Steam3Session( + + if (TokenCFG.useMachineAuth) + { + var sentryFileHash = CryptoHelper.SHAHash(File.ReadAllBytes(TokenCFG.MachineAuth)); + var machineAuthFileName = Path.GetFileName(TokenCFG.MachineAuth); + Console.WriteLine("Using Machine Auth: {0}", machineAuthFileName); + steam3 = new Steam3Session( new SteamUser.LogOnDetails { + SentryFileHash = sentryFileHash, Username = username, Password = loginKey == null ? password : null, ShouldRememberPassword = Config.RememberPassword, LoginKey = loginKey, LoginID = Config.LoginID ?? 0x534B32, // "SK2" } - ); + ); + } + else + { + steam3 = new Steam3Session( + new SteamUser.LogOnDetails + { + Username = username, + Password = loginKey == null ? password : null, + ShouldRememberPassword = Config.RememberPassword, + LoginKey = loginKey, + LoginID = Config.LoginID ?? 0x534B32, // "SK2" + } + ); + } + + + steam3Credentials = steam3.WaitForCredentials(); diff --git a/DepotDownloaderMod/Program.cs b/DepotDownloaderMod/Program.cs index c08a22b73..a36343432 100644 --- a/DepotDownloaderMod/Program.cs +++ b/DepotDownloaderMod/Program.cs @@ -16,12 +16,14 @@ static class TokenCFG { public static bool useAppToken; public static bool usePackageToken; + public static bool useMachineAuth; public static ulong appToken; public static ulong packageToken; + public static string MachineAuth; } class Program { - + static int Main(string[] args) => MainAsync(args).GetAwaiter().GetResult(); @@ -60,6 +62,9 @@ static async Task MainAsync(string[] args) TokenCFG.usePackageToken = HasParameter(args, "-packagetoken"); TokenCFG.appToken = Convert.ToUInt64(GetParameter(args, "-apptoken")); TokenCFG.packageToken = Convert.ToUInt64(GetParameter(args, "-packagetoken")); + TokenCFG.useMachineAuth = HasParameter(args, "-machineauth"); + TokenCFG.MachineAuth = GetParameter(args, "-machineauth"); + TokenCFG.MachineAuth = GetParameter(args, "-machineauth"); ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password"); @@ -430,6 +435,7 @@ static void PrintUsage() Console.WriteLine("\t-depotkeys \t- a list of depot keys to use ('depotID;hexKey' per line)"); Console.WriteLine("\t-apptoken \t- Use Specified App Access Token"); Console.WriteLine("\t-packagetoken \t- Use Specified Package Access Token"); + Console.WriteLine("\t-machineauth \t- Use Specified ssfn Machine Auth File"); Console.WriteLine(); Console.WriteLine("\t-dir \t\t- the directory in which to place downloaded files."); Console.WriteLine("\t-filelist \t- a list of files to download (from the manifest). Prefix file path with 'regex:' if you want to match with regex."); diff --git a/DepotDownloaderMod/Properties/launchSettings.json b/DepotDownloaderMod/Properties/launchSettings.json new file mode 100644 index 000000000..583cb3390 --- /dev/null +++ b/DepotDownloaderMod/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "DepotDownloaderMod": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/DepotDownloaderMod/Steam3Session.cs b/DepotDownloaderMod/Steam3Session.cs index a1390fff3..cc798fcf3 100644 --- a/DepotDownloaderMod/Steam3Session.cs +++ b/DepotDownloaderMod/Steam3Session.cs @@ -581,15 +581,13 @@ private void DisconnectedCallback(SteamClient.DisconnectedCallback disconnected) private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn) { + var isSteamGuard = loggedOn.Result == EResult.AccountLogonDenied; var is2FA = loggedOn.Result == EResult.AccountLoginDeniedNeedTwoFactor; var isLoginKey = ContentDownloader.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."); @@ -597,11 +595,7 @@ private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn) if (is2FA) { - do - { - Console.Write("Please enter your 2 factor auth code from your authenticator app: "); - logonDetails.TwoFactorCode = Console.ReadLine(); - } while (String.Empty == logonDetails.TwoFactorCode); + Console.WriteLine("2FA needed."); } else if (isLoginKey) { @@ -623,11 +617,7 @@ private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn) } else { - do - { - Console.Write("Please enter the authentication code sent to your email address: "); - logonDetails.AuthCode = Console.ReadLine(); - } while (string.Empty == logonDetails.AuthCode); + Console.WriteLine("Auth Code needed."); } Console.Write("Retrying Steam3 connection..."); @@ -635,7 +625,6 @@ private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn) return; } - if (loggedOn.Result == EResult.TryAnotherCM) { Console.Write("Retrying Steam3 connection (TryAnotherCM)..."); @@ -675,8 +664,12 @@ private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn) private void SessionTokenCallback(SteamUser.SessionTokenCallback sessionToken) { + Console.WriteLine("Got session token!"); credentials.SessionToken = sessionToken.SessionToken; + + + } private void LicenseListCallback(SteamApps.LicenseListCallback licenseList) @@ -703,6 +696,8 @@ private void LicenseListCallback(SteamApps.LicenseListCallback licenseList) private void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth) { + + var hash = Util.SHAHash(machineAuth.Data); Console.WriteLine("Got Machine Auth: {0} {1} {2} {3}", machineAuth.FileName, machineAuth.Offset, machineAuth.BytesToWrite, machineAuth.Data.Length, hash);