public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty hiddenValue = prop.FindPropertyRelative("hiddenValue");

            SetBoldIfValueOverridePrefab(prop, hiddenValue);

            SerializedProperty cryptoKey = prop.FindPropertyRelative("currentCryptoKey");
            SerializedProperty fakeValue = prop.FindPropertyRelative("fakeValue");
            SerializedProperty inited    = prop.FindPropertyRelative("inited");

            string currentCryptoKey = cryptoKey.stringValue;
            string val = "";

            if (!inited.boolValue)
            {
                if (string.IsNullOrEmpty(currentCryptoKey))
                {
                    currentCryptoKey = cryptoKey.stringValue = ObscuredString.cryptoKeyEditor;
                }
                inited.boolValue = true;
                EncryptAndSetBytes(val, hiddenValue, currentCryptoKey);
            }
            else
            {
                byte[] bytes = new byte[hiddenValue.arraySize];
                for (int i = 0; i < hiddenValue.arraySize; i++)
                {
                    bytes[i] = (byte)hiddenValue.GetArrayElementAtIndex(i).intValue;
                }

                val = ObscuredString.EncryptDecrypt(GetString(bytes), currentCryptoKey);
            }

            int dataIndex = prop.propertyPath.IndexOf("Array.data[");

            if (dataIndex >= 0)
            {
                dataIndex += 11;

                string index = "Element " + prop.propertyPath.Substring(dataIndex, prop.propertyPath.IndexOf("]", dataIndex) - dataIndex);
                label.text = index;
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.TextField(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                EncryptAndSetBytes(val, hiddenValue, currentCryptoKey);
            }
            fakeValue.stringValue = val;

            /*if (prop.isInstantiatedPrefab)
             * {
             *      SetBoldDefaultFont(prop.prefabOverride);
             * }*/
        }
Exemplo n.º 2
0
        private static void EncryptAndSetBytes(string val, SerializedProperty prop, string key)
        {
            var encrypted      = ObscuredString.EncryptDecrypt(val, key);
            var encryptedBytes = GetBytes(encrypted);

            prop.ClearArray();
            prop.arraySize = encryptedBytes.Length;

            for (var i = 0; i < encryptedBytes.Length; i++)
            {
                prop.GetArrayElementAtIndex(i).intValue = encryptedBytes[i];
            }
        }
        private static void LoadAndParseWhitelist()
        {
            whitelistPath = ACTkEditorGlobalStuff.ResolveInjectionUserWhitelistPath();
            if (string.IsNullOrEmpty(whitelistPath) || !File.Exists(whitelistPath))
            {
                return;
            }

            string[] separator = { ACTkEditorGlobalStuff.InjectionDataSeparator };

            var fs = new FileStream(whitelistPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            var br = new BinaryReader(fs);

            var count = br.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var line = br.ReadString();
                line = ObscuredString.EncryptDecrypt(line, "Elina");
                var strArr       = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                var stringsCount = strArr.Length;
                if (stringsCount > 1)
                {
                    var assemblyName = strArr[0];

                    var hashes = new int[stringsCount - 1];
                    for (var j = 1; j < stringsCount; j++)
                    {
                        var parseResult = 0;
                        var success     = int.TryParse(strArr[j], out parseResult);
                        if (success)
                        {
                            hashes[j - 1] = parseResult;
                        }
                        else
                        {
                            Debug.LogError("Could not parse value: " + strArr[j] + ", line:\n" + line);
                        }
                    }

                    whitelist.Add(new AllowedAssembly(assemblyName, hashes));
                }
                else
                {
                    Debug.LogWarning("Error parsing whitelist file line! Please report to " + ACTkEditorGlobalStuff.ReportEmail);
                }
            }

            br.Close();
            fs.Close();
        }
