MCPcopy Create free account
hub / github.com/devploit/nomore403 / loadFlagsFromRequestFile

Function loadFlagsFromRequestFile

cmd/api.go:263–314  ·  view source on GitHub ↗

loadFlagsFromRequestFile parse an HTTP request and configure the necessary flags for an execution

(requestFile string, schema bool, verbose bool, techniques []string, redirect bool)

Source from the content-addressed store, hash-verified

261
262// loadFlagsFromRequestFile parse an HTTP request and configure the necessary flags for an execution
263func loadFlagsFromRequestFile(requestFile string, schema bool, verbose bool, techniques []string, redirect bool) {
264 // Read the content of the request file
265 content, err := os.ReadFile(requestFile)
266 if err != nil {
267 log.Printf("[!] Error reading request file: %v", err)
268 return
269 }
270
271 temp := strings.Split(string(content), "\n")
272 if len(temp) == 0 {
273 log.Printf("[!] Request file is empty: %s", requestFile)
274 return
275 }
276
277 // Down HTTP/2 to HTTP/1.1 (handles both "HTTP/2" and "HTTP/2.0")
278 firstLine := temp[0]
279 if strings.Contains(firstLine, "HTTP/2.0") {
280 firstLine = strings.Replace(firstLine, "HTTP/2.0", "HTTP/1.1", 1)
281 } else if strings.Contains(firstLine, "HTTP/2") {
282 firstLine = strings.Replace(firstLine, "HTTP/2", "HTTP/1.1", 1)
283 }
284 content = []byte(strings.Join(append([]string{firstLine}, temp[1:]...), "\n"))
285
286 reqReader := strings.NewReader(string(content))
287 req, err := http.ReadRequest(bufio.NewReader(reqReader))
288 if err != nil {
289 log.Printf("[!] Error parsing request file: %v", err)
290 return
291 }
292
293 if strings.HasPrefix(req.RequestURI, "http://") {
294 parts := strings.SplitAfterN(req.RequestURI, "/", 4)
295 if len(parts) >= 4 {
296 req.RequestURI = "/" + parts[3]
297 }
298 }
299
300 httpSchema := "https://"
301 if schema {
302 httpSchema = "http://"
303 }
304
305 uri := httpSchema + req.Host + req.RequestURI
306
307 // Extract headers from the request
308 var reqHeaders []string
309 for k, v := range req.Header {
310 reqHeaders = append(reqHeaders, k+": "+strings.Join(v, ""))
311 }
312 httpMethod := req.Method
313 requester(uri, proxy, userAgent, reqHeaders, bypassIP, folder, httpMethod, verbose, techniques, nobanner, rateLimit, timeout, redirect, randomAgent)
314}
315
316// calibrationTolerance defines the acceptable variance in content-length between calibration samples.
317const calibrationTolerance = 50

Callers 4

root.goFile · 0.85

Calls 1

requesterFunction · 0.85