From bbb561b0977e8fe9653afdc66db74a2f66223b0c Mon Sep 17 00:00:00 2001 From: xm1k3 Date: Tue, 20 Dec 2022 21:32:18 +0100 Subject: [PATCH] CLI variables are not accessible in SSL Protocol (#3069) * added vars payload also in ssl * fix on ssl.go, moved function on payloadValues creation * added integration test * rebase + minor changes Co-authored-by: Mzack9999 --- integration_tests/ssl/ssl-with-vars.yaml | 14 ++++++++++++++ v2/cmd/integration-test/ssl.go | 21 +++++++++++++++++++++ v2/pkg/protocols/ssl/ssl.go | 3 ++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 integration_tests/ssl/ssl-with-vars.yaml 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