Add wildcard option to status code matcher (#26)
This commit is contained in:
parent
87c4e11674
commit
5cae980767
@ -91,7 +91,7 @@ To define the test case for ffuf, use the keyword `FUZZ` anywhere in the URL (`-
|
|||||||
Filter by amount of words in response
|
Filter by amount of words in response
|
||||||
-k TLS identity verification
|
-k TLS identity verification
|
||||||
-mc string
|
-mc string
|
||||||
Match HTTP status codes from respose (default "200,204,301,302,307,401,403")
|
Match HTTP status codes from respose, use "all" to match every response code. (default "200,204,301,302,307,401,403")
|
||||||
-mr string
|
-mr string
|
||||||
Match regexp
|
Match regexp
|
||||||
-ms string
|
-ms string
|
||||||
@ -142,6 +142,7 @@ The only dependency of ffuf is Go 1.11. No dependencies outside of Go standard l
|
|||||||
- Error counter in status bar
|
- Error counter in status bar
|
||||||
- New CLI flags: -se (stop on spurious errors) and -sa (stop on all errors, implies -se and -sf)
|
- New CLI flags: -se (stop on spurious errors) and -sa (stop on all errors, implies -se and -sf)
|
||||||
- New CLI flags: -e to provide a list of extensions to add to wordlist entries, and -D to provide DirSearch wordlist format compatibility.
|
- New CLI flags: -e to provide a list of extensions to add to wordlist entries, and -D to provide DirSearch wordlist format compatibility.
|
||||||
|
- Wildcard option for response status code matcher.
|
||||||
- v0.8
|
- v0.8
|
||||||
- New
|
- New
|
||||||
- New CLI flag to write output to a file in JSON format
|
- New CLI flag to write output to a file in JSON format
|
||||||
|
|||||||
2
main.go
2
main.go
@ -63,7 +63,7 @@ func main() {
|
|||||||
flag.StringVar(&opts.filterWords, "fw", "", "Filter by amount of words in response")
|
flag.StringVar(&opts.filterWords, "fw", "", "Filter by amount of words in response")
|
||||||
flag.StringVar(&conf.Data, "d", "", "POST data.")
|
flag.StringVar(&conf.Data, "d", "", "POST data.")
|
||||||
flag.BoolVar(&conf.Colors, "c", false, "Colorize output.")
|
flag.BoolVar(&conf.Colors, "c", false, "Colorize output.")
|
||||||
flag.StringVar(&opts.matcherStatus, "mc", "200,204,301,302,307,401,403", "Match HTTP status codes from respose")
|
flag.StringVar(&opts.matcherStatus, "mc", "200,204,301,302,307,401,403", "Match HTTP status codes from respose, use \"all\" to match every response code.")
|
||||||
flag.StringVar(&opts.matcherSize, "ms", "", "Match HTTP response size")
|
flag.StringVar(&opts.matcherSize, "ms", "", "Match HTTP response size")
|
||||||
flag.StringVar(&opts.matcherRegexp, "mr", "", "Match regexp")
|
flag.StringVar(&opts.matcherRegexp, "mr", "", "Match regexp")
|
||||||
flag.StringVar(&opts.matcherWords, "mw", "", "Match amount of words in response")
|
flag.StringVar(&opts.matcherWords, "mw", "", "Match amount of words in response")
|
||||||
|
|||||||
@ -15,17 +15,25 @@ type StatusFilter struct {
|
|||||||
func NewStatusFilter(value string) (ffuf.FilterProvider, error) {
|
func NewStatusFilter(value string) (ffuf.FilterProvider, error) {
|
||||||
var intvals []int64
|
var intvals []int64
|
||||||
for _, sv := range strings.Split(value, ",") {
|
for _, sv := range strings.Split(value, ",") {
|
||||||
intval, err := strconv.ParseInt(sv, 10, 0)
|
if sv == "all" {
|
||||||
if err != nil {
|
intvals = append(intvals, 0)
|
||||||
return &StatusFilter{}, fmt.Errorf("Status filter or matcher (-fc / -mc): invalid value %s", value)
|
} else {
|
||||||
|
intval, err := strconv.ParseInt(sv, 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
return &StatusFilter{}, fmt.Errorf("Status filter or matcher (-fc / -mc): invalid value %s", value)
|
||||||
|
}
|
||||||
|
intvals = append(intvals, intval)
|
||||||
}
|
}
|
||||||
intvals = append(intvals, intval)
|
|
||||||
}
|
}
|
||||||
return &StatusFilter{Value: intvals}, nil
|
return &StatusFilter{Value: intvals}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *StatusFilter) Filter(response *ffuf.Response) (bool, error) {
|
func (f *StatusFilter) Filter(response *ffuf.Response) (bool, error) {
|
||||||
for _, iv := range f.Value {
|
for _, iv := range f.Value {
|
||||||
|
if iv == 0 {
|
||||||
|
// Handle the "all" case
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
if iv == response.StatusCode {
|
if iv == response.StatusCode {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@ -36,7 +44,11 @@ func (f *StatusFilter) Filter(response *ffuf.Response) (bool, error) {
|
|||||||
func (f *StatusFilter) Repr() string {
|
func (f *StatusFilter) Repr() string {
|
||||||
var strval []string
|
var strval []string
|
||||||
for _, iv := range f.Value {
|
for _, iv := range f.Value {
|
||||||
strval = append(strval, strconv.Itoa(int(iv)))
|
if iv == 0 {
|
||||||
|
strval = append(strval, "all")
|
||||||
|
} else {
|
||||||
|
strval = append(strval, strconv.Itoa(int(iv)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("Response status: %s", strings.Join(strval, ","))
|
return fmt.Sprintf("Response status: %s", strings.Join(strval, ","))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user