mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
still working on #154
This commit is contained in:
parent
741d9d8f6e
commit
2d53890501
3 changed files with 70 additions and 3 deletions
48
modules/http_proxy_base_sslstriper.go
Normal file
48
modules/http_proxy_base_sslstriper.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sync"
|
||||
// "strings"
|
||||
|
||||
// "github.com/bettercap/bettercap/core"
|
||||
// "github.com/bettercap/bettercap/log"
|
||||
|
||||
"github.com/elazarl/goproxy"
|
||||
)
|
||||
|
||||
type cookieTracker struct {
|
||||
sync.RWMutex
|
||||
set map[string]string
|
||||
}
|
||||
|
||||
func NewCookieTracker() *cookieTracker {
|
||||
return &cookieTracker{
|
||||
set: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
type SSLStripper struct {
|
||||
Enabled bool
|
||||
cookies *cookieTracker
|
||||
}
|
||||
|
||||
func NewSSLStripper(enabled bool) *SSLStripper {
|
||||
return &SSLStripper{
|
||||
Enabled: enabled,
|
||||
cookies: NewCookieTracker(),
|
||||
}
|
||||
}
|
||||
|
||||
// sslstrip preprocessing, takes care of:
|
||||
//
|
||||
// - patching / removing security related headers
|
||||
// - making unknown session cookies expire
|
||||
// - handling stripped domains
|
||||
func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redir *http.Response) {
|
||||
if s.Enabled == false {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue