private void AddFilterToGui(FuzzerFilter Filter) { ListViewItem Item = new ListViewItem(); Item.Text = Filter.Name; Item.SubItems.Add(Filter.FilterType.ToString()); Item.SubItems.Add(Filter.ConditionType.ToString()); Item.SubItems.Add(Filter.ConditionValue); listViewFilters.Items.Add(Item); }
private void buttonAddFilter_Click(object sender, EventArgs e) { FuzzerFilter Filter = new FuzzerFilter(); foreach (ListViewItem item in listViewFilters.Items) { if (item.Text == textBoxFilterName.Text) { MessageBox.Show("This filter name already exists. Please choose another", "Name taken", MessageBoxButtons.OK); return; } } Filter.Name = textBoxFilterName.Text; Filter.ConditionValue = textBoxRegex.Text; if (comboBoxFilterType.SelectedIndex == 0) { Filter.FilterType = FuzzerFilter.FilterTypes.Exclude; } else { Filter.FilterType = FuzzerFilter.FilterTypes.Include; } if (comboBoxConditionType.SelectedIndex == 0) { Filter.ConditionType = FuzzerFilter.ConditionTypes.ResponseStatusCode; } else if (comboBoxConditionType.SelectedIndex == 1) { Filter.ConditionType = FuzzerFilter.ConditionTypes.ResponseHTML; } else if (comboBoxConditionType.SelectedIndex == 2) { Filter.ConditionType = FuzzerFilter.ConditionTypes.ResponseHeaders; } Filters.Add(Filter); AddFilterToGui(Filter); }
private void buttonAddFilter_Click(object sender, EventArgs e) { FuzzerFilter Filter = new FuzzerFilter(); foreach (ListViewItem item in listViewFilters.Items) { if (item.Text == textBoxFilterName.Text) { MessageBox.Show("This filter name already exists. Please choose another", "Name taken",MessageBoxButtons.OK); return; } } Filter.Name = textBoxFilterName.Text; Filter.ConditionValue = textBoxRegex.Text; if (comboBoxFilterType.SelectedIndex == 0) Filter.FilterType = FuzzerFilter.FilterTypes.Exclude; else Filter.FilterType = FuzzerFilter.FilterTypes.Include; if (comboBoxConditionType.SelectedIndex == 0) Filter.ConditionType = FuzzerFilter.ConditionTypes.ResponseStatusCode; else if (comboBoxConditionType.SelectedIndex == 1) Filter.ConditionType = FuzzerFilter.ConditionTypes.ResponseHTML; else if (comboBoxConditionType.SelectedIndex == 2) Filter.ConditionType = FuzzerFilter.ConditionTypes.ResponseHeaders; Filters.Add(Filter); AddFilterToGui(Filter); }
private void Process(CreateWebrequest webRequest) { string HTML = webRequest.StringGetWebPage(); if (webRequest.Response != null) { string ResponseHeaders = ""; for (int iKey = 0; iKey < webRequest.Response.Headers.Keys.Count; iKey++) { string Values = ""; string[] ValuesSplitted = webRequest.Response.Headers.GetValues(iKey); for (int iValue = 0; iValue < ValuesSplitted.Length; iValue++) { Values += ValuesSplitted[iValue] + " "; } ResponseHeaders += webRequest.Response.Headers.Keys[iKey] + ": " + Values + "\r\n"; } string RequestHeaders = ""; if (webRequest.Request != null) { for (int iKey = 0; iKey < webRequest.Request.Headers.Keys.Count; iKey++) { string Values = ""; string[] ValuesSplitted = webRequest.Request.Headers.GetValues(iKey); for (int iValue = 0; iValue < ValuesSplitted.Length; iValue++) { Values += ValuesSplitted[iValue] + " "; } RequestHeaders += webRequest.Request.Headers.Keys[iKey] + ": " + Values + "\r\n"; } } bool RequestSuccess = true; for (int i = 0; i < fuzzerFilters.Count; i++) { bool Filtered = true; FuzzerFilter Filter = fuzzerFilters[i]; if (Filter.ConditionType == FuzzerFilter.ConditionTypes.ResponseHeaders) { if (!RegexMatch(ResponseHeaders, Filter.ConditionValue)) { Filtered = false; } } if (Filter.ConditionType == FuzzerFilter.ConditionTypes.ResponseHTML) { if (!RegexMatch(HTML, Filter.ConditionValue)) { Filtered = false; } } if (Filter.ConditionType == FuzzerFilter.ConditionTypes.ResponseStatusCode) { if (!RegexMatch(Convert.ToInt32(webRequest.Response.StatusCode).ToString(), Filter.ConditionValue)) { Filtered = false; } } if (Filtered && Filter.FilterType == FuzzerFilter.FilterTypes.Exclude) { RequestSuccess = false; } } if (RequestSuccess) { FilteredRequest filteredRequest = new FilteredRequest(); filteredRequest.HTML = HTML; filteredRequest.URL = webRequest.URL; filteredRequest.RequestHeaders = RequestHeaders; filteredRequest.ResponseHeaders = ResponseHeaders; filteredRequests.Add(filteredRequest); } } }