Example #1
0
 void OnPlayerConnected(NetUser netuser, ConsoleSystem.Arg arg)
 {
     if (hasAccess(netuser, "noname.allowed")) { return; }    
     var name = netuser.displayName;
     if (name.Length < 4)
     {
         if (string.IsNullOrEmpty(name))
         {
            if(broadcast)
             { 
                 rust.SendChatMessage(netuser, prefixo, GetMessage("MessageNoName", netuser.userID.ToString()));
                 netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                 return;
             }
             else
             {
                 netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                 return;
             }
         }
           if(broadcast)
             {
                 rust.SendChatMessage(netuser, prefixo, string.Format(GetMessage("MessageSmallName", netuser.userID.ToString()), name));
                 netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                 return;
             }
                 else
             {
              netuser.Kick(NetError.Facepunch_Kick_RCON, true);
              return;
             }
     }  
 }
Example #2
0
        void OnPlayerConnected(NetUser netuser)
        {
            var url = string.Format("http://iphub.info/api.php?ip=" + netuser.networkPlayer.externalIP + "&showtype=4");

            Interface.GetMod().GetLibrary <WebRequests>("WebRequests").EnqueueGet(url, (code, response) =>
            {
                var targetuserid = netuser.playerClient.userID.ToString();
                var Whitelist    = GetwlPlayer("Whitelist(vpn)");
                if (Whitelist.ContainsKey(targetuserid))
                {
                    return;
                }
                var jsonresponse = JsonConvert.DeserializeObject <Dictionary <string, object> >(response, jsonsettings);
                var playervpn    = (jsonresponse["proxy"].ToString());
                var targetip     = netuser.networkPlayer.externalIP;
                var targetname   = netuser.displayName;
                var playerdata   = GetPlayerdata("Blacklist(vpn)");
                var targetid     = playervpn;
                if (shoudblockisp)
                {
                    var blacklistisp = GetPlayerdata("Blacklist(vpn.isp)");
                    var playerispvpn = (jsonresponse["asn"].ToString());
                    if (blacklistisp.ContainsKey(playerispvpn))
                    {
                        rust.SendChatMessage(netuser, systemname, colorisbanned + isbanned);
                        rust.SendChatMessage(netuser, systemname, colorisbannedmsg + isbannedmsg + " " + colorteamspeak + teamspeak);
                        rust.SendChatMessage(netuser, systemname, colorwebsite + " " + website);
                        netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                        return;
                    }
                }
                if (playervpn == shouldkick)
                {
                    var players = GetPlayer(targetname);
                    rust.SendChatMessage(netuser, systemname, colorisbanned + isbanned);
                    rust.SendChatMessage(netuser, systemname, colorisbannedmsg + isbannedmsg + " " + colorteamspeak + teamspeak);
                    rust.SendChatMessage(netuser, systemname, colorwebsite + " " + website);
                    if (!players.ContainsKey("name"))
                    {
                        players.Add("id", targetuserid);
                        players.Add("name", targetname);
                        players.Add("ip", targetip);
                    }
                    if (shouldbanidifbanned)
                    {
                        Interface.CallHook("cmdBan", targetuserid.ToString(), targetname);
                    }
                    netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                    Broadcast(string.Format(targetname + " " + isbannedd));
                }
            }, this);
        }
        void OnPlayerConnected(NetUser netuser)
        {
            string ID   = netuser.userID.ToString();
            var    Name = netuser.displayName.ToString();

            // caracteres bloquear
            if (CaracterBlock)
            {
                foreach (string value in caracteres)
                {
                    if (netuser.displayName.ToString().ToLower().Contains(value))
                    {
                        rust.BroadcastChat(chatPrefix, string.Format(GetMessage("InvalidCaractesGlobal"), netuser.displayName));
                        rust.RunClientCommand(netuser, $"deathscreen.reason \"{string.Format(GetMessage("InvalidCaractes", ID), value)}\"");
                        rust.RunClientCommand(netuser, "deathscreen.show");
                        netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                        return;
                    }
                }
            }

            // nicks bloqueados
            if (NameBlock)
            {
                foreach (string value in nomes)
                {
                    if (netuser.displayName.ToString().ToLower().Contains(value))
                    {
                        rust.BroadcastChat(chatPrefix, string.Format(GetMessage("InvalidNickGlobal"), netuser.displayName));
                        rust.RunClientCommand(netuser, $"deathscreen.reason \"{string.Format(GetMessage("InvalidNick", ID), value)}\"");
                        rust.RunClientCommand(netuser, "deathscreen.show");
                        netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                        return;
                    }
                }
            }

            // nome menor que 3 block
            if (KickSmallNick)
            {
                if (Name.Length < minNick)
                {
                    rust.BroadcastChat(chatPrefix, string.Format(GetMessage("InvalidNickPeq"), netuser.displayName));
                    netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                    return;
                }
            }
        }
        void IsFamilySharing(int code, string response, NetUser netuser)
        {
            string playerName = netuser.displayName;
            string steamID    = Convert.ToString(netuser.userID);

            switch (code)
            {
            case 200:
                var json = JsonConvert.DeserializeObject <WebResponse>(response);
                if (json.Response.LenderSteamid != "0")
                {
                    if (logToConsole)
                    {
                        Log($"{playerName} ({steamID}) is using a family shared account, kicking player...");
                    }

                    netuser.Kick(NetError.Facepunch_Whitelist_Failure, true);
                }
                break;

            case 401:
                Log("Webrequest failed, invalid Steam API key.");
                break;

            case 404:
            case 503:
                Log("Webrequest failed. Steam API unavailable.");
                break;

            default:
                Log($"Webrequest failed. Error code {code}.");
                break;
            }
        }
        void cmdLogin(NetUser netUser, string command, string[] args)
        {
            var Id       = netUser.userID.ToString();
            var username = netUser.displayName.ToString();

            if (args.Length == 0)
            {
                rust.SendChatMessage(netUser, lang.GetMessage("ChatTag", this, Id), lang.GetMessage("SyntaxLogin", this, Id));
                return;
            }
            string rcon = (args[0]);

            if (rcon == permissionCanRcon)
            {
                foreach (PlayerClient player in PlayerClient.All)
                {
                    var playerId = player.userID.ToString();
                    netUser.SetAdmin(true);
                    if (netUser.CanAdmin() || Profile.owner.ContainsKey(playerId) || Profile.admin.ContainsKey(playerId) || Profile.owner.ContainsKey(playerId) || Profile.mod.ContainsKey(playerId) || Profile.helper.ContainsKey(playerId))
                    {
                        rust.SendChatMessage(player.netUser, lang.GetMessage("ChatTag", this, Id), string.Format(lang.GetMessage("Login", this, Id), username));
                    }
                    return;
                }
            }
            else
            {
                rust.BroadcastChat(lang.GetMessage("ChatTag", this, Id), string.Format(lang.GetMessage("KickRcon", this, Id), username));
                netUser.Kick(NetError.Facepunch_Kick_Violation, true);
            }
        }
