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

This commit is contained in:
evilsocket 2019-02-13 10:12:34 +01:00
commit 4eead7eafa
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
58 changed files with 2052 additions and 2052 deletions

View file

@ -10,66 +10,66 @@ type HttpProxy struct {
}
func NewHttpProxy(s *session.Session) *HttpProxy {
p := &HttpProxy{
mod := &HttpProxy{
SessionModule: session.NewSessionModule("http.proxy", s),
proxy: NewHTTPProxy(s),
}
p.AddParam(session.NewIntParameter("http.port",
mod.AddParam(session.NewIntParameter("http.port",
"80",
"HTTP port to redirect when the proxy is activated."))
p.AddParam(session.NewStringParameter("http.proxy.address",
mod.AddParam(session.NewStringParameter("http.proxy.address",
session.ParamIfaceAddress,
session.IPv4Validator,
"Address to bind the HTTP proxy to."))
p.AddParam(session.NewIntParameter("http.proxy.port",
mod.AddParam(session.NewIntParameter("http.proxy.port",
"8080",
"Port to bind the HTTP proxy to."))
p.AddParam(session.NewStringParameter("http.proxy.script",
mod.AddParam(session.NewStringParameter("http.proxy.script",
"",
"",
"Path of a proxy JS script."))
p.AddParam(session.NewStringParameter("http.proxy.injectjs",
mod.AddParam(session.NewStringParameter("http.proxy.injectjs",
"",
"",
"URL, path or javascript code to inject into every HTML page."))
p.AddParam(session.NewBoolParameter("http.proxy.sslstrip",
mod.AddParam(session.NewBoolParameter("http.proxy.sslstrip",
"false",
"Enable or disable SSL stripping."))
p.AddHandler(session.NewModuleHandler("http.proxy on", "",
mod.AddHandler(session.NewModuleHandler("http.proxy on", "",
"Start HTTP proxy.",
func(args []string) error {
return p.Start()
return mod.Start()
}))
p.AddHandler(session.NewModuleHandler("http.proxy off", "",
mod.AddHandler(session.NewModuleHandler("http.proxy off", "",
"Stop HTTP proxy.",
func(args []string) error {
return p.Stop()
return mod.Stop()
}))
return p
return mod
}
func (p *HttpProxy) Name() string {
func (mod *HttpProxy) Name() string {
return "http.proxy"
}
func (p *HttpProxy) Description() string {
func (mod *HttpProxy) Description() string {
return "A full featured HTTP proxy that can be used to inject malicious contents into webpages, all HTTP traffic will be redirected to it."
}
func (p *HttpProxy) Author() string {
func (mod *HttpProxy) Author() string {
return "Simone Margaritelli <evilsocket@gmail.com>"
}
func (p *HttpProxy) Configure() error {
func (mod *HttpProxy) Configure() error {
var err error
var address string
var proxyPort int
@ -78,37 +78,37 @@ func (p *HttpProxy) Configure() error {
var stripSSL bool
var jsToInject string
if p.Running() {
if mod.Running() {
return session.ErrAlreadyStarted
} else if err, address = p.StringParam("http.proxy.address"); err != nil {
} else if err, address = mod.StringParam("http.proxy.address"); err != nil {
return err
} else if err, proxyPort = p.IntParam("http.proxy.port"); err != nil {
} else if err, proxyPort = mod.IntParam("http.proxy.port"); err != nil {
return err
} else if err, httpPort = p.IntParam("http.port"); err != nil {
} else if err, httpPort = mod.IntParam("http.port"); err != nil {
return err
} else if err, scriptPath = p.StringParam("http.proxy.script"); err != nil {
} else if err, scriptPath = mod.StringParam("http.proxy.script"); err != nil {
return err
} else if err, stripSSL = p.BoolParam("http.proxy.sslstrip"); err != nil {
} else if err, stripSSL = mod.BoolParam("http.proxy.sslstrip"); err != nil {
return err
} else if err, jsToInject = p.StringParam("http.proxy.injectjs"); err != nil {
} else if err, jsToInject = mod.StringParam("http.proxy.injectjs"); err != nil {
return err
}
return p.proxy.Configure(address, proxyPort, httpPort, scriptPath, jsToInject, stripSSL)
return mod.proxy.Configure(address, proxyPort, httpPort, scriptPath, jsToInject, stripSSL)
}
func (p *HttpProxy) Start() error {
if err := p.Configure(); err != nil {
func (mod *HttpProxy) Start() error {
if err := mod.Configure(); err != nil {
return err
}
return p.SetRunning(true, func() {
p.proxy.Start()
return mod.SetRunning(true, func() {
mod.proxy.Start()
})
}
func (p *HttpProxy) Stop() error {
return p.SetRunning(false, func() {
p.proxy.Stop()
func (mod *HttpProxy) Stop() error {
return mod.SetRunning(false, func() {
mod.proxy.Stop()
})
}