2020-12-20 18:34:11 +00:00
|
|
|
package output
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2020-12-24 06:43:18 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
2020-12-20 18:34:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// formatScreen formats the output for showing on screen.
|
2020-12-25 15:03:52 +00:00
|
|
|
func (w *StandardWriter) formatScreen(output *ResultEvent) ([]byte, error) {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder := &bytes.Buffer{}
|
|
|
|
|
|
|
|
if !w.noMetadata {
|
|
|
|
builder.WriteRune('[')
|
2020-12-25 07:25:46 +00:00
|
|
|
builder.WriteString(w.aurora.BrightGreen(output.TemplateID).String())
|
2020-12-20 18:34:11 +00:00
|
|
|
|
2020-12-25 07:25:46 +00:00
|
|
|
if output.MatcherName != "" {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteString(":")
|
2020-12-25 07:25:46 +00:00
|
|
|
builder.WriteString(w.aurora.BrightGreen(output.MatcherName).Bold().String())
|
2021-01-17 06:32:59 +00:00
|
|
|
} else if output.ExtractorName != "" {
|
|
|
|
builder.WriteString(":")
|
|
|
|
builder.WriteString(w.aurora.BrightGreen(output.ExtractorName).Bold().String())
|
2020-12-20 18:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
builder.WriteString("] [")
|
2020-12-25 07:25:46 +00:00
|
|
|
builder.WriteString(w.aurora.BrightBlue(output.Type).String())
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteString("] ")
|
|
|
|
|
|
|
|
builder.WriteString("[")
|
2021-02-03 19:39:29 +00:00
|
|
|
builder.WriteString(w.severityColors.Data[output.Info["severity"].(string)])
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteString("] ")
|
|
|
|
}
|
2020-12-25 07:25:46 +00:00
|
|
|
builder.WriteString(output.Matched)
|
2020-12-20 18:34:11 +00:00
|
|
|
|
|
|
|
// If any extractors, write the results
|
2020-12-25 07:25:46 +00:00
|
|
|
if len(output.ExtractedResults) > 0 {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteString(" [")
|
|
|
|
|
2020-12-25 07:25:46 +00:00
|
|
|
for i, item := range output.ExtractedResults {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteString(w.aurora.BrightCyan(item).String())
|
|
|
|
|
2020-12-25 07:25:46 +00:00
|
|
|
if i != len(output.ExtractedResults)-1 {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteRune(',')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
builder.WriteString("]")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write meta if any
|
2020-12-25 07:25:46 +00:00
|
|
|
if len(output.Metadata) > 0 {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteString(" [")
|
|
|
|
|
2020-12-25 07:25:46 +00:00
|
|
|
var first bool = true
|
|
|
|
for name, value := range output.Metadata {
|
|
|
|
if !first {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder.WriteRune(',')
|
|
|
|
}
|
|
|
|
first = false
|
|
|
|
|
|
|
|
builder.WriteString(w.aurora.BrightYellow(name).String())
|
|
|
|
builder.WriteRune('=')
|
2020-12-24 06:43:18 +00:00
|
|
|
builder.WriteString(w.aurora.BrightYellow(types.ToString(value)).String())
|
2020-12-20 18:34:11 +00:00
|
|
|
}
|
|
|
|
builder.WriteString("]")
|
|
|
|
}
|
|
|
|
return builder.Bytes(), nil
|
|
|
|
}
|