static string GetStringFromInjectionParameters(Parameters InjectionParameters, List<int> InjectionList) { StringBuilder IS = new StringBuilder(); int i = 0; foreach (string Name in InjectionParameters.GetNames()) { IS.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(Name))); IS.Append(":"); IS.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(InjectionParameters.Get(Name)))); IS.Append("-"); if (InjectionList.Contains(i)) { IS.Append("1"); } else { IS.Append("0"); } IS.Append(";"); i++; } return IS.ToString(); }
void AbsorbFormatBodyParametersFromInjectionString(string InjectionString) { InjectionParameters InjectionParameters = new InjectionParameters(); string[] Parameters = InjectionString.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); this.BodyXmlInjectionParameters = new Parameters(); this.BodyXmlInjections.Clear(); int i = 0; foreach (string Parameter in Parameters) { string[] ParameterParts = Parameter.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries); if (ParameterParts.Length != 2) throw new Exception("Invalid Injection String"); string[] SecondParameterParts = ParameterParts[1].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); if (SecondParameterParts.Length < 1 || SecondParameterParts.Length > 2) throw new Exception("Invalid Injection String"); try { string Value = ""; if (SecondParameterParts.Length == 2) Value = SecondParameterParts[0]; string InjectionState = ""; if (SecondParameterParts.Length == 2) InjectionState = SecondParameterParts[1]; else InjectionState = SecondParameterParts[0]; this.BodyXmlInjectionParameters.Add(Encoding.UTF8.GetString(Convert.FromBase64String(ParameterParts[0])), Encoding.UTF8.GetString(Convert.FromBase64String(Value))); if (InjectionState.Equals("1")) this.BodyXmlInjections.Add(i); } catch { throw new Exception("Invalid Injection String"); } i++; } }
public static bool DoesFormNodesMatchRequest(Request Req, HtmlNode FormNode) { //This method checks if a Request was actually generated from the submission of a particular HTML form node //Checks if the method of the request and method of the form node match //Checks if the input field names in the form node exactly match the request parameter names //Checks if the values of the hidden input field exactly match the corresponding request parameter values if (FormNode.Attributes["method"] != null) { if (FormNode.Attributes["method"].Value.Equals("GET", StringComparison.OrdinalIgnoreCase) && !Req.Method.Equals("GET", StringComparison.OrdinalIgnoreCase)) { return(false); } else if (FormNode.Attributes["method"].Value.Equals("POST", StringComparison.OrdinalIgnoreCase) && !Req.Method.Equals("POST", StringComparison.OrdinalIgnoreCase)) { return(false); } } Parameters Params = null; if (Req.Method.Equals("POST", StringComparison.OrdinalIgnoreCase)) { Params = Req.Body; } else { Params = Req.Query; } if (FormNode.SelectNodes("input").Count != Params.Count || Params.Count == 0) { return(false); } foreach (HtmlNode InputNode in FormNode.SelectNodes("input")) { string Name = ""; if (InputNode.Attributes["name"] != null) { Name = InputNode.Attributes["name"].Value; if (Req.Method.Equals("GET")) { if (!Req.Query.Has(Name)) { return(false); } } else { if (!Req.Body.Has(Name)) { return(false); } } } else { Name = ""; } if (Name.Length > 0 && InputNode.Attributes["type"] != null) { if (InputNode.Attributes["type"].Value.Equals("hidden", StringComparison.OrdinalIgnoreCase)) { if (InputNode.Attributes["value"] != null) { string Value = InputNode.Attributes["value"].Value; if (!Params.GetAll(Name).Contains(Value)) { return(false); } } } } } return(true); }
internal static void FillConfigureScanFormatDetails(string XML, string[,] InjectionArray, List<bool> CheckStatus, bool CheckAll, string PluginName) { if (UI.ConfigureScanRequestBodyTypeFormatPluginGrid.InvokeRequired) { FillConfigureScanFormatDetails_d FCSFD_d = new FillConfigureScanFormatDetails_d(FillConfigureScanFormatDetails); UI.Invoke(FCSFD_d, new object[] { XML, InjectionArray, CheckStatus, CheckAll, PluginName }); } else { UI.ConfigureScanRequestFormatXMLTB.Text = XML; if (CheckStatus.Count != InjectionArray.GetLength(0)) { CheckStatus.Clear(); for (int i = 0; i < InjectionArray.GetLength(0); i++) { CheckStatus.Add(CheckAll); } } //UI.ASRequestTabs.SelectTab("ASRequestBodyTab"); UI.ConfigureScanRequestBodyTypeFormatPluginGrid.Rows.Clear(); Parameters BodyXmlInjectionParameters = new Parameters(); for (int i = 0; i < InjectionArray.GetLength(0); i++) { UI.ConfigureScanRequestBodyTypeFormatPluginGrid.Rows.Add(new object[] { CheckStatus[i], InjectionArray[i, 0], InjectionArray[i, 1] }); BodyXmlInjectionParameters.Add(InjectionArray[i, 0], InjectionArray[i, 1]); } Scanner.CurrentScanner.BodyXmlInjectionParameters = BodyXmlInjectionParameters; UI.ASRequestScanBodyCB.Checked = CheckAll; foreach (DataGridViewRow Row in UI.ConfigureScanRequestFormatPluginsGrid.Rows) { if (Row.Cells[1].Value.ToString().Equals(PluginName)) Row.Cells[0].Value = true; else Row.Cells[0].Value = false; } } }
internal static void UpdateProxyHeaderFieldsWithUIHeadersParameters() { Parameters TempHolder = new Parameters(); if (IronProxy.CurrentSession.Request.Headers.Has("Host")) { TempHolder.Set("Host", IronProxy.CurrentSession.Request.Headers.Get("Host")); } if (IronProxy.CurrentSession.Request.Headers.Has("Cookie")) { TempHolder.Set("Cookie", IronProxy.CurrentSession.Request.Headers.Get("Cookie")); } IronProxy.CurrentSession.Request.Headers.RemoveAll(); foreach (DataGridViewRow Row in UI.ProxyRequestParametersHeadersGrid.Rows) { IronProxy.CurrentSession.Request.Headers.Add(Row.Cells[0].Value.ToString(), Row.Cells[1].Value.ToString()); } foreach (string Name in TempHolder.GetNames()) { IronProxy.CurrentSession.Request.Headers.Set(Name, TempHolder.Get(Name)); } FillProxyRequestHeaderFields(IronProxy.CurrentSession.Request); }
internal static void UpdateMTHeaderFieldsWithUIHeadersParameters() { if (ManualTesting.CurrentRequest == null) return; Parameters TempHolder = new Parameters(); if (ManualTesting.CurrentRequest.Headers.Has("Host")) { TempHolder.Set("Host", ManualTesting.CurrentRequest.Headers.Get("Host")); } if (ManualTesting.CurrentRequest.Headers.Has("Cookie")) { TempHolder.Set("Cookie", ManualTesting.CurrentRequest.Headers.Get("Cookie")); } ManualTesting.CurrentRequest.Headers.RemoveAll(); foreach (DataGridViewRow Row in UI.MTRequestParametersHeadersGrid.Rows) { ManualTesting.CurrentRequest.Headers.Add(Row.Cells[0].Value.ToString(), Row.Cells[1].Value.ToString()); } foreach (string Name in TempHolder.GetNames()) { ManualTesting.CurrentRequest.Headers.Set(Name, TempHolder.Get(Name)); } FillMTRequestHeaderFields(ManualTesting.CurrentRequest); }
public void InjectBody(string ParameterName, int SubParameterPosition) { if (this.BodyInjections.Has(ParameterName)) { if (!this.BodyInjections.GetAll(ParameterName).Contains(SubParameterPosition)) this.BodyInjections.Add(ParameterName, SubParameterPosition); } else { this.BodyInjections.Add(ParameterName, SubParameterPosition); } this.CustomInjectionPointStartMarker = ""; this.CustomInjectionPointEndMarker = ""; this.BodyFormat = new FormatPlugin(); this.BodyXmlInjectionParameters = new Parameters(); this.BodyXmlInjections = new List<int>(); }
public void InjectBody(string StartMarker, string EndMarker) { if (StartMarker.Length == 0) { throw new Exception("Start Marker cannot be empty"); } if (EndMarker.Length == 0) { throw new Exception("End Marker cannot be empty"); } if (StartMarker.Equals(EndMarker)) { throw new Exception("Start Marker and End Marker cannot be the same"); } this.CustomInjectionPointStartMarker = StartMarker; this.CustomInjectionPointEndMarker = EndMarker; this.BodyFormat = new FormatPlugin(); this.BodyXmlInjectionParameters = new Parameters(); this.BodyXmlInjections = new List<int>(); this.BodyInjections = new InjectionParameters(); }
internal void DeserializeRequestBodyWithFormatPlugin() { string Xml = BodyFormat.ToXmlFromRequest(this.OriginalRequest); InjectionArrayXML = Xml; XmlInjectionArray = FormatPlugin.XmlToArray(Xml); XmlInjectionSignature = Tools.MD5("Name:" + BodyFormat.Name + "|Body" + this.OriginalRequest.BodyString); this.BodyXmlInjectionParameters = new Parameters(); for (int i = 0; i < XmlInjectionArray.GetLength(0); i++) { this.BodyXmlInjectionParameters.Add(XmlInjectionArray[i, 0], XmlInjectionArray[i, 1]); } }