using System; using System.IO; using UnityEngine; using Steamworks; namespace IPA.Utilities.AntiPiracy { /// /// Provides checks for whether or not the game is pirated. /// public static class PiracyChecks { /// /// Runs through a list of checks to detect whether a game is pirated /// /// public static bool IsPirated { get { // Check for spoofed Steam Client if (BeatSaber.ReleaseType == BeatSaber.Release.Steam && IsSpoofedSteam()) return true; // Check for the presence of known pirated files if (HasKnownFiles()) return true; // If we get here, probably not a pirate return false; } } /// /// Check common Steam Emulator values for red flags /// /// static bool IsSpoofedSteam() { // Always resolves to "IGGGAMES" string userName = SteamFriends.GetFriendPersonaName(SteamUser.GetSteamID()); // Always resolves to "SteamFriends" string friendName = SteamFriends.GetFriendPersonaName(new CSteamID(76561198042581607)); // Return if they both resolve to known spoofed values return userName == "IGGGAMES" && friendName == "SteamFriends"; } /// /// Check for files that are present in pirated copies /// /// static bool HasKnownFiles() { // All known files string[] paths = new string[] { Path.Combine(Application.dataPath, "Plugins", "valve.ini"), Path.Combine(Application.dataPath, "Plugins", "steam.ini"), Path.Combine(Application.dataPath, "Plugins", "huhuvr.ini"), Path.GetFullPath(Path.Combine(Application.dataPath, "..", "SmartSteamEmu.ini")), }; // Check for the existence of each file foreach (string path in paths) { // If one is found, probably pirated if (File.Exists(path)) return true; } return false; } } }