This commit is contained in:
NYAN CAT 2019-01-27 09:23:58 -08:00
parent 247b310434
commit 7481c1a1eb
2 changed files with 12 additions and 8 deletions

View File

@ -20,6 +20,8 @@ namespace AsyncRAT_Sharp.Sockets
public ListViewItem LV { get; set; } public ListViewItem LV { get; set; }
private event ReadEventHandler Read; private event ReadEventHandler Read;
private delegate void ReadEventHandler(Clients client, byte[] data); private delegate void ReadEventHandler(Clients client, byte[] data);
private object SendSync { get; set; }
public Clients(Socket CLIENT) public Clients(Socket CLIENT)
{ {
@ -30,6 +32,7 @@ namespace AsyncRAT_Sharp.Sockets
MS = new MemoryStream(); MS = new MemoryStream();
LV = null; LV = null;
Read += HandlePacket.Read; Read += HandlePacket.Read;
SendSync = new object();
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null); Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null);
} }
@ -120,8 +123,7 @@ namespace AsyncRAT_Sharp.Sockets
public void BeginSend(object Msgs) public void BeginSend(object Msgs)
{ {
Clients Me = this; lock (SendSync)
lock (Me)
{ {
if (Client.Connected) if (Client.Connected)
{ {

View File

@ -29,11 +29,12 @@ namespace Client
class Program class Program
{ {
public static Socket Client { get; set; } public static Socket Client { get; set; }
public static byte[] Buffer { get; set; } private static byte[] Buffer { get; set; }
public static long Buffersize { get; set; } private static long Buffersize { get; set; }
public static bool BufferRecevied { get; set; } private static bool BufferRecevied { get; set; }
public static System.Threading.Timer Tick { get; set; } private static System.Threading.Timer Tick { get; set; }
public static MemoryStream MS { get; set; } private static MemoryStream MS { get; set; }
private static object SendSync { get; set; }
static void Main(string[] args) static void Main(string[] args)
{ {
@ -61,6 +62,7 @@ namespace Client
Buffersize = 0; Buffersize = 0;
BufferRecevied = false; BufferRecevied = false;
MS = new MemoryStream(); MS = new MemoryStream();
SendSync = new object();
BeginSend(SendInfo()); BeginSend(SendInfo());
TimerCallback T = Ping; TimerCallback T = Ping;
Tick = new System.Threading.Timer(T, null, new Random().Next(30 * 1000, 60 * 1000), new Random().Next(30 * 1000, 60 * 1000)); Tick = new System.Threading.Timer(T, null, new Random().Next(30 * 1000, 60 * 1000), new Random().Next(30 * 1000, 60 * 1000));
@ -232,7 +234,7 @@ namespace Client
public static void BeginSend(byte[] Msgs) public static void BeginSend(byte[] Msgs)
{ {
lock (Client) lock (SendSync)
{ {
if (Client.Connected) if (Client.Connected)
{ {