// Token: 0x06000753 RID: 1875 RVA: 0x0002FF98 File Offset: 0x0002E198 public static byte[] InitKey(byte[] key, byte[] data, int size) { YSDecrypt._dynamicKeyIndex = 0; int num = (size >= 2048) ? 256 : (size >> 3); uint num2 = (uint)((num ^ 3) & num); byte[] array = new byte[16]; Buffer.BlockCopy(key, 0, array, 0, 16); byte[] array2 = BH3ES.BH3ESDecrypt(array); for (int i = 0; i < 16; i++) { array2[i] ^= YSKey.XorKey[i]; } ulong num3 = ulong.MaxValue; ulong num4 = 0UL; ulong num5 = 0UL; ulong num6 = 0UL; byte[] result; using (BinaryStream binaryStream = new BinaryStream(data, BinaryAccess.ReadWrite, null)) { int num7 = 0; while ((long)num7 < (long)((ulong)num2)) { num3 ^= binaryStream.ReadUInt64(BinaryEndian.LittleEndian); num4 ^= binaryStream.ReadUInt64(BinaryEndian.LittleEndian); num5 ^= binaryStream.ReadUInt64(BinaryEndian.LittleEndian); num6 ^= binaryStream.ReadUInt64(BinaryEndian.LittleEndian); num7 += 4; } num3 ^= (num4 ^ num5 ^ num6); if ((ulong)num2 != (ulong)((long)num)) { long num8 = (long)num - (long)((ulong)num2); int num9 = 0; while ((long)num9 < num8) { num3 ^= binaryStream.ReadUInt64(BinaryEndian.LittleEndian); num9++; } } ulong num10 = BitConverter.ToUInt64(array2, 0); ulong num11 = BitConverter.ToUInt64(array2, 8); using (BinaryStream binaryStream2 = YSDecrypt.InitKeyData(num10 ^ num11 ^ num3 ^ 7936877569879298522UL ^ 11567864270080435830UL)) { using (BinaryStream binaryStream3 = new BinaryStream(new byte[4096], BinaryAccess.ReadWrite, null)) { for (int j = 0; j < 512; j++) { ulong dynamicKey = YSDecrypt.GetDynamicKey(binaryStream2); binaryStream3.WriteUInt64(dynamicKey, BinaryEndian.LittleEndian); } result = binaryStream3.ToArray(); } } } return(result); }
// Token: 0x06000759 RID: 1881 RVA: 0x000304A4 File Offset: 0x0002E6A4 private static async Task <bool> ExportUnityAsset(string filePath, byte[] data) { try { if (data.Length != 0) { BinaryStream binaryStream = new BinaryStream(data, BinaryAccess.ReadWrite, null); { binaryStream.ReadStringToNull(null); binaryStream.ReadUInt32(BinaryEndian.LittleEndian); byte[] key = binaryStream.ReadBytes(32); ushort size = binaryStream.ReadUInt16(BinaryEndian.LittleEndian); byte[] array = binaryStream.ReadBytes(); byte[] array2 = YSDecrypt.InitKey(key, array, (int)size); if (array2 != null) { int num = array2.Length; for (int i = 0; i < array.Length; i++) { byte[] array3 = array; int num2 = i; array3[num2] ^= array2[i % num]; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath); string text = Path.GetDirectoryName(filePath); int num3 = text.LastIndexOf("\\"); text = text.Substring(num3 + 1); string text2 = Path.Combine(YSExport._folderPath, "blocks_export", text); int key2; if (int.TryParse(fileNameWithoutExtension, out key2)) { List <int> list; if (YSExport._blkInfo.TryGetValue(key2, out list) && list.Count > 1) { list.Sort(); for (int j = 0; j < list.Count; j++) { int num4 = list[j]; int num5; if (j != list.Count - 1) { num5 = list[j + 1] - num4; } else { num5 = array.Length - num4; } byte[] DecyptedData = new byte[num5]; Buffer.BlockCopy(array, num4, DecyptedData, 0, num5); FileUtils.SaveFile(Path.Combine(text2, string.Format("{0}_{1}.unity3d", fileNameWithoutExtension, num4)), DecyptedData); } } else { text2 = Path.Combine(text2, fileNameWithoutExtension + ".unity3d"); FileUtils.SaveFile(text2, array); } ExportInfo.AddSuccess(); await Task.Delay(20); return(true); } ExportInfo.AddError(); Console.WriteLine("\nError->" + filePath + "\n\tFailInfo->FileName Error"); } } } } catch (Exception ex) { ExportInfo.AddError(); Console.WriteLine(string.Concat(new string[] { "\nError->", filePath, "\n\tFailInfo->", ex.Message, "\n\tStackInfo->", ex.StackTrace })); } await Task.Delay(20); return(false); }