mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 12:45:27 +00:00
parent
f96168fc2c
commit
fc66195b28
@ -1,7 +1,7 @@
|
||||
package responsehighlighter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
@ -9,10 +9,11 @@ import (
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
)
|
||||
|
||||
var colorizer = aurora.NewAurora(true)
|
||||
|
||||
func Highlight(operatorResult *operators.Result, response string, noColor bool) string {
|
||||
result := response
|
||||
if operatorResult != nil && !noColor {
|
||||
colorizer := aurora.NewAurora(true)
|
||||
for _, matches := range operatorResult.Matches {
|
||||
if len(matches) > 0 {
|
||||
for _, currentMatch := range matches {
|
||||
@ -25,13 +26,10 @@ func Highlight(operatorResult *operators.Result, response string, noColor bool)
|
||||
return result
|
||||
}
|
||||
|
||||
func CreateHTTPStatusMatcherSnippets(statusCode int) []string {
|
||||
httpVersions := []string{"0.9", "1.0", "1.1", "2", "2.0", "3", "3.0"}
|
||||
var matcherValues = make([]string, 0, len(httpVersions))
|
||||
|
||||
for _, httpVersion := range httpVersions {
|
||||
matcherValues = append(matcherValues, fmt.Sprintf("HTTP/%s %d", httpVersion, statusCode))
|
||||
func CreateStatusCodeSnippet(response string, statusCode int) string {
|
||||
if strings.HasPrefix(response, "HTTP/") {
|
||||
strStatusCode := strconv.Itoa(statusCode)
|
||||
return response[:strings.Index(response, strStatusCode)+len(strStatusCode)]
|
||||
}
|
||||
|
||||
return matcherValues
|
||||
return ""
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ func (request *Request) Match(data map[string]interface{}, matcher *matchers.Mat
|
||||
if !ok {
|
||||
return false, []string{}
|
||||
}
|
||||
return matcher.Result(matcher.MatchStatusCode(statusCode)), responsehighlighter.CreateHTTPStatusMatcherSnippets(statusCode)
|
||||
return matcher.Result(matcher.MatchStatusCode(statusCode)), []string{responsehighlighter.CreateStatusCodeSnippet(data["response"].(string), statusCode)}
|
||||
case matchers.SizeMatcher:
|
||||
return matcher.Result(matcher.MatchSize(len(item))), []string{}
|
||||
case matchers.WordsMatcher:
|
||||
|
||||
@ -28,7 +28,7 @@ func (request *Request) Match(data map[string]interface{}, matcher *matchers.Mat
|
||||
if !ok {
|
||||
return false, []string{}
|
||||
}
|
||||
return matcher.Result(matcher.MatchStatusCode(statusCode)), responsehighlighter.CreateHTTPStatusMatcherSnippets(statusCode)
|
||||
return matcher.Result(matcher.MatchStatusCode(statusCode)), []string{responsehighlighter.CreateStatusCodeSnippet(data["response"].(string), statusCode)}
|
||||
case matchers.SizeMatcher:
|
||||
return matcher.Result(matcher.MatchSize(len(item))), []string{}
|
||||
case matchers.WordsMatcher:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user