Example #6
0
 public void CheckActivityConnections()
 {
     if (NetCull.isServerRunning && Users.NetworkTimeout > 0f && Bootstrap.UpdateTime / 1000u < Users.NetworkTimeout)
     {
         uLink.NetworkPlayer[] connections = NetCull.connections;
         uLink.NetworkPlayer[] array       = connections;
         for (int i = 0; i < array.Length; i++)
         {
             uLink.NetworkPlayer networkPlayer = array[i];
             NetUser             netUser       = NetUser.Find(networkPlayer);
             Character           character     = null;
             if (netUser != null && Truth.LastPacketTime.ContainsKey(netUser) && Character.FindByUser(netUser.userID, out character))
             {
                 float num = Time.time - Truth.LastPacketTime[netUser];
                 if (Truth.LastPacketTime[netUser] > 0f && num > Users.NetworkTimeout)
                 {
                     Helper.LogWarning(string.Concat(new object[]
                     {
                         "Kicked by Server [",
                         netUser.displayName,
                         ":",
                         netUser.userID,
                         "]: No receiving packets from client ",
                         num.ToString("F2"),
                         " second(s)."
                     }), true);
                     netUser.Kick(NetError.ConnectionTimeout, true);
                 }
             }
         }
     }
 }
Example #7
0
        void HasPrivateProfile(int code, string response, NetUser netuser)
        {
            string playerName = netuser.displayName;
            string steamID    = Convert.ToString(netuser.userID);

            switch (code)
            {
            case 200:
                var json = JsonConvert.DeserializeObject <WebResponse>(response);
                if (json.Response.Players[0].Communityvisibilitystate != 3)
                {
                    if (logToConsole)
                    {
                        Log($"{playerName} ({steamID}) Has a private profile, kicking player...");
                    }

                    netuser.Kick(NetError.Facepunch_Whitelist_Failure, true);
                }
                break;

            case 401:
                Log("Webrequest failed, invalid Steam API key.");
                break;

            case 404:
            case 503:
                Log("Webrequest failed. Steam API unavailable.");
                break;

            default:
                Log($"Webrequest failed. Error code {code}.");
                break;
            }
        }
