further cleanup of repo

This commit is contained in:
NotAKidoS 2025-04-03 03:03:24 -05:00
parent 4f8dcb0cd0
commit 323eb92f2e
140 changed files with 1 additions and 2430 deletions

View file

@ -0,0 +1,107 @@
using System.Reflection;
using ABI_RC.API;
using ABI_RC.Core.Networking;
using ABI_RC.Core.Networking.API.Responses;
using ABI_RC.Systems.GameEventSystem;
using HarmonyLib;
using MelonLoader;
using Random = UnityEngine.Random;
namespace NAK.ScriptingSpoofer;
public class ScriptingSpoofer : MelonMod
{
private static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(ScriptingSpoofer));
private static readonly MelonPreferences_Entry<bool> EntryEnabled =
Category.CreateEntry("mod_enabled", true, "Enabled", description: "Toggle scripting spoofer.");
private static readonly MelonPreferences_Entry<bool> EntryCensorUsername =
Category.CreateEntry("censor_username", true, "Censor Username", description: "Censor username. Toggle to randomize username instead.");
private static string spoofedUsername;
private static string spoofedUserId;
private static readonly char[] CensorChars = {'!', '@', '#', '$', '%', '^', '&', '*'};
public override void OnInitializeMelon()
{
ApplyPatches(typeof(PlayerApiPatches));
// Regenerate spoofed data on login
CVRGameEventSystem.Authentication.OnLogin.AddListener(GenerateRandomSpoofedData);
}
private void ApplyPatches(Type type)
{
try
{
HarmonyInstance.PatchAll(type);
}
catch (Exception e)
{
LoggerInstance.Msg($"Failed while patching {type.Name}!");
LoggerInstance.Error(e);
}
}
private static void GenerateRandomSpoofedData(UserAuthResponse _) // we get manually
{
spoofedUsername = EntryCensorUsername.Value ? GenerateCensoredUsername() : GenerateRandomUsername();
spoofedUserId = Guid.NewGuid().ToString();
}
private static string GenerateCensoredUsername()
{
var originalUsername = AuthManager.Username;
var usernameArray = originalUsername.ToCharArray();
for (var i = 0; i < usernameArray.Length; i++)
if (Random.value > 0.7f) usernameArray[i] = CensorChars[Random.Range(0, CensorChars.Length)];
var modifiedUsername = new string(usernameArray);
string[] prefixes = { "xX", "_", Random.Range(10, 99).ToString() };
string[] suffixes = { "Xx", "_", Random.Range(10, 99).ToString() };
var prefix = prefixes[Random.Range(0, prefixes.Length)];
var suffix = suffixes[Random.Range(0, suffixes.Length)];
return prefix + modifiedUsername + suffix;
}
private static string GenerateRandomUsername()
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
char[] username = new char[Random.Range(5, 15)];
for (int i = 0; i < username.Length; i++)
username[i] = chars[Random.Range(0, chars.Length)];
return new string(username);
}
private static class PlayerApiPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(Player), nameof(Player.Username), MethodType.Getter)]
private static bool GetSpoofedUsername(ref Player __instance, ref string __result)
{
if (__instance.IsRemote) return true;
if (!EntryEnabled.Value) return true;
__result = spoofedUsername;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Player), nameof(Player.UserID), MethodType.Getter)]
private static bool GetSpoofedUserId(ref Player __instance, ref string __result)
{
if (__instance.IsRemote) return true;
if (!EntryEnabled.Value) return true;
__result = spoofedUserId;
return false;
}
}
}

View file

@ -0,0 +1,32 @@
using MelonLoader;
using NAK.ScriptingSpoofer.Properties;
using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyTitle(nameof(NAK.ScriptingSpoofer))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(NAK.ScriptingSpoofer))]
[assembly: MelonInfo(
typeof(NAK.ScriptingSpoofer.ScriptingSpoofer),
nameof(NAK.ScriptingSpoofer),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/ScriptingSpoofer"
)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonColor(255, 246, 25, 99)] // red-pink
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red
[assembly: HarmonyDontPatchAll]
namespace NAK.ScriptingSpoofer.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.1";
public const string Author = "NotAKidoS";
}

View file

@ -0,0 +1,21 @@
# ScriptingSpoofer
Prevents **local** scripts from accessing your Username or UserID by spoofing them with random values each session.
This mod is made to prevent malicious scripts executing on your local client from accessing your Username or UserID to target you with. **This mod can not prevent scripts executing on remote clients from accessing your Username or UserID.**
Example: Prevents a **blacklist** script from targeting you. **Whitelist** scripts are not affected by this mod, only **blacklists**, as the spoofed info is not exposed for customization.
## Mod Settings
- **Censor Username**: Censors existing username by replacing and appending random characters to it. Disable to generate a completely random username.
---
Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI.
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive.
> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" />

View file

@ -0,0 +1,23 @@
{
"_id": -1,
"name": "ScriptingSpoofer",
"modversion": "1.0.1",
"gameversion": "2024r176",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "Prevents **local** scripts from accessing your Username or UserID by spoofing them with random values each session.",
"searchtags": [
"spoof",
"username",
"whitelist",
"blacklist"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r25/ScriptingSpoofer.dll",
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/ScriptingSpoofer/",
"changelog": "- Initial release",
"embedcolor": "#f61963"
}