Exemplo n.º 4
0
        private void LoadAndParseAllowedAssemblies()
        {
            TextAsset textAsset = (TextAsset)Resources.Load("fndid", typeof(TextAsset));

            if (Object.op_Equality((Object)textAsset, (Object)null))
            {
                this.signaturesAreNotGenuine = true;
            }
            else
            {
                string[] separator = new string[1] {
                    ":"
                };
                MemoryStream memoryStream = new MemoryStream(textAsset.get_bytes());
                BinaryReader binaryReader = new BinaryReader((Stream)memoryStream);
                int          length1      = binaryReader.ReadInt32();
                this.allowedAssemblies = new InjectionDetector.AllowedAssembly[length1];
                for (int index1 = 0; index1 < length1; ++index1)
                {
                    string[] strArray = ObscuredString.EncryptDecrypt(binaryReader.ReadString(), "Elina").Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    int      length2  = strArray.Length;
                    if (length2 > 1)
                    {
                        string name   = strArray[0];
                        int[]  hashes = new int[length2 - 1];
                        for (int index2 = 1; index2 < length2; ++index2)
                        {
                            hashes[index2 - 1] = int.Parse(strArray[index2]);
                        }
                        this.allowedAssemblies[index1] = new InjectionDetector.AllowedAssembly(name, hashes);
                    }
                    else
                    {
                        this.signaturesAreNotGenuine = true;
                        binaryReader.Close();
                        memoryStream.Close();
                        return;
                    }
                }
                binaryReader.Close();
                memoryStream.Close();
                Resources.UnloadAsset((Object)textAsset);
                this.hexTable = new string[256];
                for (int index = 0; index < 256; ++index)
                {
                    this.hexTable[index] = index.ToString("x2");
                }
            }
        }
        private void LoadAndParseAllowedAssemblies()
        {
            TextAsset textAsset = (TextAsset)Resources.Load("fndid", typeof(TextAsset));

            if (textAsset == null)
            {
                signaturesAreNotGenuine = true;
            }
            else
            {
                string[] separator = new string[1]
                {
                    ":"
                };
                MemoryStream memoryStream = new MemoryStream(textAsset.bytes);
                BinaryReader binaryReader = new BinaryReader(memoryStream);
                int          num          = binaryReader.ReadInt32();
                allowedAssemblies = new AllowedAssembly[num];
                for (int i = 0; i < num; i++)
                {
                    string value = binaryReader.ReadString();
                    value = ObscuredString.EncryptDecrypt(value, "Elina");
                    string[] array = value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    int      num2  = array.Length;
                    if (num2 <= 1)
                    {
                        signaturesAreNotGenuine = true;
                        binaryReader.Close();
                        memoryStream.Close();
                        return;
                    }
                    string name   = array[0];
                    int[]  array2 = new int[num2 - 1];
                    for (int j = 1; j < num2; j++)
                    {
                        array2[j - 1] = int.Parse(array[j]);
                    }
                    allowedAssemblies[i] = new AllowedAssembly(name, array2);
                }
                binaryReader.Close();
                memoryStream.Close();
                Resources.UnloadAsset(textAsset);
                hexTable = new string[256];
                for (int k = 0; k < 256; k++)
                {
                    hexTable[k] = k.ToString("x2");
                }
            }
        }
        private static void WriteWhitelist()
        {
            if (whitelist.Count > 0)
            {
                var fileExisted = File.Exists(whitelistPath);
                ACTkEditorGlobalStuff.RemoveReadOnlyAttribute(whitelistPath);
                var fs = new FileStream(whitelistPath, FileMode.Create, FileAccess.Write, FileShare.Read);
                var br = new BinaryWriter(fs);

                br.Write(whitelist.Count);

                foreach (var assembly in whitelist)
                {
                    var assemblyName = assembly.name;
                    var hashes       = "";

                    for (var j = 0; j < assembly.hashes.Length; j++)
                    {
                        hashes += assembly.hashes[j];
                        if (j < assembly.hashes.Length - 1)
                        {
                            hashes += ACTkEditorGlobalStuff.InjectionDataSeparator;
                        }
                    }

                    var line = ObscuredString.EncryptDecrypt(assemblyName + ACTkEditorGlobalStuff.InjectionDataSeparator + hashes, "Elina");
                    br.Write(line);
                }
                br.Close();
                fs.Close();

                if (!fileExisted)
                {
                    AssetDatabase.Refresh();
                }
            }
            else
            {
                ACTkEditorGlobalStuff.RemoveReadOnlyAttribute(whitelistPath);

                FileUtil.DeleteFileOrDirectory(whitelistPath);
                FileUtil.DeleteFileOrDirectory(whitelistPath + ".meta");

                AssetDatabase.Refresh();
            }

            ACTkPostprocessor.InjectionAssembliesScan();
        }
Exemplo n.º 7
0
            private string DecryptKey(string encryptedKey)
            {
                string decryptedKey;

                try
                {
                    byte[] bytes = Convert.FromBase64String(encryptedKey);
                    decryptedKey = Encoding.UTF8.GetString(bytes);
                    decryptedKey = ObscuredString.EncryptDecrypt(decryptedKey, ObscuredPrefs.CryptoKey);
                }
                catch
                {
                    decryptedKey = string.Empty;
                }

                return(decryptedKey);
            }
        private void WriteWhiteList()
        {
            if (whiteList.Count > 0)
            {
                bool fileExisted = File.Exists(whitelistPath);
                ActEditorGlobalStuff.RemoveReadOnlyAttribute(whitelistPath);
                FileStream   fs = new FileStream(whitelistPath, FileMode.Create, FileAccess.Write, FileShare.Read);
                BinaryWriter br = new BinaryWriter(fs);

                br.Write(whiteList.Count);

                foreach (AllowedAssembly assembly in whiteList)
                {
                    string assemblyName = assembly.name;
                    string hashes       = "";

                    for (int j = 0; j < assembly.hashes.Length; j++)
                    {
                        hashes += assembly.hashes[j];
                        if (j < assembly.hashes.Length - 1)
                        {
                            hashes += ActEditorGlobalStuff.INJECTION_DATA_SEPARATOR;
                        }
                    }

                    string line = ObscuredString.EncryptDecrypt(assemblyName + ActEditorGlobalStuff.INJECTION_DATA_SEPARATOR + hashes, "Elina");
                    br.Write(line);
                }
                br.Close();
                fs.Close();

                if (!fileExisted)
                {
                    AssetDatabase.Refresh();
                }
            }
            else
            {
                ActEditorGlobalStuff.RemoveReadOnlyAttribute(whitelistPath);
                FileUtil.DeleteFileOrDirectory(whitelistPath);
                AssetDatabase.Refresh();
            }

            ActPostprocessor.InjectionAssembliesScan();
        }
Exemplo n.º 9
0
        private static void LoadAndParseWhitelist()
        {
            whitelistPath = ActEditorGlobalStuff.ResolveInjectionUserWhitelistPath();
            if (string.IsNullOrEmpty(whitelistPath) || !File.Exists(whitelistPath))
            {
                return;
            }

            string[] separator = { ActEditorGlobalStuff.INJECTION_DATA_SEPARATOR };

            FileStream   fs = new FileStream(whitelistPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            BinaryReader br = new BinaryReader(fs);

            int count = br.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                string line = br.ReadString();
                line = ObscuredString.EncryptDecrypt(line, "Elina");
                string[] strArr       = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                int      stringsCount = strArr.Length;
                if (stringsCount > 1)
                {
                    string assemblyName = strArr[0];

                    int[] hashes = new int[stringsCount - 1];
                    for (int j = 1; j < stringsCount; j++)
                    {
                        hashes[j - 1] = int.Parse(strArr[j]);
                    }

                    whitelist.Add(new AllowedAssembly(assemblyName, hashes));
                }
                else
                {
                    Debug.LogWarning("Error parsing whitelist file line! Please report to " + ActEditorGlobalStuff.REPORT_EMAIL);
                }
            }

            br.Close();
            fs.Close();
        }
Exemplo n.º 10
0
        private void LoadAndParseAllowedAssemblies()
        {
#if ACTK_DEBUG_NORMAL
            Debug.Log(ACTkConstants.LogPrefix + "Starting LoadAndParseAllowedAssemblies()", this);
            Stopwatch sw = Stopwatch.StartNew();
#endif
            var assembliesSignatures = (TextAsset)Resources.Load("fndid", typeof(TextAsset));
            if (assembliesSignatures == null)
            {
                signaturesAreNotGenuine = true;
                return;
            }

#if ACTK_DEBUG_NORMAL
            sw.Stop();
            Debug.Log(ACTkConstants.LogPrefix + "Creating separator array and opening MemoryStream", this);
            sw.Start();
#endif

            string[] separator = { ":" };

            var ms = new MemoryStream(assembliesSignatures.bytes);
            var br = new BinaryReader(ms);

            var count = br.ReadInt32();

#if ACTK_DEBUG_NORMAL
            sw.Stop();
            Debug.Log(ACTkConstants.LogPrefix + "Allowed assemblies count from MS: " + count, this);
            sw.Start();
#endif

            allowedAssemblies = new AllowedAssembly[count];

            for (var i = 0; i < count; i++)
            {
                var line = br.ReadString();
#if ACTK_DEBUG_PARANOID
                sw.Stop();
                Debug.Log(ACTkConstants.LogPrefix + "Line: " + line, this);
                sw.Start();
#endif
                line = ObscuredString.EncryptDecrypt(line, "Elina");
#if ACTK_DEBUG_PARANOID
                sw.Stop();
                Debug.Log(ACTkConstants.LogPrefix + "Line decrypted : " + line, this);
                sw.Start();
#endif
                var strArr       = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                var stringsCount = strArr.Length;
#if ACTK_DEBUG_PARANOID
                sw.Stop();
                Debug.Log(ACTkConstants.LogPrefix + "stringsCount : " + stringsCount, this);
                sw.Start();
#endif
                if (stringsCount > 1)
                {
                    var assemblyName = strArr[0];

                    var hashes = new int[stringsCount - 1];
                    for (var j = 1; j < stringsCount; j++)
                    {
                        hashes[j - 1] = int.Parse(strArr[j]);
                    }

                    allowedAssemblies[i] = new AllowedAssembly(assemblyName, hashes);
                }
                else
                {
                    signaturesAreNotGenuine = true;
                    br.Close();
                    ms.Close();
#if ACTK_DEBUG_NORMAL
                    sw.Stop();
#endif
                    return;
                }
            }
            br.Close();
            ms.Close();
            Resources.UnloadAsset(assembliesSignatures);

#if ACTK_DEBUG_NORMAL
            sw.Stop();
            Debug.Log(ACTkConstants.LogPrefix + "Allowed Assemblies parsing duration: " + sw.ElapsedMilliseconds + " ms.", this);
#endif

            hexTable = new string[256];
            for (var i = 0; i < 256; i++)
            {
                hexTable[i] = i.ToString("x2");
            }
        }
    protected IEnumerator LoadPlayerPrefs(string text)
    {
        WWW w = null;

        //if (!statsSaved)
        {
            var s = mainSite + "/players/" + playerName.ToLower() + "/prefs.txt";
            if (isDebug)
            {
                s += "?" + Random.value;
            }
            Debug.Log(s);
            w = new WWW(s);
            while (!w.isDone)
            {
                popupText = Tr("Logging in ") + ((int)w.progress * 100) + "%";
                yield return(null);
            }
        }
        try
        {
            StringBuilder sb = new StringBuilder();
            Dictionary <string, string> dict = ParseDict(text);
            modTypeInt = int.Parse(dict.TryGetDontSet("modType", "0"));
            //sb.AppendLine("parsed Rep: " + reputation);
            //sb.AppendLine("parsed medals: " + medals);
            //sb.AppendLine("parsed modType: " + modTypeInt);
            userId = int.Parse(dict.TryGetDontSet("id", "0"));
            print("parsed userId: " + userId);
            bool crypt         = false;
            bool ovrd          = false;
            var  plnameToLower = playerName;
            if (string.IsNullOrEmpty(w.error))
            {
                var buffer = w.bytes;
                try
                {
                    Xor(buffer);
                    buffer = GZipStream.UncompressBuffer(buffer);
                }
                catch (System.Exception) { Debug.LogWarning("Failed uncompress"); Xor(buffer); }
                if (buffer.Length > 0)
                {
                    using (var ms = new BinaryReader(buffer))
                    {
                        sb.AppendLine("loading stats ");
                        int i     = 0;
                        var local = playerPrefKeys.Count;
                        while (ms.Position < ms.Length)
                        {
                            var key   = ms.ReadString();
                            var value = ms.ReadString();
                            if (value.Length > MaxLength || key.Length > MaxLength)
                            {
                                Debug.LogError(string.Format("too big value {0} {1}", key, value));
                                continue;
                            }
#if !UNITY_WP8
                            if (crypt)
                            {
                                key   = ObscuredString.EncryptDecrypt(key);
                                value = ObscuredString.EncryptDecrypt(value);
                            }
#endif
                            if (key == "Enc" && value == "Enc")
                            {
                                Debug.LogWarning("Encoded");
                                crypt = true;
                                continue;
                            }

                            if (key == _DefinePrefsTime && loggedInTime != 0)
                            {
                                ovrd = loggedInTime < int.Parse(value);

                                //if (ovrd)
                                //lastError = "Override Detected";
                                LogEvent(EventGroup.Debug, "Override Detected");
                                Debug.Log("Set override to: " + ovrd);
                                ovrd = false;
                                continue;
                            }
                            i++;

                            //if (!playerPrefKeys.Contains(key)) //may be incorrect
                            //{

                            //if (string.IsNullOrEmpty(PlayerPrefsGetString(key)))
                            var lowerKey = key.ToLower();
                            if (ResLoader.isEditor && !lowerKey.StartsWith(plnameToLower))
                            {
                                continue;
                            }

                            if (ovrd || !PlayerPrefs.HasKey(lowerKey))
                            {
                                PlayerPrefsSetString(key, value);
                            }
                            else
                            {
                                playerPrefKeys.Add(key);
                            }
                            //}
                            sb.Append(string.Format("{0}:{1},", key, value));
                        }

                        Debug.LogWarning("loading player prefs local:" + local + " remote:" + i + " \n" + (Debug.isDebugBuild ? sb.ToString() : sb.Length.ToString()));
                        SetStrings.Clear();
                        //statsSaved = true;
                    }
                }
                else
                {
                    Debug.LogWarning("player prefs empty");
                }
                //}
            }
            else //if (!w.error.StartsWith("404") && w.error.ToLower().StartsWith("failed downloading"))
            {
                throw new Exception(w.error);
            }
            //if (!setting.disPlayerPrefs2)
            //{
            //print("reputation " + reputation);
            //if (reputation < 5)
            if (_Loader.vkSite)
            {
                StartCoroutine(AddMethod(delegate
                {
                    reputation       = Mathf.Max(int.Parse(dict.TryGetDontSet("reputation", "0")), reputation);
                    medals           = Mathf.Max(int.Parse(dict.TryGetDontSet("medals", "0")), medals);
                    _Awards.xp.count = Mathf.Max(int.Parse(dict.TryGetDontSet("xp", "0")), _Awards.xp.count);
                }));
            }

            allowSavePrefs = bool.Parse(dict.TryGetDontSet("allowSavePrefs", "true"));
            //}
        }
        catch (System.Exception e)
        {
            SetStrings.Clear();
            //if (!statsSaved)
            {
                Debug.LogError(e);
                lastError = e.Message.Replace("\r", "   ").Replace("\n", "    ");
                //GoOffline();
                LogEvent("Login Failed Critical Error");
                OnLoginFailed(e.Message + "\n" + Tr(" Critical Error"));
                yield break;
            }
        }
        RefreshPrefs();
        //SaveStrings();
        OnLoggedIn();
        WindowPool();
    }
