diff --git a/common/httpx/response.go b/common/httpx/response.go index 816551f..1b1ab47 100644 --- a/common/httpx/response.go +++ b/common/httpx/response.go @@ -69,9 +69,13 @@ func (r *Response) GetChainStatusCodes() []int { // GetChain dump the whole redirect chain as string func (r *Response) GetChain() string { var respchain strings.Builder - for _, chainItem := range r.Chain { - respchain.Write(chainItem.Request) - respchain.Write(chainItem.Response) + for counter, chainItem := range r.Chain { + if counter != 0 { + respchain.Write(chainItem.Request) + } + if counter < len(r.Chain)-1 { + respchain.Write(chainItem.Response) + } } return respchain.String() } diff --git a/runner/runner.go b/runner/runner.go index 0bfcec7..6811402 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -1794,6 +1794,10 @@ retry: respRaw = respRaw[:scanopts.MaxResponseBodySizeToSave] } data := append([]byte(fullURL), append([]byte("\n\n"), reqRaw...)...) + if scanopts.StoreChain && resp.HasChain() { + resp.GetChain() + data = append(data, append([]byte("\n"), []byte(resp.GetChain())...)...) + } data = append(data, append([]byte("\n"), respRaw...)...) _ = fileutil.CreateFolder(responseBaseDir) writeErr := os.WriteFile(responsePath, data, 0644) @@ -1801,7 +1805,7 @@ retry: gologger.Error().Msgf("Could not write response at path '%s', to disk: %s", responsePath, writeErr) } if scanopts.StoreChain && resp.HasChain() { - writeErr := os.WriteFile(responsePath, []byte(resp.GetChain()), 0644) + //writeErr := os.WriteFile(responsePath, []byte(resp.GetChain()), 0644) if writeErr != nil { gologger.Warning().Msgf("Could not write response at path '%s', to disk: %s", responsePath, writeErr) }