Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Question about how Bytes files are loaded in unity?

Featured Replies

  • Author
  • Localization

Meonpie, posted Thu Sep 22, 2022 6:14 pm (73548)


I decompile the SO file to get the source code

Decrypt()
Code:
private bool Decrypt()
      {
         
         long num = 1L;
         AssetBundle decryptedAssetBundle = m_DecryptedAssetBundle;
         if (num == 0L)
         {
         }
         bool flag = (UnityEngine.Object)0 == decryptedAssetBundle;
         AssetBundle assetBundle = m_AssetBundle;
         if (num == 0L)
         {
         }
         bool flag2 = (UnityEngine.Object)0 != assetBundle;
         AssetBundle assetBundle2 = m_AssetBundle;
         if ((object)assetBundle2 == null)
         {
            throw new NullReferenceException();
         }
         TextAsset[] array = assetBundle2.LoadAllAssets();
         if (array != null)
         {
            int ivcode = 25242;
            RijndaelManaged rijndael = AesCryptor.getRijndael(0, ivcode);
            throw new IndexOutOfRangeException();
         }
         AssetBundle decryptedAssetBundle2 = m_DecryptedAssetBundle;
         return (UnityEngine.Object)0 != decryptedAssetBundle2;
      }


AesCryptor()
Code:
public class AesCryptor
   {
      public class Phrase
      {
         private StringBuilder builder;

         private string data;

         public static byte[] fqifiv
         {
            get
            {
               Encoding uTF;
               string text = default(string);
               do
               {
                  long num = 0L;
                  if (Singleton.I() == null)
                  {
                     throw new NullReferenceException();
                  }
                  long num2 = 0L;
                  uTF = Encoding.UTF8;
                  if (text == null)
                  {
                     throw new NullReferenceException();
                  }
                  int length = text.Length;
               }
               while (uTF != null);
               throw new NullReferenceException();
            }
         }

         public static byte[] fqifkey
         {
            get
            {
               Encoding uTF = Encoding.UTF8;
               long num = 0L;
               _00210 val = (_00210)Singleton.I();
               long num2 = 0L;
               throw new NullReferenceException();
            }
         }

         public Phrase()
         {
            long num = default(long);
            StringBuilder stringBuilder = new StringBuilder((int)num);
            num = 256L;
            builder = stringBuilder;
            base._002Ector();
            long num2 = 0L;
            if (Singleton.I() == null)
            {
               throw new NullReferenceException();
            }
            string text = default(string);
            data = text;
         }

         private static int RotateBit(int value, short n)
         {
            throw new Cpp2IlInjected.AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
         }

         public byte[] GetRandomCode16(int keycode)
         {
            Encoding aSCII;
            do
            {
               long num = 0L;
               aSCII = Encoding.ASCII;
               long num2 = 16L;
               string codeXXStr_ = GetCodeXXStr_(keycode, (int)num2);
            }
            while (aSCII != null);
            throw new NullReferenceException();
         }

         public byte[] GetRandomCode32(int keycode)
         {
            Encoding aSCII;
            do
            {
               long num = 0L;
               aSCII = Encoding.ASCII;
               long num2 = 32L;
               string codeXXStr_ = GetCodeXXStr_(keycode, (int)num2);
            }
            while (aSCII != null);
            throw new NullReferenceException();
         }

         public void GetRandomCode(int keycode, out byte[] _32, out byte[] _16)
         {
            long num = 0L;
            Encoding aSCII = Encoding.ASCII;
            long num2 = 32L;
            string codeXXStr_ = GetCodeXXStr_(keycode, (int)num2);
            if (aSCII == null)
            {
               throw new NullReferenceException();
            }
            System.Runtime.CompilerServices.Unsafe.As(ref _32).m_value = (byte)(int)aSCII;
            long num3 = 0L;
            Encoding aSCII2 = Encoding.ASCII;
            long num4 = 16L;
            string codeXXStr_2 = ((Phrase)(object)aSCII2).GetCodeXXStr_(keycode, (int)num4);
            if (aSCII2 == null)
            {
               throw new NullReferenceException();
            }
            System.Runtime.CompilerServices.Unsafe.As(ref _16).m_value = (byte)(int)aSCII2;
         }

         private string GetCodeXXStr_(int keycode, int x)
         {
            StringBuilder stringBuilder4;
            do
            {
               StringBuilder stringBuilder = builder;
               if (stringBuilder == null)
               {
                  throw new NullReferenceException();
               }
               long num = 0L;
               stringBuilder.Length = (int)num;
               StringBuilder stringBuilder2 = builder;
               string text = data;
               if (text == null)
               {
                  throw new NullReferenceException();
               }
               char c = text.get_Chars((int)num);
               if (stringBuilder2 == null)
               {
                  throw new NullReferenceException();
               }
               StringBuilder stringBuilder3 = stringBuilder2.Append(c);
               string text2 = data;
               if (text2 == null)
               {
                  throw new NullReferenceException();
               }
               char c2 = text2.get_Chars((int)c);
               stringBuilder4 = builder;
               while (x != 0)
               {
               }
            }
            while (stringBuilder4 != null);
            throw new NullReferenceException();
         }
      }

      public static RijndaelManaged getRijndael()
      {
         byte[] fqifkey = Phrase.fqifkey;
         return getRijndael(Phrase.fqifiv, fqifkey);
      }

      public static RijndaelManaged getRijndael(int keycode, int ivcode)
      {
         //Discarded unreachable code: IL_0006, IL_000c
         throw new NullReferenceException();
      }

      public static RijndaelManaged getRijndael(byte[] key, byte[] iv)
      {
         //Discarded unreachable code: IL_0011, IL_0017, IL_001d, IL_001f, IL_0025, IL_002b, IL_002e, IL_0034
         RijndaelManaged rijndaelManaged = new RijndaelManaged();
         if (rijndaelManaged == null)
         {
            throw new NullReferenceException();
         }
         return rijndaelManaged;
      }

      public unsafe static byte[] EncryptBytes(SymmetricAlgorithm alg, byte[] message)
      {
         
         MemoryStream memoryStream = default(MemoryStream);
         long num2 = default(long);
         long num3 = default(long);
         while (true)
         {
            long num = 1L;
            if (message == null || num == 0L)
            {
               break;
            }
            if (alg == null)
            {
               continue;
            }
            memoryStream = new MemoryStream();
            CryptoStream cryptoStream = new CryptoStream(memoryStream, (ICryptoTransform)alg, (CryptoStreamMode)num2);
            num2 = 1L;
            if (cryptoStream == null)
            {
               throw new NullReferenceException();
            }
            cryptoStream.FlushFinalBlock();
            if (memoryStream == null)
            {
               throw new NullReferenceException();
            }
            num3 = 0L;
            int num4 = 123;
            if (cryptoStream != null && (object)typeof(IDisposable).TypeHandle != null)
            {
               long num5 = 0L;
            }
            break;
         }
         long num6 = default(long);
         if (num3 != 0L)
         {
            num6 = 0L;
         }
         if (alg != null && (object)typeof(IDisposable).TypeHandle != null)
         {
            long num7 = 0L;
         }
         long num8 = default(long);
         if (num6 != 0L)
         {
            num8 = 0L;
         }
         if (memoryStream != null)
         {
            if ((object)typeof(IDisposable).TypeHandle != null)
            {
               long num9 = 0L;
            }
            long value = ((long*)num6)->m_value;
         }
         if (num8 != 0L)
         {
            long num10 = 0L;
         }
         long num11 = 1L;
         
      }

      public static byte[] DecryptBytes(SymmetricAlgorithm alg, byte[] message)
      {
         
         long num = 1L;
         if (message != null)
         {
            if (num != 0L)
            {
               if (alg != null)
               {
                  MemoryStream memoryStream = new MemoryStream();
                  CryptoStream cryptoStream = default(CryptoStream);
                  if (cryptoStream == null)
                  {
                     throw new NullReferenceException();
                  }
                  cryptoStream.FlushFinalBlock();
                  throw new NullReferenceException();
               }
               goto IL_0083;
            }
            long num2 = default(long);
            long num3 = default(long);
            if (num2 != 0L)
            {
               num3 = 0L;
            }
            if (alg != null && (object)typeof(IDisposable).TypeHandle != null)
            {
               long num4 = 0L;
            }
            long num5 = default(long);
            if (num3 != 0L)
            {
               num5 = 0L;
            }
            long num6 = 0L;
            if (num5 != 0L)
            {
            }
            string text = 0 "Failed to decrypt:";
            if ("UNKNOWN" == null)
            {
            }
            Debug.LogWarning(0);
         }
         long num7 = 0L;
         long num8 = 1L;
         goto IL_0083;
         IL_0083:
         ArgumentNullException ex = new ArgumentNullException("alg");
         long num9 = 0L;
         long num10 = 1L;
         long num11 = 8L;
         
      }
   }


How to decrypt and restore this code with C#, I think both "ivcode" and "keycode" are wrong!
Bytes file


I upload the apk file for reference, the so in the file is not encrypted
https://drive.google.com/file/d/1eiA_B5UCiczM-QzLCpcB3dh1IwfSj6sS/view?usp=sharing
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.