From e98d7ce2a8d4854607b64a6b6c1ec9aa7f09e916 Mon Sep 17 00:00:00 2001 From: Ryan Kistner Date: Wed, 23 Jan 2013 18:16:05 -0700 Subject: [PATCH] DepotDownloader: Added beta password support --HG-- extra : rebase_source : ff1c354116dea838104716e3a998d8ca3a4c0f42 --- DepotDownloader/ContentDownloader.cs | 30 +++++++++++++++++++++++++--- DepotDownloader/DownloadConfig.cs | 2 ++ DepotDownloader/Program.cs | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index baa13d24..37bbdaab 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -244,8 +244,9 @@ namespace DepotDownloader continue; var nodes = depotChild["manifests"].Children; + var nodes_encrypted = depotChild["encryptedmanifests"].Children; - if (nodes.Count == 0) + if (nodes.Count == 0 && nodes_encrypted.Count == 0) return false; } @@ -363,14 +364,37 @@ namespace DepotDownloader return 0; var manifests = depotChild["manifests"]; + var manifests_encrypted = depotChild["encryptedmanifests"]; - if (manifests.Children.Count == 0) + if (manifests.Children.Count == 0 && manifests_encrypted.Children.Count == 0) return 0; var node = manifests[branch]; - if (branch != "Public" && node == null) + if (branch != "Public" && node == KeyValue.Invalid) { + var node_encrypted = manifests_encrypted[branch]; + if (node_encrypted != KeyValue.Invalid) + { + string password = Config.BetaPassword; + if (password == null) + { + Console.Write("Please enter the password for branch {0}: ", branch); + Config.BetaPassword = password = Console.ReadLine(); + } + + byte[] input = Utils.DecodeHexString(node_encrypted["encrypted_gid"].Value); + byte[] manifest_bytes = CryptoHelper.VerifyAndDecryptPassword(input, password); + + if (manifest_bytes == null) + { + Console.WriteLine("Password was invalid for branch {0}", branch); + return 0; + } + + return BitConverter.ToUInt64(manifest_bytes, 0); + } + Console.WriteLine("Invalid branch {0} for appId {1}", branch, appId); return 0; } diff --git a/DepotDownloader/DownloadConfig.cs b/DepotDownloader/DownloadConfig.cs index 1880a7de..548fe3ad 100644 --- a/DepotDownloader/DownloadConfig.cs +++ b/DepotDownloader/DownloadConfig.cs @@ -16,5 +16,7 @@ namespace DepotDownloader public List FilesToDownloadRegex { get; set; } public bool UsingExclusionList { get; set; } + + public string BetaPassword { get; set; } } } diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index b33b272c..9bde97e4 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -75,6 +75,7 @@ namespace DepotDownloader int depotVersion = GetIntParameter( args, "-version" ); ContentDownloader.Config.PreferBetaVersions = HasParameter( args, "-beta" ); + ContentDownloader.Config.BetaPassword = GetStringParameter( args, "-betpassword" ); // this is a Steam2 option if ( !bGameserver && !bApp && depotVersion == -1 )