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.
|
2021-02-26 07:43:11 +00:00
|
|
|
func (w *StandardWriter) formatScreen(output *ResultEvent) []byte {
|
2020-12-20 18:34:11 +00:00
|
|
|
builder := &bytes.Buffer{}
|
|
|
|
|
|
|
|
if !w.noMetadata {
|
2021-03-19 16:43:41 +00:00
|
|
|
builder.WriteRune('[')
|
|
|
|
builder.WriteString(w.aurora.Cyan(output.Timestamp.Format("2006-01-02 15:04:05")).String())
|
|
|
|
builder.WriteString("] ")
|
|
|
|
|
2020-12-20 18:34:11 +00:00
|
|
|
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-07-13 08:12:03 +00:00
|
|
|
builder.WriteString(w.severityColors(output.Info.SeverityHolder.Severity))
|
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(" [")
|
|
|
|
|
2021-07-06 15:45:40 +00:00
|
|
|
first := true
|
2020-12-25 07:25:46 +00:00
|
|
|
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("]")
|
|
|
|
}
|
2021-02-26 07:43:11 +00:00
|
|
|
return builder.Bytes()
|
2020-12-20 18:34:11 +00:00
|
|
|
}
|