(t *testing.T)
| 624 | } |
| 625 | |
| 626 | func TestRequestFilePreservesQueryString(t *testing.T) { |
| 627 | resetTestState() |
| 628 | |
| 629 | // Create a mock server that records the full request URI |
| 630 | var mu sync.Mutex |
| 631 | var capturedURIs []string |
| 632 | |
| 633 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 634 | mu.Lock() |
| 635 | capturedURIs = append(capturedURIs, r.URL.RequestURI()) |
| 636 | mu.Unlock() |
| 637 | w.WriteHeader(http.StatusForbidden) |
| 638 | fmt.Fprint(w, "Forbidden") |
| 639 | })) |
| 640 | defer ts.Close() |
| 641 | |
| 642 | // Build a raw HTTP request with query parameters (Burp-style) |
| 643 | rawRequest := fmt.Sprintf("GET /upload?action=get_config_data&user_id=239501342 HTTP/1.1\r\nHost: %s\r\n\r\n", |
| 644 | strings.TrimPrefix(ts.URL, "http://")) |
| 645 | |
| 646 | dir := t.TempDir() |
| 647 | reqFile := filepath.Join(dir, "request.txt") |
| 648 | if err := os.WriteFile(reqFile, []byte(rawRequest), 0o600); err != nil { |
| 649 | t.Fatalf("write request file: %v", err) |
| 650 | } |
| 651 | |
| 652 | payloadsDir := setupPayloadsDir(t) |
| 653 | |
| 654 | // Override package-level vars for the test |
| 655 | folder = payloadsDir |
| 656 | nobanner = true |
| 657 | technique = []string{"verbs"} |
| 658 | |
| 659 | loadFlagsFromRequestFile(reqFile, true, true, []string{"verbs"}, false) |
| 660 | |
| 661 | mu.Lock() |
| 662 | defer mu.Unlock() |
| 663 | |
| 664 | if len(capturedURIs) == 0 { |
| 665 | t.Fatal("expected requests to be sent from request file, got 0") |
| 666 | } |
| 667 | |
| 668 | // The first request (default) should contain the full query string |
| 669 | foundQueryString := false |
| 670 | for _, uri := range capturedURIs { |
| 671 | if strings.Contains(uri, "action=get_config_data") && strings.Contains(uri, "user_id=239501342") { |
| 672 | foundQueryString = true |
| 673 | break |
| 674 | } |
| 675 | } |
| 676 | if !foundQueryString { |
| 677 | t.Errorf("query string was stripped from request file URL. Captured URIs: %v", capturedURIs) |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | func TestRequestFileParsesPostWithBody(t *testing.T) { |
| 682 | resetTestState() |
nothing calls this directly
no test coverage detected