Decrypt()
Code: Select all
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<TextAsset>();
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: Select all
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<T>.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<T>.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<T>.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<byte[], byte>(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<byte[], byte>(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