diff --git a/DepotDownloader/ConsoleAuthenticator.cs b/DepotDownloader/ConsoleAuthenticator.cs new file mode 100644 index 00000000..81513405 --- /dev/null +++ b/DepotDownloader/ConsoleAuthenticator.cs @@ -0,0 +1,76 @@ +// This file is subject to the terms and conditions defined +// in file 'LICENSE', which is part of this source code package. + +using System; +using System.Threading.Tasks; +using SteamKit2.Authentication; + +namespace DepotDownloader +{ + // This is practically copied from https://github.com/SteamRE/SteamKit/blob/master/SteamKit2/SteamKit2/Steam/Authentication/UserConsoleAuthenticator.cs + internal class ConsoleAuthenticator : IAuthenticator + { + /// + public Task GetDeviceCodeAsync(bool previousCodeWasIncorrect) + { + if (previousCodeWasIncorrect) + { + Console.Error.WriteLine("The previous 2-factor auth code you have provided is incorrect."); + } + + string code; + + do + { + Console.Error.Write("STEAM GUARD! Please enter your 2-factor auth code from your authenticator app: "); + code = Console.ReadLine()?.Trim(); + + if (code == null) + { + break; + } + } + while (string.IsNullOrEmpty(code)); + + return Task.FromResult(code!); + } + + /// + public Task GetEmailCodeAsync(string email, bool previousCodeWasIncorrect) + { + if (previousCodeWasIncorrect) + { + Console.Error.WriteLine("The previous 2-factor auth code you have provided is incorrect."); + } + + string code; + + do + { + Console.Error.Write($"STEAM GUARD! Please enter the auth code sent to the email at {email}: "); + code = Console.ReadLine()?.Trim(); + + if (code == null) + { + break; + } + } + while (string.IsNullOrEmpty(code)); + + return Task.FromResult(code!); + } + + /// + public Task AcceptDeviceConfirmationAsync() + { + if (ContentDownloader.Config.SkipAppConfirmation) + { + return Task.FromResult(false); + } + + Console.Error.WriteLine("STEAM GUARD! Use the Steam Mobile App to confirm your sign in..."); + + return Task.FromResult(true); + } + } +} diff --git a/DepotDownloader/DownloadConfig.cs b/DepotDownloader/DownloadConfig.cs index 4985c446..144853bf 100644 --- a/DepotDownloader/DownloadConfig.cs +++ b/DepotDownloader/DownloadConfig.cs @@ -31,5 +31,6 @@ namespace DepotDownloader public uint? LoginID { get; set; } public bool UseQrCode { get; set; } + public bool SkipAppConfirmation { get; set; } } } diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index 99753f38..c36ecede 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -68,6 +68,7 @@ namespace DepotDownloader var password = GetParameter(args, "-password") ?? GetParameter(args, "-pass"); ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password"); ContentDownloader.Config.UseQrCode = HasParameter(args, "-qr"); + ContentDownloader.Config.SkipAppConfirmation = HasParameter(args, "-no-mobile"); if (username == null) { @@ -511,6 +512,7 @@ namespace DepotDownloader Console.WriteLine(" -remember-password - if set, remember the password for subsequent logins of this user."); Console.WriteLine(" use -username -remember-password as login credentials."); Console.WriteLine(" -qr - display a login QR code to be scanned with the Steam mobile app"); + Console.WriteLine(" -no-mobile - prefer entering a 2FA code instead of prompting to accept in the Steam mobile app"); Console.WriteLine(); Console.WriteLine(" -dir - the directory in which to place downloaded files."); Console.WriteLine(" -filelist - the name of a local file that contains a list of files to download (from the manifest)."); diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index a5e4fb5a..9104f332 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -449,7 +449,7 @@ namespace DepotDownloader Password = logonDetails.Password, IsPersistentSession = ContentDownloader.Config.RememberPassword, GuardData = guarddata, - Authenticator = new UserConsoleAuthenticator(), + Authenticator = new ConsoleAuthenticator(), }); } catch (TaskCanceledException) diff --git a/README.md b/README.md index 4697aacf..810c9466 100644 --- a/README.md +++ b/README.md @@ -65,41 +65,42 @@ For example: `./DepotDownloader -app 730 -ugc 770604181014286929` Parameter | Description ----------------------- | ----------- -`-username ` | the username of the account to login to for restricted content. -`-password ` | the password of the account to login to for restricted content. -`-remember-password` | if set, remember the password for subsequent logins of this user. (Use `-username -remember-password` as login credentials) +`-username ` | the username of the account to login to for restricted content. +`-password ` | the password of the account to login to for restricted content. +`-remember-password` | if set, remember the password for subsequent logins of this user. (Use `-username -remember-password` as login credentials) `-qr` | display a login QR code to be scanned with the Steam mobile app -`-loginid <#>` | a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently. +`-no-mobile` | prefer entering a 2FA code instead of prompting to accept in the Steam mobile app. +`-loginid <#>` | a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently. #### Downloading -Parameter | Description ------------------------ | ----------- -`-app <#>` | the AppID to download. -`-depot <#>` | the DepotID to download. -`-manifest ` | manifest id of content to download (requires `-depot`, default: current for branch). -`-ugc <#>` | the UGC ID to download. -`-pubfile <#>` | the PublishedFileId to download. (Will automatically resolve to UGC id) -`-branch ` | download from specified branch if available (default: Public). +Parameter | Description +------------------------ | ----------- +`-app <#>` | the AppID to download. +`-depot <#>` | the DepotID to download. +`-manifest ` | manifest id of content to download (requires `-depot`, default: current for branch). +`-ugc <#>` | the UGC ID to download. +`-pubfile <#>` | the PublishedFileId to download. (Will automatically resolve to UGC id) +`-branch ` | download from specified branch if available (default: Public). `-branchpassword ` | branch password if applicable. #### Download configuration Parameter | Description ----------------------- | ----------- -`-all-platforms` | downloads all platform-specific depots when `-app` is used. -`-os ` | the operating system for which to download the game (windows, macos or linux, default: OS the program is currently running on) -`-osarch ` | the architecture for which to download the game (32 or 64, default: the host's architecture) -`-all-archs` | download all architecture-specific depots when `-app` is used. -`-all-languages` | download all language-specific depots when `-app` is used. -`-language ` | the language for which to download the game (default: english) -`-lowviolence` | download low violence depots when `-app` is used. +`-all-platforms` | downloads all platform-specific depots when `-app` is used. +`-os ` | the operating system for which to download the game (windows, macos or linux, default: OS the program is currently running on) +`-osarch ` | the architecture for which to download the game (32 or 64, default: the host's architecture) +`-all-archs` | download all architecture-specific depots when `-app` is used. +`-all-languages` | download all language-specific depots when `-app` is used. +`-language ` | the language for which to download the game (default: english) +`-lowviolence` | download low violence depots when `-app` is used. `-dir ` | the directory in which to place downloaded files. -`-filelist ` | the name of a local file that contains a list of files to download (from the manifest). prefix file path with `regex:` if you want to match with regex. each file path should be on their own line. -`-validate` | include checksum verification of files already downloaded. -`-manifest-only` | downloads a human readable manifest for any depots that would be downloaded. -`-cellid <#>` | the overridden CellID of the content server to download from. -`-max-downloads <#>` | maximum number of chunks to download concurrently. (default: 8). +`-filelist ` | the name of a local file that contains a list of files to download (from the manifest). prefix file path with `regex:` if you want to match with regex. each file path should be on their own line. +`-validate` | include checksum verification of files already downloaded. +`-manifest-only` | downloads a human readable manifest for any depots that would be downloaded. +`-cellid <#>` | the overridden CellID of the content server to download from. +`-max-downloads <#>` | maximum number of chunks to download concurrently. (default: 8). `-use-lancache` | forces downloads over the local network via a Lancache instance. #### Other