From 4cc9ad910063a2698d5bd740792f9075c31d2465 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Sat, 25 Jul 2020 21:15:28 +0200 Subject: [PATCH 1/2] wip - output --- v2/pkg/executer/executer_dns.go | 4 +++- v2/pkg/executer/executer_http.go | 13 +++++++------ v2/pkg/extractors/compile.go | 1 + v2/pkg/extractors/extractors.go | 3 +++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/v2/pkg/executer/executer_dns.go b/v2/pkg/executer/executer_dns.go index 699c11613..4c9a34749 100644 --- a/v2/pkg/executer/executer_dns.go +++ b/v2/pkg/executer/executer_dns.go @@ -120,7 +120,9 @@ func (e *DNSExecuter) ExecuteDNS(URL string) (result Result) { var extractorResults []string for _, extractor := range e.dnsRequest.Extractors { for match := range extractor.ExtractDNS(resp) { - extractorResults = append(extractorResults, match) + if !extractor.Internal { + extractorResults = append(extractorResults, match) + } } } diff --git a/v2/pkg/executer/executer_http.go b/v2/pkg/executer/executer_http.go index 5c907d1ac..5b97c5857 100644 --- a/v2/pkg/executer/executer_http.go +++ b/v2/pkg/executer/executer_http.go @@ -186,7 +186,7 @@ func (e *HTTPExecuter) handleHTTP(URL string, request *requests.HttpRequest, dyn } else { // If the matcher has matched, and its an OR // write the first output then move to next matcher. - if matcherCondition == matchers.ORCondition && len(e.bulkHttpRequest.Extractors) == 0 { + if matcherCondition == matchers.ORCondition { result.Matches[matcher.Name] = nil // probably redundant but ensures we snapshot current payload values when matchers are valid result.Meta = request.Meta @@ -198,23 +198,24 @@ func (e *HTTPExecuter) handleHTTP(URL string, request *requests.HttpRequest, dyn // All matchers have successfully completed so now start with the // next task which is extraction of input from matchers. - var extractorResults []string + var extractorResults, outputExtractorResults []string for _, extractor := range e.bulkHttpRequest.Extractors { for match := range extractor.Extract(resp, body, headers) { if _, ok := dynamicvalues[extractor.Name]; !ok { dynamicvalues[extractor.Name] = match } extractorResults = append(extractorResults, match) + if !extractor.Internal { + outputExtractorResults = append(outputExtractorResults, match) + } } // probably redundant but ensures we snapshot current payload values when extractors are valid result.Meta = request.Meta result.Extractions[extractor.Name] = extractorResults } - // Write a final string of output if matcher type is - // AND or if we have extractors for the mechanism too. - if len(e.bulkHttpRequest.Extractors) > 0 || matcherCondition == matchers.ANDCondition { - e.writeOutputHTTP(request, resp, body, nil, extractorResults) + if len(outputExtractorResults) > 0 { + e.writeOutputHTTP(request, resp, body, nil, outputExtractorResults) result.GotResults = true } diff --git a/v2/pkg/extractors/compile.go b/v2/pkg/extractors/compile.go index 6040580b2..4db70dd19 100644 --- a/v2/pkg/extractors/compile.go +++ b/v2/pkg/extractors/compile.go @@ -32,5 +32,6 @@ func (e *Extractor) CompileExtractors() error { } else { e.part = BodyPart } + return nil } diff --git a/v2/pkg/extractors/extractors.go b/v2/pkg/extractors/extractors.go index 3a61e76bb..ddfd07990 100644 --- a/v2/pkg/extractors/extractors.go +++ b/v2/pkg/extractors/extractors.go @@ -25,6 +25,9 @@ type Extractor struct { Part string `yaml:"part,omitempty"` // part is the part of the request to match part Part + + // Internal defines if this is used internally + Internal bool `yaml:"internal,omitempty"` } // ExtractorType is the type of the extractor specified From 3a8ee75b93801192f649256050be937d9d70349c Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Sat, 25 Jul 2020 21:44:43 +0200 Subject: [PATCH 2/2] wip - output --- v2/pkg/executer/executer_http.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/v2/pkg/executer/executer_http.go b/v2/pkg/executer/executer_http.go index 5b97c5857..341ee362f 100644 --- a/v2/pkg/executer/executer_http.go +++ b/v2/pkg/executer/executer_http.go @@ -214,7 +214,9 @@ func (e *HTTPExecuter) handleHTTP(URL string, request *requests.HttpRequest, dyn result.Extractions[extractor.Name] = extractorResults } - if len(outputExtractorResults) > 0 { + // Write a final string of output if matcher type is + // AND or if we have extractors for the mechanism too. + if len(outputExtractorResults) > 0 || matcherCondition == matchers.ANDCondition { e.writeOutputHTTP(request, resp, body, nil, outputExtractorResults) result.GotResults = true }