Skip to content

Commit 54fb082

Browse files
committed
implement ignorestatus flag
1 parent accdb13 commit 54fb082

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

pkg/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type (
2626
HMDiff int
2727
CacheHeader string
2828
DisableColor bool
29+
IgnoreStatus []int
2930

3031
Recursivity int
3132
RecInclude string

pkg/flags.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"runtime"
8+
"strconv"
89
"strings"
910
"text/tabwriter"
1011

@@ -45,6 +46,8 @@ func ParseFlags(vers string) {
4546
// General Options
4647
techniqueNames := "deception,cookies,css,forwarding,smuggling,dos,headers,parameters,fatget,cloaking,splitting"
4748

49+
var ignoreStatus string
50+
4851
appendInt(&generalOptions, &Config.Verbosity,
4952
"verbosity", "v", 1, "Set verbosity. 0 = quiet, 1 = normal, 2 = verbose")
5053
appendFloat(&generalOptions, &Config.ReqRate,
@@ -63,6 +66,8 @@ func ParseFlags(vers string) {
6366
"proxyurl", "purl", "http://127.0.0.1:8080", "Url for the proxy. Default value is http://127.0.0.1:8080")
6467
appendBoolean(&generalOptions, &Config.Force,
6568
"force", "f", false, "Perform the tests no matter if there is a cache or even the cachebuster works or not")
69+
appendString(&generalOptions, &ignoreStatus,
70+
"ignorestatus", "is", "", "Specify a custom cache header")
6671
appendInt(&generalOptions, &Config.CLDiff,
6772
"contentlengthdifference", "cldiff", 0, "Threshold for reporting possible Finding, when 'poisoned' response differs more from the original length. Default is 0 (don't check)")
6873
appendInt(&generalOptions, &Config.HMDiff,
@@ -165,6 +170,16 @@ func ParseFlags(vers string) {
165170
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
166171
}
167172

173+
// IgnoreStatus string to int slice
174+
statusSlice := strings.Split(ignoreStatus, ",")
175+
for _, status := range statusSlice {
176+
statusInt, err := strconv.Atoi(strings.TrimSpace(status))
177+
if err != nil {
178+
PrintFatal("Error converting to int: " + err.Error())
179+
}
180+
Config.IgnoreStatus = append(Config.IgnoreStatus, statusInt)
181+
}
182+
168183
// Read RecExcludeURL(s)
169184
if recExcludeStr != "" {
170185
Config.RecExclude = ReadLocalFile(recExcludeStr, "RecExclude")

pkg/requests.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"net/http"
99
"net/http/httputil"
10+
"strconv"
1011
"strings"
1112
"sync"
1213

@@ -77,6 +78,15 @@ func checkPoisoningIndicators(repResult *reportResult, request reportRequest, su
7778
request.Reason = fmt.Sprintf("%s header contains poison value %s", headerWithPoison, poison)
7879
testForResponseSplitting = true
7980
} else if statusCode1 >= 0 && statusCode1 != Config.Website.StatusCode && statusCode1 == statusCode2 {
81+
// check if status code should be ignored
82+
if len(Config.IgnoreStatus) > 0 {
83+
for _, status := range Config.IgnoreStatus {
84+
if statusCode1 == status || Config.Website.StatusCode == status {
85+
PrintVerbose("Skipped Status Code "+strconv.Itoa(status), NoColor, 2)
86+
return testForResponseSplitting
87+
}
88+
}
89+
}
8090
if !recursive {
8191
var tmpWebsite WebsiteStruct
8292
var err error

0 commit comments

Comments
 (0)