* Check if the parameter "cb" (or any other defined by flag -cb), the headers "accept-encoding, accept, cookie, origin" or any cookie can be used as cachebuster */
(parameterList []string, headerList []string)
| 47 | |
| 48 | /* Check if the parameter "cb" (or any other defined by flag -cb), the headers "accept-encoding, accept, cookie, origin" or any cookie can be used as cachebuster */ |
| 49 | func CheckCache(parameterList []string, headerList []string) (CacheStruct, bool, []error) { |
| 50 | var cache CacheStruct |
| 51 | var errSlice []error |
| 52 | |
| 53 | // analyze the website headers for cache indicators |
| 54 | cacheIndicators := analyzeCacheIndicator(Config.Website.Headers) |
| 55 | |
| 56 | alwaysMiss := true |
| 57 | if len(cacheIndicators) == 0 { |
| 58 | msg := "No x-cache (or other cache hit/miss header) header was found\nThe time will be measured as cache hit/miss indicator\n" |
| 59 | Print(msg, Yellow) |
| 60 | } else { |
| 61 | for _, cacheIndicator := range cacheIndicators { |
| 62 | miss, err := checkIfAlwaysMiss(cacheIndicator) |
| 63 | if err != nil { |
| 64 | errSlice = append(errSlice, err) |
| 65 | } |
| 66 | if !miss { |
| 67 | alwaysMiss = false |
| 68 | msg := fmt.Sprintf("The following cache indicator indicated a hit: %s\n", cacheIndicator) |
| 69 | PrintVerbose(msg, Cyan, 1) |
| 70 | cache.Indicator = cacheIndicator |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | if cache.Indicator == "" && !cache.TimeIndicator { |
| 75 | msg := "Time measurement as indicator is deactivated, skipping cachebuster tests\n" |
| 76 | Print(msg, Yellow) |
| 77 | } else { |
| 78 | // test for cachebuster, if the cache doesnt always return a miss |
| 79 | if !alwaysMiss { |
| 80 | // Check first if a parameter can be used as cachebuster |
| 81 | if !cache.CBwasFound { |
| 82 | errs := cachebusterParameter(&cache, nil) |
| 83 | if len(errs) > 0 { |
| 84 | errSlice = append(errSlice, errs...) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // Check second if a header can be used as cachebuster |
| 89 | if !cache.CBwasFound { |
| 90 | errs := cachebusterHeader(&cache, nil) |
| 91 | if len(errs) > 0 { |
| 92 | errSlice = append(errSlice, errs...) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // Check third if a cookie can be used as cachebuster |
| 97 | if !cache.CBwasFound { |
| 98 | errs := cachebusterCookie(&cache) |
| 99 | if len(errs) > 0 { |
| 100 | errSlice = append(errSlice, errs...) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if Config.SkipWordlistCachebuster { |
| 105 | msg := "Skipping wordlist cachebuster tests\n" |
| 106 | PrintVerbose(msg, Yellow, 1) |
no test coverage detected