Example #8
0
        public void uLink_OnPlayerConnected(uLink.NetworkPlayer player)
        {
            connectingPlayer = (NetUser)player.localData;
            String playerSteamURL = "http://steamcommunity.com/profiles/" + connectingPlayer.userID.ToString();

            WebClient wc = new WebClient ();
            wc.DownloadStringCompleted += (sender, e) =>
            {
                userProfilePage = e.Result;

                if (lockGroup != "none")
                {
                    if (userProfilePage.IndexOf("http://steamcommunity.com/groups/" + lockGroup) == -1)
                    {
                        connectingPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
                    }
                }

                Match vacMatch = Regex.Match(userProfilePage, @"^([0-9]{1,5}) day\(s\) since last ban$");
                if (vacMatch.Success)
                {
                    int daysSinceBan = Convert.ToInt32(vacMatch.Groups[1].Value);
                    if (daysSinceBan < minVacDays)
                    {
                        connectingPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
                    }
                }
            };

            wc.DownloadStringAsync(new Uri(playerSteamURL));
        }
Example #9
0
 void cmdKick(string userid, string name, string reason)
 {
     cachedUser = rust.FindPlayer(userid);
     if (cachedUser != null)
     {
         cachedUser.Kick(NetError.Facepunch_Kick_RCON, true);
     }
 }
Example #10
0
        public void Disconnect()
        {
            NetUser netUser = this.ourPlayer.netUser;

            if (netUser.connected && (netUser != null))
            {
                netUser.Kick(NetError.NoError, true);
            }
        }
Example #11
0
 public static bool loginNotice(NetUser user)
 {
     try
     {
         if (Core.blackList.Contains(user.userID))
         {
             Core.tempConnect.Add(user.userID);
             user.Kick(NetError.Facepunch_Kick_Ban, true);
             return(false);
         }
         if (Core.config.GetBoolSetting("WhiteList", "enabled") && !Core.whiteList.Contains(user.userID))
         {
             user.Kick(NetError.Facepunch_Whitelist_Failure, true);
         }
         if (!Core.userCache.ContainsKey(user.userID))
         {
             Core.userCache.Add(user.userID, user.displayName);
         }
         else if (user.displayName != Core.userCache[user.userID])
         {
             Core.userCache[user.userID] = user.displayName;
         }
         if (Administrator.IsAdmin(user.userID) && Administrator.GetAdmin(user.userID).HasPermission("RCON"))
         {
             user.admin = true;
         }
         Core.motd(user.networkPlayer);
         if (Core.config.GetBoolSetting("Settings", "join_notice"))
         {
             foreach (PlayerClient client in PlayerClient.All)
             {
                 if (client.userID != user.userID)
                 {
                     Util.sayUser(client.netPlayer, Core.Name, user.displayName + " " + RustPPModule.JoinMsg);
                 }
             }
         }
     }
     catch
     {
     }
     return(true);
 }
Example #12
0
 public static bool loginNotice(NetUser user)
 {
     try
     {
         if (Core.blackList.Contains(user.userID))
         {
             Core.tempConnect.Add(user.userID);
             user.Kick(NetError.Facepunch_Connector_VAC_Banned, true);
             return(false);
         }
         if (((Core.config.GetSetting("WhiteList", "enabled") != null) && (Core.config.GetSetting("WhiteList", "enabled").ToLower() == "true")) && !Core.whiteList.Contains(user.userID))
         {
             user.Kick(NetError.Facepunch_Connector_AuthFailure, true);
         }
         if (!Core.userCache.ContainsKey(user.userID))
         {
             Core.userCache.Add(user.userID, user.displayName);
         }
         else if (user.displayName != Core.userCache[user.userID])
         {
             Core.userCache[user.userID] = user.displayName;
         }
         if (Administrator.IsAdmin(user.userID) && Administrator.GetAdmin(user.userID).HasPermission("RCON"))
         {
             user.admin = true;
         }
         Core.motd(user.networkPlayer);
         if (Core.config.GetSetting("Settings", "join_notice").ToLower() == "true")
         {
             foreach (PlayerClient client in PlayerClient.All)
             {
                 if (client.userID != user.userID)
                 {
                     Util.sayUser(client.netPlayer, Core.Name, user.displayName + " has joined the server");
                 }
             }
         }
     }
     catch
     {
     }
     return(true);
 }
