mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 12:45:27 +00:00
experimental new syntax
This commit is contained in:
parent
148c0dec89
commit
5f0edcd8aa
@ -2,6 +2,7 @@ package generators
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
@ -20,11 +21,11 @@ func LoadPayloads(payloads map[string]interface{}) map[string][]string {
|
||||
} else {
|
||||
loadedPayloads[name] = LoadFile(v)
|
||||
}
|
||||
case interface{}:
|
||||
case []interface{}, interface{}:
|
||||
vv := payload.([]interface{})
|
||||
var v []string
|
||||
for _, vvv := range vv {
|
||||
v = append(v, vvv.(string))
|
||||
v = append(v, fmt.Sprintf("%v", vvv))
|
||||
}
|
||||
loadedPayloads[name] = v
|
||||
}
|
||||
|
||||
@ -174,7 +174,6 @@ func (r *BulkHTTPRequest) handleRawWithPaylods(raw string, baseURL string, value
|
||||
var re = regexp.MustCompile(`(?m)\{\{.+}}`)
|
||||
for _, match := range re.FindAllString(raw, -1) {
|
||||
// check if the match contains a dynamic variable
|
||||
if generators.StringContainsAnyMapItem(finValues, match) {
|
||||
expr := generators.TrimDelimiters(match)
|
||||
compiled, err := govaluate.NewEvaluableExpressionWithFunctions(expr, generators.HelperFunctions())
|
||||
if err != nil {
|
||||
@ -186,7 +185,6 @@ func (r *BulkHTTPRequest) handleRawWithPaylods(raw string, baseURL string, value
|
||||
}
|
||||
dynamicValues[expr] = result
|
||||
}
|
||||
}
|
||||
|
||||
// replace dynamic values
|
||||
dynamicReplacer := newReplacer(dynamicValues)
|
||||
|
||||
@ -15,6 +15,8 @@ func newReplacer(values map[string]interface{}) *strings.Replacer {
|
||||
for k, v := range values {
|
||||
replacerItems = append(replacerItems, fmt.Sprintf("{{%s}}", k))
|
||||
replacerItems = append(replacerItems, fmt.Sprintf("%s", v))
|
||||
replacerItems = append(replacerItems, fmt.Sprintf("%s", k))
|
||||
replacerItems = append(replacerItems, fmt.Sprintf("%s", v))
|
||||
}
|
||||
|
||||
return strings.NewReplacer(replacerItems...)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user