Example #1
0
        private static bool smethod_0(TruthDetector truthDetector_0, Vector3 vector3_0, ref Vector3 vector3_1)
        {
            RaycastHit        hit;
            bool              flag;
            MeshBatchInstance instance;
            Vector3           vector = vector3_1 - vector3_0;

            if (vector.magnitude == 0f)
            {
                return(false);
            }
            Ray ray = new Ray(vector3_0 + new Vector3(0f, 0.75f, 0f), vector.normalized);

            if (!Facepunch.MeshBatch.MeshBatchPhysics.SphereCast(ray, 0.1f, out hit, vector.magnitude, 0x20180403, out flag, out instance))
            {
                return(false);
            }
            IDMain             main      = flag ? instance.idMain : IDBase.GetMain(hit.collider);
            GameObject         obj2      = (main != null) ? main.gameObject : hit.collider.gameObject;
            string             newValue  = obj2.name.Trim();
            DeployableObject   obj3      = obj2.GetComponent <DeployableObject>();
            StructureComponent component = obj2.GetComponent <StructureComponent>();

            if (newValue == "")
            {
                newValue = "Mesh Texture";
            }
            else if (obj3 != null)
            {
                newValue = Helper.NiceName(obj3.name);
                if (truthDetector_0.netUser.userID == obj3.ownerID)
                {
                    return(false);
                }
                if (Users.SharedGet(obj3.ownerID, truthDetector_0.netUser.userID))
                {
                    return(false);
                }
            }
            else if (component != null)
            {
                newValue = Helper.NiceName(component.name);
                if (truthDetector_0.netUser.userID == component._master.ownerID)
                {
                    return(false);
                }
                if (Users.SharedGet(component._master.ownerID, truthDetector_0.netUser.userID))
                {
                    return(false);
                }
            }
            PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.WallHack", truthDetector_0.netUser, "", 0, new DateTime());
            PunishDetails = PunishDetails.Replace("%OBJECT.NAME%", newValue);
            PunishDetails = PunishDetails.Replace("%OBJECT.POS%", hit.point.AsString());
            HackDetected  = HackMethod.WallHack;
            vector3_1     = MoveBack(truthDetector_0, vector3_0, vector3_1);
            return(true);
        }
