mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 20:15:27 +00:00
* feat: added initial live DAST server implementation * feat: more logging + misc additions * feat: auth file support enhancements for more complex scenarios + misc * feat: added io.Reader support to input providers for http * feat: added stats db to fuzzing + use sdk for dast server + misc * feat: more additions and enhancements * misc changes to live server * misc * use utils pprof server * feat: added simpler stats tracking system * feat: fixed analyzer timeout issue + missing case fix * misc changes fix * feat: changed the logics a bit + misc changes and additions * feat: re-added slope checks + misc * feat: added baseline measurements for time based checks * chore(server): fix typos Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix(templates): potential DOM XSS Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix(authx): potential NIL deref Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * feat: misc review changes * removed debug logging * feat: remove existing cookies only * feat: lint fixes * misc * misc text update * request endpoint update * feat: added tracking for status code, waf-detection & grouped errors (#6028) * feat: added tracking for status code, waf-detection & grouped errors * lint error fixes * feat: review changes + moving to package + misc --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com> * fix var dump (#5921) * fix var dump * fix dump test * Added filename length restriction for debug mode (-srd flag) (#5931) Co-authored-by: Andrey Matveenko <an.matveenko@vkteam.ru> * more updates * Update pkg/output/stats/waf/waf.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com> Co-authored-by: Dwi Siswanto <25837540+dwisiswant0@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Dogan Can Bakir <65292895+dogancanbakir@users.noreply.github.com> Co-authored-by: 9flowers <51699499+Lercas@users.noreply.github.com> Co-authored-by: Andrey Matveenko <an.matveenko@vkteam.ru> Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
97 lines
2.7 KiB
Go
97 lines
2.7 KiB
Go
package analyzers
|
|
|
|
import (
|
|
"math/rand"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/fuzz"
|
|
"github.com/projectdiscovery/retryablehttp-go"
|
|
)
|
|
|
|
// Analyzer is an interface for all the analyzers
|
|
// that can be used for the fuzzer
|
|
type Analyzer interface {
|
|
// Name returns the name of the analyzer
|
|
Name() string
|
|
// ApplyTransformation applies the transformation to the initial payload.
|
|
ApplyInitialTransformation(data string, params map[string]interface{}) string
|
|
// Analyze is the main function for the analyzer
|
|
Analyze(options *Options) (bool, string, error)
|
|
}
|
|
|
|
// AnalyzerTemplate is the template for the analyzer
|
|
type AnalyzerTemplate struct {
|
|
// description: |
|
|
// Name is the name of the analyzer to use
|
|
// values:
|
|
// - time_delay
|
|
Name string `json:"name" yaml:"name"`
|
|
// description: |
|
|
// Parameters is the parameters for the analyzer
|
|
//
|
|
// Parameters are different for each analyzer. For example, you can customize
|
|
// time_delay analyzer with sleep_duration, time_slope_error_range, etc. Refer
|
|
// to the docs for each analyzer to get an idea about parameters.
|
|
Parameters map[string]interface{} `json:"parameters" yaml:"parameters"`
|
|
}
|
|
|
|
var (
|
|
analyzers map[string]Analyzer
|
|
)
|
|
|
|
// RegisterAnalyzer registers a new analyzer
|
|
func RegisterAnalyzer(name string, analyzer Analyzer) {
|
|
analyzers[name] = analyzer
|
|
}
|
|
|
|
// GetAnalyzer returns the analyzer for a given name
|
|
func GetAnalyzer(name string) Analyzer {
|
|
return analyzers[name]
|
|
}
|
|
|
|
func init() {
|
|
analyzers = make(map[string]Analyzer)
|
|
}
|
|
|
|
// Options contains the options for the analyzer
|
|
type Options struct {
|
|
FuzzGenerated fuzz.GeneratedRequest
|
|
HttpClient *retryablehttp.Client
|
|
ResponseTimeDelay time.Duration
|
|
AnalyzerParameters map[string]interface{}
|
|
}
|
|
|
|
var (
|
|
random = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
)
|
|
|
|
// ApplyPayloadTransformations applies the payload transformations to the payload
|
|
// It supports the below payloads -
|
|
// - [RANDNUM] => random number between 1000 and 9999
|
|
// - [RANDSTR] => random string of 4 characters
|
|
func ApplyPayloadTransformations(value string) string {
|
|
randomInt := GetRandomInteger()
|
|
randomStr := randStringBytesMask(4)
|
|
|
|
value = strings.ReplaceAll(value, "[RANDNUM]", strconv.Itoa(randomInt))
|
|
value = strings.ReplaceAll(value, "[RANDSTR]", randomStr)
|
|
return value
|
|
}
|
|
|
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
func randStringBytesMask(n int) string {
|
|
b := make([]byte, n)
|
|
for i := range b {
|
|
b[i] = letterBytes[random.Intn(len(letterBytes))]
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
// GetRandomInteger returns a random integer between 1000 and 9999
|
|
func GetRandomInteger() int {
|
|
return random.Intn(9000) + 1000
|
|
}
|