mirror of
https://github.com/bettercap/bettercap
synced 2025-07-13 00:23:49 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
0f8c668f87
commit
c570319d66
2 changed files with 7 additions and 6 deletions
|
@ -39,8 +39,8 @@ func (t *CookieTracker) keyOf(req *http.Request) string {
|
|||
}
|
||||
|
||||
func (t *CookieTracker) IsClean(req *http.Request) bool {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
// t.RLock()
|
||||
// defer t.RUnlock()
|
||||
|
||||
// we only clean GET requests
|
||||
if req.Method != "GET" {
|
||||
|
@ -65,7 +65,8 @@ func (t *CookieTracker) IsClean(req *http.Request) bool {
|
|||
func (t *CookieTracker) Track(req *http.Request) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
t.set[t.keyOf(req)] = true
|
||||
reqKey := t.keyOf(req)
|
||||
t.set[reqKey] = true
|
||||
}
|
||||
|
||||
func (t *CookieTracker) Expire(req *http.Request) *http.Response {
|
||||
|
@ -77,7 +78,7 @@ func (t *CookieTracker) Expire(req *http.Request) *http.Response {
|
|||
redir.Header.Add("Set-Cookie", fmt.Sprintf("%s=EXPIRED; path=/; domain=%s; Expires=Mon, 01-Jan-1990 00:00:00 GMT", c.Name, c.Domain))
|
||||
}
|
||||
|
||||
redir.Header.Add("Location", req.URL.String())
|
||||
redir.Header.Add("Location", fmt.Sprintf("http://%s/", req.Host))
|
||||
redir.Header.Add("Connection", "close")
|
||||
|
||||
return redir
|
||||
|
|
|
@ -280,9 +280,9 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi
|
|||
req.Header.Set("Host", original.Hostname)
|
||||
}
|
||||
|
||||
if s.cookies.IsClean(req) == false {
|
||||
// check if we need to redirect the user in order
|
||||
// to make unknown session cookies expire
|
||||
if s.cookies.IsClean(req) == false {
|
||||
log.Info("[%s] Sending expired cookies for %s to %s", core.Green("sslstrip"), core.Yellow(req.Host), req.RemoteAddr)
|
||||
s.cookies.Track(req)
|
||||
redir = s.cookies.Expire(req)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue