using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("bricks04.holoCheck")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+895a53b81970e2f8cefa6d9ae428c83edc296d4e")] [assembly: AssemblyProduct("HoloCheck")] [assembly: AssemblyTitle("bricks04.holoCheck")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HoloCheck { internal class HoloCheckConfig { public readonly ConfigEntry configAllowedSteamIDs; public readonly ConfigEntry configPasskey; public readonly ConfigEntry configPayloadInjection; public HoloCheckConfig(ConfigFile cfg) { cfg.Bind("General", "READ ME", "PLEASE READ ME", "To use whitelisting, please obtain the steam IDs of everyone you wish to allow into the server. While active, a steam ID check will be performed regardless of if you use a private or public server. Whitelisting will not work if you use LAN mode."); cfg.Bind("General", "Contact", "andrew3199 or Xitter@bricks041lol, email bricks041@gmail.com", "Please contact me if you find any issues with the mod, or if you have any questions. (Please do not spam any of these contact channels as I will block people if needed.)"); configAllowedSteamIDs = cfg.Bind("General", "Allowed Steam IDs", "", "A comma-separated string, containing a list of Steam IDs that you wish to allow entry into your servers. Ensure that there is no whitespace in the string. Example - '123456789,987654321,011131017'. YOUR STEAM ID IS NOT THE SAME THING AS THE STEAM FRIEND CODE! Obtain steam IDs by going to your profile, and taking the numbers at the end of the URL. "); configPayloadInjection = cfg.Bind("General", "Payload Injection Method", false, "Whether to utilise payload injections or version changes for passkey checking. Set to true if you do not wish for the version number to be changed eg. A different mod modifies this number and actively uses it."); } } [BepInPlugin("bricks04.holoCheck", "HoloCheck", "1.0.0")] public class HoloCheck : BaseUnityPlugin { internal static string[] allowedSteamIDs; internal static int originalVersion = 0; internal static int targetVersion = 999950; public static string passkey = ""; public static bool payloadInjection = false; public static bool displaySettings = false; internal static HoloCheckConfig BoundConfig { get; private set; } = null; public static HoloCheck Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } public static void SaveConfig() { string text = ""; string[] array = allowedSteamIDs; foreach (string text2 in array) { text = text + "," + text2; } Logger.LogInfo((object)text); ((ConfigEntryBase)BoundConfig.configAllowedSteamIDs).BoxedValue = text; ((ConfigEntryBase)BoundConfig.configPayloadInjection).BoxedValue = payloadInjection; } private void Awake() { BoundConfig = new HoloCheckConfig(((BaseUnityPlugin)this).Config); string text = (string)((ConfigEntryBase)BoundConfig.configAllowedSteamIDs).BoxedValue; allowedSteamIDs = text.Split(","); if (allowedSteamIDs[0] == "") { allowedSteamIDs = Array.Empty(); } payloadInjection = (bool)((ConfigEntryBase)BoundConfig.configPayloadInjection).BoxedValue; passkey = ""; Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Patch(); Logger.LogInfo((object)$"Passkey = {passkey}, Steam IDs = {allowedSteamIDs.Length}"); Logger.LogInfo((object)"bricks04.holoCheck v1.0.0 has loaded!"); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("bricks04.holoCheck"); } Logger.LogInfo((object)"Patching..."); Harmony.PatchAll(); Logger.LogInfo((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "bricks04.holoCheck"; public const string PLUGIN_NAME = "HoloCheck"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace HoloCheck.Patches { [HarmonyPatch(typeof(GameNetworkManager))] public class GameNetworkManagerPatches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostFix() { HoloCheck.Logger.LogInfo((object)"GameNetworkManager awoken!"); } [HarmonyPatch("ConnectionApproval")] [HarmonyPostfix] private static void ConnectionApprovalPostFix(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (HoloCheck.allowedSteamIDs.Length != 0) { CheckForSteamID(__instance, request, response); } CheckForPassPIN(__instance, request, response); } [HarmonyPatch("SetConnectionDataBeforeConnecting")] [HarmonyPostfix] [HarmonyAfter(new string[] { "me.swipez.melonloader.morecompany" })] private static void SetConnectionDataPostFix(GameNetworkManager __instance) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) HoloCheck.Logger.LogInfo((object)("Checking Connection data = " + Encoding.ASCII.GetString(NetworkManager.Singleton.NetworkConfig.ConnectionData))); if (HoloCheck.payloadInjection) { __instance.localClientWaitingForApproval = true; HoloCheck.Logger.LogInfo((object)("Pass to inject: " + HoloCheck.passkey.ToString())); if (__instance.disableSteam) { NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + "," + 32 + "," + HoloCheck.passkey.ToString()); } else { NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + "," + SteamId.op_Implicit(SteamClient.SteamId) + "," + HoloCheck.passkey.ToString()); } HoloCheck.Logger.LogInfo((object)("Post-injection Connection data = " + Encoding.ASCII.GetString(NetworkManager.Singleton.NetworkConfig.ConnectionData))); } } [HarmonyPatch("SteamMatchmaking_OnLobbyCreated")] [HarmonyPostfix] private static void S_OnLobbyCreatedPostFix(GameNetworkManager __instance, ref Result result, ref Lobby lobby) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) HoloCheck.Logger.LogInfo((object)"Running onLobbyCreated patch"); HoloCheck.Logger.LogInfo((object)result); HoloCheck.Logger.LogInfo((object)lobby); if (!__instance.disableSteam && __instance.lobbyHostSettings.isLobbyPublic && (HoloCheck.allowedSteamIDs.Length != 0 || HoloCheck.passkey.Length > 0)) { HoloCheck.Logger.LogInfo((object)"Changing the lobby mode to an Invisible lobby. "); ((Lobby)(ref lobby)).SetInvisible(); } } private static void CheckForSteamID(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) HoloCheck.Logger.LogInfo((object)"A connection approval check happened! Checking for steamID"); HoloCheck.Logger.LogInfo((object)__instance.disallowConnection); HoloCheck.Logger.LogInfo((object)__instance.disableSteam); HoloCheck.Logger.LogInfo((object)response.Approved); bool flag = !__instance.disallowConnection; if (__instance.disableSteam) { HoloCheck.Logger.LogWarning((object)"You are in LAN mode, or you somehow have Steam disabled! User ID checks will not be conducted. "); } if (flag && response.Approved && !__instance.disableSteam) { string @string = Encoding.ASCII.GetString(request.Payload); string[] array = @string.Split(","); string[] array2 = array; foreach (string text in array2) { HoloCheck.Logger.LogInfo((object)text); } HoloCheck.Logger.LogInfo((object)("Steam ID = " + array[1])); HoloCheck.Logger.LogInfo((object)HoloCheck.allowedSteamIDs); if (HoloCheck.allowedSteamIDs.Contains(array[1])) { HoloCheck.Logger.LogWarning((object)("User " + array[1] + " was approved to join the server! ")); flag = true; } else { HoloCheck.Logger.LogWarning((object)("User " + array[1] + " attempted to join the server, but has been denied because they are not on the list. ")); response.Reason = "Your account has not been approved to join this server."; flag = false; } response.Approved = flag; } } private static void CheckForPassPIN(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) HoloCheck.Logger.LogInfo((object)"A connection approval check happened! Checking for pass"); bool approved = response.Approved; if (__instance.disallowConnection) { return; } string @string = Encoding.ASCII.GetString(request.Payload); string[] array = @string.Split(","); HoloCheck.Logger.LogInfo((object)("Length of Payload = " + array.Length)); switch (array.Length) { case 3: HoloCheck.Logger.LogInfo((object)("Attempted Passkey = " + array[2])); HoloCheck.Logger.LogInfo((object)("Passkey to check = " + HoloCheck.passkey.ToString())); if (array[2].ToString() == HoloCheck.passkey.ToString()) { HoloCheck.Logger.LogWarning((object)"User's password matches."); break; } HoloCheck.Logger.LogWarning((object)"User attempted to join the server, but has been denied because their passkey does not match. Overriding any previous connection approval."); response.Reason = "Your account has not been approved to join this server."; approved = false; break; case 1: case 2: HoloCheck.Logger.LogInfo((object)("Attempted Version = " + array[0])); if (array[0] == HoloCheck.targetVersion.ToString()) { HoloCheck.Logger.LogWarning((object)"User's password matches."); break; } HoloCheck.Logger.LogWarning((object)"User attempted to join the server, but has been denied because their passkey does not match. Overriding any previous connection approval."); response.Reason = "Your account has not been approved to join this server."; approved = false; break; default: HoloCheck.Logger.LogError((object)"No case found for payload handling! Immediately rejecting user by default."); response.Reason = "Your account cannot join the server for safety reasons."; approved = false; break; } response.Approved = approved; } } [HarmonyPatch(typeof(SteamLobbyManager))] public class SteamLobbyManagerPatches { private static SteamLobbyManager lobbyManager; [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void OnEnablePostfix(SteamLobbyManager __instance) { HoloCheck.Logger.LogInfo((object)"OnEnable postfix patch run!"); lobbyManager = __instance; } public static void CallRefreshServerListButton() { if ((Object)(object)lobbyManager == (Object)null) { HoloCheck.Logger.LogError((object)"There is no stored reference to the game's SteamLobbyManager!"); return; } HoloCheck.Logger.LogInfo((object)"Forcing a server list refresh!"); lobbyManager.RefreshServerListButton(); } [HarmonyPatch("LoadServerList")] [HarmonyPostfix] private static void LoadServerListPostfix() { if (HoloCheck.passkey == "") { HoloCheck.Logger.LogWarning((object)"Accessing the server list with no passkey set!"); UIPatches.DisplayWarningMessage("> No Passkey Set!", 10f); } } } [HarmonyPatch(typeof(MenuManager))] public class UIPatches { [CompilerGenerated] private static class <>O { public static UnityAction <0>__EnableHoloCheckSettingsPanel; public static UnityAction <1>__DisableHoloCheckSettingsPanel; public static UnityAction <2>__RevealPasskeyButton; public static UnityAction <3>__ChangePasskeyButton; public static UnityAction <4>__InjectorButtonPressed; } public static AssetBundle HoloCheckUIAssets; public static GameObject holoCheckUI; public static GameObject instantiatedUI; public static GameObject enableHoloCheckSettingsButton; public static GameObject disableHoloCheckSettingsButton; public static GameObject settingsPanel; public static GameObject passkeyField; public static GameObject passkeyMode; public static GameObject pendingChangesAlert; public static GameObject revealPasskeyButton; public static GameObject changePasskeyButton; private static RectTransform settingsClosedPasskeyPosition; private static RectTransform settingsOpenPasskeyPosition; public static GameObject injectorButton; public static GameObject injectorText; private static float inputMessageTimer; private static bool userWarned; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void AwakePrefix() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "holocheckassetbundle")); if ((Object)(object)val == (Object)null) { HoloCheck.Logger.LogError((object)"Failed to load custom assets. If custom assets were previously loaded, you can safely ignore this error. "); return; } HoloCheckUIAssets = val; HoloCheck.Logger.LogInfo((object)"Custom assets loaded!"); } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostfix() { //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Expected O, but got Unknown //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Expected O, but got Unknown //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Expected O, but got Unknown //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) try { holoCheckUI = HoloCheckUIAssets.LoadAsset("HoloCheckUI"); instantiatedUI = Object.Instantiate(holoCheckUI); enableHoloCheckSettingsButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("ActivateButton")).gameObject; disableHoloCheckSettingsButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("Back Button")).gameObject; settingsPanel = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel")).gameObject; passkeyMode = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode")).gameObject; passkeyField = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Passkey Field")).gameObject; pendingChangesAlert = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Unsaved Changes Label")).gameObject; revealPasskeyButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Reveal Button")).gameObject; changePasskeyButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Change Button")).gameObject; settingsClosedPasskeyPosition = ((Component)instantiatedUI.transform.Find("Canvas").Find("Menu Closed Passkey")).gameObject.GetComponent(); settingsOpenPasskeyPosition = ((Component)instantiatedUI.transform.Find("Canvas").Find("Menu Opened Passkey")).gameObject.GetComponent(); injectorButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("Injector Mode") .Find("InjectorButton")).gameObject; injectorText = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("Injector Mode") .Find("Text (TMP)")).gameObject; passkeyField.GetComponent().contentType = (ContentType)7; if (HoloCheck.passkey != "") { passkeyField.GetComponent().text = HoloCheck.passkey; } else { passkeyField.GetComponent().text = ""; } passkeyField.GetComponent().ForceLabelUpdate(); ButtonClickedEvent onClick = enableHoloCheckSettingsButton.GetComponent