misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-03-09 13:28:38 +01:00
parent 0f8c668f87
commit c570319d66
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 7 additions and 6 deletions

View file

@ -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

View file

@ -280,9 +280,9 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi
req.Header.Set("Host", original.Hostname)
}
// check if we need to redirect the user in order
// to make unknown session cookies expire
if s.cookies.IsClean(req) == false {
// check if we need to redirect the user in order
// to make unknown session cookies expire
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)