Example #2
0
 private static bool smethod_2(TruthDetector truthDetector_0, Vector3 vector3_0, ref Vector3 vector3_1, double double_0)
 {
     if (double_0 > 0.0)
     {
         double    num       = ((double)(vector3_1.y - vector3_0.y)) / double_0;
         UserData  bySteamID = Users.GetBySteamID(truthDetector_0.netUser.userID);
         Character idMain    = truthDetector_0.netUser.playerClient.controllable.idMain;
         if (!FallHeight.ContainsKey(truthDetector_0.netUser))
         {
             FallHeight.Add(truthDetector_0.netUser, 0.0);
         }
         if (!AirMovement.ContainsKey(truthDetector_0.netUser))
         {
             AirMovement.Add(truthDetector_0.netUser, 0.0);
         }
         if (idMain.stateFlags.airborne)
         {
             AirMovement[truthDetector_0.netUser] = 0.0;
         }
         if ((CheckJumphack && (num > 0.0)) && ((idMain != null) && idMain.stateFlags.airborne))
         {
             truthDetector_0.jumpHeight += num;
             if ((truthDetector_0.jumpHeight <= MaxJumpingHeight) && (num <= (MaxJumpingHeight * 2f)))
             {
                 if (((server.log > 2) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin)) && (truthDetector_0.jumpHeight > 1.0))
                 {
                     Broadcast.Message(truthDetector_0.netUser, "JumpHeight: " + truthDetector_0.jumpHeight.ToString("0.0") + " of maximum " + MaxJumpingHeight.ToString("0.0"), "DEBUG", 0f);
                 }
             }
             else
             {
                 if ((server.log > 1) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin))
                 {
                     Broadcast.Message(truthDetector_0.netUser, "[COLOR#D02F2F]JumpHeight: " + truthDetector_0.jumpHeight.ToString("0.0") + " of maximum " + MaxJumpingHeight.ToString("0.0"), "DEBUG", 0f);
                 }
                 PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.JumpHack", truthDetector_0.netUser, "", 0, new DateTime());
                 PunishDetails = PunishDetails.Replace("%JUMP.HEIGHT%", truthDetector_0.jumpHeight.ToString("0.00"));
                 PunishDetails = PunishDetails.Replace("%JUMP.MAXHEIGHT%", MaxJumpingHeight.ToString("0.00"));
                 HackDetected  = HackMethod.JumpHack;
                 vector3_1     = MoveBack(truthDetector_0, vector3_0, vector3_1);
             }
             return(HackDetected == HackMethod.JumpHack);
         }
         if ((CheckFallhack && (num < 0.0)) && ((idMain != null) && idMain.stateFlags.airborne))
         {
             Dictionary <NetUser, double> dictionary;
             NetUser user;
             (dictionary = FallHeight)[user = truthDetector_0.netUser] = dictionary[user] + (num = -num);
             if (((FallHeight[truthDetector_0.netUser] >= MinFallingHeight) && (bySteamID != null)) && (bySteamID.FallCheck != FallCheckState.damaged))
             {
                 bySteamID.FallCheck = FallCheckState.check;
                 if (((server.log > 2) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin)) && (FallHeight[truthDetector_0.netUser] > 1.0))
                 {
                     Broadcast.Message(truthDetector_0.netUser, "[COLOR#D02F2F]FallHeight: " + FallHeight[truthDetector_0.netUser].ToString("0.00") + " of minimum " + MinFallingHeight.ToString("0.0"), "DEBUG", 0f);
                 }
             }
             else if (((server.log > 2) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin)) && (FallHeight[truthDetector_0.netUser] > 1.0))
             {
                 Broadcast.Message(truthDetector_0.netUser, "FallHeight: " + FallHeight[truthDetector_0.netUser].ToString("0.00") + " of minimum " + MinFallingHeight.ToString("0.0"), "DEBUG", 0f);
             }
         }
         else if (!idMain.stateFlags.airborne)
         {
             if (CheckFallhack && (FallHeight[truthDetector_0.netUser] >= MinFallingHeight))
             {
                 if ((bySteamID != null) && (bySteamID.FallCheck == FallCheckState.check))
                 {
                     PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.FallHack", truthDetector_0.netUser, "", 0, new DateTime());
                     PunishDetails = PunishDetails.Replace("%FALL.HEIGHT%", FallHeight[truthDetector_0.netUser].ToString("0.00"));
                     PunishDetails = PunishDetails.Replace("%FALL.MINHEIGHT%", MinFallingHeight.ToString("0.00"));
                     HackDetected  = HackMethod.FallHack;
                 }
             }
             else if (Facepunch.MeshBatch.MeshBatchPhysics.OverlapSphere(vector3_1, 0.5f, 0x20180403).Length == 0)
             {
                 Dictionary <NetUser, double> dictionary2;
                 NetUser user2;
                 (dictionary2 = AirMovement)[user2 = truthDetector_0.netUser] = dictionary2[user2] + 1.0;
                 if (AirMovement[truthDetector_0.netUser] > NetCull.sendRate)
                 {
                     PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.MoveHack", truthDetector_0.netUser, "", 0, new DateTime());
                     AirMovement[truthDetector_0.netUser] = 0.0;
                     HackDetected = HackMethod.MoveHack;
                 }
             }
             bySteamID.FallCheck = FallCheckState.none;
             FallHeight[truthDetector_0.netUser] = truthDetector_0.jumpHeight = 0.0;
             if (HackDetected != HackMethod.FallHack)
             {
                 return(HackDetected == HackMethod.MoveHack);
             }
             return(true);
         }
     }
     return(false);
 }
