Adding tls support

dev
Mzack9999 2021-02-18 01:37:48 +01:00
parent d08cd93838
commit 0985df30c3
2 changed files with 19 additions and 3 deletions

View File

@ -15,7 +15,7 @@ import (
type Request struct {
ID string `yaml:"id"`
// Address is the address to send requests to (host:port combos generally)
// Address is the address to send requests to (host:port:tls combos generally)
Address []string `yaml:"host"`
addresses []keyValue

View File

@ -15,6 +15,8 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/replacer"
)
const tlsSuffix = ":tls"
var _ protocols.Request = &Request{}
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
@ -53,12 +55,26 @@ func (r *Request) executeAddress(actualAddress, address, input string, previous
return err
}
var hostname string
var (
hostname string
tls bool
conn net.Conn
err error
)
// check if the connection should be encrypted
if strings.HasSuffix(actualAddress, tlsSuffix) {
tls = true
actualAddress = strings.TrimSuffix(actualAddress, tlsSuffix)
}
if host, _, err := net.SplitHostPort(actualAddress); err == nil {
hostname = host
}
conn, err := r.dialer.Dial(context.Background(), "tcp", actualAddress)
if tls {
conn, err = r.dialer.DialTLS(context.Background(), "tcp", actualAddress)
} else {
conn, err = r.dialer.Dial(context.Background(), "tcp", actualAddress)
}
if err != nil {
r.options.Output.Request(r.options.TemplateID, address, "network", err)
r.options.Progress.DecrementRequests(1)