nuclei/cmd/integration-test/dns.go

102 lines
2.9 KiB
Go
Raw Normal View History

2021-02-27 07:03:27 +00:00
package main
import (
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
2021-02-27 07:03:27 +00:00
)
var dnsTestCases = []TestCaseInfo{
2023-08-04 14:51:22 +00:00
{Path: "protocols/dns/basic.yaml", TestCase: &dnsBasic{}},
{Path: "protocols/dns/ptr.yaml", TestCase: &dnsPtr{}},
{Path: "protocols/dns/caa.yaml", TestCase: &dnsCAA{}},
{Path: "protocols/dns/tlsa.yaml", TestCase: &dnsTLSA{}},
{Path: "protocols/dns/variables.yaml", TestCase: &dnsVariables{}},
{Path: "protocols/dns/payload.yaml", TestCase: &dnsPayload{}},
{Path: "protocols/dns/dsl-matcher-variable.yaml", TestCase: &dnsDSLMatcherVariable{}},
2021-02-27 07:03:27 +00:00
}
type dnsBasic struct{}
2021-09-03 14:25:50 +00:00
// Execute executes a test case and returns an error if occurred
2021-02-27 07:03:27 +00:00
func (h *dnsBasic) Execute(filePath string) error {
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug)
2021-02-27 07:03:27 +00:00
if err != nil {
return err
}
return expectResultsCount(results, 1)
2021-02-27 07:03:27 +00:00
}
2022-01-18 12:47:15 +00:00
type dnsPtr struct{}
// Execute executes a test case and returns an error if occurred
2022-01-18 12:49:23 +00:00
func (h *dnsPtr) Execute(filePath string) error {
2022-01-18 12:47:15 +00:00
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "1.1.1.1", debug)
if err != nil {
return err
}
return expectResultsCount(results, 1)
}
2022-02-02 06:54:15 +00: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)
}
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)
}
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)
}
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)
}
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)
}