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

Function parseCurlOutput

cmd/requester.go:2576–2661  ·  view source on GitHub ↗
(output string, httpVersion string)

Source from the content-addressed store, hash-verified

2574}
2575
2576func parseCurlOutput(output string, httpVersion string) Result {
2577 httpVersionOutput := strings.ReplaceAll(httpVersion, "--http", "HTTP/")
2578
2579 serverResponse := output
2580 if blocks := strings.Split(output, "\r\n\r\n"); len(blocks) > 1 {
2581 for i, block := range blocks {
2582 if strings.Contains(strings.ToLower(block), "connection established") && i+1 < len(blocks) {
2583 serverResponse = strings.Join(blocks[i+1:], "\r\n\r\n")
2584 break
2585 }
2586 }
2587 }
2588
2589 if serverResponse == "" {
2590 log.Println("[!] No valid HTTP server response found in curl output")
2591 return Result{}
2592 }
2593
2594 headerBodyParts := strings.SplitN(serverResponse, "\r\n\r\n", 2)
2595 if len(headerBodyParts) == 0 || headerBodyParts[0] == "" {
2596 log.Printf("[!] Invalid server response format: %s", serverResponse)
2597 return Result{}
2598 }
2599
2600 headerBlock := headerBodyParts[0]
2601 body := ""
2602 if len(headerBodyParts) == 2 {
2603 body = headerBodyParts[1]
2604 }
2605
2606 lines := strings.Split(headerBlock, "\r\n")
2607 if len(lines) < 1 {
2608 log.Printf("[!] Invalid server response format: %s", serverResponse)
2609 return Result{}
2610 }
2611
2612 parts := strings.SplitN(lines[0], " ", 3)
2613 if len(parts) < 2 || !strings.HasPrefix(parts[0], "HTTP/") {
2614 log.Printf("[!] Invalid status line: %s", lines[0])
2615 return Result{}
2616 }
2617
2618 statusCode, err := strconv.Atoi(strings.TrimSpace(parts[1]))
2619 if err != nil {
2620 log.Printf("[!] Error parsing status code: %v", err)
2621 return Result{}
2622 }
2623
2624 bodyHash := ""
2625 bodySize := len(body)
2626 location := ""
2627 contentType := ""
2628 server := ""
2629 for _, headerLine := range lines[1:] {
2630 pair := strings.SplitN(headerLine, ":", 2)
2631 if len(pair) != 2 {
2632 continue
2633 }

Callers 4

executeReplayFunction · 0.85
curlRequestFunction · 0.85
requestAbsoluteURIFunction · 0.85

Calls

no outgoing calls