public Task LoginAttemptFailed(string ipAddress, string source, string userName, string machineGuid, string osName, string osVersion, int count, DateTime timestamp) { var events = new IPAddressLogEvent[] { new IPAddressLogEvent(ipAddress, userName, source, count, IPAddressEventType.Blocked, IPBanService.UtcNow, true) }; service.AddIPAddressLogEvents(events); return(Task.CompletedTask); }
/// <summary> /// Process event viewer XML /// </summary> /// <param name="xml">XML</param> public void ProcessEventViewerXml(string xml) { IPBanLog.Debug("Processing event viewer xml: {0}", xml); XmlDocument doc = ParseXml(xml); IPAddressLogEvent info = ExtractEventViewerXml(doc); if (info != null && info.FoundMatch && (info.Type == IPAddressEventType.FailedLogin || info.Type == IPAddressEventType.SuccessfulLogin)) { if (!FindSourceAndUserNameForInfo(info, doc)) { // bad ip address return; } service.AddIPAddressLogEvents(new IPAddressLogEvent[] { info }); IPBanLog.Debug("Event viewer found: {0}, {1}, {2}, {4}", info.IPAddress, info.Source, info.UserName, info.Type); } }
/// <summary> /// Process event viewer XML /// </summary> /// <param name="xml">XML</param> public void ProcessEventViewerXml(string xml) { IPBanLog.Debug("Processing event viewer xml: {0}", xml); XmlDocument doc = ParseXml(xml); IPAddressLogEvent info = ExtractEventViewerXml(doc); if (info != null && info.FoundMatch) { if (info.Type == IPAddressEventType.FailedLogin && !AddFailedLoginForEventViewerXml(info, doc)) { // if fail to add the failed login (bad ip, etc.) exit out return; } System.Diagnostics.Debug.Assert(info.Type == IPAddressEventType.FailedLogin || info.Type == IPAddressEventType.SuccessfulLogin); service.AddIPAddressLogEvents(new IPAddressLogEvent[] { info }); IPBanLog.Debug("Event viewer found: {0}, {1}, {2}, {4}", info.IPAddress, info.Source, info.UserName, info.Type); } }