Extending http variables list with dns generated variables

dev
mzack 2022-01-14 12:00:59 +01:00
parent 7ff2335935
commit 33f6f510b1
2 changed files with 6 additions and 3 deletions

View File

@ -183,7 +183,7 @@ func (request *Request) Make(domain string) (*dns.Msg, error) {
var q dns.Question
final := replacer.Replace(request.Name, generateDNSVariables(domain))
final := replacer.Replace(request.Name, GenerateDNSVariables(domain))
q.Name = dns.Fqdn(final)
q.Qclass = request.class
@ -250,7 +250,8 @@ func classToInt(class string) uint16 {
return uint16(result)
}
func generateDNSVariables(domain string) map[string]interface{} {
// GenerateDNSVariables from a dns name
func GenerateDNSVariables(domain string) map[string]interface{} {
parsed, err := publicsuffix.Parse(strings.TrimSuffix(domain, "."))
if err != nil {
return map[string]interface{}{"FQDN": domain}

View File

@ -20,6 +20,7 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/replacer"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/dns"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/race"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/raw"
"github.com/projectdiscovery/nuclei/v2/pkg/types"
@ -377,7 +378,7 @@ func generateVariables(parsed *url.URL, trailingSlash bool) map[string]interface
if base == "." {
base = ""
}
return map[string]interface{}{
httpVariables := map[string]interface{}{
"BaseURL": parsed.String(),
"RootURL": fmt.Sprintf("%s://%s", parsed.Scheme, parsed.Host),
"Hostname": parsed.Host,
@ -387,4 +388,5 @@ func generateVariables(parsed *url.URL, trailingSlash bool) map[string]interface
"File": base,
"Scheme": parsed.Scheme,
}
return generators.MergeMaps(httpVariables, dns.GenerateDNSVariables(domain))
}