diff --git a/integration_tests/ssl/ssl-with-vars.yaml b/integration_tests/ssl/ssl-with-vars.yaml new file mode 100644 index 000000000..1827aa0e9 --- /dev/null +++ b/integration_tests/ssl/ssl-with-vars.yaml @@ -0,0 +1,14 @@ +id: ssl-with-vars + +info: + name: SSL with variables + author: pdteam + severity: info + tags: ssl + +ssl: + - address: "{{Host}}:{{Port}}" + matchers: + - type: dsl + dsl: + - "print_debug(test)" diff --git a/v2/cmd/integration-test/ssl.go b/v2/cmd/integration-test/ssl.go index 62f103cb1..7f3374816 100644 --- a/v2/cmd/integration-test/ssl.go +++ b/v2/cmd/integration-test/ssl.go @@ -12,6 +12,7 @@ var sslTestcases = map[string]testutils.TestCase{ "ssl/basic-ztls.yaml": &sslBasicZtls{}, "ssl/custom-cipher.yaml": &sslCustomCipher{}, "ssl/custom-version.yaml": &sslCustomVersion{}, + "ssl/ssl-with-vars.yaml": &sslWithVars{}, } type sslBasic struct{} @@ -97,3 +98,23 @@ func (h *sslCustomVersion) Execute(filePath string) error { return expectResultsCount(results, 1) } + +type sslWithVars struct{} + +func (h *sslWithVars) Execute(filePath string) error { + ts := testutils.NewTCPServer(&tls.Config{}, defaultStaticPort, func(conn net.Conn) { + defer conn.Close() + data := make([]byte, 4) + if _, err := conn.Read(data); err != nil { + return + } + }) + defer ts.Close() + + results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug, "-V", "test=asdasdas") + if err != nil { + return err + } + + return expectResultsCount(results, 1) +} diff --git a/v2/pkg/protocols/ssl/ssl.go b/v2/pkg/protocols/ssl/ssl.go index ec54a352b..aba6be818 100644 --- a/v2/pkg/protocols/ssl/ssl.go +++ b/v2/pkg/protocols/ssl/ssl.go @@ -145,10 +145,11 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa hostname, port, _ := net.SplitHostPort(hostPort) requestOptions := request.options - payloadValues := make(map[string]interface{}) + payloadValues := generators.BuildPayloadFromOptions(request.options.Options) for k, v := range dynamicValues { payloadValues[k] = v } + payloadValues["Hostname"] = hostPort payloadValues["Host"] = hostname payloadValues["Port"] = port