Example #3
0
        private static bool smethod_1(TruthDetector truthDetector_0, Vector3 vector3_0, Vector3 vector3_1, double double_0)
        {
            Predicate <EventTimer> match      = null;
            Predicate <EventTimer> predicate2 = null;
            Predicate <EventTimer> predicate3 = null;
            Class48 class2 = new Class48 {
                truthDetector_0 = truthDetector_0
            };

            if (double_0 > 0.0)
            {
                Vector2 vector    = new Vector2(vector3_1.x - vector3_0.x, vector3_1.z - vector3_0.z);
                double  magnitude = vector.magnitude;
                double  num2      = magnitude / double_0;
                if (num2 == 0.0)
                {
                    return(false);
                }
                if (match == null)
                {
                    match = new Predicate <EventTimer>(class2.method_0);
                }
                EventTimer timer = Events.Timer.Find(match);
                if (timer != null)
                {
                    timer.Dispose();
                    Broadcast.Notice(class2.truthDetector_0.netUser.networkPlayer, "☢", Config.GetMessageCommand("Command.Home.Interrupt", "", class2.truthDetector_0.netUser), 5f);
                }
                if (predicate2 == null)
                {
                    predicate2 = new Predicate <EventTimer>(class2.method_1);
                }
                EventTimer timer2 = Events.Timer.Find(predicate2);
                if (timer2 != null)
                {
                    timer2.Dispose();
                    Broadcast.Notice(class2.truthDetector_0.netUser.networkPlayer, "☢", Config.GetMessageCommand("Command.Clan.Warp.Interrupt", "", class2.truthDetector_0.netUser), 5f);
                }
                if (predicate3 == null)
                {
                    predicate3 = new Predicate <EventTimer>(class2.method_2);
                }
                EventTimer timer3 = Events.Timer.Find(predicate3);
                if (timer3 != null)
                {
                    if (timer3.Sender != null)
                    {
                        Broadcast.Notice(timer3.Sender, "☢", Config.GetMessageCommand("Command.Teleport.Interrupt", "", timer3.Sender), 5f);
                    }
                    if (timer3.Target != null)
                    {
                        Broadcast.Notice(timer3.Target, "☢", Config.GetMessageCommand("Command.Teleport.Interrupt", "", timer3.Target), 5f);
                    }
                    timer3.Dispose();
                }
                if (num2 > MaxMovementSpeed)
                {
                    if ((server.log > 1) && Users.HasFlag(class2.truthDetector_0.netUser.userID, UserFlags.admin))
                    {
                        Broadcast.Message(class2.truthDetector_0.netUser, "[COLOR#D02F2F]MovementSpeed: " + num2.ToString("0.0") + " of maximum " + MaxMovementSpeed.ToString("0.0"), "DEBUG", 0f);
                    }
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.SpeedHack", class2.truthDetector_0.netUser, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%SPEED.MOVEMENT%", num2.ToString("0.00"));
                    PunishDetails = PunishDetails.Replace("%SPEED.MAXIMUM%", MaxMovementSpeed.ToString("0.00"));
                    HackDetected  = HackMethod.SpeedHack;
                    vector3_1     = MoveBack(class2.truthDetector_0, vector3_0, vector3_1);
                    return(true);
                }
                if (((server.log > 2) && Users.HasFlag(class2.truthDetector_0.netUser.userID, UserFlags.admin)) && (num2 > 1.0))
                {
                    Broadcast.Message(class2.truthDetector_0.netUser, "MovementSpeed: " + num2.ToString("0.0") + " of maximum " + MaxMovementSpeed.ToString("0.0"), "DEBUG", 0f);
                }
            }
            return(false);
        }