Example #13
0
 private object IOnGetClientMove(NetUser netUser, Vector3 pos)
 {
     if (float.IsNaN(pos.x) || float.IsInfinity(pos.x) || float.IsNaN(pos.y) || float.IsInfinity(pos.y) || float.IsNaN(pos.z) || float.IsInfinity(pos.z))
     {
         Interface.Oxide.LogInfo($"Banned {netUser.displayName} [{netUser.userID}] for sending bad packets (possible teleport hack)");
         BanList.Add(netUser.userID, netUser.displayName, "Sending bad packets (possible teleport hack)");
         netUser.Kick(NetError.ConnectionBanned, true);
         return(false);
     }
     return(null);
 }
Example #14
0
 void cmdBan(string userid, string name, string reason)
 {
     if (!BanList.Contains(Convert.ToUInt64(userid)))
     {
         BanList.Add(Convert.ToUInt64(userid), name, reason);
         BanList.Save();
     }
     cachedUser = rust.FindPlayer(userid);
     if (cachedUser != null)
     {
         cachedUser.Kick(NetError.ConnectionBanned, true);
     }
 }
Example #15
0
        public void Disconnect()
        {
            NetUser netUser = this.ourPlayer.netUser;

            if (netUser == null)
            {
                throw new InvalidOperationException("Player's netUser is null.");
            }

            if (netUser.connected)
            {
                netUser.Kick(NetError.NoError, true);
            }
        }
Example #16
0
        void cmdBanID(NetUser netUser, string command, string[] args)
        {
            ulong netUserID = netUser.userID;

            if (!(netUser.CanAdmin() || permission.UserHasPermission(netUserID.ToString(), permissionCanBan)))
            {
                rust.Notice(netUser, lang.GetMessage("NoPermission", this), lang.GetMessage("FailureIcon", this));
                return;
            }

            if (args.Length == 0 || args == null)
            {
                rust.Notice(netUser, lang.GetMessage("InvalidSyntax", this), lang.GetMessage("FailureIcon", this));
                return;
            }

            string targetUserIDString = args[0];

            if (targetUserIDString.Length != 17)
            {
                rust.Notice(netUser, lang.GetMessage("InvalidSteamID", this), lang.GetMessage("FailureIcon", this));
                return;
            }

            if (rust.FindPlayer(targetUserIDString) == null)
            {
                rust.RunServerCommand($"banid {targetUserIDString} \"OfflinePlayer\" \"Reason\"");

                rust.Notice(netUser, $"{lang.GetMessage("SuccessBannedNotice", this)} {targetUserIDString}.", lang.GetMessage("SuccessIcon", this));
                rust.BroadcastChat(lang.GetMessage("ChatPrefix", this), $"{targetUserIDString} {lang.GetMessage("SuccessBannedBroadcast", this)}");

                Puts($"{targetUserIDString} {lang.GetMessage("SuccessBannedBroadcast", this)}");

                return;
            }

            NetUser targetUser = rust.FindPlayer(targetUserIDString);

            targetUser.Ban();
            targetUser.Kick(NetError.Facepunch_Kick_Ban, true);

            rust.Notice(netUser, $"{lang.GetMessage("SuccessBannedNotice", this)} {targetUser.displayName}.", lang.GetMessage("SuccessIcon", this));
            rust.BroadcastChat(lang.GetMessage("ChatPrefix", this), $"{targetUser.displayName} {lang.GetMessage("SuccessBannedBroadcast", this)}");

            Puts($"{targetUser.displayName} {lang.GetMessage("SuccessBannedBroadcast", this)}");

            return;
        }
Example #17
0
        void CheckWarns(NetUser netuser)
        {
            string ID      = netuser.userID.ToString();
            var    PlayerW = GetPlayerData(ID);

            if (PlayerW.playerWarns == WarnMax)
            {
                rust.BroadcastChat(chatPrefix, string.Format(GetMessage("WarnPunition"), netuser.displayName));
                timer.Once(0.1f, () =>
                {
                    netuser.Ban();
                    netuser.Kick(NetError.Facepunch_Kick_Ban, true);
                });
                SaveData();
            }
        }
Example #18
0
 public void KickPlayer(NetUser badPlayer, NetUser myAdmin)
 {
     if (badPlayer == myAdmin)
     {
         Util.sayUser(myAdmin.networkPlayer, Core.Name, "You can't kick yourself.");
     }
     else if (Administrator.IsAdmin(badPlayer.userID) && !Administrator.GetAdmin(myAdmin.userID).HasPermission("RCON"))
     {
         Util.sayUser(myAdmin.networkPlayer, Core.Name, badPlayer.displayName + " is an administrator. You can't kick administrators.");
     }
     else
     {
         Administrator.NotifyAdmins(string.Format("{0} has been kicked by {1}.", badPlayer.displayName, myAdmin.displayName));
         badPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
     }
 }
