2020-08-29 15:26:11 +02:00
|
|
|
package runner
|
|
|
|
|
|
|
|
|
|
import (
|
2022-09-20 16:33:57 -05:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/loader"
|
2022-05-08 08:52:21 +02:00
|
|
|
"path/filepath"
|
2020-08-29 15:26:11 +02:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/projectdiscovery/gologger"
|
2021-08-19 02:10:36 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/parsers"
|
2022-03-14 12:32:05 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
2021-02-04 18:29:28 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
2020-08-29 15:26:11 +02:00
|
|
|
)
|
|
|
|
|
|
2022-09-20 16:33:57 -05:00
|
|
|
// log available templates for verbose (-vv)
|
2020-08-29 23:02:45 +02:00
|
|
|
func (r *Runner) logAvailableTemplate(tplPath string) {
|
2022-08-10 23:35:58 +05:30
|
|
|
t, err := parsers.ParseTemplate(tplPath, r.catalog)
|
2020-12-29 15:38:14 +05:30
|
|
|
if err != nil {
|
|
|
|
|
gologger.Error().Msgf("Could not parse file '%s': %s\n", tplPath, err)
|
2021-01-14 13:21:21 +05:30
|
|
|
} else {
|
2022-03-14 12:32:05 +05:30
|
|
|
gologger.Print().Msgf("%s\n", templates.TemplateLogMessage(t.ID,
|
2021-07-12 17:20:01 +03:00
|
|
|
types.ToString(t.Info.Name),
|
2021-09-01 17:36:07 +03:00
|
|
|
t.Info.Authors.ToSlice(),
|
2021-07-13 11:12:03 +03:00
|
|
|
t.Info.SeverityHolder.Severity))
|
2020-08-29 23:02:45 +02:00
|
|
|
}
|
2020-08-29 15:26:11 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-20 16:33:57 -05:00
|
|
|
func (r *Runner) listAvailableStoreTemplates(store *loader.Store) {
|
2020-12-29 15:38:14 +05:30
|
|
|
gologger.Print().Msgf(
|
2020-08-30 13:25:34 +02:00
|
|
|
"\nListing available v.%s nuclei templates for %s",
|
2021-09-15 04:01:40 +05:30
|
|
|
r.templatesConfig.TemplateVersion,
|
2020-08-30 13:25:34 +02:00
|
|
|
r.templatesConfig.TemplatesDirectory,
|
|
|
|
|
)
|
2022-09-20 16:33:57 -05:00
|
|
|
extraFlags := r.options.Templates != nil || r.options.Authors != nil ||
|
|
|
|
|
r.options.Tags != nil || len(r.options.ExcludeTags) > 3 ||
|
|
|
|
|
r.options.IncludeTags != nil || r.options.IncludeIds != nil ||
|
|
|
|
|
r.options.ExcludeIds != nil || r.options.IncludeTemplates != nil ||
|
|
|
|
|
r.options.ExcludedTemplates != nil || r.options.ExcludeMatchers != nil ||
|
|
|
|
|
r.options.Severities != nil || r.options.ExcludeSeverities != nil ||
|
|
|
|
|
r.options.Protocols != nil || r.options.ExcludeProtocols != nil ||
|
|
|
|
|
r.options.IncludeConditions != nil || r.options.TemplateList
|
|
|
|
|
for _, tl := range store.Templates() {
|
|
|
|
|
if extraFlags {
|
|
|
|
|
path := strings.TrimPrefix(tl.Path, r.templatesConfig.TemplatesDirectory+string(filepath.Separator))
|
|
|
|
|
gologger.Silent().Msgf("%s\n", path)
|
|
|
|
|
} else {
|
|
|
|
|
gologger.Print().Msgf("%s\n", templates.TemplateLogMessage(tl.ID,
|
|
|
|
|
types.ToString(tl.Info.Name),
|
|
|
|
|
tl.Info.Authors.ToSlice(),
|
|
|
|
|
tl.Info.SeverityHolder.Severity))
|
|
|
|
|
}
|
2020-08-29 15:26:11 +02:00
|
|
|
}
|
|
|
|
|
}
|