2020-08-29 13:26:11 +00:00
|
|
|
package runner
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/projectdiscovery/gologger"
|
2020-12-29 12:32:45 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
|
|
|
"github.com/remeh/sizedwaitgroup"
|
|
|
|
"go.uber.org/atomic"
|
2020-08-29 13:26:11 +00:00
|
|
|
)
|
|
|
|
|
2020-12-29 12:32:45 +00:00
|
|
|
// processTemplateWithList process a template on the URL list
|
|
|
|
func (r *Runner) processTemplateWithList(template *templates.Template) bool {
|
|
|
|
results := &atomic.Bool{}
|
2020-10-12 18:15:21 +00:00
|
|
|
wg := sizedwaitgroup.New(r.options.BulkSize)
|
2020-12-29 12:32:45 +00:00
|
|
|
r.hostMap.Scan(func(k, _ []byte) error {
|
2020-11-15 23:40:32 +00:00
|
|
|
URL := string(k)
|
2020-12-30 15:44:04 +00:00
|
|
|
|
2020-10-12 18:15:21 +00:00
|
|
|
wg.Add()
|
2020-08-29 13:26:11 +00:00
|
|
|
go func(URL string) {
|
|
|
|
defer wg.Done()
|
2020-12-29 13:18:13 +00:00
|
|
|
|
2020-12-29 12:32:45 +00:00
|
|
|
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)
|
2020-08-29 13:26:11 +00:00
|
|
|
}
|
2020-12-29 15:02:04 +00:00
|
|
|
results.CAS(false, match)
|
2020-10-09 21:11:07 +00:00
|
|
|
}(URL)
|
2020-11-15 23:40:32 +00:00
|
|
|
return nil
|
|
|
|
})
|
2020-08-29 13:26:11 +00:00
|
|
|
wg.Wait()
|
2020-12-29 12:32:45 +00:00
|
|
|
return results.Load()
|
2020-08-29 13:26:11 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 12:32:45 +00:00
|
|
|
// processTemplateWithList process a template on the URL list
|
|
|
|
func (r *Runner) processWorkflowWithList(template *templates.Template) bool {
|
|
|
|
results := &atomic.Bool{}
|
2020-10-12 18:15:21 +00:00
|
|
|
wg := sizedwaitgroup.New(r.options.BulkSize)
|
2020-08-29 13:26:11 +00:00
|
|
|
|
2020-12-29 12:32:45 +00:00
|
|
|
r.hostMap.Scan(func(k, _ []byte) error {
|
|
|
|
URL := string(k)
|
|
|
|
wg.Add()
|
|
|
|
go func(URL string) {
|
2020-08-29 13:26:11 +00:00
|
|
|
defer wg.Done()
|
2021-02-22 12:19:02 +00:00
|
|
|
match := template.CompiledWorkflow.RunWorkflow(URL)
|
2020-12-29 15:02:04 +00:00
|
|
|
results.CAS(false, match)
|
2020-12-29 12:32:45 +00:00
|
|
|
}(URL)
|
2020-11-15 23:40:32 +00:00
|
|
|
return nil
|
|
|
|
})
|
2020-08-29 13:26:11 +00:00
|
|
|
wg.Wait()
|
2020-12-29 12:32:45 +00:00
|
|
|
return results.Load()
|
2020-08-29 13:26:11 +00:00
|
|
|
}
|