public PresenceInfo GetPresenceInfo(UUID agentID) { PresenceInfo agent = new PresenceInfo(); Dictionary <string, object> where = new Dictionary <string, object>(1); where["AgentID"] = agentID; List <string> query = GD.Query(new string[] { "*" }, "baninfo", new QueryFilter { andFilters = where }, null, null, null); if (query.Count == 0) //Couldn't find it, return null then. { return(null); } agent.AgentID = agentID; if (query[1] != "") { agent.Flags = (PresenceInfo.PresenceInfoFlags)Enum.Parse(typeof(PresenceInfo.PresenceInfoFlags), query[1]); } agent.KnownAlts = Util.ConvertToList(query[2]); agent.KnownID0s = Util.ConvertToList(query[3]); agent.KnownIPs = Util.ConvertToList(query[4]); agent.KnownMacs = Util.ConvertToList(query[5]); agent.KnownViewers = Util.ConvertToList(query[6]); agent.LastKnownID0 = query[7]; agent.LastKnownIP = query[8]; agent.LastKnownMac = query[9]; agent.LastKnownViewer = query[10]; agent.Platform = query[11]; return(agent); }
private bool CheckViewer(PresenceInfo info, out string reason) { //Check for banned viewers if (IsViewerBanned(info.LastKnownViewer)) { reason = "Viewer is banned"; return(false); } //Overkill, and perm-bans people who only log in with a bad viewer once //foreach (string mac in info.KnownMacs) { if (info.LastKnownMac.Contains("000")) { //Ban this asshole reason = "Viewer is blocked (MAC)"; return(false); } } //foreach (string id0 in info.KnownID0s) { if (info.LastKnownID0.Contains("000")) { //Ban this asshole reason = "Viewer is blocked (IO)"; return(false); } } reason = ""; return(true); }
protected void SetUserInfo(IScene scene, string[] cmdparams) { string name = MainConsole.Instance.Prompt("Name: "); UserAccount account = m_accountService.GetUserAccount(null, name); if (account == null) { MainConsole.Instance.Warn("Cannot find user."); return; } UUID AgentID = account.PrincipalID; PresenceInfo info = GetInformation(AgentID); if (info == null) { MainConsole.Instance.Warn("Cannot find user."); return; } try { info.Flags = (PresenceInfo.PresenceInfoFlags) Enum.Parse(typeof(PresenceInfo.PresenceInfoFlags), MainConsole.Instance.Prompt("Flags (Clean, Suspected, Known, Banned): ", "Clean")); } catch { MainConsole.Instance.Warn("Please choose a valid flag: Clean, Suspected, Known, Banned"); return; } MainConsole.Instance.Info("Set Flags for " + info.AgentID.ToString() + " to " + info.Flags.ToString()); presenceInfo.UpdatePresenceInfo(info); }
public PresenceInfo GetPresenceInfo(UUID agentID) { PresenceInfo agent = new PresenceInfo(); Dictionary<string, object> where = new Dictionary<string, object>(1); where["AgentID"] = agentID; List<string> query = GD.Query(new string[] { "*" }, "baninfo", new QueryFilter { andFilters = where }, null, null, null); if (query.Count == 0) //Couldn't find it, return null then. { return null; } agent.AgentID = agentID; if (query[1] != "") { agent.Flags = (PresenceInfo.PresenceInfoFlags)Enum.Parse(typeof(PresenceInfo.PresenceInfoFlags), query[1]); } agent.KnownAlts = Util.ConvertToList(query[2]); agent.KnownID0s = Util.ConvertToList(query[3]); agent.KnownIPs = Util.ConvertToList(query[4]); agent.KnownMacs = Util.ConvertToList(query[5]); agent.KnownViewers = Util.ConvertToList(query[6]); agent.LastKnownID0 = query[7]; agent.LastKnownIP = query[8]; agent.LastKnownMac = query[9]; agent.LastKnownViewer = query[10]; agent.Platform = query[11]; return agent; }
private bool DoGC(PresenceInfo info) { bool update = false; List <string> newIPs = new List <string>(); foreach (string ip in info.KnownIPs) { string[] split; string newIP = ip; if ((split = ip.Split(':')).Length > 1) { //Remove the port if it exists and force an update newIP = split[0]; update = true; } if (!newIPs.Contains(newIP)) { newIPs.Add(newIP); } } if (info.KnownIPs.Count != newIPs.Count) { update = true; } info.KnownIPs = newIPs; return(update); }
private bool CheckClient(UUID AgentID, out string message) { message = ""; IAgentInfo data = DataManager.DataManager.RequestPlugin <IAgentConnector>().GetAgent(AgentID); if (data != null && ((data.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan || (data.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan)) { message = "User is banned from the grid."; return(false); } PresenceInfo info = GetInformation(AgentID); if (m_checkOnLogin) { CheckForSimilarities(info); } if (!CheckThreatLevel(info, out message)) { return(false); } if (!CheckViewer(info)) { message = "This viewer has been blocked from connecting, please connect with a different viewer."; return(false); } return(true); }
private bool CheckViewer(PresenceInfo info) { //Check for banned viewers if (IsViewerBanned(info.LastKnownViewer)) { return(false); } foreach (string mac in info.KnownMacs) { if (mac.Contains("000")) { //Ban this asshole return(false); } //if (mac.Length != 32) // return false; //Valid length! } foreach (string id0 in info.KnownID0s) { if (id0.Contains("000")) { //Ban this asshole return(false); } //if (id0.Length != 32) // return false; //Valid length! } return(true); }
protected void UnBlockUser(IScene scene, string[] cmdparams) { string name = MainConsole.Instance.Prompt("Name: "); UserAccount account = m_accountService.GetUserAccount(null, name); if (account == null) { MainConsole.Instance.Warn("Cannot find user."); return; } UUID AgentID = account.PrincipalID; PresenceInfo info = GetInformation(AgentID); if (info == null) { MainConsole.Instance.Warn("Cannot find user."); return; } info.Flags = PresenceInfo.PresenceInfoFlags.Clean; presenceInfo.UpdatePresenceInfo(info); var conn = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>(); IAgentInfo agentInfo = conn.GetAgent(AgentID); agentInfo.Flags &= IAgentFlags.TempBan; agentInfo.Flags &= IAgentFlags.PermBan; if (agentInfo.OtherAgentInformation.ContainsKey("TemperaryBanInfo") == true) { agentInfo.OtherAgentInformation.Remove("TemperaryBanInfo"); } conn.UpdateAgent(agentInfo); MainConsole.Instance.Fatal("User block removed"); }
public void UpdatePresenceInfo(PresenceInfo agent) { List <object> SetValues = new List <object>(); List <string> SetRows = new List <string>(); SetRows.Add("AgentID" /*"AgentID"*/); SetRows.Add("Flags" /*"Flags"*/); SetRows.Add("KnownAlts" /*"KnownAlts"*/); SetRows.Add("KnownID0s" /*"KnownID0s"*/); SetRows.Add("KnownIPs" /*"KnownIPs"*/); SetRows.Add("KnownMacs" /*"KnownMacs"*/); SetRows.Add("KnownViewers" /*"KnownViewers"*/); SetRows.Add("LastKnownID0" /*"LastKnownID0"*/); SetRows.Add("LastKnownIP" /*"LastKnownIP"*/); SetRows.Add("LastKnownMac" /*"LastKnownMac"*/); SetRows.Add("LastKnownViewer" /*"LastKnownViewer"*/); SetRows.Add("Platform" /*"Platform"*/); SetValues.Add(agent.AgentID); SetValues.Add(agent.Flags); SetValues.Add(Util.ConvertToString(agent.KnownAlts)); SetValues.Add(Util.ConvertToString(agent.KnownID0s)); SetValues.Add(Util.ConvertToString(agent.KnownIPs)); SetValues.Add(Util.ConvertToString(agent.KnownMacs)); SetValues.Add(Util.ConvertToString(agent.KnownViewers)); SetValues.Add(agent.LastKnownID0); SetValues.Add(agent.LastKnownIP); SetValues.Add(agent.LastKnownMac); SetValues.Add(agent.LastKnownViewer); SetValues.Add(agent.Platform); GD.Replace("baninfo", SetRows.ToArray(), SetValues.ToArray()); }
private PresenceInfo UpdatePresenceInfo(UUID AgentID, PresenceInfo oldInfo, string ip, string version, string platform, string mac, string id0) { PresenceInfo info = new PresenceInfo(); info.AgentID = AgentID; if (!string.IsNullOrEmpty(ip)) { info.LastKnownIP = ip; } if (!string.IsNullOrEmpty(version)) { info.LastKnownViewer = version; } if (!string.IsNullOrEmpty(platform)) { info.Platform = platform; } if (!string.IsNullOrEmpty(mac)) { info.LastKnownMac = mac; } if (!string.IsNullOrEmpty(id0)) { info.LastKnownID0 = id0; } if (!oldInfo.KnownID0s.Contains(info.LastKnownID0)) { oldInfo.KnownID0s.Add(info.LastKnownID0); } if (!oldInfo.KnownIPs.Contains(info.LastKnownIP)) { oldInfo.KnownIPs.Add(info.LastKnownIP); } if (!oldInfo.KnownMacs.Contains(info.LastKnownMac)) { oldInfo.KnownMacs.Add(info.LastKnownMac); } if (!oldInfo.KnownViewers.Contains(info.LastKnownViewer)) { oldInfo.KnownViewers.Add(info.LastKnownViewer); } info.KnownViewers = oldInfo.KnownViewers; info.KnownMacs = oldInfo.KnownMacs; info.KnownIPs = oldInfo.KnownIPs; info.KnownID0s = oldInfo.KnownID0s; info.KnownAlts = oldInfo.KnownAlts; info.Flags = oldInfo.Flags; presenceInfo.UpdatePresenceInfo(info); return(info); }
private void DisplayUserInfo(PresenceInfo info) { MainConsole.Instance.Info("User Info for " + info.AgentID); MainConsole.Instance.Info(" AgentID: " + info.AgentID); MainConsole.Instance.Info(" Flags: " + info.Flags); /*MainConsole.Instance.Info(" ID0: " + info.LastKnownID0); * MainConsole.Instance.Info(" IP: " + info.LastKnownIP); * MainConsole.Instance.Info(" Mac: " + info.LastKnownMac); * MainConsole.Instance.Info(" Viewer: " + info.LastKnownViewer); * MainConsole.Instance.Info(" Platform: " + info.Platform);*/ }
private bool CheckViewer(PresenceInfo info, out string reason) { //Check for banned viewers if (IsViewerBanned(info.LastKnownViewer)) { reason = "Viewer is banned"; return(false); } reason = ""; return(true); }
private void AddFlag(ref PresenceInfo info, PresenceInfo.PresenceInfoFlags presenceInfoFlags) { if (presenceInfoFlags == 0) { return; } info.Flags &= PresenceInfo.PresenceInfoFlags.Clean; //Remove clean if (presenceInfoFlags == PresenceInfo.PresenceInfoFlags.Known) { info.Flags &= PresenceInfo.PresenceInfoFlags.Clean; //Remove suspected as well } info.Flags |= presenceInfoFlags; //Add the flag }
public void SetUserLevel(UUID AgentID, PresenceInfo.PresenceInfoFlags presenceInfoFlags) { if (!m_enabled) { return; } //Get PresenceInfo info = GetInformation(AgentID); //Set the flags info.Flags = presenceInfoFlags; //Save presenceInfo.UpdatePresenceInfo(info); }
private PresenceInfo GetInformation(UUID AgentID) { PresenceInfo oldInfo = presenceInfo.GetPresenceInfo(AgentID); if (oldInfo == null) { PresenceInfo info = new PresenceInfo(); info.AgentID = AgentID; info.Flags = PresenceInfo.PresenceInfoFlags.Clean; presenceInfo.UpdatePresenceInfo(info); oldInfo = presenceInfo.GetPresenceInfo(AgentID); } return(oldInfo); }
protected void BlockUser(IScene scene, string[] cmdparams) { string name = MainConsole.Instance.Prompt("Name: "); UserAccount account = m_accountService.GetUserAccount(null, name); if (account == null) { MainConsole.Instance.Warn("Cannot find user."); return; } UUID AgentID = account.PrincipalID; PresenceInfo info = GetInformation(AgentID); if (info == null) { MainConsole.Instance.Warn("Cannot find user."); return; } var conn = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>(); IAgentInfo agentInfo = conn.GetAgent(AgentID); if ( MainConsole.Instance.Prompt("Do you want to have this only be a temporary ban?", "no", new List <string>() { "yes", "no" }).ToLower() == "yes") { float days = float.Parse(MainConsole.Instance.Prompt("How long (in days) should this ban last?", "5.0")); agentInfo.Flags |= IAgentFlags.TempBan; agentInfo.OtherAgentInformation["TemperaryBanInfo"] = DateTime.Now.ToUniversalTime().AddDays(days); } else { info.Flags |= PresenceInfo.PresenceInfoFlags.Banned; presenceInfo.UpdatePresenceInfo(info); agentInfo.Flags |= IAgentFlags.PermBan; } conn.UpdateAgent(agentInfo); MainConsole.Instance.Fatal("User blocked from logging in"); }
public void UpdatePresenceInfo(PresenceInfo agent) { Dictionary <string, object> row = new Dictionary <string, object>(12); row["AgentID"] = agent.AgentID; row["Flags"] = agent.Flags; row["KnownAlts"] = Util.ConvertToString(agent.KnownAlts); row["KnownID0s"] = Util.ConvertToString(agent.KnownID0s); row["KnownIPs"] = Util.ConvertToString(agent.KnownIPs); row["KnownMacs"] = Util.ConvertToString(agent.KnownMacs); row["KnownViewers"] = Util.ConvertToString(agent.KnownViewers); row["LastKnownID0"] = agent.LastKnownID0; row["LastKnownIP"] = agent.LastKnownIP; row["LastKnownMac"] = agent.LastKnownMac; row["LastKnownViewer"] = agent.LastKnownViewer; row["Platform"] = agent.Platform; GD.Replace("baninfo", row); }
private bool CheckClient(UUID AgentID, out string message) { message = ""; PresenceInfo info = GetInformation(AgentID); if (m_checkOnLogin) { CheckForSimilarities(info); } if (!CheckThreatLevel(info, out message)) { return(false); } return(CheckViewer(info, out message)); }
public bool CheckUser(UUID AgentID, string ip, string version, string platform, string mac, string id0, out string message) { message = ""; if (!m_enabled) { return(true); } PresenceInfo oldInfo = GetInformation(AgentID); oldInfo = UpdatePresenceInfo(AgentID, oldInfo, ip, version, platform, mac, id0); if (m_debug) { DisplayUserInfo(oldInfo); } return(CheckClient(AgentID, out message)); }
private bool CheckThreatLevel(PresenceInfo info, out string message) { message = ""; if ((info.Flags & PresenceInfo.PresenceInfoFlags.Banned) == PresenceInfo.PresenceInfoFlags.Banned) { message = "Banned agent."; return(false); } if (GrieferAllowLevel == AllowLevel.AllowKnown) { return(true); //Allow all } else if (GrieferAllowLevel == AllowLevel.AllowCleanOnly) { //Allow people with only clean flag or suspected alt if ((info.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected || (info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known || (info.Flags & PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.Banned) == PresenceInfo.PresenceInfoFlags.Banned) { message = "Not a Clean agent and have been denied access."; return(false); } } else if (GrieferAllowLevel == AllowLevel.AllowSuspected) { //Block all alts of knowns, and suspected alts of knowns if ((info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known || (info.Flags & PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.Banned) == PresenceInfo.PresenceInfoFlags.Banned) { message = "Not a Clean agent and have been denied access."; return(false); } } return(true); }
protected void UserInfo(IScene scene, string[] cmdparams) { string name = MainConsole.Instance.Prompt("Name: "); UserAccount account = m_accountService.GetUserAccount(null, name); if (account == null) { MainConsole.Instance.Warn("Cannot find user."); return; } UUID AgentID = account.PrincipalID; PresenceInfo info = GetInformation(AgentID); if (info == null) { MainConsole.Instance.Warn("Cannot find user."); return; } DisplayUserInfo(info); }
private void DisplayUserInfo(PresenceInfo info) { UserAccount account = m_accountService.GetUserAccount(null, info.AgentID); if (account != null) { MainConsole.Instance.Info("User Info for " + account.Name); } else { MainConsole.Instance.Info("User Info for " + info.AgentID); } MainConsole.Instance.Info(" AgentID: " + info.AgentID); MainConsole.Instance.Info(" Flags: " + info.Flags); MainConsole.Instance.Info(" ID0: " + info.LastKnownID0); MainConsole.Instance.Info(" IP: " + info.LastKnownIP); //MainConsole.Instance.Info(" Mac: " + info.LastKnownMac); MainConsole.Instance.Info(" Viewer: " + info.LastKnownViewer); MainConsole.Instance.Info(" Platform: " + info.Platform); if (info.KnownAlts.Count > 0) { MainConsole.Instance.Info(" Known Alt Accounts: "); foreach (var acc in info.KnownAlts) { account = m_accountService.GetUserAccount(null, UUID.Parse(acc)); if (account != null) { MainConsole.Instance.Info(" " + account.Name); } else { MainConsole.Instance.Info(" " + acc); } } } }
private void DisplayUserInfo(PresenceInfo info) { UserAccount account = m_accountService.GetUserAccount(null, info.AgentID); if (account != null) MainConsole.Instance.Info("User Info for " + account.Name); else MainConsole.Instance.Info("User Info for " + info.AgentID); MainConsole.Instance.Info(" AgentID: " + info.AgentID); MainConsole.Instance.Info(" Flags: " + info.Flags); MainConsole.Instance.Info(" ID0: " + info.LastKnownID0); MainConsole.Instance.Info(" IP: " + info.LastKnownIP); //MainConsole.Instance.Info(" Mac: " + info.LastKnownMac); MainConsole.Instance.Info(" Viewer: " + info.LastKnownViewer); MainConsole.Instance.Info(" Platform: " + info.Platform); if (info.KnownAlts.Count > 0) { MainConsole.Instance.Info(" Known Alt Accounts: "); foreach (var acc in info.KnownAlts) { account = m_accountService.GetUserAccount(null, UUID.Parse(acc)); if (account != null) MainConsole.Instance.Info(" " + account.Name); else MainConsole.Instance.Info(" " + acc); } } }
private bool CheckViewer(PresenceInfo info, out string reason) { //Check for banned viewers if (IsViewerBanned(info.LastKnownViewer)) { reason = "Viewer is banned"; return false; } reason = ""; return true; }
private void CheckForSimilarities(PresenceInfo info) { presenceInfo.Check(info, m_useIncludeList ? m_allowedViewers : m_bannedViewers, m_useIncludeList); }
private bool CheckThreatLevel(PresenceInfo info, out string message) { message = ""; if ((info.Flags & PresenceInfo.PresenceInfoFlags.Banned) == PresenceInfo.PresenceInfoFlags.Banned) { message = "Banned agent."; return false; } if (GrieferAllowLevel == AllowLevel.AllowKnown) return true; //Allow all else if (GrieferAllowLevel == AllowLevel.AllowCleanOnly) { //Allow people with only clean flag or suspected alt if ((info.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected || (info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known || (info.Flags & PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.Banned) == PresenceInfo.PresenceInfoFlags.Banned) { message = "Not a Clean agent and have been denied access."; return false; } } else if (GrieferAllowLevel == AllowLevel.AllowSuspected) { //Block all alts of knowns, and suspected alts of knowns if ((info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known || (info.Flags & PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown) == PresenceInfo.PresenceInfoFlags.KnownAltAccountOfKnown || (info.Flags & PresenceInfo.PresenceInfoFlags.Banned) == PresenceInfo.PresenceInfoFlags.Banned) { message = "Not a Clean agent and have been denied access."; return false; } } return true; }
private void AddFlag (ref PresenceInfo info, PresenceInfo.PresenceInfoFlags presenceInfoFlags) { if (presenceInfoFlags == 0) return; info.Flags &= PresenceInfo.PresenceInfoFlags.Clean; //Remove clean if (presenceInfoFlags == PresenceInfo.PresenceInfoFlags.Known) info.Flags &= PresenceInfo.PresenceInfoFlags.Clean; //Remove suspected as well info.Flags |= presenceInfoFlags; //Add the flag }
public void Check (PresenceInfo info, List<string> viewers, bool includeList) { // //Check passwords //Check IPs, Mac's, etc // bool needsUpdated = false; #region Check Password Dictionary<string, object> where = new Dictionary<string, object>(1); where["UUID"] = info.AgentID; List<string> query = GD.Query(new string[] { "passwordHash" }, DatabaseToAuthTable, new QueryFilter { andFilters = where }, null, null, null); if (query.Count != 0) { where.Remove("UUID"); where["passwordHash"] = query[0]; query = GD.Query(new string[] { "UUID" }, DatabaseToAuthTable, new QueryFilter { andFilters = where }, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo.AgentID == info.AgentID) { continue; } CoralateLists (info, suspectedInfo); needsUpdated = true; } } #endregion #region Check ID0, IP, Mac, etc //Only check suspected and known offenders in this scan // 2 == Flags QueryFilter filter = new QueryFilter(); filter.orMultiFilters["Flags"] = new List<object>(5); filter.orMultiFilters["Flags"].Add("SuspectedAltAccountOfKnown"); filter.orMultiFilters["Flags"].Add("Known"); filter.orMultiFilters["Flags"].Add("SuspectedAltAccountOfSuspected"); filter.orMultiFilters["Flags"].Add("Banned"); filter.orMultiFilters["Flags"].Add("Suspected"); query = GD.Query(new string[1] { "AgentID" }, "baninfo", filter, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo.AgentID == info.AgentID) continue; foreach (string ID0 in suspectedInfo.KnownID0s) { if (info.KnownID0s.Contains(ID0)) { CoralateLists (info, suspectedInfo); needsUpdated = true; } } foreach (string IP in suspectedInfo.KnownIPs) { if (info.KnownIPs.Contains(IP.Split(':')[0])) { CoralateLists (info, suspectedInfo); needsUpdated = true; } } foreach (string Mac in suspectedInfo.KnownMacs) { if (info.KnownMacs.Contains(Mac)) { CoralateLists (info, suspectedInfo); needsUpdated = true; } } } foreach (string viewer in info.KnownViewers) { if (IsViewerBanned(viewer, includeList, viewers)) { if ((info.Flags & PresenceInfo.PresenceInfoFlags.Clean) == PresenceInfo.PresenceInfoFlags.Clean) { //Update them to suspected for their viewer AddFlag (ref info, PresenceInfo.PresenceInfoFlags.Suspected); //And update them later needsUpdated = true; } else if ((info.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected) { //Suspected, we don't really want to move them higher than this... } else if ((info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known) { //Known, can't update anymore } } } if (DoGC(info) & !needsUpdated)//Clean up all info needsUpdated = true; #endregion //Now update ours if (needsUpdated) UpdatePresenceInfo(info); }
public void UpdatePresenceInfo(PresenceInfo agent) { List<object> SetValues = new List<object>(); List<string> SetRows = new List<string>(); SetRows.Add("AgentID"/*"AgentID"*/); SetRows.Add("Flags"/*"Flags"*/); SetRows.Add("KnownAlts"/*"KnownAlts"*/); SetRows.Add("KnownID0s"/*"KnownID0s"*/); SetRows.Add("KnownIPs"/*"KnownIPs"*/); SetRows.Add("KnownMacs"/*"KnownMacs"*/); SetRows.Add("KnownViewers"/*"KnownViewers"*/); SetRows.Add("LastKnownID0"/*"LastKnownID0"*/); SetRows.Add("LastKnownIP"/*"LastKnownIP"*/); SetRows.Add("LastKnownMac"/*"LastKnownMac"*/); SetRows.Add("LastKnownViewer"/*"LastKnownViewer"*/); SetRows.Add("Platform"/*"Platform"*/); SetValues.Add(agent.AgentID); SetValues.Add(agent.Flags); SetValues.Add(Util.ConvertToString(agent.KnownAlts)); SetValues.Add(Util.ConvertToString(agent.KnownID0s)); SetValues.Add(Util.ConvertToString(agent.KnownIPs)); SetValues.Add(Util.ConvertToString(agent.KnownMacs)); SetValues.Add(Util.ConvertToString(agent.KnownViewers)); SetValues.Add(agent.LastKnownID0); SetValues.Add(agent.LastKnownIP); SetValues.Add(agent.LastKnownMac); SetValues.Add(agent.LastKnownViewer); SetValues.Add(agent.Platform); GD.Replace("baninfo", SetRows.ToArray(), SetValues.ToArray()); }
public void UpdatePresenceInfo(PresenceInfo agent) { Dictionary<string, object> row = new Dictionary<string, object>(12); row["AgentID"] = agent.AgentID; row["Flags"] = agent.Flags; row["KnownAlts"] = Util.ConvertToString(agent.KnownAlts); row["KnownID0s"] = Util.ConvertToString(agent.KnownID0s); row["KnownIPs"] = Util.ConvertToString(agent.KnownIPs); row["KnownMacs"] = Util.ConvertToString(agent.KnownMacs); row["KnownViewers"] = Util.ConvertToString(agent.KnownViewers); row["LastKnownID0"] = agent.LastKnownID0; row["LastKnownIP"] = agent.LastKnownIP; row["LastKnownMac"] = agent.LastKnownMac; row["LastKnownViewer"] = agent.LastKnownViewer; row["Platform"] = agent.Platform; GD.Replace("baninfo", row); }
public void SetUserLevel(UUID AgentID, PresenceInfo.PresenceInfoFlags presenceInfoFlags) { if (!m_enabled) return; //Get PresenceInfo info = GetInformation(AgentID); //Set the flags info.Flags = presenceInfoFlags; //Save presenceInfo.UpdatePresenceInfo(info); }
private void CoralateLists(PresenceInfo info, PresenceInfo suspectedInfo) { bool addedFlag = false; PresenceInfo.PresenceInfoFlags Flag = 0; if ((suspectedInfo.Flags & PresenceInfo.PresenceInfoFlags.Clean) == PresenceInfo.PresenceInfoFlags.Clean && (info.Flags & PresenceInfo.PresenceInfoFlags.Clean) == PresenceInfo.PresenceInfoFlags.Clean) { //They are both clean, do nothing } else if ((suspectedInfo.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected || (info.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected) { //Suspected, update them both addedFlag = true; AddFlag(ref info, PresenceInfo.PresenceInfoFlags.Suspected); AddFlag(ref suspectedInfo, PresenceInfo.PresenceInfoFlags.Suspected); } else if ((suspectedInfo.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known || (info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known) { //Known, update them both addedFlag = true; AddFlag(ref info, PresenceInfo.PresenceInfoFlags.Known); AddFlag(ref suspectedInfo, PresenceInfo.PresenceInfoFlags.Known); } //Add the alt account flag AddFlag(ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccount); AddFlag(ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccount); if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Suspected || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected || info.Flags == PresenceInfo.PresenceInfoFlags.Suspected || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected) { //They might be an alt, but the other is clean, so don't bother them too much AddFlag(ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected); AddFlag(ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected); } else if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Known || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || info.Flags == PresenceInfo.PresenceInfoFlags.Known || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) { //Flag 'em AddFlag(ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); AddFlag(ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); } //Add each user to the list of alts, then add the lists of both together info.KnownAlts.Add(suspectedInfo.AgentID.ToString()); suspectedInfo.KnownAlts.Add(info.AgentID.ToString()); //Add the lists together List <string> alts = new List <string> (); foreach (string alt in info.KnownAlts) { if (!alts.Contains(alt)) { alts.Add(alt); } } foreach (string alt in suspectedInfo.KnownAlts) { if (!alts.Contains(alt)) { alts.Add(alt); } } //If we have added a flag, we need to update ALL alts as well if (addedFlag && alts.Count != 0) { foreach (string alt in alts) { PresenceInfo altInfo = GetPresenceInfo(UUID.Parse(alt)); if (altInfo != null) { //Give them the flag as well AddFlag(ref altInfo, Flag); //Add the alt account flag AddFlag(ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccount); //Also give them the flags for alts if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Suspected || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected || info.Flags == PresenceInfo.PresenceInfoFlags.Suspected || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected) { //They might be an alt, but the other is clean, so don't bother them too much AddFlag(ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected); } else if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Known || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || info.Flags == PresenceInfo.PresenceInfoFlags.Known || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) { //Flag 'em AddFlag(ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); } //And update them in the db UpdatePresenceInfo(suspectedInfo); } } } //Replace both lists now that they are merged info.KnownAlts = alts; suspectedInfo.KnownAlts = alts; //Update them, as we changed their info, we get updated below UpdatePresenceInfo(suspectedInfo); }
private PresenceInfo GetInformation(UUID AgentID) { PresenceInfo oldInfo = presenceInfo.GetPresenceInfo(AgentID); if (oldInfo == null) { PresenceInfo info = new PresenceInfo(); info.AgentID = AgentID; info.Flags = PresenceInfo.PresenceInfoFlags.Clean; presenceInfo.UpdatePresenceInfo(info); oldInfo = presenceInfo.GetPresenceInfo(AgentID); } return oldInfo; }
private PresenceInfo UpdatePresenceInfo(UUID AgentID, PresenceInfo oldInfo, string ip, string version, string platform, string mac, string id0) { PresenceInfo info = new PresenceInfo(); info.AgentID = AgentID; if (!string.IsNullOrEmpty(ip)) info.LastKnownIP = ip; if (!string.IsNullOrEmpty(version)) info.LastKnownViewer = version; if (!string.IsNullOrEmpty(platform)) info.Platform = platform; if (!string.IsNullOrEmpty(mac)) info.LastKnownMac = mac; if (!string.IsNullOrEmpty(id0)) info.LastKnownID0 = id0; if (!oldInfo.KnownID0s.Contains(info.LastKnownID0)) oldInfo.KnownID0s.Add(info.LastKnownID0); if (!oldInfo.KnownIPs.Contains(info.LastKnownIP)) oldInfo.KnownIPs.Add(info.LastKnownIP); if (!oldInfo.KnownMacs.Contains(info.LastKnownMac)) oldInfo.KnownMacs.Add(info.LastKnownMac); if (!oldInfo.KnownViewers.Contains(info.LastKnownViewer)) oldInfo.KnownViewers.Add(info.LastKnownViewer); info.KnownViewers = oldInfo.KnownViewers; info.KnownMacs = oldInfo.KnownMacs; info.KnownIPs = oldInfo.KnownIPs; info.KnownID0s = oldInfo.KnownID0s; info.KnownAlts = oldInfo.KnownAlts; info.Flags = oldInfo.Flags; presenceInfo.UpdatePresenceInfo(info); return info; }
private bool DoGC(PresenceInfo info) { bool update = false; List<string> newIPs = new List<string>(); foreach (string ip in info.KnownIPs) { string[] split; string newIP = ip; if ((split = ip.Split(':')).Length > 1) { //Remove the port if it exists and force an update newIP = split[0]; update = true; } if (!newIPs.Contains(newIP)) newIPs.Add(newIP); } if (info.KnownIPs.Count != newIPs.Count) update = true; info.KnownIPs = newIPs; return update; }
public void Check(PresenceInfo info, List <string> viewers, bool includeList) { // //Check passwords //Check IPs, Mac's, etc // bool needsUpdated = false; #region Check Password Dictionary <string, object> where = new Dictionary <string, object>(1); where["UUID"] = info.AgentID; List <string> query = GD.Query(new string[] { "passwordHash" }, DatabaseToAuthTable, new QueryFilter { andFilters = where }, null, null, null); if (query.Count != 0) { where.Remove("UUID"); where["passwordHash"] = query[0]; query = GD.Query(new string[] { "UUID" }, DatabaseToAuthTable, new QueryFilter { andFilters = where }, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo.AgentID == info.AgentID) { continue; } CoralateLists(info, suspectedInfo); needsUpdated = true; } } #endregion #region Check ID0, IP, Mac, etc //Only check suspected and known offenders in this scan // 2 == Flags QueryFilter filter = new QueryFilter(); filter.orMultiFilters["Flags"] = new List <object>(5); filter.orMultiFilters["Flags"].Add("SuspectedAltAccountOfKnown"); filter.orMultiFilters["Flags"].Add("Known"); filter.orMultiFilters["Flags"].Add("SuspectedAltAccountOfSuspected"); filter.orMultiFilters["Flags"].Add("Banned"); filter.orMultiFilters["Flags"].Add("Suspected"); query = GD.Query(new string[1] { "AgentID" }, "baninfo", filter, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo.AgentID == info.AgentID) { continue; } foreach (string ID0 in suspectedInfo.KnownID0s) { if (info.KnownID0s.Contains(ID0)) { CoralateLists(info, suspectedInfo); needsUpdated = true; } } foreach (string IP in suspectedInfo.KnownIPs) { if (info.KnownIPs.Contains(IP.Split(':')[0])) { CoralateLists(info, suspectedInfo); needsUpdated = true; } } foreach (string Mac in suspectedInfo.KnownMacs) { if (info.KnownMacs.Contains(Mac)) { CoralateLists(info, suspectedInfo); needsUpdated = true; } } } foreach (string viewer in info.KnownViewers) { if (IsViewerBanned(viewer, includeList, viewers)) { if ((info.Flags & PresenceInfo.PresenceInfoFlags.Clean) == PresenceInfo.PresenceInfoFlags.Clean) { //Update them to suspected for their viewer AddFlag(ref info, PresenceInfo.PresenceInfoFlags.Suspected); //And update them later needsUpdated = true; } else if ((info.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected) { //Suspected, we don't really want to move them higher than this... } else if ((info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known) { //Known, can't update anymore } } } if (DoGC(info) & !needsUpdated)//Clean up all info { needsUpdated = true; } #endregion //Now update ours if (needsUpdated) { UpdatePresenceInfo(info); } }
private void CoralateLists (PresenceInfo info, PresenceInfo suspectedInfo) { bool addedFlag = false; PresenceInfo.PresenceInfoFlags Flag = 0; if ((suspectedInfo.Flags & PresenceInfo.PresenceInfoFlags.Clean) == PresenceInfo.PresenceInfoFlags.Clean && (info.Flags & PresenceInfo.PresenceInfoFlags.Clean) == PresenceInfo.PresenceInfoFlags.Clean) { //They are both clean, do nothing } else if ((suspectedInfo.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected || (info.Flags & PresenceInfo.PresenceInfoFlags.Suspected) == PresenceInfo.PresenceInfoFlags.Suspected) { //Suspected, update them both addedFlag = true; AddFlag (ref info, PresenceInfo.PresenceInfoFlags.Suspected); AddFlag (ref suspectedInfo, PresenceInfo.PresenceInfoFlags.Suspected); } else if ((suspectedInfo.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known || (info.Flags & PresenceInfo.PresenceInfoFlags.Known) == PresenceInfo.PresenceInfoFlags.Known) { //Known, update them both addedFlag = true; AddFlag (ref info, PresenceInfo.PresenceInfoFlags.Known); AddFlag (ref suspectedInfo, PresenceInfo.PresenceInfoFlags.Known); } //Add the alt account flag AddFlag (ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccount); AddFlag (ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccount); if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Suspected || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected || info.Flags == PresenceInfo.PresenceInfoFlags.Suspected || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected) { //They might be an alt, but the other is clean, so don't bother them too much AddFlag (ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected); AddFlag (ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected); } else if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Known || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || info.Flags == PresenceInfo.PresenceInfoFlags.Known || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) { //Flag 'em AddFlag (ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); AddFlag (ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); } //Add each user to the list of alts, then add the lists of both together info.KnownAlts.Add (suspectedInfo.AgentID.ToString ()); suspectedInfo.KnownAlts.Add (info.AgentID.ToString ()); //Add the lists together List<string> alts = new List<string> (); foreach (string alt in info.KnownAlts) { if (!alts.Contains (alt)) alts.Add (alt); } foreach (string alt in suspectedInfo.KnownAlts) { if (!alts.Contains (alt)) alts.Add (alt); } //If we have added a flag, we need to update ALL alts as well if (addedFlag && alts.Count != 0) { foreach (string alt in alts) { PresenceInfo altInfo = GetPresenceInfo (UUID.Parse (alt)); if (altInfo != null) { //Give them the flag as well AddFlag (ref altInfo, Flag); //Add the alt account flag AddFlag (ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccount); //Also give them the flags for alts if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Suspected || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected || info.Flags == PresenceInfo.PresenceInfoFlags.Suspected || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected) { //They might be an alt, but the other is clean, so don't bother them too much AddFlag (ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfSuspected); } else if (suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.Known || suspectedInfo.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown || info.Flags == PresenceInfo.PresenceInfoFlags.Known || info.Flags == PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown) { //Flag 'em AddFlag (ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); } //And update them in the db UpdatePresenceInfo (suspectedInfo); } } } //Replace both lists now that they are merged info.KnownAlts = alts; suspectedInfo.KnownAlts = alts; //Update them, as we changed their info, we get updated below UpdatePresenceInfo (suspectedInfo); }