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 7f2cb4e..205e818 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -1819,18 +1819,15 @@ retry: respRaw = respRaw[:scanopts.MaxResponseBodySizeToSave] } data := append([]byte(fullURL), append([]byte("\n\n"), reqRaw...)...) + if scanopts.StoreChain && resp.HasChain() { + 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) if writeErr != nil { 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) - if writeErr != nil { - gologger.Warning().Msgf("Could not write response at path '%s', to disk: %s", responsePath, writeErr) - } - } } parsed, err := r.parseURL(fullURL)