Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for using ranges in size, word count or status code mat…
…ching/filtering (#47) * allow ranges on response size matching/filtering * allow ranges on word count matching/filtering * allow ranges on http status matching/filtering * documentation update about using ranges in size, word count and status code filtering/matching * moved valuerange code to ffuf main package
- Loading branch information
Showing
9 changed files
with
110 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ffuf | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"strconv" | ||
) | ||
|
||
type ValueRange struct { | ||
Min, Max int64 | ||
} | ||
|
||
func ValueRangeFromString(instr string) (ValueRange, error) { | ||
// is the value a range | ||
minmax := regexp.MustCompile("^(\\d+)\\-(\\d+)$").FindAllStringSubmatch(instr, -1) | ||
if minmax != nil { | ||
// yes | ||
minval, err := strconv.ParseInt(minmax[0][1], 10, 0) | ||
if err != nil { | ||
return ValueRange{}, fmt.Errorf("Invalid value: %s", minmax[0][1]) | ||
} | ||
maxval, err := strconv.ParseInt(minmax[0][2], 10, 0) | ||
if err != nil { | ||
return ValueRange{}, fmt.Errorf("Invalid value: %s", minmax[0][2]) | ||
} | ||
if minval >= maxval { | ||
return ValueRange{}, fmt.Errorf("Minimum has to be smaller than maximum") | ||
} | ||
return ValueRange{minval, maxval}, nil | ||
} else { | ||
// no, a single value or something else | ||
intval, err := strconv.ParseInt(instr, 10, 0) | ||
if err != nil { | ||
return ValueRange{}, fmt.Errorf("Invalid value: %s", instr) | ||
} | ||
return ValueRange{intval, intval}, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters