bool CheckClient(UUID agentID, out string message) { message = ""; PresenceInfo info = GetInformation(agentID); if (info == null) { return(false); // something bad here.. } if (m_checkOnLogin) { CheckForSimilarities(info); } else { _checkForSimilaritiesLater.Add(agentID, info); } if (!CheckThreatLevel(info, out message)) { return(false); } return(CheckViewer(info, out message)); }
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 + " to " + info.Flags); presenceInfo.UpdatePresenceInfo(info); }
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); }
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("TemporaryBanInfo")) { agentInfo.OtherAgentInformation.Remove("TemporaryBanInfo"); } conn.UpdateAgent(agentInfo); MainConsole.Instance.Fatal("User block removed"); }
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[] { "*" }, "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], false); agent.KnownID0s = Util.ConvertToList(query[3], false); agent.KnownIPs = Util.ConvertToList(query[4], false); agent.KnownMacs = Util.ConvertToList(query[5], false); agent.KnownViewers = Util.ConvertToList(query[6], false); agent.LastKnownID0 = query[7]; agent.LastKnownIP = query[8]; agent.LastKnownMac = query[9]; agent.LastKnownViewer = query[10]; agent.Platform = query[11]; return(agent); }
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 [] { "*" }, "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], false); agent.KnownID0s = Util.ConvertToList (query [3], false); agent.KnownIPs = Util.ConvertToList (query [4], false); agent.KnownMacs = Util.ConvertToList (query [5], false); agent.KnownViewers = Util.ConvertToList (query [6], false); agent.LastKnownID0 = query [7]; agent.LastKnownIP = query [8]; agent.LastKnownMac = query [9]; agent.LastKnownViewer = query [10]; agent.Platform = query [11]; return agent; }
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); }
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); }
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); }
public void SetUserLevel(UUID agentID, PresenceInfo.PresenceInfoFlags presenceInfoFlags) { if (!m_enabled) { return; } PresenceInfo info = GetInformation(agentID); if (info != null) { info.Flags = presenceInfoFlags; presenceInfo.UpdatePresenceInfo(info); } }
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 ["TemporaryBanInfo"] = 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); }
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 } 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 known, and suspected alts of known 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); }
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)); }
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); }
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); if (oldInfo == null) { return(false); // something bad here.. } oldInfo = UpdatePresenceInfo(agentID, oldInfo, ip, version, platform, mac, id0); if (m_debug) { DisplayUserInfo(oldInfo); } return(CheckClient(agentID, out message)); }
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); } } } }
bool CheckViewer (PresenceInfo info, out string reason) { //Check for banned viewers if (IsViewerBanned (info.LastKnownViewer)) { reason = "Viewer is banned"; return false; } reason = ""; return true; }
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); } } }
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; }
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; }
void CheckForSimilarities (PresenceInfo info) { presenceInfo.Check (info, m_useIncludeList ? m_allowedViewers : m_bannedViewers, m_useIncludeList); }
void CoralateLists(PresenceInfo info, PresenceInfo suspectedInfo) { bool addedFlag = false; const PresenceInfo.PresenceInfoFlags INFOFLAG = 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 them AddFlag(ref info, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); AddFlag(ref suspectedInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); } //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 (!alts.Contains(suspectedInfo.AgentID.ToString())) { alts.Add(suspectedInfo.AgentID.ToString()); } if (!alts.Contains(info.AgentID.ToString())) { alts.Add(info.AgentID.ToString()); } //If we have added a flag, we need to update ALL alts as well if (addedFlag || alts.Count != 0) { foreach ( string alt in alts.Where(s => s != suspectedInfo.AgentID.ToString() && s != info.AgentID.ToString()) ) { PresenceInfo altInfo = GetPresenceInfo(UUID.Parse(alt)); if (altInfo != null) { //Give them the flag as well AddFlag(ref altInfo, INFOFLAG); //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 them AddFlag(ref altInfo, PresenceInfo.PresenceInfoFlags.SuspectedAltAccountOfKnown); } altInfo.KnownAlts = new List <string> (alts.Where(s => s != altInfo.AgentID.ToString())); //And update them in the db UpdatePresenceInfo(altInfo); } } } //Replace both lists now that they are merged info.KnownAlts = new List <string> (alts.Where(s => s != info.AgentID.ToString())); suspectedInfo.KnownAlts = new List <string> (alts.Where(s => s != suspectedInfo.AgentID.ToString())); //Update them, as we changed their info, we get updated below UpdatePresenceInfo(suspectedInfo); }
void CheckForSimilarities(PresenceInfo info) { presenceInfo.Check(info, m_useIncludeList ? m_allowedViewers : m_bannedViewers, m_useIncludeList); }
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); }
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 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 known, and suspected alts of known 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; }
public void Check(PresenceInfo info, List<string> viewers, bool includeList) { // //Check passwords //Check IPs, Mac's, etc // bool needsUpdated = false; #region Check Password QueryFilter filter = new QueryFilter(); filter.andFilters["UUID"] = info.AgentID; List<string> query = GD.Query(new[] {"passwordHash"}, DatabaseToAuthTable, filter, null, null, null); if (query.Count != 0) { filter = new QueryFilter(); filter.andFilters["passwordHash"] = query[0]; query = GD.Query(new[] {"UUID"}, DatabaseToAuthTable, filter, 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 filter = new QueryFilter(); query = GD.Query(new[] {"AgentID"}, "baninfo", filter, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo == null || 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 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 void CoralateLists(PresenceInfo info, PresenceInfo suspectedInfo) { bool addedFlag = false; const 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 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 (!alts.Contains(suspectedInfo.AgentID.ToString())) alts.Add(suspectedInfo.AgentID.ToString()); if (!alts.Contains(info.AgentID.ToString())) alts.Add(info.AgentID.ToString()); //If we have added a flag, we need to update ALL alts as well if (addedFlag || alts.Count != 0) { foreach ( string alt in alts.Where(s => s != suspectedInfo.AgentID.ToString() && s != info.AgentID.ToString()) ) { 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); } altInfo.KnownAlts = new List<string>(alts.Where(s => s != altInfo.AgentID.ToString())); //And update them in the db UpdatePresenceInfo(altInfo); } } } //Replace both lists now that they are merged info.KnownAlts = new List<string>(alts.Where(s => s != info.AgentID.ToString())); suspectedInfo.KnownAlts = new List<string>(alts.Where(s => s != suspectedInfo.AgentID.ToString())); //Update them, as we changed their info, we get updated below UpdatePresenceInfo(suspectedInfo); }
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 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; PresenceInfo info = GetInformation (agentID); if (info != null) { info.Flags = presenceInfoFlags; presenceInfo.UpdatePresenceInfo (info); } }
public void Check(PresenceInfo info, List <string> viewers, bool includeList) { // //Check passwords //Check IPs, Mac's, etc // bool needsUpdated = false; #region Check Password QueryFilter filter = new QueryFilter(); filter.andFilters ["UUID"] = info.AgentID; List <string> query = GD.Query(new [] { "passwordHash" }, DatabaseToAuthTable, filter, null, null, null); if (query.Count != 0) { filter = new QueryFilter(); filter.andFilters ["passwordHash"] = query [0]; query = GD.Query(new [] { "UUID" }, DatabaseToAuthTable, filter, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo != null) { 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 filter = new QueryFilter(); query = GD.Query(new [] { "AgentID" }, "baninfo", filter, null, null, null); foreach (string ID in query) { PresenceInfo suspectedInfo = GetPresenceInfo(UUID.Parse(ID)); if (suspectedInfo == null || 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); } }