new: implemented http.proxy.injectjs and https.proxy.injectjs to inject javascript code, files or URLs without a proxy module

This commit is contained in:
evilsocket 2018-08-14 17:12:22 +02:00
parent 7839a90c82
commit 6c3157e9c4
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
4 changed files with 74 additions and 12 deletions

View file

@ -35,6 +35,11 @@ func NewHttpsProxy(s *session.Session) *HttpsProxy {
"false",
"Enable or disable SSL stripping."))
p.AddParam(session.NewStringParameter("https.proxy.injectjs",
"",
"",
"URL, path or javascript code to inject into every HTML page."))
p.AddParam(session.NewStringParameter("https.proxy.certificate",
"~/.bettercap-ca.cert.pem",
"",
@ -86,6 +91,7 @@ func (p *HttpsProxy) Configure() error {
var certFile string
var keyFile string
var stripSSL bool
var jsToInject string
if p.Running() {
return session.ErrAlreadyStarted
@ -107,6 +113,8 @@ func (p *HttpsProxy) Configure() error {
return err
} else if err, scriptPath = p.StringParam("https.proxy.script"); err != nil {
return err
} else if err, jsToInject = p.StringParam("https.proxy.injectjs"); err != nil {
return err
}
if !core.Exists(certFile) || !core.Exists(keyFile) {
@ -120,7 +128,7 @@ func (p *HttpsProxy) Configure() error {
log.Info("Loading proxy certification authority TLS certificate from %s", certFile)
}
return p.proxy.ConfigureTLS(address, proxyPort, httpPort, scriptPath, certFile, keyFile, stripSSL)
return p.proxy.ConfigureTLS(address, proxyPort, httpPort, scriptPath, certFile, keyFile, jsToInject, stripSSL)
}
func (p *HttpsProxy) Start() error {