Example #19
0
        void cmdBan(string userid, string name = "Unknown", string reason = "Unkown")
        {
            ulong playerid;

            if (!ulong.TryParse(userid, out playerid))
            {
                return;
            }
            if (!BanList.Contains(playerid))
            {
                BanList.Add(playerid, name, reason);
                BanList.Save();
            }
            cachedUser = rust.FindPlayer(userid);
            if (cachedUser != null)
            {
                cachedUser.Kick(NetError.ConnectionBanned, true);
            }
        }
 public void CheckActivityConnections()
 {
     if ((NetCull.isServerRunning && (Users.NetworkTimeout > 0f)) && ((UpdateTime / 0x3e8) < Users.NetworkTimeout))
     {
         foreach (uLink.NetworkPlayer player in NetCull.connections)
         {
             NetUser   key       = NetUser.Find(player);
             Character character = null;
             if (((key != null) && Truth.LastPacketTime.ContainsKey(key)) && Character.FindByUser(key.userID, out character))
             {
                 float num = Time.time - Truth.LastPacketTime[key];
                 if ((Truth.LastPacketTime[key] > 0f) && (num > Users.NetworkTimeout))
                 {
                     Helper.LogWarning(string.Concat(new object[] { "Kicked by Server [", key.displayName, ":", key.userID, "]: No receiving packets from client ", num.ToString("F2"), " second(s)." }), true);
                     key.Kick(NetError.ConnectionTimeout, true);
                 }
             }
         }
     }
 }
Example #21
0
        void OnPlayerConnected(NetUser netuser, ConsoleSystem.Arg arg)
        {
            if (hasAccess(netuser, "namefilter.allowed"))
            {
                return;
            }
            var name       = netuser.displayName.ToLower();
            var namenormal = netuser.displayName;

            foreach (string value in block)
            {
                if (name.Contains(value))
                {
                    if (broadcast)
                    {
                        rust.SendChatMessage(netuser, prefixo, string.Format(GetMessage("InvalidNickName", netuser.userID.ToString()), name));
                    }
                    netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                    return;
                }
            }
        }
Example #22
0
 void OnPlayerConnected(NetUser netuser)
 {
     if (apikey != "")
     {
         var url = string.Format("http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key={0}&steamids={1}", apikey, netuser.playerClient.userID.ToString());
         Interface.GetMod().GetLibrary <WebRequests>("WebRequests").EnqueueGet(url, (code, response) =>
         {
             if (code != 200)
             {
                 return;
             }
             var jsonresponse = JsonConvert.DeserializeObject <Dictionary <string, object> >(response, jsonsettings);
             if (!(jsonresponse["players"] is List <object>))
             {
                 return;
             }
             if (!(((List <object>)jsonresponse["players"])[0] is Dictionary <string, object>))
             {
                 return;
             }
             var playerdata = ((List <object>)jsonresponse["players"])[0] as Dictionary <string, object>;
             if (Convert.ToInt32(playerdata["NumberOfVACBans"]) < maxAllowed)
             {
                 return;
             }
             if (shouldBan)
             {
                 if (!BanList.Contains(netuser.playerClient.userID))
                 {
                     BanList.Add(netuser.playerClient.userID, netuser.displayName, string.Format("{0} VAC Bans", playerdata["NumberOfVACBans"].ToString()));
                 }
             }
             netuser.Kick(NetError.Facepunch_Kick_RCON, true);
         }
                                                                               , this);
     }
 }
Example #23
0
        void cmdBan(NetUser netUser, string command, string[] args)
        {
            ulong netUserID = netUser.userID;

            if (!(netUser.CanAdmin() || permission.UserHasPermission(netUserID.ToString(), permissionCanBan)))
            {
                rust.Notice(netUser, lang.GetMessage("NoPermission", this), lang.GetMessage("FailureIcon", this));
                return;
            }

            if (args.Length == 0 || args == null)
            {
                rust.Notice(netUser, lang.GetMessage("InvalidSyntax", this), lang.GetMessage("FailureIcon", this));
                return;
            }

            NetUser targetUser = rust.FindPlayer(args[0]);

            if (targetUser == null)
            {
                rust.Notice(netUser, lang.GetMessage("NoPlayersFound", this), lang.GetMessage("FailureIcon", this));
                return;
            }

            rust.RunClientCommand(targetUser, $"deathscreen.reason \"{lang.GetMessage("DeathscreenBanned", this)}\"");
            rust.RunClientCommand(targetUser, "deathscreen.show");

            targetUser.Ban();
            targetUser.Kick(NetError.Facepunch_Kick_Ban, true);

            rust.Notice(netUser, $"{lang.GetMessage("SuccessBannedNotice", this)} {targetUser.displayName}.", lang.GetMessage("SuccessIcon", this));
            rust.BroadcastChat(lang.GetMessage("ChatPrefix", this), $"{targetUser.displayName} {lang.GetMessage("SuccessBannedBroadcast", this)}");

            Puts($"{targetUser.displayName} {lang.GetMessage("SuccessBannedBroadcast", this)}");

            return;
        }
