mirror of https://github.com/daffainfo/nuclei.git
added dns support in workflow
parent
d3ceb76585
commit
429369c971
|
@ -375,7 +375,12 @@ func (r *Runner) ProcessWorkflow(workflow *workflows.Workflow, URL string) error
|
|||
ProxySocksURL: r.options.ProxySocksURL,
|
||||
CustomHeaders: r.options.CustomHeaders,
|
||||
}
|
||||
script.Add(name, &workflows.NucleiVar{Options: httpOptions, URL: URL})
|
||||
dnsOptions := &executor.DNSOptions{
|
||||
Debug: r.options.Debug,
|
||||
Template: template,
|
||||
Writer: writer,
|
||||
}
|
||||
script.Add(name, &workflows.NucleiVar{HTTPOptions: httpOptions, DNSOptions: dnsOptions, URL: URL})
|
||||
}
|
||||
|
||||
_, err := script.RunContext(context.Background())
|
||||
|
@ -384,8 +389,6 @@ func (r *Runner) ProcessWorkflow(workflow *workflows.Workflow, URL string) error
|
|||
return err
|
||||
}
|
||||
|
||||
// OUTPUT - TODO - Any suggestion?
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +1,39 @@
|
|||
package workflows
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/d5/tengo/v2"
|
||||
"github.com/projectdiscovery/nuclei/pkg/executor"
|
||||
)
|
||||
|
||||
// NucleiVar within the scripting engine
|
||||
type NucleiVar struct {
|
||||
tengo.ObjectImpl
|
||||
Options *executor.HTTPOptions
|
||||
URL string
|
||||
HTTPOptions *executor.HTTPOptions
|
||||
DNSOptions *executor.DNSOptions
|
||||
URL string
|
||||
}
|
||||
|
||||
// TypeName of the variable
|
||||
func (n *NucleiVar) TypeName() string {
|
||||
return "nuclei-var"
|
||||
}
|
||||
|
||||
// CanCall can be called from within the scripting engine
|
||||
func (n *NucleiVar) CanCall() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Call logic - actually it doesn't require arguments
|
||||
func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
|
||||
for _, request := range n.Options.Template.RequestsHTTP {
|
||||
n.Options.HTTPRequest = request
|
||||
httpExecutor, err := executor.NewHTTPExecutor(n.Options)
|
||||
for _, request := range n.HTTPOptions.Template.RequestsHTTP {
|
||||
n.HTTPOptions.HTTPRequest = request
|
||||
httpExecutor, err := executor.NewHTTPExecutor(n.HTTPOptions)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return nil, err
|
||||
}
|
||||
err = httpExecutor.ExecuteHTTP(n.URL)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return nil, err
|
||||
}
|
||||
if httpExecutor.GotResults() {
|
||||
return tengo.TrueValue, nil
|
||||
|
@ -38,5 +41,18 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
|
|||
return tengo.FalseValue, nil
|
||||
}
|
||||
|
||||
for _, request := range n.DNSOptions.Template.RequestsDNS {
|
||||
n.DNSOptions.DNSRequest = request
|
||||
dnsExecutor := executor.NewDNSExecutor(n.DNSOptions)
|
||||
err = dnsExecutor.ExecuteDNS(n.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if dnsExecutor.GotResults() {
|
||||
return tengo.TrueValue, nil
|
||||
}
|
||||
return tengo.FalseValue, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue