Skip to content

Commit

Permalink
Record input from the user in the logs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Jan 27, 2025
1 parent ec151c3 commit 67c2e9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ArchiSteamFarm/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -792,4 +792,8 @@ Process uptime: {1}</value>
<data name="CustomPluginUpdatesEnabled" xml:space="preserve">
<value>Custom plugins have been registered for automatic updates. ASF team would like to remind you that, for your own safety, you should enable automatic updates only from trusted parties. If you didn't intend to do this, you can disable plugin updates in ASF global config.</value>
</data>
<data name="Input" xml:space="preserve">
<value>Input: {0}</value>
<comment>{0} will be replaced by text input from the user.</comment>
</data>
</root>
16 changes: 16 additions & 0 deletions ArchiSteamFarm/NLog/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ internal static void EnableTraceLogging() {
Console.Write(cryptKeyText);
result = ConsoleReadLineMasked();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result.Length)));

break;
case ASF.EUserInputType.DeviceConfirmation:
string deviceConfirmationText = Bot.FormatBotResponse(Strings.UserInputDeviceConfirmation, botName);
Expand All @@ -116,6 +118,8 @@ internal static void EnableTraceLogging() {
Console.Write(deviceConfirmationText);
result = ConsoleReadLine();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result));

if (string.IsNullOrEmpty(result) || result.Equals("Y", StringComparison.OrdinalIgnoreCase) || result.Equals("N", StringComparison.OrdinalIgnoreCase)) {
break;
}
Expand All @@ -130,6 +134,8 @@ internal static void EnableTraceLogging() {
Console.Write(loginText);
result = ConsoleReadLine();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result));

break;
case ASF.EUserInputType.Password:
string passwordText = Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName);
Expand All @@ -139,6 +145,8 @@ internal static void EnableTraceLogging() {
Console.Write(passwordText);
result = ConsoleReadLineMasked();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result.Length)));

break;
case ASF.EUserInputType.SteamGuard:
string steamGuardText = Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName);
Expand All @@ -148,6 +156,8 @@ internal static void EnableTraceLogging() {
Console.Write(steamGuardText);
result = ConsoleReadLine();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result));

break;
case ASF.EUserInputType.SteamParentalCode:
string steamParentalCodeText = Bot.FormatBotResponse(Strings.UserInputSteamParentalCode, botName);
Expand All @@ -157,6 +167,8 @@ internal static void EnableTraceLogging() {
Console.Write(steamParentalCodeText);
result = ConsoleReadLineMasked();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result.Length)));

break;
case ASF.EUserInputType.TwoFactorAuthentication:
string twoFactorAuthenticationText = Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName);
Expand All @@ -166,6 +178,8 @@ internal static void EnableTraceLogging() {
Console.Write(twoFactorAuthenticationText);
result = ConsoleReadLine();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result));

This comment has been minimized.

Copy link
@Abrynos

Abrynos Jan 27, 2025

Member

Even tho it is considered a one-time password, I believe it should not be logged. This might give statistical insight into generation of such code and should be treated the same as a multi-use passphrase.

This comment has been minimized.

Copy link
@JustArchi

JustArchi Jan 27, 2025

Author Member

True, I can write it masked instead, thanks!


break;
default:
ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(userInputType), userInputType));
Expand Down Expand Up @@ -423,6 +437,8 @@ private static async Task HandleConsoleInteractively() {
Console.Write(enterCommandText);
string? command = ConsoleReadLine();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(command));

if (string.IsNullOrEmpty(command)) {
continue;
}
Expand Down

0 comments on commit 67c2e9c

Please sign in to comment.