making payloads usable in DSL

dev
Mzack9999 2020-11-25 18:27:14 +01:00
parent e5d4c7a6d0
commit 3831bfffa5
4 changed files with 14 additions and 2 deletions

View File

@ -531,6 +531,13 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest,
if len(result.historyData) < defaultMaxHistorydata {
result.Lock()
result.historyData = generators.MergeMaps(result.historyData, matchers.HTTPToMap(resp, body, headers, duration, format))
// retrieve current payloads
currentPayloads := e.bulkHTTPRequest.GetPayloadsValues(reqURL)
if currentPayloads != nil {
// merge them to history data
result.historyData = generators.MergeMaps(result.historyData, currentPayloads)
}
result.historyData = generators.MergeMaps(result.historyData, dynamicvalues)
result.Unlock()
}

View File

@ -199,7 +199,7 @@ func (m *Matcher) matchBinary(corpus string) bool {
// matchDSL matches on a generic map result
func (m *Matcher) matchDSL(mp map[string]interface{}) bool {
// Iterate over all the regexes accepted as valid
// Iterate over all the expressions accepted as valid
for i, expression := range m.dslCompiled {
result, err := expression.Evaluate(mp)
if err != nil {

View File

@ -482,3 +482,8 @@ func (r *BulkHTTPRequest) Total() int {
func (r *BulkHTTPRequest) Increment(reqURL string) {
r.gsfm.Increment(reqURL)
}
// GetPayloadsValues for the specified URL
func (r *BulkHTTPRequest) GetPayloadsValues(reqURL string) map[string]interface{} {
return r.gsfm.Value(reqURL)
}

View File

@ -66,7 +66,7 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
p.AddToTotal(template.HTTPOptions.Template.GetHTTPRequestCount())
for _, request := range template.HTTPOptions.Template.BulkRequestsHTTP {
// apply externally supplied payloads if any
// apply externally supplied headers if any
request.Headers = generators.MergeMapsWithStrings(request.Headers, headers)
// apply externally supplied payloads if any
request.Payloads = generators.MergeMaps(request.Payloads, externalVars)