mirror of https://github.com/daffainfo/nuclei.git
Merge branch 'dev' of https://github.com/projectdiscovery/nuclei into self-contained-templates
commit
9073075451
|
@ -44,6 +44,8 @@ We have a [dedicated repository](https://github.com/projectdiscovery/nuclei-temp
|
||||||
|
|
||||||
# Install Nuclei
|
# Install Nuclei
|
||||||
|
|
||||||
|
Nuclei requires **go1.17** to install successfully. Run the following command to install the latest version -
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest
|
go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest
|
||||||
```
|
```
|
||||||
|
|
|
@ -224,6 +224,15 @@ var functions = map[string]govaluate.ExpressionFunction{
|
||||||
}
|
}
|
||||||
return rand.Intn(max-min) + min, nil
|
return rand.Intn(max-min) + min, nil
|
||||||
},
|
},
|
||||||
|
"unixtime": func(args ...interface{}) (interface{}, error) {
|
||||||
|
seconds := 0
|
||||||
|
if len(args) >= 1 {
|
||||||
|
seconds = int(args[0].(float64))
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
offset := now.Add(time.Duration(seconds) * time.Second)
|
||||||
|
return offset.Unix(), nil
|
||||||
|
},
|
||||||
// Time Functions
|
// Time Functions
|
||||||
"waitfor": func(args ...interface{}) (interface{}, error) {
|
"waitfor": func(args ...interface{}) (interface{}, error) {
|
||||||
seconds := args[0].(float64)
|
seconds := args[0].(float64)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package generators
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BuildPayloadFromOptions returns a map with the payloads provided via CLI
|
||||||
|
func BuildPayloadFromOptions(options *types.Options) map[string]interface{} {
|
||||||
|
m := make(map[string]interface{})
|
||||||
|
// merge with vars
|
||||||
|
if !options.Vars.IsEmpty() {
|
||||||
|
m = MergeMaps(m, options.Vars.AsMap())
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge with env vars
|
||||||
|
if options.EnvironmentVariables {
|
||||||
|
m = MergeMaps(EnvVars(), m)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
|
@ -64,17 +64,10 @@ func (r *requestGenerator) Make(baseURL string, dynamicValues map[string]interfa
|
||||||
if !isRawRequest && strings.HasSuffix(parsed.Path, "/") && strings.Contains(data, "{{BaseURL}}/") {
|
if !isRawRequest && strings.HasSuffix(parsed.Path, "/") && strings.Contains(data, "{{BaseURL}}/") {
|
||||||
trailingSlash = true
|
trailingSlash = true
|
||||||
}
|
}
|
||||||
values := generators.MergeMaps(dynamicValues, generateVariables(parsed, trailingSlash))
|
values := generators.MergeMaps(
|
||||||
|
generators.MergeMaps(dynamicValues, generateVariables(parsed, trailingSlash)),
|
||||||
// merge with vars
|
generators.BuildPayloadFromOptions(r.request.options.Options),
|
||||||
if !r.options.Options.Vars.IsEmpty() {
|
)
|
||||||
values = generators.MergeMaps(values, r.options.Options.Vars.AsMap())
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge with env vars
|
|
||||||
if r.options.Options.EnvironmentVariables {
|
|
||||||
values = generators.MergeMaps(generators.EnvVars(), values)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If data contains \n it's a raw request, process it like raw. Else
|
// If data contains \n it's a raw request, process it like raw. Else
|
||||||
// continue with the template based request flow.
|
// continue with the template based request flow.
|
||||||
|
|
|
@ -66,6 +66,8 @@ func (request *Request) executeAddress(actualAddress, address, input string, sho
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
payloads := generators.BuildPayloadFromOptions(request.options.Options)
|
||||||
|
|
||||||
if request.generator != nil {
|
if request.generator != nil {
|
||||||
iterator := request.generator.NewIterator()
|
iterator := request.generator.NewIterator()
|
||||||
|
|
||||||
|
@ -74,12 +76,13 @@ func (request *Request) executeAddress(actualAddress, address, input string, sho
|
||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
value = generators.MergeMaps(value, payloads)
|
||||||
if err := request.executeRequestWithPayloads(actualAddress, address, input, shouldUseTLS, value, previous, callback); err != nil {
|
if err := request.executeRequestWithPayloads(actualAddress, address, input, shouldUseTLS, value, previous, callback); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value := make(map[string]interface{})
|
value := generators.MergeMaps(map[string]interface{}{}, payloads)
|
||||||
if err := request.executeRequestWithPayloads(actualAddress, address, input, shouldUseTLS, value, previous, callback); err != nil {
|
if err := request.executeRequestWithPayloads(actualAddress, address, input, shouldUseTLS, value, previous, callback); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -93,6 +96,7 @@ func (request *Request) executeRequestWithPayloads(actualAddress, address, input
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
request.dynamicValues = generators.MergeMaps(payloads, map[string]interface{}{"Hostname": address})
|
request.dynamicValues = generators.MergeMaps(payloads, map[string]interface{}{"Hostname": address})
|
||||||
|
|
||||||
if host, _, splitErr := net.SplitHostPort(actualAddress); splitErr == nil {
|
if host, _, splitErr := net.SplitHostPort(actualAddress); splitErr == nil {
|
||||||
|
|
Loading…
Reference in New Issue