using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using HarmonyLib;
using Jotunn.Managers;
using SimpleJson;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("vrp-stable")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("1010101110")]
[assembly: AssemblyProduct("vrp-stable")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3B95EEF7-4A97-4393-91A0-3626434F3631")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace vrpstable
{
[BepInPlugin("1010101110.vrpstable", "vrpstable", "1.0.0")]
public class Mod : BaseUnityPlugin
{
public static Mod instance;
public static readonly Harmony harmony = new Harmony(typeof(Mod).GetCustomAttributes(typeof(BepInPlugin), inherit: false).Cast<BepInPlugin>().First()
.GUID);
private void Awake()
{
instance = this;
harmony.PatchAll();
}
private void OnDestroy()
{
instance = null;
harmony.UnpatchSelf();
}
}
}
namespace vrpstable.Patches
{
public class Patches
{
[HarmonyPatch(typeof(Player), "FixedUpdate")]
public static class PlayerCheck
{
private static void Postfix(ref Player __instance)
{
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Invalid comparison between Unknown and I4
if (!((Object)(object)Player.m_localPlayer != (Object)null) || __instance.GetPlayerID() != Player.m_localPlayer.GetPlayerID() || SynchronizationManager.Instance.PlayerIsAdmin)
{
return;
}
if (__instance.m_runStaminaDrain == 0f || __instance.m_maxStamina > 800f)
{
cheatInfstam = true;
SendModerationLog(__instance.GetPlayerName(), "infstam", "cheat", "", "");
}
if (__instance.m_ghostMode)
{
cheatGhost = true;
SendModerationLog(__instance.GetPlayerName(), "ghost", "cheat", "", "");
}
if (__instance.m_noPlacementCost)
{
cheatNocost = true;
SendModerationLog(__instance.GetPlayerName(), "nocost", "cheat", "", "");
}
if (__instance.m_godMode)
{
cheatGod = true;
SendModerationLog(__instance.GetPlayerName(), "god", "cheat", "", "");
}
if (__instance.m_debugFly)
{
cheatFly = true;
SendModerationLog(__instance.GetPlayerName(), "fly", "cheat", "", "");
}
cheattimer += Time.deltaTime;
if (!(cheattimer > 20f))
{
return;
}
bool flag = false;
cheattimer = 0f;
flag = checkforcheats();
if (cheatFly || cheatGhost || cheatGod || cheatInfstam || cheatNocost)
{
SendModerationLog(__instance.GetPlayerName(), "kicked for cheating", "cheat", "", "");
flag = true;
}
if ((Object)(object)ZNetScene.instance != (Object)null && (Object)(object)MessageHud.instance != (Object)null && ZNetScene.instance.NrOfInstances() > 11000)
{
MessageHud.instance.ShowMessage((MessageType)2, "VRP WARNING: INSTANCE COUNT OVER 11k!", 0, (Sprite)null);
}
if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.NrOfInstances() > 15000)
{
string text = ((Component)__instance).transform.position.x + "," + ((Component)__instance).transform.position.z + "," + ((Component)__instance).transform.position.y;
SendModerationLog(__instance.GetPlayerName(), "", "instance count kicked", "", "loc: " + text);
ZLog.LogError((object)"VRP ERROR: INSTANCE COUNT TOO HIGH");
flag = true;
}
if ((Object)(object)ZNetScene.instance != (Object)null && (int)ZNet.m_connectionStatus == 2)
{
float num = default(float);
float num2 = default(float);
int num3 = default(int);
float num4 = default(float);
float num5 = default(float);
ZNet.instance.GetNetStats(ref num, ref num2, ref num3, ref num4, ref num5);
if (num3 > 600)
{
SendModerationLog(__instance.GetPlayerName(), "", "ping kicked", "", "");
ZLog.LogError((object)"VRP ERROR: PING OUT OF BOUNDS");
ZLog.LogError((object)num3.ToString());
flag = true;
}
if (!ZNet.instance.IsServer() && (num < 0.5f || num2 < 0.5f))
{
SendModerationLog(__instance.GetPlayerName(), "", "quality kicked", "", "");
ZLog.LogError((object)"VRP ERROR: QUALITY OUT OF BOUNDS");
ZLog.LogError((object)(num + " " + num2));
flag = true;
}
}
if (flag && !SynchronizationManager.Instance.PlayerIsAdmin)
{
ZLog.LogError((object)"VRP KICKED");
Game.instance.Logout(true, true);
}
}
}
public static DateTime checkcheattime = DateTime.Now.AddSeconds(-290.0);
public static float cheattimer = 0f;
public static bool cheatInfstam = false;
public static bool cheatGhost = false;
public static bool cheatNocost = false;
public static bool cheatGod = false;
public static bool cheatFly = false;
private static bool checkforcheats()
{
bool result = false;
if (!ZNet.m_isServer && (DateTime.Now - checkcheattime).TotalSeconds > 300.0)
{
ZLog.Log((object)"VRP check");
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = "cmd.exe";
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.Arguments = "/C tasklist & exit";
processStartInfo.RedirectStandardOutput = true;
processStartInfo.UseShellExecute = false;
Process process = Process.Start(processStartInfo);
string text = process.StandardOutput.ReadToEnd().ToLowerInvariant();
process.WaitForExit();
if (text.Contains("cheatengine") || text.Contains("wemod"))
{
result = true;
SendModerationLog(Game.instance.m_playerProfile.m_playerName, "", "CHEAT PROGRAM", "", "");
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
ZLog.LogError((object)("Please don't cheat" + Environment.NewLine));
Application.Quit();
}
checkcheattime = DateTime.Now;
}
return result;
}
public static void SendModerationLog(string player, string item, string action, string creator, string raw)
{
var anon = new
{
p = player,
i = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(item)),
a = action,
c = creator,
r = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(raw))
};
string input = SimpleJson.SerializeObject((object)anon);
input = Regex.Replace(input, "[^\\u0009\\u000A\\u000D\\u0020-\\u007E]", "");
if (ZRoutedRpc.instance != null && !ZRoutedRpc.instance.m_server)
{
ZRoutedRpc.instance.InvokeRoutedRPC("ServerModerationLog", new object[1] { input });
}
}
}
}