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

Function cachebusterHeader

pkg/recon.go:451–691  ·  view source on GitHub ↗
(cache *CacheStruct, headerList []string)

Source from the content-addressed store, hash-verified

449}
450
451func cachebusterHeader(cache *CacheStruct, headerList []string) []error {
452 headers := []string{}
453 values := []string{}
454 if len(headerList) > 0 {
455 headers = append(headers, headerList...)
456 } else {
457 headers = append(headers, "Accept-Encoding", "Accept", "Cookie", "Origin")
458 values = append(values, "gzip, deflate, ", "*/*, text/", "wcvs_cookie=")
459 for _, header := range Config.Headers {
460 headers = append(headers, strings.TrimSpace(strings.Split(header, ":")[0])) // Only add headername
461 }
462 }
463
464 var errSlice []error
465
466 for i, header := range headers {
467 errorString := "cachebusterHeader " + header
468 identifier := "Header " + header + " as Cachebuster"
469
470 if len(values) < i+1 { // prevent index out of range
471 values = append(values, "")
472 }
473
474 if header == "" { // skip empty headers
475 continue
476 }
477
478 req := fasthttp.AcquireRequest()
479 resp := fasthttp.AcquireResponse()
480 defer fasthttp.ReleaseRequest(req)
481 defer fasthttp.ReleaseResponse(resp)
482 var err error
483 var times []int64
484
485 if cache.Indicator == "" {
486 // No Cache Indicator was found. So time will be used as Indicator
487
488 for ii := range 5 * 2 {
489 weburl := Config.Website.Url.String()
490
491 if Config.DoPost {
492 req.Header.SetMethod("POST")
493 req.SetBodyString(Config.Body)
494 } else {
495 req.Header.SetMethod("GET")
496 if Config.Body != "" {
497 req.SetBodyString(Config.Body)
498
499 }
500 }
501 req.SetRequestURI(weburl)
502
503 setRequest(req, Config.DoPost, "", nil, false)
504 if ii%2 == 0 {
505 cbvalue := values[i] + "cb" + randInt()
506 if h := req.Header.Peek(header); h != nil {
507 msg := fmt.Sprintf("Overwriting %s:%s with %s:%s\n", header, h, header, cbvalue)
508 Print(msg, NoColor)

Callers 1

CheckCacheFunction · 0.85

Calls 9

setRequestFunction · 0.85
randIntFunction · 0.85
PrintFunction · 0.85
waitLimiterFunction · 0.85
PrintVerboseFunction · 0.85
headerToMultiMapFunction · 0.85
checkCacheHitFunction · 0.85
cbNotFoundDifferenceFunction · 0.85
cbFoundDifferenceFunction · 0.85

Tested by

no test coverage detected