Skip to content

Commit 3aa9823

Browse files
committed
improve/fix check whether the cache returns always a miss
1 parent bc7698d commit 3aa9823

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

pkg/deception.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func webCacheDeceptionTemplate(repResult *reportResult, appendStr string) error
159159
indicValue = strings.TrimSpace(strings.ToLower(resp.Header.Get(Config.Website.Cache.Indicator)))
160160

161161
// check if there's a cache hit and if the body didn't change (otherwise it could be a cached error page, for example)
162-
if checkCacheHit(indicValue) && string(body) == Config.Website.Body {
162+
if checkCacheHit(indicValue, "") && string(body) == Config.Website.Body {
163163
repResult.Vulnerable = true
164164
repRequest.Reason = "The response got cached due to Web Cache Deception"
165165
msg = fmt.Sprintf("%s was successfully decepted! appended: %s\n", rUrl, appendStr)

pkg/recon.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func checkIfAlwaysMiss(cache CacheStruct) (bool, error) {
329329
}
330330

331331
indicValue := strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
332-
if !checkCacheHit(indicValue) {
332+
if !checkCacheHit(indicValue, cache.Indicator) {
333333
addCachebusterMap("always-miss")
334334

335335
msg := "cache returns always miss"
@@ -470,7 +470,7 @@ func cachebusterCookie(cache *CacheStruct) []error {
470470
}
471471

472472
indicValue := strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
473-
if checkCacheHit(indicValue) {
473+
if checkCacheHit(indicValue, cache.Indicator) {
474474
// If there is a hit, the cachebuster didn't work
475475
msg := fmt.Sprintf("%s was not successful (Cookie)\n", identifier)
476476
PrintVerbose(msg, NoColor, 2)
@@ -520,7 +520,7 @@ func cachebusterCookie(cache *CacheStruct) []error {
520520
}
521521

522522
indicValue = strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
523-
if checkCacheHit(indicValue) {
523+
if checkCacheHit(indicValue, cache.Indicator) {
524524
// If there is a hit, the cachebuster didn't work
525525
msg := fmt.Sprintf("%s was not successful (Cookie)\n", identifier)
526526
PrintVerbose(msg, NoColor, 2)
@@ -687,7 +687,7 @@ func cachebusterHeader(cache *CacheStruct) []error {
687687
}
688688

689689
indicValue := strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
690-
if checkCacheHit(indicValue) {
690+
if checkCacheHit(indicValue, cache.Indicator) {
691691
// If there is a hit, the cachebuster didn't work
692692
msg := fmt.Sprintf("%s was not successful (Header)\n", identifier)
693693
PrintVerbose(msg, NoColor, 2)
@@ -742,7 +742,7 @@ func cachebusterHeader(cache *CacheStruct) []error {
742742
}
743743

744744
indicValue = strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
745-
if checkCacheHit(indicValue) {
745+
if checkCacheHit(indicValue, cache.Indicator) {
746746
// If there is a hit, the cachebuster didn't work
747747
msg := fmt.Sprintf("%s was not successful (Header)\n", identifier)
748748
PrintVerbose(msg, NoColor, 2)
@@ -879,7 +879,7 @@ func cachebusterParameter(cache *CacheStruct) error {
879879
}
880880

881881
indicValue := strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
882-
if checkCacheHit(indicValue) {
882+
if checkCacheHit(indicValue, cache.Indicator) {
883883
// If there is a hit, the cachebuster didn't work
884884
msg := fmt.Sprintf("%s was not successful (Parameter)\n", identifier)
885885
PrintVerbose(msg, NoColor, 2)
@@ -925,7 +925,7 @@ func cachebusterParameter(cache *CacheStruct) error {
925925
}
926926

927927
indicValue = strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
928-
if checkCacheHit(indicValue) {
928+
if checkCacheHit(indicValue, cache.Indicator) {
929929
// If there is a hit, the cachebuster didn't work
930930
msg := fmt.Sprintf("%s was not successful (Parameter)\n", identifier)
931931
PrintVerbose(msg, NoColor, 2)
@@ -1085,7 +1085,7 @@ func cachebusterHTTPMethod(cache *CacheStruct) []error {
10851085
}
10861086

10871087
indicValue := strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
1088-
if checkCacheHit(indicValue) {
1088+
if checkCacheHit(indicValue, cache.Indicator) {
10891089
// If there is a hit, the cachebuster didn't work
10901090
msg := fmt.Sprintf("%s was not successful (HTTP Method)\n", identifier)
10911091
PrintVerbose(msg, NoColor, 2)
@@ -1129,7 +1129,7 @@ func cachebusterHTTPMethod(cache *CacheStruct) []error {
11291129
}
11301130

11311131
indicValue = strings.TrimSpace(strings.ToLower(resp.Header.Get(cache.Indicator)))
1132-
if checkCacheHit(indicValue) {
1132+
if checkCacheHit(indicValue, cache.Indicator) {
11331133
// If there is a hit, the cachebuster didn't work
11341134
msg := fmt.Sprintf("%s was not successful (HTTP Method)\n", identifier)
11351135
PrintVerbose(msg, NoColor, 2)

pkg/techniques.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ func ScanParameterCloaking() reportResult {
680680
m.Unlock()
681681
}
682682
indicValue := respHeader.Get(cache.Indicator)
683-
if checkCacheHit(indicValue) {
683+
if checkCacheHit(indicValue, cache.Indicator) {
684684
m.Lock()
685685
unkeyed_parameter = append(unkeyed_parameter, s)
686686
m.Unlock()

pkg/utils.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@ func searchBodyHeadersForString(cb string, body string, headers http.Header) boo
209209
}
210210

211211
// check if cache was hit
212-
func checkCacheHit(value string) bool {
213-
indicator := Config.Website.Cache.Indicator
212+
func checkCacheHit(value string, indicator string) bool {
213+
if indicator == "" {
214+
indicator = Config.Website.Cache.Indicator
215+
}
214216
if strings.EqualFold("age", indicator) {
215217
value = strings.TrimSpace(value)
216-
if value != "0" {
218+
if value != "0" && value != "" {
217219
return true
218220
}
219221
} else if strings.EqualFold("x-iinfo", indicator) {

0 commit comments

Comments
 (0)