diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 76246c2d3..20128416a 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -96,7 +96,6 @@ namespace ArchiSteamFarm { private bool IsAccountLocked => AccountFlags.HasFlag(EAccountFlags.Lockdown); private string SentryFile => BotPath + ".bin"; - [JsonProperty] internal BotConfig BotConfig { get; private set; } [JsonProperty] diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index acd0c2406..9f1aeb0bf 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -85,33 +85,39 @@ namespace ArchiSteamFarm { switch (userInputType) { case ASF.EUserInputType.DeviceID: Console.Write(Bot.FormatBotResponse(Strings.UserInputDeviceID, botName)); + result = Console.ReadLine(); break; case ASF.EUserInputType.IPCHostname: Console.Write(Bot.FormatBotResponse(Strings.UserInputIPCHost, botName)); + result = Console.ReadLine(); break; case ASF.EUserInputType.Login: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamLogin, botName)); + result = Console.ReadLine(); break; case ASF.EUserInputType.Password: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName)); + result = Utilities.ReadLineMasked(); break; case ASF.EUserInputType.SteamGuard: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName)); + result = Console.ReadLine(); break; case ASF.EUserInputType.SteamParentalPIN: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamParentalPIN, botName)); + result = Utilities.ReadLineMasked(); break; case ASF.EUserInputType.TwoFactorAuthentication: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName)); + result = Console.ReadLine(); break; default: ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType)); Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName)); + result = Console.ReadLine(); break; } - result = Console.ReadLine(); - if (!Console.IsOutputRedirected) { Console.Clear(); // For security purposes } diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index 1d87da265..948ac7121 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -29,6 +29,7 @@ using System.Globalization; using System.Linq; using System.Net; using System.Runtime.CompilerServices; +using System.Text; using System.Threading.Tasks; using Humanizer; @@ -85,6 +86,31 @@ namespace ArchiSteamFarm { } } + internal static string ReadLineMasked(char mask = '*') { + StringBuilder result = new StringBuilder(); + + ConsoleKeyInfo keyInfo; + while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter) { + if (!char.IsControl(keyInfo.KeyChar)) { + result.Append(keyInfo.KeyChar); + Console.Write(mask); + } else if ((keyInfo.Key == ConsoleKey.Backspace) && (result.Length > 0)) { + result.Remove(result.Length - 1, 1); + + if (Console.CursorLeft == 0) { + Console.SetCursorPosition(Console.BufferWidth - 1, Console.CursorTop - 1); + Console.Write(' '); + Console.SetCursorPosition(Console.BufferWidth - 1, Console.CursorTop - 1); + } else { + Console.Write("\b \b"); + } + } + } + + Console.WriteLine(); + return result.ToString(); + } + internal static void StartBackgroundAction(Action action, bool longRunning = true) { if (action == null) { ASF.ArchiLogger.LogNullError(nameof(action));