mirror of
https://github.com/bettercap/bettercap
synced 2025-08-22 22:34:22 -07:00
Max redirects check is now arbitary
This commit is contained in:
parent
e740af2d50
commit
46ab3365cc
1 changed files with 6 additions and 32 deletions
|
@ -296,27 +296,6 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SSLStripper) isMaxRedirs(hostname string) bool {
|
|
||||||
// did we already track redirections for this host?
|
|
||||||
if nredirs, found := s.redirs[hostname]; found == true {
|
|
||||||
// reached the threshold?
|
|
||||||
if nredirs >= maxRedirs {
|
|
||||||
log.Warning("[%s] Hit max redirections for %s, serving HTTPS.", core.Green("sslstrip"), hostname)
|
|
||||||
// reset
|
|
||||||
delete(s.redirs, hostname)
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
// increment
|
|
||||||
s.redirs[hostname]++
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// start tracking redirections
|
|
||||||
s.redirs[hostname] = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
||||||
if s.enabled == false {
|
if s.enabled == false {
|
||||||
return
|
return
|
||||||
|
@ -336,17 +315,12 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
||||||
|
|
||||||
log.Info("[%s] Got redirection from HTTPS to HTTP: %s -> %s", core.Green("sslstrip"), core.Yellow("http://"+origHost), core.Bold("https://"+newHost))
|
log.Info("[%s] Got redirection from HTTPS to HTTP: %s -> %s", core.Green("sslstrip"), core.Yellow("http://"+origHost), core.Bold("https://"+newHost))
|
||||||
|
|
||||||
// if we still did not reach max redirections, strip the URL down to
|
// strip the URL down to an alternative HTTP version
|
||||||
// an alternative HTTP version
|
strippedURL := s.processURL(newURL)
|
||||||
if s.isMaxRedirs(origHost) {
|
u, _ := url.Parse(strippedURL)
|
||||||
strippedURL := s.processURL(newURL)
|
hostStripped := u.Hostname()
|
||||||
u, _ := url.Parse(strippedURL)
|
s.hosts.Track(origHost, hostStripped)
|
||||||
hostStripped := u.Hostname()
|
res.Header.Set("Location", strippedURL)
|
||||||
|
|
||||||
s.hosts.Track(origHost, hostStripped)
|
|
||||||
|
|
||||||
res.Header.Set("Location", strippedURL)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue