new: implemented (http|https).proxy.whitelist and (http|https).proxy.blacklist parameters (closes #508)

This commit is contained in:
evilsocket 2019-03-26 14:20:34 +01:00
parent 6785650887
commit cfd93c555a
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
4 changed files with 118 additions and 55 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/bettercap/bettercap/tls"
"github.com/evilsocket/islazy/fs"
"github.com/evilsocket/islazy/str"
)
type HttpsProxy struct {
@ -58,6 +59,12 @@ func NewHttpsProxy(s *session.Session) *HttpsProxy {
"",
"Path of a proxy JS script."))
mod.AddParam(session.NewStringParameter("https.proxy.blacklist", "", "",
"Comma separated list of hostnames to skip while proxying (wildcard expressions can be used)."))
mod.AddParam(session.NewStringParameter("https.proxy.whitelist", "", "",
"Comma separated list of hostnames to proxy if the blacklist is used (wildcard expressions can be used)."))
mod.AddHandler(session.NewModuleHandler("https.proxy on", "",
"Start HTTPS proxy.",
func(args []string) error {
@ -95,6 +102,8 @@ func (mod *HttpsProxy) Configure() error {
var keyFile string
var stripSSL bool
var jsToInject string
var whitelist string
var blacklist string
if mod.Running() {
return session.ErrAlreadyStarted
@ -118,8 +127,15 @@ func (mod *HttpsProxy) Configure() error {
return err
} else if err, jsToInject = mod.StringParam("https.proxy.injectjs"); err != nil {
return err
} else if err, blacklist = mod.StringParam("https.proxy.blacklist"); err != nil {
return err
} else if err, whitelist = mod.StringParam("https.proxy.whitelist"); err != nil {
return err
}
mod.proxy.Blacklist = str.Comma(blacklist)
mod.proxy.Whitelist = str.Comma(whitelist)
if !fs.Exists(certFile) || !fs.Exists(keyFile) {
err, cfg := tls.CertConfigFromModule("https.proxy", mod.SessionModule)
if err != nil {