mirror of https://github.com/daffainfo/nuclei.git
Merge pull request #1490 from projectdiscovery/issue-1433-additional-http-vars
Extending http variables list with dns generated variablesdev
commit
562c89c1d4
|
@ -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}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGenerateDNSVariables(t *testing.T) {
|
||||
vars := generateDNSVariables("www.projectdiscovery.io")
|
||||
vars := GenerateDNSVariables("www.projectdiscovery.io")
|
||||
require.Equal(t, map[string]interface{}{
|
||||
"FQDN": "www.projectdiscovery.io",
|
||||
"RDN": "projectdiscovery.io",
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue