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 <mzack9999@protonmail.com>
This commit is contained in:
xm1k3 2022-12-20 21:32:18 +01:00 committed by GitHub
parent aaae68ee50
commit bbb561b097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -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)"

View File

@ -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)
}

View File

@ -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