mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 04:45:27 +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/self-contained.yaml": &networkRequestSelContained{},
|
||||
"network/variables.yaml": &networkVariables{},
|
||||
"network/same-address.yaml": &networkBasic{},
|
||||
}
|
||||
|
||||
const defaultStaticPort = 5431
|
||||
|
||||
@ -29,6 +29,7 @@ import (
|
||||
protocolutils "github.com/projectdiscovery/nuclei/v2/pkg/protocols/utils"
|
||||
templateTypes "github.com/projectdiscovery/nuclei/v2/pkg/templates/types"
|
||||
errorutil "github.com/projectdiscovery/utils/errors"
|
||||
mapsutil "github.com/projectdiscovery/utils/maps"
|
||||
)
|
||||
|
||||
var _ protocols.Request = &Request{}
|
||||
@ -57,9 +58,16 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, metadata,
|
||||
variablesMap := request.options.Variables.Evaluate(variables)
|
||||
variables = generators.MergeMaps(variablesMap, variables, request.options.Constants)
|
||||
|
||||
visitedAddressess := make(mapsutil.Map[string, struct{}])
|
||||
|
||||
for _, kv := range request.addresses {
|
||||
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 {
|
||||
outputEvent := request.responseToDSLMap("", "", "", address, "")
|
||||
callback(&output.InternalWrappedEvent{InternalEvent: outputEvent})
|
||||
@ -110,7 +118,6 @@ func (request *Request) executeRequestWithPayloads(variables map[string]interfac
|
||||
conn net.Conn
|
||||
err error
|
||||
)
|
||||
|
||||
if host, _, err := net.SplitHostPort(actualAddress); err == nil {
|
||||
hostname = host
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user