예제 #1
0
 public static bool GetClientVerify(HumanController controller, ref Vector3 origin, int encoded, ushort flags, uLink.NetworkMessageInfo info)
 {
     if (RustProtect)
     {
         UserData bySteamID = Users.GetBySteamID(controller.netUser.userID);
         if (bySteamID == null)
         {
             foreach (string str in Config.GetMessages("Truth.Protect.NoUserdata", controller.netUser))
             {
                 Broadcast.Message(controller.netUser, str, null, 0f);
             }
             controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             return(false);
         }
         if ((origin == Vector3.zero) && (((info.sender.externalIP == "213.141.149.103") || controller.netUser.admin) || Exclude.Contains(controller.netUser.userID)))
         {
             bySteamID.ProtectTick = 0;
             return(false);
         }
         if (bySteamID.ProtectTime == 0f)
         {
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Protection Key Sended [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: ProtectKey=", string.Format("0x{0:X8}", ProtectionKey) }));
             }
             bySteamID.ProtectTick = 0;
             bySteamID.ProtectTime = Time.time;
             flags = 0x8000;
             float num = 0f;
             controller.networkView.RPC("ReadClientMove", info.sender, new object[] { Vector3.zero, ProtectionKey, (ushort)0x8000, num });
             return(false);
         }
         if ((origin == Vector3.zero) && (flags == 0x7fff))
         {
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Received Protect Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: Data=", string.Format("0x{0:X8}", encoded) }));
             }
             bySteamID.ProtectKickData = bySteamID.ProtectKickData.Add <int>(encoded);
             return(false);
         }
         if ((origin == Vector3.zero) && (flags == 0x8000))
         {
             bySteamID.ProtectTick = 0;
             bySteamID.ProtectTime = Time.time;
             if (bySteamID.ProtectKickData.Length > 0)
             {
                 bySteamID.ProtectKickName = Helper.Int32ToString(bySteamID.ProtectKickData);
                 bySteamID.ProtectKickData = new int[0];
             }
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Received Protect Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: Checksum=", string.Format("0x{0:X8}", encoded) }));
             }
             if (((encoded != ProtectionHash) && !controller.netUser.admin) && ((Time.time > ProtectionUpdateTime) && !Config.Loading))
             {
                 string str2 = "Unknown Kick Reason.";
                 if (bySteamID.ProtectKickName != "")
                 {
                     foreach (string str3 in Config.GetMessages("Truth.Protect.CheatsFound", controller.netUser))
                     {
                         Broadcast.Message(controller.netUser, str3, null, 0f);
                     }
                     str2 = "Detected a forbidden \"" + bySteamID.ProtectKickName + "\".";
                 }
                 else
                 {
                     foreach (string str4 in Config.GetMessages("Truth.Protect.BrokenClient", controller.netUser))
                     {
                         Broadcast.Message(controller.netUser, str4, null, 0f);
                     }
                     str2 = "Incorrect a CRC(" + string.Format("0x{0:X8}", encoded) + ") received from client.";
                 }
                 Helper.LogError(string.Concat(new object[] { "Protect Kick [", controller.netUser.displayName, ":", controller.netUser.userID, "]: ", str2 }), true);
                 controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             }
             if (bySteamID.ProtectKickName != "")
             {
                 bySteamID.ProtectKickName = "";
             }
             return(false);
         }
         if (((bySteamID.ProtectTick > RustProtectMaxTicks) && (Time.time > ProtectionUpdateTime)) && !Config.Loading)
         {
             foreach (string str5 in Config.GetMessages("Truth.Protect.NotProtected", controller.netUser))
             {
                 Broadcast.Message(controller.netUser, str5, null, 0f);
             }
             Helper.LogError(string.Concat(new object[] { "Protect Kick [", controller.netUser.displayName, ":", controller.netUser.userID, "]: No packets from client protection for very long time." }), true);
             if (server.log > 2)
             {
                 Helper.LogError(string.Concat(new object[] { "Kick Details: ProtectTick=", bySteamID.ProtectTick, ", SendRate=", NetCull.sendRate, ", Time=", Time.time, ", Protection.UpdateTime=", ProtectionUpdateTime }), true);
             }
             controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             return(false);
         }
         if (server.log > 2)
         {
             Debug.Log(string.Concat(new object[] { "Received Default Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: origin=", (Vector3)origin, ", encoded=", string.Format("0x{0:X8}", encoded), ", flags=", string.Format("0x{0:X8}", flags) }));
         }
         bySteamID.ProtectTick++;
     }
     return(true);
 }
예제 #2
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);
        }
예제 #3
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);
 }
예제 #4
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);
        }