Skip to content

Commit b9b9bb4

Browse files
committed
New flag to choose reason types
1 parent 7476d7a commit b9b9bb4

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pkg/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type (
2121
DeclineCookies bool
2222
Force bool
2323
UseHTTP bool
24+
ReasonTypes string
2425
CLDiff int
2526
HMDiff int
2627
SkipTimebased bool

pkg/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ func ParseFlags(vers string) {
7171
"force", "f", false, "Perform the tests no matter if there is a cache or even the cachebuster works or not")
7272
appendString(&generalOptions, &ignoreStatus,
7373
"ignorestatus", "is", "", "Ignore a specific status code for cache poisoning")
74+
appendString(&generalOptions, &Config.ReasonTypes,
75+
"reasontypes", "rt", "body,header,status,length", "Choose which reason types to use for cache poisoning. Choose from: body (reflection in body),header (reflection in header), status (change of status code), length (change of body length). Default is 'body,header,status,length'")
7476
appendInt(&generalOptions, &Config.CLDiff,
7577
"contentlengthdifference", "cldiff", 5000, "Threshold for reporting possible Finding, when 'poisoned' response differs more from the original length. Default is 5000. 0 = don't check. May be prone to false positives!")
7678
appendInt(&generalOptions, &Config.HMDiff,

pkg/requests.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func getRespSplit() string {
4949

5050
func checkPoisoningIndicators(repResult *reportResult, repCheck reportCheck, success string, body string, poison string, statusCode1 int, statusCode2 int, sameBodyLength bool, header http.Header, recursive bool) []string {
5151
headersWithPoison := []string{}
52-
if header != nil && poison != "" && poison != "http" && poison != "https" && poison != "nothttps" && poison != "1" { // dont check for reflection of http/https/nothttps (used by forwarded headers), 1 (used by DOS) or empty poison
52+
if strings.Contains(Config.ReasonTypes, "header") && header != nil && poison != "" && poison != "http" && poison != "https" && poison != "nothttps" && poison != "1" { // dont check for reflection of http/https/nothttps (used by forwarded headers), 1 (used by DOS) or empty poison
5353
for x := range header {
5454
if x == RESP_SPLIT_HEADER && header.Get(x) == RESP_SPLIT_VALUE {
5555
repCheck.Reason = "HTTP Response Splitting"
@@ -62,14 +62,14 @@ func checkPoisoningIndicators(repResult *reportResult, repCheck reportCheck, suc
6262

6363
if repCheck.Reason == "" {
6464
// check for reflrection in body
65-
if poison != "" && poison != "http" && poison != "https" && poison != "nothttps" && poison != "1" && strings.Contains(body, poison) { // dont check for reflection of http/https/nothttps (used by forwarded headers), 1 (used by DOS) or empty poison
65+
if strings.Contains(Config.ReasonTypes, "body") && poison != "" && poison != "http" && poison != "https" && poison != "nothttps" && poison != "1" && strings.Contains(body, poison) { // dont check for reflection of http/https/nothttps (used by forwarded headers), 1 (used by DOS) or empty poison
6666
repCheck.Reason = fmt.Sprintf("Reflection Body: Response Body contained poison value %s %d times", poison, strings.Count(body, poison))
6767
repCheck.Occurrences = findOccurrencesWithContext(body, poison, 25)
6868
// check for reflection in headers
6969
} else if len(headersWithPoison) > 0 {
7070
repCheck.Reason = fmt.Sprintf("Reflection Header: Response Header(s) %s contained poison value %s", strings.Join(headersWithPoison, ", "), poison)
7171
// check for different status code
72-
} else if statusCode1 >= 0 && statusCode1 != Config.Website.StatusCode && statusCode1 == statusCode2 {
72+
} else if strings.Contains(Config.ReasonTypes, "status") && statusCode1 >= 0 && statusCode1 != Config.Website.StatusCode && statusCode1 == statusCode2 {
7373
// check if status code should be ignored
7474
for _, status := range Config.IgnoreStatus {
7575
if statusCode1 == status || Config.Website.StatusCode == status {
@@ -104,7 +104,7 @@ func checkPoisoningIndicators(repResult *reportResult, repCheck reportCheck, suc
104104
repCheck.Reason = fmt.Sprintf("Changed Status Code: Status Code %d differed from %d", statusCode1, Config.Website.StatusCode)
105105
}
106106
// check for different body length
107-
} else if Config.CLDiff != 0 && success != "" && sameBodyLength && len(body) > 0 && compareLengths(len(body), len(Config.Website.Body), Config.CLDiff) {
107+
} else if strings.Contains(Config.ReasonTypes, "length") && Config.CLDiff != 0 && success != "" && sameBodyLength && len(body) > 0 && compareLengths(len(body), len(Config.Website.Body), Config.CLDiff) {
108108
if !recursive {
109109
var tmpWebsite WebsiteStruct
110110
var err error

0 commit comments

Comments
 (0)