mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 20:45:24 +00:00
parent
57fa83ca35
commit
407a89acd2
@ -118,12 +118,14 @@ func (r *Runner) processTemplateWithList(ctx context.Context, p progress.IProgre
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProcessWorkflowWithList coming from stdin or list of targets
|
// ProcessWorkflowWithList coming from stdin or list of targets
|
||||||
func (r *Runner) processWorkflowWithList(p progress.IProgress, workflow *workflows.Workflow) {
|
func (r *Runner) processWorkflowWithList(p progress.IProgress, workflow *workflows.Workflow) bool {
|
||||||
|
result := false
|
||||||
|
|
||||||
workflowTemplatesList, err := r.preloadWorkflowTemplates(p, workflow)
|
workflowTemplatesList, err := r.preloadWorkflowTemplates(p, workflow)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gologger.Warningf("Could not preload templates for workflow %s: %s\n", workflow.ID, err)
|
gologger.Warningf("Could not preload templates for workflow %s: %s\n", workflow.ID, err)
|
||||||
|
|
||||||
return
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
logicBytes := []byte(workflow.Logic)
|
logicBytes := []byte(workflow.Logic)
|
||||||
@ -143,13 +145,18 @@ func (r *Runner) processWorkflowWithList(p progress.IProgress, workflow *workflo
|
|||||||
script := tengo.NewScript(logicBytes)
|
script := tengo.NewScript(logicBytes)
|
||||||
script.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...))
|
script.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...))
|
||||||
|
|
||||||
|
variables := make(map[string]*workflows.NucleiVar)
|
||||||
|
|
||||||
for _, workflowTemplate := range *workflowTemplatesList {
|
for _, workflowTemplate := range *workflowTemplatesList {
|
||||||
err := script.Add(workflowTemplate.Name, &workflows.NucleiVar{Templates: workflowTemplate.Templates, URL: targetURL})
|
name := workflowTemplate.Name
|
||||||
|
variable := &workflows.NucleiVar{Templates: workflowTemplate.Templates, URL: targetURL}
|
||||||
|
err := script.Add(name, variable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gologger.Errorf("Could not initialize script for workflow '%s': %s\n", workflow.ID, err)
|
gologger.Errorf("Could not initialize script for workflow '%s': %s\n", workflow.ID, err)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
variables[name] = variable
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := script.RunContext(context.Background())
|
_, err := script.RunContext(context.Background())
|
||||||
@ -157,11 +164,20 @@ func (r *Runner) processWorkflowWithList(p progress.IProgress, workflow *workflo
|
|||||||
gologger.Errorf("Could not execute workflow '%s': %s\n", workflow.ID, err)
|
gologger.Errorf("Could not execute workflow '%s': %s\n", workflow.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, variable := range variables {
|
||||||
|
result = variable.IsFalsy()
|
||||||
|
if result {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<-r.limiter
|
<-r.limiter
|
||||||
}(targetURL)
|
}(targetURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runner) preloadWorkflowTemplates(p progress.IProgress, workflow *workflows.Workflow) (*[]workflowTemplates, error) {
|
func (r *Runner) preloadWorkflowTemplates(p progress.IProgress, workflow *workflows.Workflow) (*[]workflowTemplates, error) {
|
||||||
|
|||||||
@ -254,8 +254,7 @@ func (r *Runner) RunEnumeration() {
|
|||||||
results.Or(r.processTemplateWithList(ctx, p, tt, request))
|
results.Or(r.processTemplateWithList(ctx, p, tt, request))
|
||||||
}
|
}
|
||||||
case *workflows.Workflow:
|
case *workflows.Workflow:
|
||||||
workflow := template.(*workflows.Workflow)
|
results.Or(r.processWorkflowWithList(p, template.(*workflows.Workflow)))
|
||||||
r.processWorkflowWithList(p, workflow)
|
|
||||||
}
|
}
|
||||||
}(t)
|
}(t)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user