Example #4
0
        public static TruthDetector.ActionTaken Punish(NetUser netUser, UserData userData, HackMethod hackMethod, [Optional, DefaultParameterValue(false)] bool PunishBan)
        {
            string str = "";

            if ((server.log > 1) && Users.HasFlag(netUser.userID, UserFlags.admin))
            {
                if (hackMethod == HackMethod.AimedHack)
                {
                    Broadcast.Message(netUser, string.Concat(new object[] { "Violation ", netUser.truthDetector.violation, "(+", 100, ") of ", truth.threshold }), "TRUTH", 0f);
                }
                else
                {
                    Broadcast.Message(netUser, string.Concat(new object[] { "Violation ", netUser.truthDetector.violation, "(+", Rate, ") of ", truth.threshold }), "TRUTH", 0f);
                }
            }
            switch (hackMethod)
            {
            case HackMethod.AimedHack:
                str = "'Aimbot Hack'";
                netUser.truthDetector.violation += truth.threshold;
                break;

            case HackMethod.SpeedHack:
                str = "'Speed Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.MoveHack:
                str = "'Move Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.JumpHack:
                str = "'Jump Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.WallHack:
                str = "'Wall Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.FallHack:
                str = "'Fall Hack'";
                netUser.truthDetector.violation += truth.threshold;
                break;

            case HackMethod.NetExploit:
                str = "'Network Exploit'";
                netUser.truthDetector.violation += truth.threshold;
                break;

            case HackMethod.OtherHack:
                str = "'Object Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            default:
                return(TruthDetector.ActionTaken.None);
            }
            if (netUser.truthDetector.violation >= truth.threshold)
            {
                if ((MaxViolations != -1) && (userData != null))
                {
                    userData.ViolationDate = DateTime.Now;
                    userData.Violations++;
                }
                netUser.truthDetector.violation = 0;
                if ((MaxViolations != -1) && ((PunishAction.Contains <string>("BAN") || PunishBan) || ((MaxViolations <= 0) || (userData.Violations >= MaxViolations))))
                {
                    Users.SetViolations(userData.SteamID, 0);
                    DateTime period = new DateTime();
                    if (BannedPeriod > 0)
                    {
                        period = DateTime.Now.AddMinutes((double)BannedPeriod);
                    }
                    PunishReason = Config.GetMessageTruth("Truth.Logger.Banned", netUser, str, userData.Violations, new DateTime());
                    if (PunishDetails != "")
                    {
                        Helper.LogError(string.Concat(new object[] { "Violated [", netUser.displayName, ":", netUser.userID, "]: ", PunishDetails }), ViolationDetails);
                    }
                    Helper.Log(PunishReason, true);
                    if (ReportRank > 0)
                    {
                        Broadcast.MessageGM(PunishReason);
                    }
                    if (Core.DatabaseType.Equals("MYSQL"))
                    {
                        MySQL.Update(string.Format(string_0, userData.SteamID, MySQL.QuoteString(PunishReason), MySQL.QuoteString(PunishDetails)));
                        MySQL.Update(string.Format(string_1, userData.SteamID, userData.ViolationDate.ToString("yyyy-MM-dd HH:mm:ss")));
                    }
                    if (PunishAction.Contains <string>("NOTICE"))
                    {
                        Broadcast.Message(ViolationColor, netUser, Config.GetMessageTruth("Truth.Violation.Banned", netUser, str, userData.Violations, period), null, 0f);
                        Broadcast.MessageAll(ViolationColor, Config.GetMessageTruth("Truth.Punish.Banned", netUser, str, userData.Violations, new DateTime()), netUser);
                        Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                    }
                    else
                    {
                        Broadcast.Message(ViolationColor, netUser, Config.GetMessageTruth("Truth.Violation.Banned", netUser, str, userData.Violations, period), null, 0f);
                        Broadcast.Message(ViolationColor, netUser, PunishDetails, null, 0f);
                    }
                    if (BannedBlockIP && !BannedExcludeIP.Contains <string>(userData.LastConnectIP))
                    {
                        Blocklist.Add(userData.LastConnectIP);
                    }
                    Users.Ban(netUser.userID, "Banned for using " + str + " by SERVER.", period, PunishDetails);
                    netUser.Kick(NetError.Facepunch_Kick_Violation, true);
                    return(TruthDetector.ActionTaken.Kicked);
                }
                PunishReason = Config.GetMessageTruth("Truth.Logger.Notice", netUser, str, userData.Violations, new DateTime());
                if (PunishDetails != "")
                {
                    Helper.LogError(string.Concat(new object[] { "Violated [", netUser.displayName, ":", netUser.userID, "]: ", PunishDetails }), ViolationDetails);
                }
                Helper.Log(PunishReason, true);
                if (ReportRank > 0)
                {
                    Broadcast.MessageGM(PunishReason);
                }
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    MySQL.Update(string.Format(string_0, userData.SteamID, MySQL.QuoteString(PunishReason), MySQL.QuoteString(PunishDetails)));
                    MySQL.Update(string.Format(string_1, userData.SteamID, userData.ViolationDate.ToString("yyyy-MM-dd HH:mm:ss")));
                }
                string text = Config.GetMessageTruth("Truth.Violation.Notice", netUser, str, userData.Violations, new DateTime());
                string str3 = Config.GetMessageTruth("Truth.Punish.Notice", netUser, str, userData.Violations, new DateTime());
                if (PunishAction.Contains <string>("KILL"))
                {
                    text = Config.GetMessageTruth("Truth.Violation.Killed", netUser, str, userData.Violations, new DateTime());
                    str3 = Config.GetMessageTruth("Truth.Punish.Killed", netUser, str, userData.Violations, new DateTime());
                }
                if (PunishAction.Contains <string>("KICK"))
                {
                    text = Config.GetMessageTruth("Truth.Violation.Kicked", netUser, str, userData.Violations, new DateTime());
                    str3 = Config.GetMessageTruth("Truth.Punish.Kicked", netUser, str, userData.Violations, new DateTime());
                }
                if (PunishAction.Contains <string>("NOTICE"))
                {
                    Broadcast.Message(ViolationColor, netUser, text, null, 0f);
                    Broadcast.MessageAll(ViolationColor, str3, netUser);
                    Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                }
                if (PunishAction.Contains <string>("KILL"))
                {
                    TakeDamage.KillSelf(netUser.playerClient.controllable.character, null);
                }
                if (PunishAction.Contains <string>("KICK"))
                {
                    netUser.Kick(NetError.Facepunch_Kick_Violation, true);
                }
            }
            return(actionTaken_0);
        }
