public LogAssociation(LogAssociationType AssoType, RefererAssociationType RefAssoType, IronHtml.UrlInHtmlMatch UrlMatchLevel, LogAssociationMatchLevel MtcLvl, Session SrcLog, Session DestLog) { AssociationType = AssoType; RefererMatch = RefAssoType; UrlMatch = UrlMatchLevel; MatchLevel = MtcLvl; SourceLog = SrcLog; DestinationLog = DestLog; }
List <LogAssociation> FindFormSubmitAssociations(Session MainLog, List <Session> SessionList, RefererAssociationType RefAssoType) { List <LogAssociation> Associations = new List <LogAssociation>(); if (MainLog.Response == null) { return(Associations); } //Match form submission with absolute url match and absolute field/values match foreach (IronHtml.FormElement FormEle in MainLog.Response.Html.GetFormElements()) { try { Request FormReq = new Request(FormEle.Action); foreach (Session Sess in SessionList) { if (!Sess.Request.IsNormal) { continue; } if (Sess.Request.FullUrl.Equals(FormReq.FullUrl) && Sess.Request.Method.Equals(FormEle.Method, StringComparison.OrdinalIgnoreCase) && Sess.Response != null) { if (FormEle.DoAllInputFieldValuesMatchRequest(Sess.Request)) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.FormSubmission, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.FormNamesAndValues, MainLog, Sess); Associations.Add(LogAsso); } else if (FormEle.DoHiddenInputFieldValuesMatchRequest(Sess.Request)) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.FormSubmission, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.FormNamesAndHiddenValuesOnly, MainLog, Sess); Associations.Add(LogAsso); } else if (FormEle.DoInputFieldNamesMatchRequest(Sess.Request)) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.FormSubmission, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.FormNamesOnly, MainLog, Sess); Associations.Add(LogAsso); } } } } catch { Request FormReq = new Request(MainLog.Request.RelativeUrlToAbsoluteUrl(FormEle.Action)); foreach (Session Sess in SessionList) { if (!Sess.Request.IsNormal) { continue; } if (Sess.Request.FullUrl.Equals(FormReq.FullUrl) && Sess.Request.Method.Equals(FormEle.Method, StringComparison.OrdinalIgnoreCase) && Sess.Response != null) { if (FormEle.DoAllInputFieldValuesMatchRequest(Sess.Request)) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.FormSubmission, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.FormNamesAndValues, MainLog, Sess); Associations.Add(LogAsso); } else if (FormEle.DoHiddenInputFieldValuesMatchRequest(Sess.Request)) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.FormSubmission, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.FormNamesAndHiddenValuesOnly, MainLog, Sess); Associations.Add(LogAsso); } else if (FormEle.DoInputFieldNamesMatchRequest(Sess.Request)) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.FormSubmission, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.FormNamesOnly, MainLog, Sess); Associations.Add(LogAsso); } } } } } return(Associations); }
List <LogAssociation> FindLinkClickAssociations(Session MainLog, List <Session> SessionList, RefererAssociationType RefAssoType) { List <LogAssociation> Associations = new List <LogAssociation>(); if (MainLog.Response == null) { return(Associations); } //Match link urls with absolute match foreach (string LinkUrl in MainLog.Response.Html.GetDecodedValues("a", "href")) { try { Request LinkReq = new Request(LinkUrl.Trim()); foreach (Session Sess in SessionList) { if (!Sess.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { continue; } if (Sess.Request.FullUrl.Equals(LinkReq.FullUrl) && Sess.Response != null) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.LinkClick, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.UrlMatchOnly, MainLog, Sess); Associations.Add(LogAsso); } } } catch { Request LinkReq = new Request(MainLog.Request.RelativeUrlToAbsoluteUrl(LinkUrl.Trim())); foreach (Session Sess in SessionList) { if (!Sess.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { continue; } if (Sess.Request.FullUrl.Equals(LinkReq.FullUrl) && Sess.Response != null) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.LinkClick, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.UrlMatchOnly, MainLog, Sess); Associations.Add(LogAsso); } } } } return(Associations); }
List <LogAssociation> FindImgSourceAssociations(Session MainLog, List <Session> SessionList, RefererAssociationType RefAssoType) { List <LogAssociation> Associations = new List <LogAssociation>(); if (MainLog.Response == null) { return(Associations); } //Match img urls with absolute match and response content type match foreach (string ImgSrc in MainLog.Response.Html.GetDecodedValues("img", "src")) { try { Request ImgReq = new Request(ImgSrc.Trim()); foreach (Session Sess in SessionList) { if (!Sess.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { continue; } if (Sess.Request.FullUrl.Equals(ImgReq.FullUrl) && Sess.Response != null)// && Sess.Response.Code == 304 || Sess.Response.IsBinary) { if (Sess.Response.Code == 304 || Sess.Response.IsBinary) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.ExternalImage, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.UrlMatchAndResponseType, MainLog, Sess); Associations.Add(LogAsso); } else { LogAssociation LogAsso = new LogAssociation(LogAssociationType.ExternalImage, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.UrlMatchOnly, MainLog, Sess); Associations.Add(LogAsso); } } } } catch { Request ImgReq = new Request(MainLog.Request.RelativeUrlToAbsoluteUrl(ImgSrc.Trim())); foreach (Session Sess in SessionList) { if (!Sess.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { continue; } if (Sess.Request.FullUrl.Equals(ImgReq.FullUrl) && Sess.Response != null)// && Sess.Response.Code == 304 || Sess.Response.IsBinary) { if (Sess.Response.Code == 304 || Sess.Response.IsBinary) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.ExternalImage, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.UrlMatchAndResponseType, MainLog, Sess); Associations.Add(LogAsso); } else { LogAssociation LogAsso = new LogAssociation(LogAssociationType.ExternalImage, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.UrlMatchOnly, MainLog, Sess); Associations.Add(LogAsso); } } } } } return(Associations); }
List <LogAssociation> FindRedirectAssociations(Session MainLog, List <Session> SessionList, RefererAssociationType RefAssoType) { List <LogAssociation> Associations = new List <LogAssociation>(); if (MainLog.Response == null) { return(null); } if (MainLog.Response.IsRedirect) { if (MainLog.Response.Headers.Has("Location")) { string RedirUrl = MainLog.Response.Headers.Get("Location").Trim(); try { Request RedirReq = new Request(RedirUrl); foreach (Session Sess in SessionList) { if (!Sess.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { continue; } if (Sess.Request.FullUrl.Equals(RedirReq.FullUrl) && Sess.Response != null) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.Redirect, RefAssoType, IronHtml.UrlInHtmlMatch.FullAbsolute, LogAssociationMatchLevel.Other, MainLog, Sess); Associations.Add(LogAsso); } } } catch { Request RedirReq = MainLog.Request.GetRedirect(MainLog.Response); foreach (Session Sess in SessionList) { if (!Sess.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { continue; } if (Sess.Request.FullUrl.Equals(RedirReq.FullUrl) && Sess.Response != null) { LogAssociation LogAsso = new LogAssociation(LogAssociationType.Redirect, RefAssoType, IronHtml.UrlInHtmlMatch.FullRelative, LogAssociationMatchLevel.Other, MainLog, Sess); Associations.Add(LogAsso); } } } } } return(Associations); }
List <LogAssociation> FindAssociations(Session MainLog, List <Session> SessionList, RefererAssociationType RefAssoType) { List <LogAssociation> Associations = new List <LogAssociation>(); List <int> AssociatedIds = new List <int>(); Associations.AddRange(FindRedirectAssociations(MainLog, SessionList, RefAssoType)); Associations.AddRange(FindScriptSourceAssociations(MainLog, SessionList, RefAssoType)); Associations.AddRange(FindStyleSourceAssociations(MainLog, SessionList, RefAssoType)); Associations.AddRange(FindImgSourceAssociations(MainLog, SessionList, RefAssoType)); Associations.AddRange(FindLinkClickAssociations(MainLog, SessionList, RefAssoType)); Associations.AddRange(FindFormSubmitAssociations(MainLog, SessionList, RefAssoType)); return(Associations); }