Exemplo n.º 12
0
        internal static void InjectionAssembliesScan(bool forced)
        {
            if (!InjectionDetectorTargetCompatibleCheck() && !forced)
            {
                return;
            }

#if (DEBUG || DEBUG_VERBOSE || DEBUG_PARANIOD)
            Stopwatch sw = Stopwatch.StartNew();
        #if (DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Injection Detector Assemblies Scan\n");
            Debug.Log("[ACT] Paths:\n" +

                      "Assets: " + ActEditorGlobalStuff.ASSETS_PATH + "\n" +
                      "Assemblies: " + ActEditorGlobalStuff.ASSEMBLIES_PATH + "\n" +
                      "Injection Detector Data: " + ActEditorGlobalStuff.INJECTION_DATA_PATH);
            sw.Start();
        #endif
#endif

#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Looking for all assemblies in current project...");
            sw.Start();
#endif
            allLibraries.Clear();
            allowedAssemblies.Clear();

            allLibraries.AddRange(ActEditorGlobalStuff.FindLibrariesAt(ActEditorGlobalStuff.ASSETS_PATH));
            allLibraries.AddRange(ActEditorGlobalStuff.FindLibrariesAt(ActEditorGlobalStuff.ASSEMBLIES_PATH));
#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Total libraries found: " + allLibraries.Count);
            sw.Start();
#endif
            const string editorSubdir            = "/editor/";
            string       assembliesPathLowerCase = ActEditorGlobalStuff.ASSEMBLIES_PATH_RELATIVE.ToLower();
            foreach (string libraryPath in allLibraries)
            {
                string libraryPathLowerCase = libraryPath.ToLower();
#if (DEBUG_PARANIOD)
                sw.Stop();
                Debug.Log("[ACT] Checking library at the path: " + libraryPathLowerCase);
                sw.Start();
#endif
                if (libraryPathLowerCase.Contains(editorSubdir))
                {
                    continue;
                }
                if (libraryPathLowerCase.Contains("-editor.dll") && libraryPathLowerCase.Contains(assembliesPathLowerCase))
                {
                    continue;
                }

                try
                {
                    AssemblyName assName = AssemblyName.GetAssemblyName(libraryPath);
                    string       name    = assName.Name;
                    int          hash    = ActEditorGlobalStuff.GetAssemblyHash(assName);

                    AllowedAssembly allowed = allowedAssemblies.FirstOrDefault(allowedAssembly => allowedAssembly.name == name);

                    if (allowed != null)
                    {
                        allowed.AddHash(hash);
                    }
                    else
                    {
                        allowed = new AllowedAssembly(name, new[] { hash });
                        allowedAssemblies.Add(allowed);
                    }
                }
                catch
                {
                    // not a valid IL assembly, skipping
                }
            }

#if (DEBUG || DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            string trace = "[ACT] Found assemblies (" + allowedAssemblies.Count + "):\n";

            foreach (AllowedAssembly allowedAssembly in allowedAssemblies)
            {
                trace += "  Name: " + allowedAssembly.name + "\n";
                trace  = allowedAssembly.hashes.Aggregate(trace, (current, hash) => current + ("    Hash: " + hash + "\n"));
            }

            Debug.Log(trace);
            sw.Start();
#endif
            if (!Directory.Exists(ActEditorGlobalStuff.RESOURCES_PATH))
            {
#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
                sw.Stop();
                Debug.Log("[ACT] Creating resources folder: " + ActEditorGlobalStuff.RESOURCES_PATH);
                sw.Start();
#endif
                Directory.CreateDirectory(ActEditorGlobalStuff.RESOURCES_PATH);
            }

            ActEditorGlobalStuff.RemoveReadOnlyAttribute(ActEditorGlobalStuff.INJECTION_DATA_PATH);
            BinaryWriter bw = new BinaryWriter(new FileStream(ActEditorGlobalStuff.INJECTION_DATA_PATH, FileMode.Create, FileAccess.Write, FileShare.Read));
            int          allowedAssembliesCount = allowedAssemblies.Count;

            int totalWhitelistedAssemblies = 0;

#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Processing default whitelist");
            sw.Start();
#endif

            string defaultWhitelistPath = ActEditorGlobalStuff.ResolveInjectionDefaultWhitelistPath();
            if (File.Exists(defaultWhitelistPath))
            {
                BinaryReader br = new BinaryReader(new FileStream(defaultWhitelistPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
                int          assembliesCount = br.ReadInt32();
                totalWhitelistedAssemblies = assembliesCount + allowedAssembliesCount;

                bw.Write(totalWhitelistedAssemblies);

                for (int i = 0; i < assembliesCount; i++)
                {
                    bw.Write(br.ReadString());
                }
                br.Close();
            }
            else
            {
#if (DEBUG || DEBUG_VERBOSE || DEBUG_PARANIOD)
                sw.Stop();
#endif
                bw.Close();
                Debug.LogError("[ACT] Can't find " + ActEditorGlobalStuff.INJECTION_DEFAULT_WHITELIST_FILE + " file!\nPlease, report to " + ActEditorGlobalStuff.REPORT_EMAIL);
                return;
            }

#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Processing user whitelist");
            sw.Start();
#endif

            string userWhitelistPath = ActEditorGlobalStuff.ResolveInjectionUserWhitelistPath();
            if (File.Exists(userWhitelistPath))
            {
                BinaryReader br = new BinaryReader(new FileStream(userWhitelistPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
                int          assembliesCount = br.ReadInt32();

                bw.Seek(0, SeekOrigin.Begin);
                bw.Write(totalWhitelistedAssemblies + assembliesCount);
                bw.Seek(0, SeekOrigin.End);
                for (int i = 0; i < assembliesCount; i++)
                {
                    bw.Write(br.ReadString());
                }
                br.Close();
            }

#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Processing project assemblies");
            sw.Start();
#endif

            for (int i = 0; i < allowedAssembliesCount; i++)
            {
                AllowedAssembly assembly = allowedAssemblies[i];
                string          name     = assembly.name;
                string          hashes   = "";

                for (int j = 0; j < assembly.hashes.Length; j++)
                {
                    hashes += assembly.hashes[j];
                    if (j < assembly.hashes.Length - 1)
                    {
                        hashes += ActEditorGlobalStuff.INJECTION_DATA_SEPARATOR;
                    }
                }

                string line = ObscuredString.EncryptDecrypt(name + ActEditorGlobalStuff.INJECTION_DATA_SEPARATOR + hashes, "Elina");

#if (DEBUG_VERBOSE || DEBUG_PARANIOD)
                Debug.Log("[ACT] Writing assembly:\n" + name + ActEditorGlobalStuff.INJECTION_DATA_SEPARATOR + hashes);
#endif
                bw.Write(line);
            }

            bw.Close();
#if (DEBUG || DEBUG_VERBOSE || DEBUG_PARANIOD)
            sw.Stop();
            Debug.Log("[ACT] Assemblies scan duration: " + sw.ElapsedMilliseconds + " ms.");
#endif

            if (allowedAssembliesCount == 0)
            {
                Debug.LogError("[ACT] Can't find any assemblies!\nPlease, report to " + ActEditorGlobalStuff.REPORT_EMAIL);
            }

            AssetDatabase.Refresh();
            //EditorApplication.UnlockReloadAssemblies();
        }
Exemplo n.º 13
0
        public static void MigrateObscuredTypesOnPrefabs()
        {
            if (!EditorUtility.DisplayDialog("ACTk Obscured types migration",
                                             "Are you sure you wish to scan all prefabs in your project and automatically migrate values to the new format?",
                                             "Yes", "No"))
            {
                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Obscured types migration was cancelled by user.");
                return;
            }

            AssetDatabase.SaveAssets();

            string[] assets = AssetDatabase.FindAssets("t:ScriptableObject t:Prefab");
            //string[] prefabs = AssetDatabase.FindAssets("TestPrefab");
            int touchedCount = 0;
            int count        = assets.Length;

            for (int i = 0; i < count; i++)
            {
                if (EditorUtility.DisplayCancelableProgressBar("Looking through objects", "Object " + (i + 1) + " from " + count,
                                                               i / (float)count))
                {
                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Obscured types migration was cancelled by user.");
                    break;
                }

                string guid = assets[i];
                string path = AssetDatabase.GUIDToAssetPath(guid);

                Object[] objects = AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (Object unityObject in objects)
                {
                    if (unityObject == null)
                    {
                        continue;
                    }
                    if (unityObject.name == "Deprecated EditorExtensionImpl")
                    {
                        continue;
                    }

                    bool modified         = false;
                    var  so               = new SerializedObject(unityObject);
                    SerializedProperty sp = so.GetIterator();

                    if (sp == null)
                    {
                        continue;
                    }

                    while (sp.NextVisible(true))
                    {
                        if (sp.propertyType != SerializedPropertyType.Generic)
                        {
                            continue;
                        }

                        string type = sp.type;

                        switch (type)
                        {
                        case "ObscuredBool":
                        {
                            SerializedProperty hiddenValue      = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey        = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue        = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueChanged = sp.FindPropertyRelative("fakeValueChanged");
                            SerializedProperty fakeValueActive  = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited           = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                int  currentCryptoKey = cryptoKey.intValue;
                                bool real             = ObscuredBool.Decrypt(hiddenValue.intValue, (byte)currentCryptoKey);
                                bool fake             = fakeValue.boolValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.boolValue = real;
                                    if (fakeValueChanged != null)
                                    {
                                        fakeValueChanged.boolValue = true;
                                    }
                                    if (fakeValueActive != null)
                                    {
                                        fakeValueActive.boolValue = true;
                                    }
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredDouble":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValue1 = hiddenValue.FindPropertyRelative("b1");
                            SerializedProperty hiddenValue2 = hiddenValue.FindPropertyRelative("b2");
                            SerializedProperty hiddenValue3 = hiddenValue.FindPropertyRelative("b3");
                            SerializedProperty hiddenValue4 = hiddenValue.FindPropertyRelative("b4");
                            SerializedProperty hiddenValue5 = hiddenValue.FindPropertyRelative("b5");
                            SerializedProperty hiddenValue6 = hiddenValue.FindPropertyRelative("b6");
                            SerializedProperty hiddenValue7 = hiddenValue.FindPropertyRelative("b7");
                            SerializedProperty hiddenValue8 = hiddenValue.FindPropertyRelative("b8");

                            SerializedProperty hiddenValueOld = sp.FindPropertyRelative("hiddenValueOld");

                            if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 8)
                            {
                                hiddenValue1.intValue = hiddenValueOld.GetArrayElementAtIndex(0).intValue;
                                hiddenValue2.intValue = hiddenValueOld.GetArrayElementAtIndex(1).intValue;
                                hiddenValue3.intValue = hiddenValueOld.GetArrayElementAtIndex(2).intValue;
                                hiddenValue4.intValue = hiddenValueOld.GetArrayElementAtIndex(3).intValue;
                                hiddenValue5.intValue = hiddenValueOld.GetArrayElementAtIndex(4).intValue;
                                hiddenValue6.intValue = hiddenValueOld.GetArrayElementAtIndex(5).intValue;
                                hiddenValue7.intValue = hiddenValueOld.GetArrayElementAtIndex(6).intValue;
                                hiddenValue8.intValue = hiddenValueOld.GetArrayElementAtIndex(7).intValue;

                                hiddenValueOld.arraySize = 0;

                                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Migrated property " + sp.displayName + ":" + type +
                                          " at the object " + unityObject.name + "\n" + path);
                                modified = true;
                            }

#if UNITY_5_0_PLUS
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                var union = new LongBytesUnion();
                                union.b8.b1 = (byte)hiddenValue1.intValue;
                                union.b8.b2 = (byte)hiddenValue2.intValue;
                                union.b8.b3 = (byte)hiddenValue3.intValue;
                                union.b8.b4 = (byte)hiddenValue4.intValue;
                                union.b8.b5 = (byte)hiddenValue5.intValue;
                                union.b8.b6 = (byte)hiddenValue6.intValue;
                                union.b8.b7 = (byte)hiddenValue7.intValue;
                                union.b8.b8 = (byte)hiddenValue8.intValue;

                                long   currentCryptoKey = cryptoKey.longValue;
                                double real             = ObscuredDouble.Decrypt(union.l, currentCryptoKey);
                                double fake             = fakeValue.doubleValue;

                                if (Math.Abs(real - fake) > 0.0000001d)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);

                                    fakeValue.doubleValue     = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
#endif
                        }
                        break;

                        case "ObscuredFloat":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValue1 = hiddenValue.FindPropertyRelative("b1");
                            SerializedProperty hiddenValue2 = hiddenValue.FindPropertyRelative("b2");
                            SerializedProperty hiddenValue3 = hiddenValue.FindPropertyRelative("b3");
                            SerializedProperty hiddenValue4 = hiddenValue.FindPropertyRelative("b4");

                            SerializedProperty hiddenValueOld = sp.FindPropertyRelative("hiddenValueOld");

                            if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 4)
                            {
                                hiddenValue1.intValue = hiddenValueOld.GetArrayElementAtIndex(0).intValue;
                                hiddenValue2.intValue = hiddenValueOld.GetArrayElementAtIndex(1).intValue;
                                hiddenValue3.intValue = hiddenValueOld.GetArrayElementAtIndex(2).intValue;
                                hiddenValue4.intValue = hiddenValueOld.GetArrayElementAtIndex(3).intValue;

                                hiddenValueOld.arraySize = 0;

                                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Migrated property " + sp.displayName + ":" + type +
                                          " at the object " + unityObject.name + "\n" + path);
                                modified = true;
                            }

                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                var union = new IntBytesUnion();
                                union.b4.b1 = (byte)hiddenValue1.intValue;
                                union.b4.b2 = (byte)hiddenValue2.intValue;
                                union.b4.b3 = (byte)hiddenValue3.intValue;
                                union.b4.b4 = (byte)hiddenValue4.intValue;

                                int   currentCryptoKey = cryptoKey.intValue;
                                float real             = ObscuredFloat.Decrypt(union.i, currentCryptoKey);
                                float fake             = fakeValue.floatValue;
                                if (Math.Abs(real - fake) > 0.0000001f)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);

                                    fakeValue.floatValue      = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredInt":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                int currentCryptoKey = cryptoKey.intValue;
                                int real             = ObscuredInt.Decrypt(hiddenValue.intValue, currentCryptoKey);
                                int fake             = fakeValue.intValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.intValue        = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

#if UNITY_5_0_PLUS
                        case "ObscuredLong":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                long currentCryptoKey = cryptoKey.longValue;
                                long real             = ObscuredLong.Decrypt(hiddenValue.longValue, currentCryptoKey);
                                long fake             = fakeValue.longValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.longValue       = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredShort":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                short currentCryptoKey = (short)cryptoKey.intValue;
                                short real             = ObscuredShort.EncryptDecrypt((short)hiddenValue.intValue, currentCryptoKey);
                                short fake             = (short)fakeValue.intValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.intValue        = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;
#endif
                        case "ObscuredString":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                string currentCryptoKey = cryptoKey.stringValue;
                                byte[] bytes            = new byte[hiddenValue.arraySize];
                                for (int j = 0; j < hiddenValue.arraySize; j++)
                                {
                                    bytes[j] = (byte)hiddenValue.GetArrayElementAtIndex(j).intValue;
                                }

                                string real = ObscuredString.EncryptDecrypt(GetString(bytes), currentCryptoKey);
                                string fake = fakeValue.stringValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.stringValue     = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

#if UNITY_5_0_PLUS
                        case "ObscuredUInt":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                uint currentCryptoKey = (uint)cryptoKey.intValue;
                                uint real             = ObscuredUInt.Decrypt((uint)hiddenValue.intValue, currentCryptoKey);
                                uint fake             = (uint)fakeValue.intValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.intValue        = (int)real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredULong":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                ulong currentCryptoKey = (ulong)cryptoKey.longValue;
                                ulong real             = ObscuredULong.Decrypt((ulong)hiddenValue.longValue, currentCryptoKey);
                                ulong fake             = (ulong)fakeValue.longValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.longValue       = (long)real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;
#endif
                        case "ObscuredVector2":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValueX = hiddenValue.FindPropertyRelative("x");
                            SerializedProperty hiddenValueY = hiddenValue.FindPropertyRelative("y");

                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                ObscuredVector2.RawEncryptedVector2 ev = new ObscuredVector2.RawEncryptedVector2();
                                ev.x = hiddenValueX.intValue;
                                ev.y = hiddenValueY.intValue;

                                int     currentCryptoKey = cryptoKey.intValue;
                                Vector2 real             = ObscuredVector2.Decrypt(ev, currentCryptoKey);
                                Vector2 fake             = fakeValue.vector2Value;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.vector2Value    = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredVector3":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValueX = hiddenValue.FindPropertyRelative("x");
                            SerializedProperty hiddenValueY = hiddenValue.FindPropertyRelative("y");
                            SerializedProperty hiddenValueZ = hiddenValue.FindPropertyRelative("z");

                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                var ev = new ObscuredVector3.RawEncryptedVector3();
                                ev.x = hiddenValueX.intValue;
                                ev.y = hiddenValueY.intValue;
                                ev.z = hiddenValueZ.intValue;

                                int     currentCryptoKey = cryptoKey.intValue;
                                Vector3 real             = ObscuredVector3.Decrypt(ev, currentCryptoKey);
                                Vector3 fake             = fakeValue.vector3Value;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.vector3Value    = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;
                        }
                    }

                    if (modified)
                    {
                        touchedCount++;
                        so.ApplyModifiedProperties();
                        EditorUtility.SetDirty(unityObject);
                    }
                }
            }

            AssetDatabase.SaveAssets();

            EditorUtility.ClearProgressBar();

            if (touchedCount > 0)
            {
                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Migrated obscured types on " + touchedCount + " objects.");
            }
            else
            {
                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "No objects were found for obscured types migration.");
            }
        }
