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

Function GetWebsite

pkg/recon.go:1134–1257  ·  view source on GitHub ↗

* Simple get request to get the body of a normal response and the cookies */

(requrl string, setStatusCode bool, cacheBuster bool)

Source from the content-addressed store, hash-verified

1132
1133/* Simple get request to get the body of a normal response and the cookies */
1134func GetWebsite(requrl string, setStatusCode bool, cacheBuster bool) (WebsiteStruct, error) {
1135 errorString := "GetWebsite"
1136
1137 var web WebsiteStruct
1138 cache := Config.Website.Cache
1139 queryParameterMap := make(map[string]string)
1140
1141 // get domain
1142 domainParts := strings.SplitN(requrl, "/", 4)
1143 domain := domainParts[0] + "//" + domainParts[2]
1144
1145 // splitting url like {https://www.m10x.de/}?{name=max&role=admin}
1146 urlSlice := strings.SplitN(requrl, "?", 2)
1147
1148 // splitting queries like {name=max}&{role=admin}
1149 var parameterSlice []string
1150 if strings.Contains(requrl, "?") {
1151 parameterSlice = strings.Split(urlSlice[1], Config.QuerySeparator)
1152 }
1153
1154 if len(parameterSlice) > 0 {
1155 queryParameterMap = setQueryParameterMap(queryParameterMap, parameterSlice)
1156 }
1157
1158 if len(Config.Parameters) > 0 {
1159 queryParameterMap = setQueryParameterMap(queryParameterMap, Config.Parameters)
1160 }
1161
1162 requrl = urlSlice[0]
1163 urlNoQueries := urlSlice[0]
1164
1165 // adding query parameter
1166 for key, val := range queryParameterMap {
1167 if !strings.Contains(requrl, "?") {
1168 requrl += "?"
1169 } else {
1170 requrl += Config.QuerySeparator
1171 }
1172 requrl += key + "=" + val
1173 }
1174
1175 cb := ""
1176 if cacheBuster {
1177 cb = "cb" + randInt()
1178 }
1179
1180 req := fasthttp.AcquireRequest()
1181 resp := fasthttp.AcquireResponse()
1182 defer fasthttp.ReleaseRequest(req)
1183 defer fasthttp.ReleaseResponse(resp)
1184 var err error
1185 if Config.Website.Cache.CBisHTTPMethod {
1186 req.Header.SetMethod(Config.Website.Cache.CBName)
1187 } else if Config.DoPost {
1188 req.Header.SetMethod("POST")
1189 } else {
1190 req.Header.SetMethod("GET")
1191 }

Callers 4

runTestsFunction · 0.92
CrawlUrlsFunction · 0.85
checkPoisoningIndicatorsFunction · 0.85
ScanCSSFunction · 0.85

Calls 7

setQueryParameterMapFunction · 0.85
randIntFunction · 0.85
setRequestFunction · 0.85
waitLimiterFunction · 0.85
PrintFunction · 0.85
responseCookiesToMapFunction · 0.85
headerToMultiMapFunction · 0.85

Tested by

no test coverage detected