From 2ed33e472367c9ffe77062a1723d5b893020e0b8 Mon Sep 17 00:00:00 2001 From: mzack Date: Thu, 11 Apr 2024 18:57:50 +0200 Subject: [PATCH 1/3] adding dns srv type --- pkg/protocols/dns/dns.go | 2 ++ pkg/protocols/dns/dns_types.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pkg/protocols/dns/dns.go b/pkg/protocols/dns/dns.go index 80c14d23..0a1bbca6 100644 --- a/pkg/protocols/dns/dns.go +++ b/pkg/protocols/dns/dns.go @@ -275,6 +275,8 @@ func questionTypeToInt(questionType string) uint16 { question = dns.TypeTLSA case "ANY": question = dns.TypeANY + case "SRV": + question = dns.TypeSRV } return question } diff --git a/pkg/protocols/dns/dns_types.go b/pkg/protocols/dns/dns_types.go index 034f69b3..8201df22 100644 --- a/pkg/protocols/dns/dns_types.go +++ b/pkg/protocols/dns/dns_types.go @@ -37,6 +37,8 @@ const ( TLSA // name:ANY ANY + // name:SRV + SRV limit ) @@ -54,6 +56,7 @@ var DNSRequestTypeMapping = map[DNSRequestType]string{ CAA: "CAA", TLSA: "TLSA", ANY: "ANY", + SRV: "SRV", } // GetSupportedDNSRequestTypes returns list of supported types From 0807113e6c445171b62a0a18a53a0bd09f950af5 Mon Sep 17 00:00:00 2001 From: mzack Date: Fri, 12 Apr 2024 00:02:43 +0200 Subject: [PATCH 2/3] adding more query types test --- cmd/integration-test/dns.go | 18 +++++++++++++++--- .../protocols/dns/{basic.yaml => a.yaml} | 6 +++--- integration_tests/protocols/dns/aaaa.yaml | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) rename integration_tests/protocols/dns/{basic.yaml => a.yaml} (69%) create mode 100644 integration_tests/protocols/dns/aaaa.yaml diff --git a/cmd/integration-test/dns.go b/cmd/integration-test/dns.go index 982aab98..9f188371 100644 --- a/cmd/integration-test/dns.go +++ b/cmd/integration-test/dns.go @@ -5,7 +5,8 @@ import ( ) var dnsTestCases = []TestCaseInfo{ - {Path: "protocols/dns/basic.yaml", TestCase: &dnsBasic{}}, + {Path: "protocols/dns/a.yaml", TestCase: &dnsA{}}, + {Path: "protocols/dns/aaaa.yaml", TestCase: &dnsAAAA{}}, {Path: "protocols/dns/ptr.yaml", TestCase: &dnsPtr{}}, {Path: "protocols/dns/caa.yaml", TestCase: &dnsCAA{}}, {Path: "protocols/dns/tlsa.yaml", TestCase: &dnsTLSA{}}, @@ -14,10 +15,21 @@ var dnsTestCases = []TestCaseInfo{ {Path: "protocols/dns/dsl-matcher-variable.yaml", TestCase: &dnsDSLMatcherVariable{}}, } -type dnsBasic struct{} +type dnsA struct{} // Execute executes a test case and returns an error if occurred -func (h *dnsBasic) Execute(filePath string) error { +func (h *dnsA) Execute(filePath string) error { + results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug) + if err != nil { + return err + } + return expectResultsCount(results, 1) +} + +type dnsAAAA struct{} + +// Execute executes a test case and returns an error if occurred +func (h *dnsAAAA) Execute(filePath string) error { results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug) if err != nil { return err diff --git a/integration_tests/protocols/dns/basic.yaml b/integration_tests/protocols/dns/a.yaml similarity index 69% rename from integration_tests/protocols/dns/basic.yaml rename to integration_tests/protocols/dns/a.yaml index b0dbdf3b..53897462 100644 --- a/integration_tests/protocols/dns/basic.yaml +++ b/integration_tests/protocols/dns/a.yaml @@ -1,7 +1,7 @@ -id: basic-dns-example +id: basic-dns-a-example info: - name: Test DNS Template + name: Test DNS A Query Template author: pdteam severity: info @@ -14,4 +14,4 @@ dns: matchers: - type: word words: - - "1.1.1.1" \ No newline at end of file + - "1.1.1.1" diff --git a/integration_tests/protocols/dns/aaaa.yaml b/integration_tests/protocols/dns/aaaa.yaml new file mode 100644 index 00000000..3df3293a --- /dev/null +++ b/integration_tests/protocols/dns/aaaa.yaml @@ -0,0 +1,17 @@ +id: basic-dns-aaaa-example + +info: + name: Test DNS AAAA Query Template + author: pdteam + severity: info + +dns: + - name: "{{FQDN}}" + type: AAAA + class: inet + recursion: true + retries: 3 + matchers: + - type: word + words: + - "2606:4700:4700::1001" From 8f084eedd63b3892f90d8d58b9d1ba73074d9fda Mon Sep 17 00:00:00 2001 From: mzack Date: Fri, 12 Apr 2024 00:22:11 +0200 Subject: [PATCH 3/3] adding more tests --- cmd/integration-test/dns.go | 23 +++++++------------ cmd/nuclei/srv.yaml | 18 +++++++++++++++ .../protocols/code/pre-condition.yaml | 2 +- .../protocols/code/py-env-var.yaml | 2 +- integration_tests/protocols/code/py-file.yaml | 2 +- .../protocols/code/py-interactsh.yaml | 2 +- .../protocols/code/py-snippet.yaml | 2 +- integration_tests/protocols/dns/a.yaml | 2 +- integration_tests/protocols/dns/aaaa.yaml | 2 +- integration_tests/protocols/dns/cname.yaml | 18 +++++++++++++++ integration_tests/protocols/dns/ns.yaml | 18 +++++++++++++++ integration_tests/protocols/dns/srv.yaml | 18 +++++++++++++++ integration_tests/protocols/dns/txt.yaml | 18 +++++++++++++++ 13 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 cmd/nuclei/srv.yaml create mode 100644 integration_tests/protocols/dns/cname.yaml create mode 100644 integration_tests/protocols/dns/ns.yaml create mode 100644 integration_tests/protocols/dns/srv.yaml create mode 100644 integration_tests/protocols/dns/txt.yaml diff --git a/cmd/integration-test/dns.go b/cmd/integration-test/dns.go index 9f188371..82cf9c91 100644 --- a/cmd/integration-test/dns.go +++ b/cmd/integration-test/dns.go @@ -5,8 +5,12 @@ import ( ) var dnsTestCases = []TestCaseInfo{ - {Path: "protocols/dns/a.yaml", TestCase: &dnsA{}}, - {Path: "protocols/dns/aaaa.yaml", TestCase: &dnsAAAA{}}, + {Path: "protocols/dns/a.yaml", TestCase: &dnsBasic{}}, + {Path: "protocols/dns/aaaa.yaml", TestCase: &dnsBasic{}}, + {Path: "protocols/dns/cname.yaml", TestCase: &dnsBasic{}}, + {Path: "protocols/dns/srv.yaml", TestCase: &dnsBasic{}}, + {Path: "protocols/dns/ns.yaml", TestCase: &dnsBasic{}}, + {Path: "protocols/dns/txt.yaml", TestCase: &dnsBasic{}}, {Path: "protocols/dns/ptr.yaml", TestCase: &dnsPtr{}}, {Path: "protocols/dns/caa.yaml", TestCase: &dnsCAA{}}, {Path: "protocols/dns/tlsa.yaml", TestCase: &dnsTLSA{}}, @@ -15,21 +19,10 @@ var dnsTestCases = []TestCaseInfo{ {Path: "protocols/dns/dsl-matcher-variable.yaml", TestCase: &dnsDSLMatcherVariable{}}, } -type dnsA struct{} +type dnsBasic struct{} // Execute executes a test case and returns an error if occurred -func (h *dnsA) Execute(filePath string) error { - results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug) - if err != nil { - return err - } - return expectResultsCount(results, 1) -} - -type dnsAAAA struct{} - -// Execute executes a test case and returns an error if occurred -func (h *dnsAAAA) Execute(filePath string) error { +func (h *dnsBasic) Execute(filePath string) error { results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug) if err != nil { return err diff --git a/cmd/nuclei/srv.yaml b/cmd/nuclei/srv.yaml new file mode 100644 index 00000000..198b397c --- /dev/null +++ b/cmd/nuclei/srv.yaml @@ -0,0 +1,18 @@ +id: basic-dns-a-example + +info: + name: Test DNS A Query Template + author: pdteam + severity: info + +dns: + - name: "{{FQDN}}" + type: SRV + class: inet + recursion: true + retries: 3 + matchers: + - type: word + part: all + words: + - "SRV" diff --git a/integration_tests/protocols/code/pre-condition.yaml b/integration_tests/protocols/code/pre-condition.yaml index a61b4f90..1c44e957 100644 --- a/integration_tests/protocols/code/pre-condition.yaml +++ b/integration_tests/protocols/code/pre-condition.yaml @@ -23,4 +23,4 @@ code: - type: dsl dsl: - true -# digest: 4a0a00473045022100c7215ce9f11e6a51c193bb54643a05cdd1cde18a3abb6c9983c5c7524d3ff03002203d93581c81d3ad5db463570cbbd2bdee529328d32a5b00e037610c211e448cef:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file +# digest: 490a004630440220192fb8f704b078c2885047b85ac1a0491be86485c033a976d201599683a35aab0220604b1c3781e9d97079d0e5c23c18e6a2d87493c8e2b930536e692ee7d06e9247:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file diff --git a/integration_tests/protocols/code/py-env-var.yaml b/integration_tests/protocols/code/py-env-var.yaml index 4ccf3648..9ff947c2 100644 --- a/integration_tests/protocols/code/py-env-var.yaml +++ b/integration_tests/protocols/code/py-env-var.yaml @@ -20,4 +20,4 @@ code: - type: word words: - "hello from input baz" -# digest: 4a0a0047304502207e3a5eda5f3207c3c01c820562243281926c1215224a7c80ed7528559b9f52cb022100f6ef99bb45843f481705778630f2cfd8f4d1cc3acb96392ff016f22e06aa91af:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file +# digest: 4a0a00473045022033f72f1b9d5143f58a2dc79c2597000f34080251ac3702c36c3fad00917dfeeb0221009ba05c715c9e2e36dba471be6c0106a09ae3822d8a3e9e4bcf377e9f4a395a01:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file diff --git a/integration_tests/protocols/code/py-file.yaml b/integration_tests/protocols/code/py-file.yaml index 9e0b041b..ad69371d 100644 --- a/integration_tests/protocols/code/py-file.yaml +++ b/integration_tests/protocols/code/py-file.yaml @@ -18,4 +18,4 @@ code: - type: word words: - "hello from input" -# digest: 4a0a004730450220069673af9bd6d6677f9529d06f5d8bd46d543089a4731ed18ee806761d75fd60022100913a3e27b0a5809baf710ba9585bf9fe729634c0e19e3e13eef70a6bd100df34:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file +# digest: 4a0a004730450220377128cb11d9f6f0fee1f4dbd841e46783de26e90a216fa55a7609ee2bc823c60221009166ee0f85e3a1811588ab19e73ea96ab3d582dc8180dbcbbad0ea9ab7e9025d:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file diff --git a/integration_tests/protocols/code/py-interactsh.yaml b/integration_tests/protocols/code/py-interactsh.yaml index 24e4b062..76d14efb 100644 --- a/integration_tests/protocols/code/py-interactsh.yaml +++ b/integration_tests/protocols/code/py-interactsh.yaml @@ -26,4 +26,4 @@ code: part: interactsh_protocol words: - "http" -# digest: 490a00463044022003b8d069e3c84412729c43e33013a52ee04eabcf096d511979691d71d8e905f60220011f4475899abed4f86b4bd5e6c2423750759135206e4729826afe1ed8a44f4d:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file +# digest: 4b0a00483046022100d472d50bd83117d334f5217c7a40dcdf34138e90029eaace51697d902296bf37022100a393b49420a96f60d6d89b79b5135ee2233b2468d374851890eea114b08195d1:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file diff --git a/integration_tests/protocols/code/py-snippet.yaml b/integration_tests/protocols/code/py-snippet.yaml index 287ca2c6..4837fa7e 100644 --- a/integration_tests/protocols/code/py-snippet.yaml +++ b/integration_tests/protocols/code/py-snippet.yaml @@ -21,4 +21,4 @@ code: - type: word words: - "hello from input" -# digest: 4a0a00473045022100c291615cf2a8005450c17a6554e81a9cdab14743b299f0679c644247929198b502206fdacc8ab173bde2b4015340012637916bf2659f66f320fcc06b97ac639072a1:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file +# digest: 4b0a004830460221008886054bb5dd6345e434e30f31c8fddce3c484a4f33aa6321b5185675866029d022100d188a83d0fde029f8b586061c65ab72b43755c3fb10fdd59501bb9bbadbb1ff7:4a3eb6b4988d95847d4203be25ed1d46 \ No newline at end of file diff --git a/integration_tests/protocols/dns/a.yaml b/integration_tests/protocols/dns/a.yaml index 53897462..0e512458 100644 --- a/integration_tests/protocols/dns/a.yaml +++ b/integration_tests/protocols/dns/a.yaml @@ -1,4 +1,4 @@ -id: basic-dns-a-example +id: dns-a-query-example info: name: Test DNS A Query Template diff --git a/integration_tests/protocols/dns/aaaa.yaml b/integration_tests/protocols/dns/aaaa.yaml index 3df3293a..58a2e496 100644 --- a/integration_tests/protocols/dns/aaaa.yaml +++ b/integration_tests/protocols/dns/aaaa.yaml @@ -1,4 +1,4 @@ -id: basic-dns-aaaa-example +id: dns-aaaa-query-example info: name: Test DNS AAAA Query Template diff --git a/integration_tests/protocols/dns/cname.yaml b/integration_tests/protocols/dns/cname.yaml new file mode 100644 index 00000000..f4ddb8a2 --- /dev/null +++ b/integration_tests/protocols/dns/cname.yaml @@ -0,0 +1,18 @@ +id: dns-cname-query-example + +info: + name: Test DNS CNAME Query Template + author: pdteam + severity: info + +dns: + - name: "{{FQDN}}" + type: CNAME + class: inet + recursion: true + retries: 3 + matchers: + - type: word + part: all + words: + - "CNAME" diff --git a/integration_tests/protocols/dns/ns.yaml b/integration_tests/protocols/dns/ns.yaml new file mode 100644 index 00000000..9d406557 --- /dev/null +++ b/integration_tests/protocols/dns/ns.yaml @@ -0,0 +1,18 @@ +id: dns-ns-query-example + +info: + name: Test DNS NS Query Template + author: pdteam + severity: info + +dns: + - name: "{{FQDN}}" + type: NS + class: inet + recursion: true + retries: 3 + matchers: + - type: word + part: all + words: + - "NS" diff --git a/integration_tests/protocols/dns/srv.yaml b/integration_tests/protocols/dns/srv.yaml new file mode 100644 index 00000000..2669333c --- /dev/null +++ b/integration_tests/protocols/dns/srv.yaml @@ -0,0 +1,18 @@ +id: dns-a-query-example + +info: + name: Test DNS SRV Query Template + author: pdteam + severity: info + +dns: + - name: "{{FQDN}}" + type: SRV + class: inet + recursion: true + retries: 3 + matchers: + - type: word + part: all + words: + - "SRV" diff --git a/integration_tests/protocols/dns/txt.yaml b/integration_tests/protocols/dns/txt.yaml new file mode 100644 index 00000000..273a53ab --- /dev/null +++ b/integration_tests/protocols/dns/txt.yaml @@ -0,0 +1,18 @@ +id: dns-txt-query-example + +info: + name: Test DNS TXT Query Template + author: pdteam + severity: info + +dns: + - name: "{{FQDN}}" + type: TXT + class: inet + recursion: true + retries: 3 + matchers: + - type: word + part: all + words: + - "TXT"