mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-23 21:35:26 +00:00
Automatic target merge in network templates (#3904)
* skip visited actual addressess * removed test * adding disable clustering support
This commit is contained in:
parent
305ac6a143
commit
3dca03163c
29
integration_tests/network/same-address.yaml
Normal file
29
integration_tests/network/same-address.yaml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
id: same-target
|
||||||
|
|
||||||
|
info:
|
||||||
|
name: same-target
|
||||||
|
author: pdteam
|
||||||
|
severity: info
|
||||||
|
description: Riak is a distributed NoSQL key-value data store that offers high availability, fault tolerance, operational simplicity, and scalability.
|
||||||
|
|
||||||
|
network:
|
||||||
|
- host:
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
- "{{Hostname}}"
|
||||||
|
inputs:
|
||||||
|
- data: "PING\r\n"
|
||||||
|
read-size: 4
|
||||||
|
matchers:
|
||||||
|
- type: word
|
||||||
|
part: data
|
||||||
|
words:
|
||||||
|
- "PONG"
|
||||||
@ -12,6 +12,7 @@ var networkTestcases = map[string]testutils.TestCase{
|
|||||||
"network/multi-step.yaml": &networkMultiStep{},
|
"network/multi-step.yaml": &networkMultiStep{},
|
||||||
"network/self-contained.yaml": &networkRequestSelContained{},
|
"network/self-contained.yaml": &networkRequestSelContained{},
|
||||||
"network/variables.yaml": &networkVariables{},
|
"network/variables.yaml": &networkVariables{},
|
||||||
|
"network/same-address.yaml": &networkBasic{},
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultStaticPort = 5431
|
const defaultStaticPort = 5431
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import (
|
|||||||
protocolutils "github.com/projectdiscovery/nuclei/v2/pkg/protocols/utils"
|
protocolutils "github.com/projectdiscovery/nuclei/v2/pkg/protocols/utils"
|
||||||
templateTypes "github.com/projectdiscovery/nuclei/v2/pkg/templates/types"
|
templateTypes "github.com/projectdiscovery/nuclei/v2/pkg/templates/types"
|
||||||
errorutil "github.com/projectdiscovery/utils/errors"
|
errorutil "github.com/projectdiscovery/utils/errors"
|
||||||
|
mapsutil "github.com/projectdiscovery/utils/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ protocols.Request = &Request{}
|
var _ protocols.Request = &Request{}
|
||||||
@ -57,9 +58,16 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, metadata,
|
|||||||
variablesMap := request.options.Variables.Evaluate(variables)
|
variablesMap := request.options.Variables.Evaluate(variables)
|
||||||
variables = generators.MergeMaps(variablesMap, variables, request.options.Constants)
|
variables = generators.MergeMaps(variablesMap, variables, request.options.Constants)
|
||||||
|
|
||||||
|
visitedAddressess := make(mapsutil.Map[string, struct{}])
|
||||||
|
|
||||||
for _, kv := range request.addresses {
|
for _, kv := range request.addresses {
|
||||||
actualAddress := replacer.Replace(kv.address, variables)
|
actualAddress := replacer.Replace(kv.address, variables)
|
||||||
|
|
||||||
|
if visitedAddressess.Has(actualAddress) && !request.options.Options.DisableClustering {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
visitedAddressess.Set(actualAddress, struct{}{})
|
||||||
|
|
||||||
if err := request.executeAddress(variables, actualAddress, address, input.MetaInput.Input, kv.tls, previous, callback); err != nil {
|
if err := request.executeAddress(variables, actualAddress, address, input.MetaInput.Input, kv.tls, previous, callback); err != nil {
|
||||||
outputEvent := request.responseToDSLMap("", "", "", address, "")
|
outputEvent := request.responseToDSLMap("", "", "", address, "")
|
||||||
callback(&output.InternalWrappedEvent{InternalEvent: outputEvent})
|
callback(&output.InternalWrappedEvent{InternalEvent: outputEvent})
|
||||||
@ -110,7 +118,6 @@ func (request *Request) executeRequestWithPayloads(variables map[string]interfac
|
|||||||
conn net.Conn
|
conn net.Conn
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if host, _, err := net.SplitHostPort(actualAddress); err == nil {
|
if host, _, err := net.SplitHostPort(actualAddress); err == nil {
|
||||||
hostname = host
|
hostname = host
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user