Exemplo n.º 14
0
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            var hiddenValue = prop.FindPropertyRelative("hiddenValue");

            SetBoldIfValueOverridePrefab(prop, hiddenValue);

            var cryptoKey = prop.FindPropertyRelative("currentCryptoKey");
            var inited    = prop.FindPropertyRelative("inited");

            var currentCryptoKey = cryptoKey.stringValue;
            var val = string.Empty;

            if (!inited.boolValue)
            {
                if (string.IsNullOrEmpty(currentCryptoKey))
                {
                    currentCryptoKey = cryptoKey.stringValue = ObscuredString.cryptoKeyEditor;
                }
                inited.boolValue = true;
                EncryptAndSetBytes(val, hiddenValue, currentCryptoKey);
            }
            else
            {
                var size      = hiddenValue.FindPropertyRelative("Array.size");
                var showMixed = size.hasMultipleDifferentValues;

                if (!showMixed)
                {
                    for (var i = 0; i < hiddenValue.arraySize; i++)
                    {
                        showMixed |= hiddenValue.GetArrayElementAtIndex(i).hasMultipleDifferentValues;
                        if (showMixed)
                        {
                            break;
                        }
                    }
                }

                if (!showMixed)
                {
                    var bytes = new byte[hiddenValue.arraySize];
                    for (var i = 0; i < hiddenValue.arraySize; i++)
                    {
                        bytes[i] = (byte)hiddenValue.GetArrayElementAtIndex(i).intValue;
                    }

                    val = ObscuredString.EncryptDecrypt(GetString(bytes), currentCryptoKey);
                }
                else
                {
                    EditorGUI.showMixedValue = true;
                }
            }

            var dataIndex = prop.propertyPath.IndexOf("Array.data[", System.StringComparison.Ordinal);

            if (dataIndex >= 0)
            {
                dataIndex += 11;

                var index = "Element " + prop.propertyPath.Substring(dataIndex, prop.propertyPath.IndexOf("]", dataIndex, System.StringComparison.Ordinal) - dataIndex);
                label.text = index;
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.TextField(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                EncryptAndSetBytes(val, hiddenValue, currentCryptoKey);
            }

            EditorGUI.showMixedValue = false;

            /*if (prop.isInstantiatedPrefab)
             *          {
             *                  SetBoldDefaultFont(prop.prefabOverride);
             *          }*/
            ResetBoldFont();
        }