Example #24
0
 void OnPlayerChat(NetUser netuser, string message)
 {
     if (!Cooldown.ContainsKey(netuser.userID))
     {
         Cooldown[netuser.userID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds;
     }
     else
     {
         double calc = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - Cooldown[netuser.userID];
         if (calc < Seconds)
         {
             SendReply(netuser, Message);
             if (!Detections.ContainsKey(netuser.userID))
             {
                 Detections[netuser.userID] = 0;
             }
             Detections[netuser.userID] = Detections[netuser.userID] + 1;
             if (Detections[netuser.userID] == MaxWarnings)
             {
                 netuser.Kick(NetError.Facepunch_Kick_Violation, true);
                 foreach (NetUser all in rust.GetAllNetUsers())
                 {
                     rust.Notice(all, netuser.displayName + " has been auto kicked for spamming");
                 }
             }
         }
         else
         {
             Cooldown[netuser.userID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds;
             if (Detections.ContainsKey(netuser.userID))
             {
                 Detections.Remove(netuser.userID);
             }
         }
     }
 }
Example #25
0
 public static void KickUser(NetUser player, NetError reason, bool notify)
 {
     // reson = NetError.Facepunch_Kick_Violation
     player.Kick(reason, notify);
     //player.playerClient.netUser.Kick(reason, notify);
 }
Example #26
0
 public static bool loginNotice(NetUser user)
 {
     try
     {
         if (Core.blackList.Contains(user.userID))
         {
             Core.tempConnect.Add(user.userID);
             user.Kick(NetError.Facepunch_Connector_VAC_Banned, true);
             return false;
         }
         if (((Core.config.GetSetting("WhiteList", "enabled") != null) && (Core.config.GetSetting("WhiteList", "enabled").ToLower() == "true")) && !Core.whiteList.Contains(user.userID))
         {
             user.Kick(NetError.Facepunch_Connector_AuthFailure, true);
         }
         if (!Core.userCache.ContainsKey(user.userID))
         {
             Core.userCache.Add(user.userID, user.displayName);
         }
         else if (user.displayName != Core.userCache[user.userID])
         {
             Core.userCache[user.userID] = user.displayName;
         }
         if (Administrator.IsAdmin(user.userID) && Administrator.GetAdmin(user.userID).HasPermission("RCON"))
         {
             user.admin = true;
         }
         Core.motd(user.networkPlayer);
         if (Core.config.GetSetting("Settings", "join_notice").ToLower() == "true")
         {
             foreach (PlayerClient client in PlayerClient.All)
             {
                 if (client.userID != user.userID)
                 {
                     Util.sayUser(client.netPlayer, Core.Name, user.displayName + " has joined the server");
                 }
             }
         }
     }
     catch
     {
     }
     return true;
 }
Example #27
0
 private void OnPlayerConnected(NetUser netuser)
 {
     timer.Once(3f, () => {
         if (netuser.playerClient == null)
         {
             return;
         }
         string Name = netuser.displayName.ToString();
         string ID   = netuser.userID.ToString();
         if (!AcessUsers(netuser))
         {
             if (reservedName || reservedWord)
             {
                 foreach (var pair in Data.Names.ToList())
                 {
                     if (reservedName)
                     {
                         if (pair.Value.ToLower() == Name.ToLower())
                         {
                             if (pair.Key != ID)
                             {
                                 rust.Notice(netuser, string.Format(GetMessage("ReservedName", ID), Name), "!", timeNotices);
                                 netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                                 return;
                             }
                         }
                     }
                     if (reservedWord)
                     {
                         if (Name.ToLower().Contains(pair.Value.ToLower()))
                         {
                             if (pair.Key != ID)
                             {
                                 rust.Notice(netuser, string.Format(GetMessage("ReservedWord", ID), pair.Value), "!", timeNotices);
                                 netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                                 return;
                             }
                         }
                     }
                 }
             }
             if (changeName)
             {
                 if (Data.Names.ContainsKey(ID))
                 {
                     if (Data.Names[ID] != Name)
                     {
                         rust.Notice(netuser, string.Format(GetMessage("ChangeName", ID), Data.Names[ID]), "!", timeNotices);
                         netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                         return;
                     }
                 }
             }
         }
         if (Data.Names.ContainsKey(ID))
         {
             if (Data.Names[ID] != Name)
             {
                 Data.Names[ID] = Name;
                 SaveData();
             }
         }
         else if (!Data.Names.ContainsKey(ID))
         {
             Data.Names.Add(ID, Name);
             SaveData();
         }
     });
 }
Example #28
0
 public static void whitelistKick(NetUser target, string reason)
 {
     if (target != null)
     {
         kickQueue.Add(target.userID.ToString());
         Broadcast.broadcastTo(target.networkPlayer, "You were kicked! Reason: " + reason);
         Vars.conLog.Error("Nonwhitelisted player " + target.displayName + " (" + target.userID + ") attempted to join.");
         target.Kick(NetError.Facepunch_Kick_Ban, false);
     }
 }
Example #29
0
 public static void kickPlayer(NetUser target, string reason, bool isBan)
 {
     if (target != null)
     {
         kickQueue.Add(target.userID.ToString());
         Broadcast.broadcastTo(target.networkPlayer, (isBan ? "You were banned! Reason: " : "You were kicked! Reason: ") + reason);
         if (isBan)
             Vars.conLog.Error("Banned player " + target.displayName + " (" + target.userID + ") attempted to join.");
         target.Kick(NetError.Facepunch_Kick_Ban, false);
         if (!isBan)
         {
             Broadcast.broadcastAll("Player " + target.displayName + " was kicked. Reason: " + reason);
             Vars.conLog.Error("Player " + target.displayName + " (" + target.userID + ") was kicked for: " + reason);
         }
     }
 }
Example #30
0
 private object IOnGetClientMove(NetUser netUser, Vector3 pos)
 {
     if (float.IsNaN(pos.x) || float.IsInfinity(pos.x) || float.IsNaN(pos.y) || float.IsInfinity(pos.y) || float.IsNaN(pos.z) || float.IsInfinity(pos.z))
     {
         Interface.Oxide.LogInfo($"Banned {netUser.displayName} [{netUser.userID}] for sending bad packets (possible teleport hack)");
         BanList.Add(netUser.userID, netUser.displayName, "Sending bad packets (possible teleport hack)");
         netUser.Kick(NetError.ConnectionBanned, true);
         return false;
     }
     return null;
 }
Example #31
0
 public static void KickUser(NetUser player, NetError reason, bool notify)
 {
     // reson = NetError.Facepunch_Kick_Violation
     player.Kick(reason, notify);
     //player.playerClient.netUser.Kick(reason, notify);
 }
Example #32
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 #33
0
 public static void otherKick(NetUser target, string reason)
 {
     if (target != null)
     {
         kickQueue.Add(target.userID.ToString());
         Broadcast.broadcastTo(target.networkPlayer, "You were kicked! Reason: " + reason);
         Vars.conLog.Error("Player " + target.displayName + " (" + target.userID + ") was kicked for: " + reason);
         target.Kick(NetError.Facepunch_Kick_Ban, false);
     }
 }
Example #34
0
        void cmdChatAddbanip(NetUser netuser, string command, string[] args)
        {
            if (!hasAccess(netuser, "canbanip"))
            {
                rust.SendChatMessage(netuser, systemname, "you are not allowed to use this command"); return;
            }
            var playerdata = GetPlayerdata("Blacklist(ip)");

            if (args.Length == 0)
            {
                rust.SendChatMessage(netuser, systemname, "wrong syntax: /banip playername");
                return;
            }
            NetUser targetuser = rust.FindPlayer(args[0]);

            if (targetuser == null)
            {
                rust.SendChatMessage(netuser, systemname, couldntFindPlayer);
                return;
            }
            if (shouldpreventbanonself)
            {
                if (targetuser == netuser)
                {
                    rust.SendChatMessage(netuser, systemname, banselfmsg);
                    return;
                }
            }
            if (shouldpreventbanonrconadmin)
            {
                if (hasimmunity(targetuser, "ipbanimunity"))
                {
                    rust.SendChatMessage(netuser, systemname, isrconadminmsg); return;
                }
            }
            cachedSteamid = targetuser.playerClient.userID.ToString();
            cachedName    = targetuser.playerClient.userName.ToString();
            var targetname = targetuser.displayName;
            var targetid   = targetuser.networkPlayer.externalIP;

            cachedName   = string.Empty;
            cachedReason = string.Empty;
            if (args.Length > 1)
            {
                if (cachedName == string.Empty)
                {
                    cachedName = args[1];
                    if (args.Length > 2)
                    {
                        cachedReason = args[2];
                    }
                    else
                    {
                        cachedReason = args[1];
                    }
                }
            }
            cachedReason += "(" + netuser.displayName + ")";

            if (playerdata.ContainsKey(targetid))
            {
                rust.SendChatMessage(netuser, systemname, targetname + " " + alreadybanned);
                return;
            }
            if (!playerdata.ContainsKey(targetid))
            {
                var targetuid = targetuser.playerClient.userID.ToString();
                var staffname = netuser.displayName;
                var staffid   = netuser.playerClient.userID.ToString();
                rust.SendChatMessage(netuser, systemname, targetname + " " + addedban + " " + cachedReason);
                playerdata.Add(targetid, targetname + " " + "(id:" + targetuid + " )" + "(by: " + netuser.displayName + ")" + " (staffid: " + staffid + " )" + "Reason: " + cachedReason);
                if (shouldcrashclientafterban)
                {
                    rust.RunClientCommand(targetuser, "quit");
                }
                if (shouldkick)
                {
                    targetuser.Kick(NetError.Facepunch_Kick_RCON, true);
                }
                if (shouldbanid)
                {
                    var targetuserid = targetuser.playerClient.userID.ToString();
                    Interface.CallHook("cmdBan", targetuserid, targetname, cachedReason);
                }
                if (shouldcapframesafterban)
                {
                    rust.RunClientCommand(targetuser, "render.frames " + capedamount);
                    rust.RunClientCommand(targetuser, "config.save");
                }
                if (shouldbroadcast)
                {
                    Broadcast(string.Format(targetname + " " + banMessage + " " + cachedReason));
                }
                return;
            }
            rust.SendChatMessage(netuser, systemname, notinbanlist + " " + targetname.ToString());
        }
Example #35
0
        void OnPlayerConnected(NetUser netuser)
        {
            var playerdata   = GetPlayerdata("Blacklist(ip)");
            var Whitelist    = GetPlayerWl("Blacklist(ip.wl)");
            var targetid     = netuser.networkPlayer.externalIP;
            var targetuserid = netuser.playerClient.userID.ToString();
            var targetname   = netuser.displayName;

            if (shouldrebindknownhackkey)
            {
                rust.RunClientCommand(netuser, "input.bind Chat Return q");
                rust.RunClientCommand(netuser, "input.bind Inventory Tab LeftAlt");
            }
            if (shouldlogall)
            {
                var playerlog = GetPlayerinfo(targetname);
                if (playerlog.ContainsKey("id"))
                {
                    playerlog.Remove("id");
                    playerlog.Remove("name");
                    playerlog.Remove("ip");
                }
                playerlog.Add("id", targetuserid);
                playerlog.Add("name", targetname);
                playerlog.Add("ip", targetid);
            }
            if (Whitelist.ContainsKey(targetuserid))
            {
                return;
            }
            if (playerdata.ContainsKey(targetid))
            {
                if (shouldcapframes)
                {
                    rust.RunClientCommand(netuser, "render.frames " + capedamount);
                    rust.RunClientCommand(netuser, "config.save");
                }
                if (shouldcrashclient)
                {
                    rust.RunClientCommand(netuser, "quit");
                }
                if (shouldbanidifbanned)
                {
                    Interface.CallHook("cmdBan", targetuserid.ToString(), targetname, cachedreason + " " + targetid + " )");
                }

                if (shouldbroadcasttryconnect)
                {
                    Broadcast(string.Format(targetname + " " + tryconnectMessage));
                }
                netuser.Kick(NetError.Facepunch_Kick_RCON, true);
                if (shouldlogall)
                {
                    return;
                }
                if (shouldallowwhitelist)
                {
                    var playerlog = GetPlayerinfo(targetname);
                    if (playerlog.ContainsKey("id"))
                    {
                        playerlog.Remove("id");
                        playerlog.Remove("name");
                        playerlog.Remove("ip");
                    }
                    playerlog.Add("id", targetuserid);
                    playerlog.Add("name", targetname);
                    playerlog.Add("ip", targetid);
                }
            }
        }