MCPcopy Create free account
hub / github.com/Hackmanit/Web-Cache-Vulnerability-Scanner / checkCacheHit

Function checkCacheHit

pkg/utils.go:302–344  ·  view source on GitHub ↗

check if cache was hit

(value string, indicator string)

Source from the content-addressed store, hash-verified

300
301// check if cache was hit
302func checkCacheHit(value string, indicator string) bool {
303 if indicator == "" {
304 indicator = Config.Website.Cache.Indicator
305 }
306 if strings.EqualFold("age", indicator) {
307 value = strings.TrimSpace(value)
308 if value != "0" && value != "" {
309 return true
310 }
311 } else if strings.EqualFold("x-iinfo", indicator) {
312 // String anhand von Leerzeichen aufteilen
313 parts := strings.Split(value, " ")
314
315 // Prüfen, ob der zweite Part existiert
316 if len(parts) > 1 {
317 secondPart := parts[1]
318
319 // Sicherstellen, dass der zweite Part mindestens zwei Zeichen lang ist
320 if len(secondPart) > 1 {
321 secondChar := strings.ToUpper(string(secondPart[1]))
322 if secondChar == "C" || secondChar == "V" {
323 return true
324 }
325 }
326 }
327 // Cache Hit may have 0,>0 or >0,0 as value. Both responses are cached
328 } else if strings.EqualFold("x-cache-hits", indicator) {
329 for _, x := range strings.Split(indicator, ",") {
330 x = strings.TrimSpace(x)
331 if x != "0" {
332 return true
333 }
334 }
335 } else if strings.EqualFold("x-cc-via", indicator) {
336 if strings.Contains(indicator, "[H,") {
337 return true
338 }
339 // Some Headers may have "miss,hit" or "hit,miss" as value. But both are cached responses.
340 } else if strings.Contains(strings.ToLower(value), "hit") || strings.Contains(strings.ToLower(value), "cached") {
341 return true
342 }
343 return false
344}
345
346// like grep -C
347func findOccurrencesWithContext(body, search string, context int) []string {

Callers 8

checkIfAlwaysMissFunction · 0.85
cachebusterCookieFunction · 0.85
cachebusterHeaderFunction · 0.85
cachebusterParameterFunction · 0.85
cachebusterHTTPMethodFunction · 0.85
issueRequestsFunction · 0.85
ScanParameterCloakingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected