mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Remove file checker restrictions, what's the point now ¯\_(ツ)_/¯
This commit is contained in:
1 parent
2ba2edf7b4
commit
3900add575
4 files changed
-195
No files matched your search
@@ -96,7 +96,6 @@ internal class BAUPlugin : BasePlugin
|
||||
Translator.Init();
|
||||
Harmony.PatchAll();
|
||||
GameSettingMenuPatch.SetupSettings(true);
|
||||
FileChecker.Initialize();
|
||||
InstanceAttribute.RegisterAll();
|
||||
OutfitData.Init();
|
||||
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterAmongUs.Modules;
|
||||
|
||||
internal static class FileChecker
|
||||
{
|
||||
private static bool enabled = false;
|
||||
private static FileSystemWatcher? fileWatcher;
|
||||
private static bool hasUnauthorizedFileOrMod = false;
|
||||
internal static string WarningMsg { get; private set; } = string.Empty;
|
||||
internal static bool HasShownWarning { get; set; } = false;
|
||||
internal static bool HasUnauthorizedFileOrMod => hasUnauthorizedFileOrMod;
|
||||
|
||||
private static readonly ReadOnlyCollection<string> TrustedNamespaces = new(new List<string>
|
||||
{
|
||||
"System", "Unity", "Harmony", "BepInEx", "Microsoft", "Il2Cpp", "Hazel", "AppleAuth", "QRCoder",
|
||||
"MonoMod", "netstandard", "mscorlib", "AssetRipper", "Cpp2IL", "AsmResolver", "Iced", "CsvHelper",
|
||||
"SemanticVersioning", "Mono.Cecil", "Assembly-CSharp", "StableNameDotNet", "AmongUsCaching",
|
||||
"Disarm", "Gee.External.Capstone", "Rewired_Core", "AddressablesPlayAssetDelivery", "Newtonsoft.Json", "Purchasing.Common",
|
||||
"Assembly-CSharp-firstpass", "Sentry", "Rewired_Windows", "__Generated", "XGamingRuntime",
|
||||
"BetterAmongUs", "MCI", "CrowdedMod", "Mini.RegionInstall", "Unlock", "Skin"
|
||||
});
|
||||
|
||||
private static readonly ReadOnlyCollection<string> UntrustedNamespaces = new(new List<string>
|
||||
{
|
||||
"Sicko", "AmongUsMenu", "Malum", "GoatNetClient", "SM", "AUM", "GNC", "MM", "Cheat", "Menu", "Hack", "Exploit", "Bypass", "Crack", "Spoof"
|
||||
});
|
||||
|
||||
private static readonly string[] TrustedPaths =
|
||||
{
|
||||
Environment.CurrentDirectory,
|
||||
Path.Combine(Environment.CurrentDirectory, "BepInEx"),
|
||||
};
|
||||
|
||||
private static readonly string[] UnauthorizedFiles = [
|
||||
"version.dll",
|
||||
"sicko-settings.json",
|
||||
"sicko-log.txt",
|
||||
"sicko-prev-log.txt",
|
||||
"sicko-config",
|
||||
"settings.json",
|
||||
"aum-log.txt",
|
||||
"aum-prev-log.txt"
|
||||
];
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (enabled) return;
|
||||
enabled = true;
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
|
||||
{
|
||||
CheckUnauthorizedAssemblies();
|
||||
CheckUnauthorizedFiles();
|
||||
};
|
||||
|
||||
fileWatcher = new FileSystemWatcher(Environment.CurrentDirectory)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.DirectoryName,
|
||||
IncludeSubdirectories = true
|
||||
};
|
||||
|
||||
fileWatcher.Created += (sender, args) => CheckUnauthorizedFiles();
|
||||
fileWatcher.Deleted += (sender, args) => CheckUnauthorizedFiles();
|
||||
|
||||
fileWatcher.EnableRaisingEvents = true;
|
||||
|
||||
CheckUnauthorizedFiles();
|
||||
CheckUnauthorizedAssemblies();
|
||||
}
|
||||
|
||||
private static void CheckUnauthorizedFiles()
|
||||
{
|
||||
if (hasUnauthorizedFileOrMod) return;
|
||||
|
||||
foreach (var fileName in UnauthorizedFiles)
|
||||
{
|
||||
if (File.Exists(Path.Combine(Environment.CurrentDirectory, fileName)))
|
||||
{
|
||||
WarningMsg = "<#D20200>Unauthorized File Detected</color>\n<#9D9D9D><size=70%>Look in logs for further information!</size></color>";
|
||||
Logger_.Warning($"Unauthorized File: {Path.Combine(Environment.CurrentDirectory, fileName)}");
|
||||
if (GameState.IsInGame)
|
||||
{
|
||||
SceneChanger.ChangeScene("MainMenu");
|
||||
}
|
||||
hasUnauthorizedFileOrMod = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly HashSet<Assembly> _processedAssemblies = [];
|
||||
|
||||
private static void CheckUnauthorizedAssemblies()
|
||||
{
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (_processedAssemblies.Contains(assembly) || assembly.IsDynamic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_processedAssemblies.Add(assembly);
|
||||
|
||||
if (UntrustedNamespaces.Any(ns => assembly.FullName.Contains(ns, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
if (TrustedNamespaces.Any(ns => assembly.FullName.Contains(ns, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
WarningMsg = "<#D20200>Untrusted Assembly Detected</color>\n<#9D9D9D><size=70%>Look in logs for further information!</size></color>";
|
||||
Logger_.Warning($"Unauthorized Assembly: {assembly.FullName} (Untrusted Namespace)");
|
||||
hasUnauthorizedFileOrMod = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TrustedNamespaces.Any(ns => assembly.FullName.Contains(ns, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
WarningMsg = "<#D20200>Unregistered Assembly Detected</color>\n<#9D9D9D><size=70%>Look in logs for further information!</size></color>";
|
||||
Logger_.Warning($"Unauthorized Assembly: {assembly.FullName} (Unregistered Namespace)");
|
||||
hasUnauthorizedFileOrMod = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsSafeLocation(assembly))
|
||||
{
|
||||
WarningMsg = "<#D20200>Unregistered Assembly Location Detected</color>\n<#9D9D9D><size=70%>Look in logs for further information!</size></color>";
|
||||
Logger_.Warning($"Unauthorized Assembly: {assembly.FullName} (Unregistered Location: {assembly.Location})");
|
||||
hasUnauthorizedFileOrMod = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetHasUnauthorizedFileOrMod()
|
||||
{
|
||||
hasUnauthorizedFileOrMod = true;
|
||||
}
|
||||
|
||||
internal static void SetWarningMsg(string msg)
|
||||
{
|
||||
if (string.IsNullOrEmpty(WarningMsg))
|
||||
{
|
||||
WarningMsg = msg;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsSafeLocation(Assembly assembly)
|
||||
{
|
||||
if (string.IsNullOrEmpty(assembly.Location))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return TrustedPaths.Any(path => assembly.Location.StartsWith(path, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,6 @@ internal static class ClientPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool SetOnline_Prefix(SignInStatusComponent __instance)
|
||||
{
|
||||
var lines = "<color=#ebbd34>----------------------------------------------------------------------------------------------</color>";
|
||||
if (!FileChecker.HasShownWarning && FileChecker.HasUnauthorizedFileOrMod)
|
||||
{
|
||||
Utils.ShowPopUp($"{lines}\n<b><size=200%><#0DFF00>{Translator.GetString("BetterAmongUs")}</color></size></b>\n<color=#757575><u><size=150%>{FileChecker.WarningMsg}</size></u>\n{lines}");
|
||||
FileChecker.HasShownWarning = true;
|
||||
}
|
||||
|
||||
var varSupportedVersions = BAUPlugin.SupportedAmongUsVersions;
|
||||
Version currentVersion = new(BAUPlugin.AppVersion);
|
||||
Version firstSupportedVersion = new(varSupportedVersions.First());
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace BetterAmongUs.Patches.Client;
|
||||
|
||||
@@ -17,32 +15,6 @@ internal static class MainMenuPatch
|
||||
[HarmonyPostfix]
|
||||
private static void LateUpdate_Postfix(MainMenuManager __instance)
|
||||
{
|
||||
if (FileChecker.HasUnauthorizedFileOrMod)
|
||||
{
|
||||
__instance.playButton.enabled = false;
|
||||
sprite ??= __instance.playButton.transform.Find("Inactive").GetComponent<SpriteRenderer>();
|
||||
if (sprite != null)
|
||||
{
|
||||
sprite.color = new Color(0.7f, 0.7f, 0.7f);
|
||||
ObjectHelper.AddColor(sprite);
|
||||
}
|
||||
|
||||
SceneManager.s_AllowLoadScene = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.playButton.enabled = true;
|
||||
sprite ??= __instance.playButton.transform.Find("Inactive").GetComponent<SpriteRenderer>();
|
||||
if (sprite != null)
|
||||
{
|
||||
sprite.color = Color.white;
|
||||
ObjectHelper.AddColor(sprite);
|
||||
}
|
||||
|
||||
SceneManager.s_AllowLoadScene = true;
|
||||
}
|
||||
|
||||
|
||||
List<PassiveButton> buttons = [__instance.playButton, __instance.inventoryButton, __instance.shopButton, __instance.playLocalButton, __instance.PlayOnlineButton, __instance.backButtonOnline,
|
||||
__instance.newsButton, __instance.myAccountButton, __instance.settingsButton, __instance.howToPlayButton, __instance.freePlayButton, __instance.accountCTAButton, __instance.accountStatsButton];
|
||||
foreach (var button in buttons)
|
||||
|
||||
Reference in new issue
Block a user