Example #5
0
        public static TruthDetector.ActionTaken NoteMoved(TruthDetector detector, ref Vector3 pos, Angle2 ang, double time)
        {
            UserData userData = null;

            HackDetected  = HackMethod.None;
            actionTaken_0 = TruthDetector.ActionTaken.None;
            try
            {
                uint notedTime = detector.notedTime;
                detector.notedTime = (uint)Environment.TickCount;
                if (notedTime > 0)
                {
                    notedTime = ((uint)Environment.TickCount) - notedTime;
                }
                userData = Users.GetBySteamID(detector.netUser.userID);
                if (detector.prevSnap.time > 0.0)
                {
                    double num2 = time - detector.prevSnap.time;
                    if (detector.ignoreSeconds > 0.0)
                    {
                        if (time > detector.prevSnap.time)
                        {
                            detector.ignoreSeconds -= num2;
                        }
                    }
                    else if (!detector.netUser.admin && !Exclude.Contains(detector.netUser.userID))
                    {
                        if (CheckWallhack && smethod_0(detector, detector.prevSnap.pos, ref pos))
                        {
                            actionTaken_0 = TruthDetector.ActionTaken.Moved;
                        }
                        else if (CheckSpeedhack && smethod_1(detector, detector.prevSnap.pos, pos, num2))
                        {
                            actionTaken_0 = TruthDetector.ActionTaken.Moved;
                        }
                        else if (smethod_2(detector, detector.prevSnap.pos, ref pos, num2))
                        {
                            actionTaken_0 = TruthDetector.ActionTaken.Moved;
                        }
                    }
                }
                if (actionTaken_0 == TruthDetector.ActionTaken.None)
                {
                    detector.prevSnap.pos  = pos;
                    detector.prevSnap.time = time;
                    detector.Record();
                    if (detector.violation > 0)
                    {
                        detector.violation--;
                    }
                    if (((userData != null) && (userData.Violations > 0)) && (userData.ViolationDate.Ticks > 0L))
                    {
                        DateTime time2 = userData.ViolationDate.AddMinutes((double)ViolationTimelife);
                        if (time2 < DateTime.Now)
                        {
                            userData.ViolationDate = time2;
                            userData.Violations--;
                        }
                    }
                }
                else if ((truth.punish && (notedTime > 0)) && (notedTime > detector.netUser.networkPlayer.averagePing))
                {
                    actionTaken_0 = Punish(detector.netUser, userData, HackDetected, false);
                    PunishReason  = "";
                    PunishDetails = "";
                }
            }
            catch (Exception exception)
            {
                Helper.LogError(exception.ToString(), true);
            }
            return(actionTaken_0);
        }