From 58b31d351ffdb4f02259a50edd687ec4545a1ef3 Mon Sep 17 00:00:00 2001 From: mo Date: Thu, 13 Feb 2020 18:08:44 -0600 Subject: [PATCH] Correcting content-length for stripped response body --- modules/http_proxy/http_proxy_base_sslstriper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/http_proxy/http_proxy_base_sslstriper.go b/modules/http_proxy/http_proxy_base_sslstriper.go index 0c1d664b..1a4824f2 100644 --- a/modules/http_proxy/http_proxy_base_sslstriper.go +++ b/modules/http_proxy/http_proxy_base_sslstriper.go @@ -8,6 +8,7 @@ import ( "net/url" "regexp" "strings" + "strconv" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" @@ -377,6 +378,8 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) { s.hosts.Track(hostOriginal, hostStripped) } + res.Header.Set("Content-Length", strconv.Itoa(len(body))) + // reset the response body to the original unread state // but with just a string reader, this way further calls // to ioutil.ReadAll(res.Body) will just return the content