From c7593aefbd18e47db005548fc2af8cd0fe57f1e3 Mon Sep 17 00:00:00 2001 From: azuisleet Date: Thu, 8 Dec 2011 22:37:59 -0700 Subject: [PATCH] Added depot encryption key support. --- DepotDownloader/ContentDownloader.cs | 15 +++++++++++++-- DepotDownloader/Steam3Session.cs | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index ee16db12..d7dba1da 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -209,10 +209,11 @@ namespace DepotDownloader */ // find a proper bootstrap... - IPEndPoint contentServer1 = new IPEndPoint(IPAddress.Parse("4.28.20.42"), 80); - List cdnServers = CDNClient.FetchServerList(contentServer1, cellId); + CDNClient.ClientEndPoint contentServer1 = new CDNClient.ClientEndPoint("4.28.20.42", 80); + List cdnServers = CDNClient.FetchServerList(contentServer1, cellId); Console.WriteLine(" Done!"); + Console.Write("Downloading depot manifest..."); CDNClient cdnClient = new CDNClient(cdnServers[0], credentials.AppTicket); @@ -231,9 +232,19 @@ namespace DepotDownloader } string manifestFile = Path.Combine(installDir, "manifest.bin"); + string keyFile = Path.Combine(installDir, "depotkey.bin"); File.WriteAllBytes(manifestFile, manifest); + File.WriteAllBytes(keyFile, steam3.DepotKey); DepotManifest depotManifest = new DepotManifest(manifest); + + if (!depotManifest.DecryptFilenames(steam3.DepotKey)) + { + Console.WriteLine("\nUnable to decrypt manifest for depot {0}", depotId); + return; + } + + Console.WriteLine(" Done!"); } private static void DownloadSteam2( ContentServerClient.Credentials credentials, int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList ) diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index c3bcb62d..9f989c89 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -27,6 +27,7 @@ namespace DepotDownloader private set; } + public byte[] DepotKey { get; private set; } public ReadOnlyCollection AppInfo { get; private set; } SteamClient steamClient; @@ -37,6 +38,7 @@ namespace DepotDownloader Thread callbackThread; ManualResetEvent credentialHandle; bool bConnected; + bool bKeyResponse; DateTime connectTime; @@ -58,6 +60,7 @@ namespace DepotDownloader this.credentials = new Credentials(); this.credentialHandle = new ManualResetEvent( false ); this.bConnected = false; + this.bKeyResponse = false; this.steamClient = new SteamClient(); @@ -101,7 +104,7 @@ namespace DepotDownloader if ( diff > STEAM3_TIMEOUT && !bConnected ) break; - if ( credentials.HasSessionToken && credentials.AppTicket != null && Licenses != null && credentials.Steam2Ticket != null && AppInfo != null ) + if ( credentials.HasSessionToken && credentials.AppTicket != null && Licenses != null && credentials.Steam2Ticket != null && AppInfo != null && bKeyResponse ) break; if ( callback == null ) @@ -145,6 +148,7 @@ namespace DepotDownloader steamApps.GetAppInfo( depotId ); steamApps.GetAppOwnershipTicket( depotId ); + steamApps.GetDepotDecryptionKey( depotId ); } if ( callback.IsType() ) @@ -204,6 +208,16 @@ namespace DepotDownloader Console.WriteLine("Got AppInfo for {0}", msg.Apps[0].AppID); AppInfo = msg.Apps; } + + if (callback.IsType()) + { + var msg = callback as SteamApps.DepotKeyCallback; + + DepotKey = msg.DepotKey; + + Console.WriteLine("Got depot key for {0} result: {1}", msg.DepotID, msg.Result); + bKeyResponse = true; + } } credentialHandle.Set();