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

Function TestRequestFileHandlesHTTP20

cmd/bypass_test.go:760–808  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

758}
759
760func TestRequestFileHandlesHTTP20(t *testing.T) {
761 resetTestState()
762
763 var mu sync.Mutex
764 var capturedURIs []string
765
766 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
767 mu.Lock()
768 capturedURIs = append(capturedURIs, r.URL.RequestURI())
769 mu.Unlock()
770 w.WriteHeader(http.StatusForbidden)
771 fmt.Fprint(w, "Forbidden")
772 }))
773 defer ts.Close()
774
775 // Test with "HTTP/2.0" (another common Burp format)
776 rawRequest := fmt.Sprintf("GET /admin/panel HTTP/2.0\r\nHost: %s\r\n\r\n",
777 strings.TrimPrefix(ts.URL, "http://"))
778
779 dir := t.TempDir()
780 reqFile := filepath.Join(dir, "request.txt")
781 if err := os.WriteFile(reqFile, []byte(rawRequest), 0o600); err != nil {
782 t.Fatalf("write request file: %v", err)
783 }
784
785 payloadsDir := setupPayloadsDir(t)
786 folder = payloadsDir
787 nobanner = true
788
789 loadFlagsFromRequestFile(reqFile, true, true, []string{"verbs"}, false)
790
791 mu.Lock()
792 defer mu.Unlock()
793
794 if len(capturedURIs) == 0 {
795 t.Fatal("expected requests from HTTP/2.0 request file, got 0")
796 }
797
798 foundURI := false
799 for _, uri := range capturedURIs {
800 if strings.Contains(uri, "/admin/panel") {
801 foundURI = true
802 break
803 }
804 }
805 if !foundURI {
806 t.Errorf("expected /admin/panel in URIs, got: %v", capturedURIs)
807 }
808}
809
810func TestPayloadPositionsSendsRequests(t *testing.T) {
811 resetTestState()

Callers

nothing calls this directly

Calls 3

resetTestStateFunction · 0.85
setupPayloadsDirFunction · 0.85
loadFlagsFromRequestFileFunction · 0.85

Tested by

no test coverage detected