Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }