Example #1
0
        public string ToXml()
        {
            StringWriter  SW = new StringWriter();
            XmlTextWriter XW = new XmlTextWriter(SW);

            XW.Formatting = Formatting.Indented;
            XW.WriteStartElement("xml");
            XW.WriteStartElement("version"); XW.WriteValue("1.0"); XW.WriteEndElement();
            XW.WriteStartElement("name"); XW.WriteValue(this.Name); XW.WriteEndElement();
            XW.WriteStartElement("username"); XW.WriteValue(Tools.Base64Encode(Username)); XW.WriteEndElement();
            XW.WriteStartElement("password"); XW.WriteValue(Tools.Base64Encode(Password)); XW.WriteEndElement();
            XW.WriteStartElement("csrf_token"); XW.WriteValue(Tools.Base64Encode(intCsrfParameterName)); XW.WriteEndElement();

            XW.WriteStartElement("sessions");
            foreach (int LogId in LoginAssociations.LogIds)
            {
                try
                {
                    Analysis.LogAssociation Asso = LoginAssociations.GetAssociation(LogId);
                    XW.WriteStartElement("session");
                    XW.WriteStartElement("log_id"); XW.WriteValue(Asso.DestinationLog.LogId); XW.WriteEndElement();
                    XW.WriteStartElement("request"); XW.WriteValue(Asso.DestinationLog.Request.ToBinaryString()); XW.WriteEndElement();
                    XW.WriteStartElement("response"); XW.WriteValue(Asso.DestinationLog.Response.ToBinaryString()); XW.WriteEndElement();
                    XW.WriteEndElement();
                }
                catch { }
            }
            XW.WriteEndElement();

            XW.WriteStartElement("login_check_request"); XW.WriteValue(LoginCheckRequest.ToBinaryString()); XW.WriteEndElement();
            XW.WriteStartElement("response_when_logged_in"); XW.WriteValue(LoginCheckResponseWhenLoggedIn.ToBinaryString()); XW.WriteEndElement();
            XW.WriteStartElement("response_when_logged_out"); XW.WriteValue(LoginCheckResponseWhenLoggedOut.ToBinaryString()); XW.WriteEndElement();

            /*
             * XW.WriteStartElement("csrf_token_sessions");
             * foreach (int LogId in CsrfAssociations.LogIds)
             * {
             *  try
             *  {
             *      Analysis.LogAssociation Asso = LoginAssociations.GetAssociation(LogId);
             *      XW.WriteStartElement("session");
             *      XW.WriteStartElement("log_id"); XW.WriteValue(Asso.DestinationLog.LogId); XW.WriteEndElement();
             *      XW.WriteStartElement("request"); XW.WriteValue(Asso.DestinationLog.Request.ToBinaryString()); XW.WriteEndElement();
             *      XW.WriteStartElement("response"); XW.WriteValue(Asso.DestinationLog.Response.ToBinaryString()); XW.WriteEndElement();
             *      XW.WriteEndElement();
             *  }
             *  catch { }
             * }
             * XW.WriteEndElement();
             */
            XW.WriteEndElement();
            XW.Close();
            SW.Close();
            return(SW.ToString().Trim());
        }
Example #2
0
 static void ScanAssociation(Analysis.LogAssociations Association, List <string> HostsToScan, int[] Marker)
 {
     if (Association.NonIgnorableCount > 0)
     {
         int Index = 0;
         foreach (int Id in Association.LogIds)
         {
             Analysis.LogAssociation Asso = Association.GetAssociation(Id);
             if (!Asso.IsIgnorable && HostsToScan.Contains(Asso.DestinationLog.Request.BaseUrl))
             {
                 Scanner S = new Scanner(Asso.DestinationLog.Request);
                 if (S.BaseRequest.File.Length == 0 && S.BaseRequest.Query.Count == 0 && S.BaseRequest.UrlPathParts.Count > 1)
                 {
                     S.InjectUrl();
                 }
                 S.InjectQuery();
                 if (S.BaseRequest.BodyType == BodyFormatType.Soap ||
                     S.BaseRequest.BodyType == BodyFormatType.Json ||
                     S.BaseRequest.BodyType == BodyFormatType.Multipart ||
                     S.BaseRequest.BodyType == BodyFormatType.Xml)
                 {
                     S.BodyFormat = FormatPlugin.Get(S.BaseRequest.BodyType);
                 }
                 S.InjectBody();
                 S.CheckAll();
                 if (S.InjectionPointsCount > 0)
                 {
                     S.WorkFlowLogAssociations = Association;
                     S.IndexOfRequestToScanInWorkFlowLogAssociations = Index;
                     WorkflowScannerWindow.UpdateScanStatusInUi(true, string.Format("Scanning Request no.{0} in workflow between logs {1}-{2}", Index, Marker[0], Marker[1]));
                     S.Scan();
                 }
                 Index++;
             }
         }
     }
 }