2021-02-27 12:33:27 +05:30
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2021-11-05 03:01:41 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
2021-02-27 12:33:27 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var dnsTestCases = map[string]testutils.TestCase{
|
2023-06-09 17:24:24 +02:00
|
|
|
"protocols/dns/basic.yaml": &dnsBasic{},
|
|
|
|
|
"protocols/dns/ptr.yaml": &dnsPtr{},
|
|
|
|
|
"protocols/dns/caa.yaml": &dnsCAA{},
|
|
|
|
|
"protocols/dns/tlsa.yaml": &dnsTLSA{},
|
|
|
|
|
"protocols/dns/variables.yaml": &dnsVariables{},
|
|
|
|
|
"protocols/dns/payload.yaml": &dnsPayload{},
|
|
|
|
|
"protocols/dns/dsl-matcher-variable.yaml": &dnsDSLMatcherVariable{},
|
2021-02-27 12:33:27 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type dnsBasic struct{}
|
|
|
|
|
|
2021-09-03 17:25:50 +03:00
|
|
|
// Execute executes a test case and returns an error if occurred
|
2021-02-27 12:33:27 +05:30
|
|
|
func (h *dnsBasic) Execute(filePath string) error {
|
2021-10-01 18:23:06 +03:00
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug)
|
2021-02-27 12:33:27 +05:30
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2021-12-15 16:03:57 +02:00
|
|
|
return expectResultsCount(results, 1)
|
2021-02-27 12:33:27 +05:30
|
|
|
}
|
2022-01-18 13:47:15 +01:00
|
|
|
|
|
|
|
|
type dnsPtr struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
2022-01-18 13:49:23 +01:00
|
|
|
func (h *dnsPtr) Execute(filePath string) error {
|
2022-01-18 13:47:15 +01:00
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "1.1.1.1", debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return expectResultsCount(results, 1)
|
|
|
|
|
}
|
2022-02-02 07:54:15 +01:00
|
|
|
|
|
|
|
|
type dnsCAA struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *dnsCAA) Execute(filePath string) error {
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "google.com", debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return expectResultsCount(results, 1)
|
|
|
|
|
}
|
2022-04-02 02:14:00 +05:30
|
|
|
|
2022-12-28 22:42:02 +07:00
|
|
|
type dnsTLSA struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *dnsTLSA) Execute(filePath string) error {
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "scanme.sh", debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return expectResultsCount(results, 0)
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-02 02:14:00 +05:30
|
|
|
type dnsVariables struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *dnsVariables) Execute(filePath string) error {
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return expectResultsCount(results, 1)
|
|
|
|
|
}
|
2023-05-02 17:13:11 +05:30
|
|
|
|
2023-05-11 03:26:29 +05:30
|
|
|
type dnsPayload struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *dnsPayload) Execute(filePath string) error {
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "google.com", debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if err := expectResultsCount(results, 3); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// override payload from CLI
|
|
|
|
|
results, err = testutils.RunNucleiTemplateAndGetResults(filePath, "google.com", debug, "-var", "subdomain_wordlist=subdomains.txt")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return expectResultsCount(results, 4)
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-02 17:13:11 +05:30
|
|
|
type dnsDSLMatcherVariable struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *dnsDSLMatcherVariable) Execute(filePath string) error {
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return expectResultsCount(results, 1)
|
|
|
|
|
}
|