Beispiel #1
0
 public static byte[] Unzip(byte[] buffer)
 {
     Assembly callingAssembly = Assembly.GetCallingAssembly();
     Assembly executingAssembly = Assembly.GetExecutingAssembly();
     if ((callingAssembly != executingAssembly) && !PublicKeysMatch(executingAssembly, callingAssembly))
     {
         return null;
     }
     ZipStream stream = new ZipStream(buffer);
     byte[] buf = new byte[0];
     int num = stream.ReadInt();
     if (num == 0x4034b50)
     {
         short num2 = (short) stream.ReadShort();
         int num3 = stream.ReadShort();
         int num4 = stream.ReadShort();
         if (((num != 0x4034b50) || (num2 != 20)) || ((num3 != 0) || (num4 != 8)))
         {
             throw new FormatException("Wrong Header Signature");
         }
         stream.ReadInt();
         stream.ReadInt();
         stream.ReadInt();
         int num5 = stream.ReadInt();
         int count = stream.ReadShort();
         int num7 = stream.ReadShort();
         if (count > 0)
         {
             byte[] buffer3 = new byte[count];
             stream.Read(buffer3, 0, count);
         }
         if (num7 > 0)
         {
             byte[] buffer4 = new byte[num7];
             stream.Read(buffer4, 0, num7);
         }
         byte[] buffer5 = new byte[stream.Length - stream.Position];
         stream.Read(buffer5, 0, buffer5.Length);
         Inflater inflater = new Inflater(buffer5);
         buf = new byte[num5];
         inflater.Inflate(buf, 0, buf.Length);
         buffer5 = null;
     }
     else
     {
         int num8 = num >> 0x18;
         num -= num8 << 0x18;
         if (num == 0x7d7a7b)
         {
             switch (num8)
             {
                 case 1:
                 {
                     int num12;
                     int num9 = stream.ReadInt();
                     buf = new byte[num9];
                     for (int i = 0; i < num9; i += num12)
                     {
                         int num11 = stream.ReadInt();
                         num12 = stream.ReadInt();
                         byte[] buffer6 = new byte[num11];
                         stream.Read(buffer6, 0, buffer6.Length);
                         new Inflater(buffer6).Inflate(buf, i, num12);
                     }
                     break;
                 }
                 case 2:
                 {
                     byte[] buffer7 = new byte[] { 0x94, 0xad, 0xc3, 0x85, 0xa5, 0x2a, 0xbd, 9 };
                     byte[] buffer8 = new byte[] { 0xbf, 0x45, 3, 0x1a, 0x41, 80, 14, 0xbf };
                     using (ICryptoTransform transform = GetDesTransform(buffer7, buffer8, true))
                     {
                         buf = Unzip(transform.TransformFinalBlock(buffer, 4, buffer.Length - 4));
                     }
                     break;
                 }
             }
             if (num8 != 3)
             {
                 goto Label_026B;
             }
             byte[] key = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
             byte[] iv = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
             using (ICryptoTransform transform2 = GetAesTransform(key, iv, true))
             {
                 buf = Unzip(transform2.TransformFinalBlock(buffer, 4, buffer.Length - 4));
                 goto Label_026B;
             }
         }
         throw new FormatException("Unknown Header");
     }
 Label_026B:
     stream.Close();
     stream = null;
     return buf;
 }