mirror of https://github.com/daffainfo/nuclei.git
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package runner
|
|
|
|
import (
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
|
"github.com/remeh/sizedwaitgroup"
|
|
"go.uber.org/atomic"
|
|
)
|
|
|
|
// processTemplateWithList process a template on the URL list
|
|
func (r *Runner) processTemplateWithList(template *templates.Template) bool {
|
|
results := &atomic.Bool{}
|
|
wg := sizedwaitgroup.New(r.options.BulkSize)
|
|
r.hostMap.Scan(func(k, _ []byte) error {
|
|
URL := string(k)
|
|
|
|
wg.Add()
|
|
go func(URL string) {
|
|
defer wg.Done()
|
|
|
|
match, err := template.Executer.Execute(URL)
|
|
if err != nil {
|
|
gologger.Warning().Msgf("[%s] Could not execute step: %s\n", r.colorizer.BrightBlue(template.ID), err)
|
|
}
|
|
results.CAS(false, match)
|
|
}(URL)
|
|
return nil
|
|
})
|
|
wg.Wait()
|
|
return results.Load()
|
|
}
|
|
|
|
// processTemplateWithList process a template on the URL list
|
|
func (r *Runner) processWorkflowWithList(template *templates.Template) bool {
|
|
results := &atomic.Bool{}
|
|
wg := sizedwaitgroup.New(r.options.BulkSize)
|
|
|
|
r.hostMap.Scan(func(k, _ []byte) error {
|
|
URL := string(k)
|
|
wg.Add()
|
|
go func(URL string) {
|
|
defer wg.Done()
|
|
match := template.CompiledWorkflow.RunWorkflow(URL)
|
|
results.CAS(false, match)
|
|
}(URL)
|
|
return nil
|
|
})
|
|
wg.Wait()
|
|
return results.Load()
|
|
}
|