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

Function webCacheDeceptionTemplate

pkg/deception.go:78–175  ·  view source on GitHub ↗
(repResult *reportResult, appendStr string)

Source from the content-addressed store, hash-verified

76}
77
78func webCacheDeceptionTemplate(repResult *reportResult, appendStr string) error {
79 var msg string
80 var repCheck reportCheck
81 req := fasthttp.AcquireRequest()
82 resp := fasthttp.AcquireResponse()
83 defer fasthttp.ReleaseRequest(req)
84 defer fasthttp.ReleaseResponse(resp)
85 var err error
86
87 rUrl := Config.Website.Url.String()
88 // Überprüfen, ob der String genau zwei `//` enthält
89 if strings.Count(rUrl, "/") == 2 && !strings.HasPrefix(appendStr, "/") {
90 // append `/`, so e.g. https://example%0A does not throw an error when building the request
91 rUrl += "/"
92 }
93
94 req.Header.SetMethod("GET")
95 req.SetRequestURI(rUrl + appendStr)
96 setRequest(req, false, "", nil, false)
97
98 err = client.Do(req, resp)
99 if err != nil {
100 msg = fmt.Sprintf("webCacheDeceptionTemplate: %s: client.Do: %s\n", appendStr, err.Error())
101 Print(msg, Red)
102 return errors.New(msg)
103 }
104
105 waitLimiter("Web Cache Deception")
106
107 if resp.StatusCode() != Config.Website.StatusCode || string(resp.Body()) != Config.Website.Body {
108 return nil // no cache deception, as the response is not the same as the original one
109 }
110
111 if Config.Website.Cache.NoCache || Config.Website.Cache.Indicator == "age" {
112 time.Sleep(1 * time.Second) // wait a second to ensure that age header is not set to 0
113 }
114
115 waitLimiter("Web Cache Deception")
116
117 err = client.Do(req, resp)
118 if err != nil {
119 msg = fmt.Sprintf("webCacheDeceptionTemplate: %s: client.Do: %s\n", appendStr, err.Error())
120 Print(msg, Red)
121 return errors.New(msg)
122 }
123 respHeader := headerToMultiMap(&resp.Header)
124
125 // Add the request as curl command to the report
126 command, err := fasthttp2curl.GetCurlCommandFastHttp(req)
127 if err != nil {
128 PrintVerbose("Error: fasthttp2curl: "+err.Error()+"\n", Yellow, 1)
129 }
130
131 repCheck.Request.CurlCommand = command.String()
132 PrintVerbose("Curl command: "+repCheck.Request.CurlCommand+"\n", NoColor, 2)
133
134 var cacheIndicators []string
135 if Config.Website.Cache.Indicator == "" { // check if now a cache indicator exists

Callers 1

TestWebCacheDeceptionFunction · 0.85

Calls 7

setRequestFunction · 0.85
PrintFunction · 0.85
waitLimiterFunction · 0.85
headerToMultiMapFunction · 0.85
PrintVerboseFunction · 0.85
analyzeCacheIndicatorFunction · 0.85
checkCacheHitFunction · 0.85

Tested by 1

TestWebCacheDeceptionFunction · 0.68