github.com/projectdiscovery/nuclei/v2@v2.9.15/pkg/templates/templates_doc_examples.go (about)

     1  // Package templates
     2  // nolint //do not lint as examples with no usage
     3  package templates
     4  
     5  import (
     6  	"github.com/projectdiscovery/nuclei/v2/pkg/model"
     7  	"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
     8  	"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
     9  	"github.com/projectdiscovery/nuclei/v2/pkg/operators"
    10  	"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
    11  	"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
    12  	"github.com/projectdiscovery/nuclei/v2/pkg/protocols/dns"
    13  	"github.com/projectdiscovery/nuclei/v2/pkg/protocols/file"
    14  	"github.com/projectdiscovery/nuclei/v2/pkg/protocols/http"
    15  	"github.com/projectdiscovery/nuclei/v2/pkg/protocols/network"
    16  )
    17  
    18  var (
    19  	exampleInfoStructure = model.Info{
    20  		Name:           "Argument Injection in Ruby Dragonfly",
    21  		Authors:        stringslice.StringSlice{Value: "0xspara"},
    22  		SeverityHolder: severity.Holder{Severity: severity.High},
    23  		Reference:      stringslice.NewRawStringSlice("https://zxsecurity.co.nz/research/argunment-injection-ruby-dragonfly/"),
    24  		Tags:           stringslice.StringSlice{Value: "cve,cve2021,rce,ruby"},
    25  	}
    26  	exampleNormalHTTPRequest = &http.Request{
    27  		Method: http.HTTPMethodTypeHolder{MethodType: http.HTTPGet},
    28  		Path:   []string{"{{BaseURL}}/.git/config"},
    29  		Operators: operators.Operators{
    30  			MatchersCondition: "and",
    31  			Matchers: []*matchers.Matcher{
    32  				{Type: matchers.MatcherTypeHolder{MatcherType: matchers.WordsMatcher}, Words: []string{"[core]"}},
    33  				{Type: matchers.MatcherTypeHolder{MatcherType: matchers.DSLMatcher}, DSL: []string{"!contains(tolower(body), '<html')", "!contains(tolower(body), '<body')"}, Condition: "and"},
    34  				{Type: matchers.MatcherTypeHolder{MatcherType: matchers.StatusMatcher}, Status: []int{200}}},
    35  		},
    36  	}
    37  	_ = exampleNormalHTTPRequest
    38  
    39  	recursion               = false
    40  	exampleNormalDNSRequest = &dns.Request{
    41  		Name:        "{{FQDN}}",
    42  		RequestType: dns.DNSRequestTypeHolder{DNSRequestType: dns.CNAME},
    43  		Class:       "inet",
    44  		Retries:     2,
    45  		Recursion:   &recursion,
    46  		Operators: operators.Operators{
    47  			Extractors: []*extractors.Extractor{
    48  				{Type: extractors.ExtractorTypeHolder{ExtractorType: extractors.RegexExtractor}, Regex: []string{"ec2-[-\\d]+\\.compute[-\\d]*\\.amazonaws\\.com", "ec2-[-\\d]+\\.[\\w\\d\\-]+\\.compute[-\\d]*\\.amazonaws\\.com"}},
    49  			},
    50  		},
    51  	}
    52  	_ = exampleNormalDNSRequest
    53  
    54  	exampleNormalFileRequest = &file.Request{
    55  		Extensions: []string{"all"},
    56  		Operators: operators.Operators{
    57  			Extractors: []*extractors.Extractor{
    58  				{Type: extractors.ExtractorTypeHolder{ExtractorType: extractors.RegexExtractor}, Regex: []string{"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"}},
    59  			},
    60  		},
    61  	}
    62  	_ = exampleNormalFileRequest
    63  
    64  	exampleNormalNetworkRequest = &network.Request{
    65  		Inputs:   []*network.Input{{Data: "envi\r\nquit\r\n"}},
    66  		Address:  []string{"{{Hostname}}", "{{Hostname}}:2181"},
    67  		ReadSize: 2048,
    68  		Operators: operators.Operators{
    69  			Matchers: []*matchers.Matcher{
    70  				{Type: matchers.MatcherTypeHolder{MatcherType: matchers.WordsMatcher}, Words: []string{"zookeeper.version"}},
    71  			},
    72  		},
    73  	}
    74  	_ = exampleNormalNetworkRequest
    75  )