Commit 47f48902 authored by Sophie Brun's avatar Sophie Brun

Update upstream source from tag 'upstream/2.8'

Update to upstream version '2.8'
with Debian dir 1bb324fa656b3f7a4a5e557d573d3e5ab70366a4
parents a220b393 b30ee253
......@@ -2,7 +2,6 @@ sudo: false
language: go
go:
- 1.8.x
- 1.9.x
- 1.10.x
- master
......
......@@ -2,15 +2,16 @@
[[projects]]
digest = "1:fa526d5f6ec66a1833c687768639251d6db3bc3b7f32abd0265ae9625a9233de"
digest = "1:4132a4623657c2ba93a7cf83dccc6869b3e3bb91dc2afefa7c7032e10ceeaa12"
name = "github.com/adrianmo/go-nmea"
packages = ["."]
pruneopts = "UT"
revision = "22095aa1b48050243d3eb9a001ca80eb91a0c6fa"
revision = "a32116e4989e2b0e17c057ee378b4d5246add74e"
version = "v1.1.0"
[[projects]]
branch = "master"
digest = "1:6cd4d9bc1e78392036da7cc4fb1fbd65c10b5807d74aaee5fa5e025b441ff6d2"
digest = "1:d8ad15f83381fd0e1f6b75c55a3fa3c7070628dbf120a96725183d30dbb0cec9"
name = "github.com/bettercap/gatt"
packages = [
".",
......@@ -59,7 +60,7 @@
[[projects]]
branch = "master"
digest = "1:28e398bb752cd0367439a86d3a7cebfa008c9143d154dd5516397a790a2901e1"
digest = "1:911bcb1598df4c960dd9e0a62443d2ac3fa33111ef691937af3bd1ed7ecdebdd"
name = "github.com/gobwas/glob"
packages = [
".",
......@@ -91,7 +92,7 @@
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
[[projects]]
digest = "1:22cffca7cf16314eb3cb0c5d2298f7b2f60266d8da172cbae258cdfcc169c1ad"
digest = "1:a1b2a09d080e0229db471efc7f030b6d3931cd54989f6a1a4d676e085139cc2d"
name = "github.com/google/gopacket"
packages = [
".",
......@@ -169,7 +170,7 @@
[[projects]]
branch = "master"
digest = "1:0320f2921b55f500278fec7d7fe4454e401b9074ef1a88597c3359bc66144a6e"
digest = "1:a55df695568f48d84d2b5c3d250871bb9f74d9950c201190b6615a4f94727e3c"
name = "github.com/mdlayher/dhcp6"
packages = [
".",
......@@ -205,7 +206,7 @@
[[projects]]
branch = "master"
digest = "1:f4877c1ea67bb492d1b91125bb7f45604736bfbd2ffcbfb9eb44055607525fc3"
digest = "1:dbfe572cc258e5bcf54cb650a06d90edd0da04e42ca1ed909cc1d49f00011c63"
name = "github.com/robertkrimen/otto"
packages = [
".",
......@@ -236,7 +237,7 @@
revision = "d0faeb539838e250bd0a9db4182d48d4a1915181"
[[projects]]
digest = "1:68d74b9fe9594646dc411e68b85b73b70d861b710570a99e0b2803b5844646b5"
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"
name = "gopkg.in/sourcemap.v1"
packages = [
".",
......
......@@ -93,6 +93,10 @@
branch = "master"
name = "github.com/tarm/serial"
[[constraint]]
name = "github.com/adrianmo/go-nmea"
version = "1.1.0"
[prune]
go-tests = true
unused-packages = true
......@@ -2,7 +2,7 @@ package core
const (
Name = "bettercap"
Version = "2.7"
Version = "2.8"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)
......@@ -19,7 +19,7 @@ type Options struct {
func ParseOptions() (Options, error) {
o := Options{
InterfaceName: flag.String("iface", "", "Network interface to bind to, if empty the default interface will be auto selected."),
AutoStart: flag.String("autostart", "events.stream, net.recon, update.check", "Comma separated list of modules to auto start."),
AutoStart: flag.String("autostart", "events.stream, net.recon", "Comma separated list of modules to auto start."),
Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."),
Debug: flag.Bool("debug", false, "Print debug messages."),
Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
......
......@@ -42,6 +42,7 @@ func main() {
sess.Register(modules.NewDNSSpoofer(sess))
sess.Register(modules.NewSniffer(sess))
sess.Register(modules.NewPacketProxy(sess))
sess.Register(modules.NewAnyProxy(sess))
sess.Register(modules.NewTcpProxy(sess))
sess.Register(modules.NewHttpProxy(sess))
sess.Register(modules.NewHttpsProxy(sess))
......
package modules
import (
"github.com/bettercap/bettercap/firewall"
"github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/session"
)
type AnyProxy struct {
session.SessionModule
Redirection *firewall.Redirection
}
func NewAnyProxy(s *session.Session) *AnyProxy {
p := &AnyProxy{
SessionModule: session.NewSessionModule("any.proxy", s),
}
p.AddParam(session.NewStringParameter("any.proxy.iface",
session.ParamIfaceName,
"",
"Interface to redirect packets from."))
p.AddParam(session.NewStringParameter("any.proxy.protocol",
"TCP",
"(TCP|UDP)",
"Proxy protocol."))
p.AddParam(session.NewIntParameter("any.proxy.src_port",
"80",
"Remote port to redirect when the module is activated."))
p.AddParam(session.NewStringParameter("any.proxy.src_address",
"",
"",
"Leave empty to intercept any source address."))
p.AddParam(session.NewStringParameter("any.proxy.dst_address",
session.ParamIfaceAddress,
session.IPv4Validator,
"Address where the proxy is listening."))
p.AddParam(session.NewIntParameter("any.proxy.dst_port",
"8080",
"Port where the proxy is listening."))
p.AddHandler(session.NewModuleHandler("any.proxy on", "",
"Start the custom proxy redirection.",
func(args []string) error {
return p.Start()
}))
p.AddHandler(session.NewModuleHandler("any.proxy off", "",
"Stop the custom proxy redirection.",
func(args []string) error {
return p.Stop()
}))
return p
}
func (p *AnyProxy) Name() string {
return "any.proxy"
}
func (p *AnyProxy) Description() string {
return "A firewall redirection to any custom proxy."
}
func (p *AnyProxy) Author() string {
return "Simone Margaritelli <evilsocket@protonmail.com>"
}
func (p *AnyProxy) Configure() error {
var err error
var srcPort int
var dstPort int
var iface string
var protocol string
var srcAddress string
var dstAddress string
if p.Running() {
return session.ErrAlreadyStarted
} else if err, iface = p.StringParam("any.proxy.iface"); err != nil {
return err
} else if err, protocol = p.StringParam("any.proxy.protocol"); err != nil {
return err
} else if err, srcPort = p.IntParam("any.proxy.src_port"); err != nil {
return err
} else if err, dstPort = p.IntParam("any.proxy.dst_port"); err != nil {
return err
} else if err, srcAddress = p.StringParam("any.proxy.src_address"); err != nil {
return err
} else if err, dstAddress = p.StringParam("any.proxy.dst_address"); err != nil {
return err
}
if !p.Session.Firewall.IsForwardingEnabled() {
log.Info("Enabling forwarding.")
p.Session.Firewall.EnableForwarding(true)
}
p.Redirection = firewall.NewRedirection(iface,
protocol,
srcPort,
dstAddress,
dstPort)
if srcAddress != "" {
p.Redirection.SrcAddress = srcAddress
}
if err := p.Session.Firewall.EnableRedirection(p.Redirection, true); err != nil {
return err
}
log.Info("Applied redirection %s", p.Redirection.String())
return nil
}
func (p *AnyProxy) Start() error {
if err := p.Configure(); err != nil {
return err
}
return p.SetRunning(true, func() {})
}
func (p *AnyProxy) Stop() error {
if p.Redirection != nil {
log.Info("Disabling redirection %s", p.Redirection.String())
if err := p.Session.Firewall.EnableRedirection(p.Redirection, false); err != nil {
return err
}
p.Redirection = nil
}
return p.SetRunning(false, func() {})
}
......@@ -63,6 +63,8 @@ func NewRestAPI(s *session.Session) *RestAPI {
"",
"API TLS certificate."))
tls.CertConfigToModule("api.rest", &api.SessionModule, tls.DefaultLegitConfig)
api.AddParam(session.NewStringParameter("api.rest.key",
"~/.bcap-api.rest.key.pem",
"",
......@@ -132,10 +134,18 @@ func (api *RestAPI) Configure() error {
return err
} else if err, api.useWebsocket = api.BoolParam("api.rest.websocket"); err != nil {
return err
} else if !core.Exists(api.certFile) || !core.Exists(api.keyFile) {
}
if !core.Exists(api.certFile) || !core.Exists(api.keyFile) {
err, cfg := tls.CertConfigFromModule("api.rest", api.SessionModule)
if err != nil {
return err
}
log.Debug("%+v", cfg)
log.Info("Generating TLS key to %s", api.keyFile)
log.Info("Generating TLS certificate to %s", api.certFile)
if err := tls.Generate(api.certFile, api.keyFile); err != nil {
if err := tls.Generate(cfg, api.certFile, api.keyFile); err != nil {
return err
}
} else {
......
......@@ -148,8 +148,6 @@ func (s *EventsStream) viewSnifferEvent(e session.Event) {
misc += fmt.Sprintf(" \n %s:\n\n %s\n", core.Bold("Body"), string(b))
}
}
} else if se.Data != nil {
misc = fmt.Sprintf("%s", se.Data)
}
fmt.Fprintf(s.output, "[%s] [%s] %s %s\n",
......
......@@ -129,13 +129,10 @@ func (gps *GPS) Start() error {
for gps.Running() {
if line, err := gps.readLine(); err == nil {
if info, err := nmea.Parse(line); err == nil {
s := info.Sentence()
if s, err := nmea.Parse(line); err == nil {
// http://aprs.gids.nl/nmea/#gga
if s.Type == "GNGGA" {
gps.Session.GPS = info.(nmea.GNGGA)
} else {
log.Debug("Skipping message %s: %v", s.Type, s)
if m, ok := s.(nmea.GNGGA); ok {
gps.Session.GPS = m
}
} else {
log.Debug("Error parsing line '%s': %s", line, err)
......
......@@ -33,6 +33,11 @@ func NewHttpProxy(s *session.Session) *HttpProxy {
"",
"Path of a proxy JS script."))
p.AddParam(session.NewStringParameter("http.proxy.injectjs",
"",
"",
"URL, path or javascript code to inject into every HTML page."))
p.AddParam(session.NewBoolParameter("http.proxy.sslstrip",
"false",
"Enable or disable SSL stripping."))
......@@ -71,6 +76,7 @@ func (p *HttpProxy) Configure() error {
var httpPort int
var scriptPath string
var stripSSL bool
var jsToInject string
if p.Running() {
return session.ErrAlreadyStarted
......@@ -84,9 +90,11 @@ func (p *HttpProxy) Configure() error {
return err
} else if err, stripSSL = p.BoolParam("http.proxy.sslstrip"); err != nil {
return err
} else if err, jsToInject = p.StringParam("http.proxy.injectjs"); err != nil {
return err
}
return p.proxy.Configure(address, proxyPort, httpPort, scriptPath, stripSSL)
return p.proxy.Configure(address, proxyPort, httpPort, scriptPath, jsToInject, stripSSL)
}
func (p *HttpProxy) Start() error {
......
......@@ -40,6 +40,7 @@ type HTTPProxy struct {
CertFile string
KeyFile string
jsHook string
isTLS bool
isRunning bool
stripper *SSLStripper
......@@ -106,12 +107,29 @@ func (p *HTTPProxy) doProxy(req *http.Request) bool {
return true
}
func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scriptPath string, stripSSL bool) error {
func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scriptPath string, jsToInject string, stripSSL bool) error {
var err error
p.stripper.Enable(stripSSL)
p.Address = address
if strings.HasPrefix(jsToInject, "http://") || strings.HasPrefix(jsToInject, "https://") {
p.jsHook = fmt.Sprintf("<script src=\"%s\" type=\"text/javascript\"></script></head>", jsToInject)
} else if core.Exists(jsToInject) {
if data, err := ioutil.ReadFile(jsToInject); err != nil {
return err
} else {
jsToInject = string(data)
}
}
if p.jsHook == "" && jsToInject != "" {
if strings.HasPrefix(jsToInject, "<script ") == false {
jsToInject = fmt.Sprintf("<script type=\"text/javascript\">%s</script>", jsToInject)
}
p.jsHook = fmt.Sprintf("%s</head>", jsToInject)
}
if scriptPath != "" {
if err, p.Script = LoadHttpProxyScript(scriptPath, p.sess); err != nil {
return err
......@@ -187,8 +205,8 @@ func TLSConfigFromCA(ca *tls.Certificate) func(host string, ctx *goproxy.ProxyCt
}
}
func (p *HTTPProxy) ConfigureTLS(address string, proxyPort int, httpPort int, scriptPath string, certFile string, keyFile string, stripSSL bool) (err error) {
if p.Configure(address, proxyPort, httpPort, scriptPath, stripSSL); err != nil {
func (p *HTTPProxy) ConfigureTLS(address string, proxyPort int, httpPort int, scriptPath string, certFile string, keyFile string, jsToInject string, stripSSL bool) (err error) {
if p.Configure(address, proxyPort, httpPort, scriptPath, jsToInject, stripSSL); err != nil {
return err
}
......
package modules
import (
"io/ioutil"
"net/http"
"strings"
......@@ -10,9 +11,19 @@ import (
"github.com/elazarl/goproxy"
)
func (p *HTTPProxy) fixRequestHeaders(req *http.Request) {
req.Header.Del("Accept-Encoding")
req.Header.Del("If-None-Match")
req.Header.Del("If-Modified-Since")
req.Header.Del("Upgrade-Insecure-Requests")
req.Header.Set("Pragma", "no-cache")
}
func (p *HTTPProxy) onRequestFilter(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
log.Debug("(%s) < %s %s %s%s", core.Green(p.Name), req.RemoteAddr, req.Method, req.Host, req.URL.Path)
p.fixRequestHeaders(req)
redir := p.stripper.Preprocess(req, ctx)
if redir != nil {
// we need to redirect the user in order to make
......@@ -40,27 +51,103 @@ func (p *HTTPProxy) onRequestFilter(req *http.Request, ctx *goproxy.ProxyCtx) (*
return req, nil
}
func (p *HTTPProxy) fixResponseHeaders(res *http.Response) {
res.Header.Del("Content-Security-Policy-Report-Only")
res.Header.Del("Content-Security-Policy")
res.Header.Del("Strict-Transport-Security")
res.Header.Del("Public-Key-Pins")
res.Header.Del("Public-Key-Pins-Report-Only")
res.Header.Del("X-Frame-Options")
res.Header.Del("X-Content-Type-Options")
res.Header.Del("X-WebKit-CSP")
res.Header.Del("X-Content-Security-Policy")
res.Header.Del("X-Download-Options")
res.Header.Del("X-Permitted-Cross-Domain-Policies")
res.Header.Del("X-Xss-Protection")
res.Header.Set("Allow-Access-From-Same-Origin", "*")
res.Header.Set("Access-Control-Allow-Origin", "*")
res.Header.Set("Access-Control-Allow-Methods", "*")
res.Header.Set("Access-Control-Allow-Headers", "*")
}
func (p *HTTPProxy) getHeader(res *http.Response, header string) string {
header = strings.ToLower(header)
for name, values := range res.Header {
for _, value := range values {
if strings.ToLower(name) == header {
return value
}
}
}
return ""
}
func (p *HTTPProxy) isScriptInjectable(res *http.Response) (bool, string) {
if p.jsHook == "" {
return false, ""
} else if contentType := p.getHeader(res, "Content-Type"); strings.Contains(contentType, "text/html") {
return true, contentType
}
return false, ""
}
func (p *HTTPProxy) doScriptInjection(res *http.Response, cType string) (error, *http.Response) {
defer res.Body.Close()
raw, err := ioutil.ReadAll(res.Body)
if err != nil {
return err, nil
} else if html := string(raw); strings.Contains(html, "</head>") {
log.Info("(%s) > injecting javascript (%d bytes) into %s (%d bytes) for %s",
core.Green(p.Name),
len(p.jsHook),
core.Yellow(res.Request.Host+res.Request.URL.Path),
len(raw),
core.Bold(strings.Split(res.Request.RemoteAddr, ":")[0]))
html = strings.Replace(html, "</head>", p.jsHook, -1)
newResp := goproxy.NewResponse(res.Request, cType, res.StatusCode, html)
for k, vv := range res.Header {
for _, v := range vv {
newResp.Header.Add(k, v)
}
}
return nil, newResp
}
return nil, nil
}
func (p *HTTPProxy) onResponseFilter(res *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
// sometimes it happens ¯\_(ツ)_/¯
if res == nil {
return nil
}
req := res.Request
log.Debug("(%s) > %s %s %s%s", core.Green(p.Name), req.RemoteAddr, req.Method, req.Host, req.URL.Path)
log.Debug("(%s) > %s %s %s%s", core.Green(p.Name), res.Request.RemoteAddr, res.Request.Method, res.Request.Host, res.Request.URL.Path)
p.fixResponseHeaders(res)
p.stripper.Process(res, ctx)
// do we have a proxy script?
if p.Script == nil {
return res
if p.Script != nil {
_, jsres := p.Script.OnResponse(res)
if jsres != nil {
// the response has been changed by the script
p.logResponseAction(res.Request, jsres)
return jsres.ToResponse(res.Request)
}
}
_, jsres := p.Script.OnResponse(res)
if jsres != nil {
// the response has been changed by the script
p.logResponseAction(res.Request, jsres)
return jsres.ToResponse(res.Request)
// inject javascript code if specified and needed
if doInject, cType := p.isScriptInjectable(res); doInject {
if err, injectedResponse := p.doScriptInjection(res, cType); err != nil {
log.Error("(%s) error while injecting javascript: %s", p.Name, err)
} else if injectedResponse != nil {
return injectedResponse
}
}
return res
......
......@@ -192,35 +192,6 @@ func (s *SSLStripper) Enable(enabled bool) {
}
}
func (s *SSLStripper) stripRequestHeaders(req *http.Request) {
req.Header.Del("Accept-Encoding")
req.Header.Del("If-None-Match")
req.Header.Del("If-Modified-Since")
req.Header.Del("Upgrade-Insecure-Requests")
req.Header.Set("Pragma", "no-cache")
}
func (s *SSLStripper) stripResponseHeaders(res *http.Response) {
res.Header.Del("Content-Security-Policy-Report-Only")
res.Header.Del("Content-Security-Policy")
res.Header.Del("Strict-Transport-Security")
res.Header.Del("Public-Key-Pins")
res.Header.Del("Public-Key-Pins-Report-Only")
res.Header.Del("X-Frame-Options")
res.Header.Del("X-Content-Type-Options")
res.Header.Del("X-WebKit-CSP")
res.Header.Del("X-Content-Security-Policy")
res.Header.Del("X-Download-Options")
res.Header.Del("X-Permitted-Cross-Domain-Policies")
res.Header.Del("X-Xss-Protection")
res.Header.Set("Allow-Access-From-Same-Origin", "*")
res.Header.Set("Access-Control-Allow-Origin", "*")
res.Header.Set("Access-Control-Allow-Methods", "*")
res.Header.Set("Access-Control-Allow-Headers", "*")
}
func (s *SSLStripper) isContentStrippable(res *http.Response) bool {
for name, values := range res.Header {
for _, value := range values {
......@@ -258,7 +229,6 @@ func (s *SSLStripper) processURL(url string) string {
// sslstrip preprocessing, takes care of:
//
// - patching / removing security related headers
// - handling stripped domains
// - making unknown session cookies expire
func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redir *http.Response) {
......@@ -266,9 +236,6 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi
return
}
// preprocess request headers
s.stripRequestHeaders(req)
// well ...
if req.URL.Scheme == "https" {
// TODO: check for max redirects?
......@@ -349,9 +316,6 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
}
}
// process response headers
s.stripResponseHeaders(res)
// if we have a text or html content type, fetch the body
// and perform sslstripping
if s.isContentStrippable(res) {
......
......@@ -50,6 +50,8 @@ func NewHttpServer(s *session.Session) *HttpServer {
"",
"TLS key file, if not empty will configure this as a HTTPS server (will be auto generated if filled but not existing)."))
tls.CertConfigToModule("http.server", &httpd.SessionModule, tls.DefaultLegitConfig)
httpd.AddHandler(session.NewModuleHandler("http.server on", "",
"Start httpd server.",
func(args []string) error {
......@@ -131,9 +133,15 @@ func (httpd *HttpServer) Configure() error {
if certFile != "" && keyFile != "" {
if !core.Exists(certFile) || !core.Exists(keyFile) {
err, cfg := tls.CertConfigFromModule("http.server", httpd.SessionModule)
if err != nil {
return err
}
log.Debug("%+v", cfg)
log.Info("Generating server TLS key to %s", keyFile)
log.Info("Generating server TLS certificate to %s", certFile)
if err := tls.Generate(certFile, keyFile); err != nil {
if err := tls.Generate(cfg, certFile, keyFile); err != nil {
return err
}
} else {
......
......@@ -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",
"",
......@@ -45,6 +50,8 @@ func NewHttpsProxy(s *session.Session) *HttpsProxy {
"",
"HTTPS proxy certification authority TLS key file."))
tls.CertConfigToModule("https.proxy", &p.SessionModule, tls.DefaultSpoofConfig)
p.AddParam(session.NewStringParameter("https.proxy.script",
"",
"",
......@@ -86,6 +93,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,12 +115,20 @@ 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) {
err, cfg := tls.CertConfigFromModule("https.proxy", p.SessionModule)
if err != nil {
return err
}
log.Debug("%+v", cfg)
log.Info("Generating proxy certification authority TLS key to %s", keyFile)
log.Info("Generating proxy certification authority TLS certificate to %s", certFile)
if err := tls.Generate(certFile, keyFile); err != nil {
if err := tls.Generate(cfg, certFile, keyFile); err != nil {
return err
}
} else {
......@@ -120,7 +136,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 {
......
......@@ -236,6 +236,15 @@ func (p *TcpProxy) Start() error {
}
func (p *TcpProxy) Stop() error {
if p.Redirection != nil {
log.Debug("Disabling redirection %s", p.Redirection.String())
if err := p.Session.Firewall.EnableRedirection(p.Redirection, false); err != nil {
return err
}
p.Redirection = nil
}
return p.SetRunning(false, func() {
p.listener.Close()
})
......
......@@ -59,7 +59,7 @@ func (s *TcpProxyScript) doDefines(from, to net.Addr, data []byte) (err error) {
} else if err = s.VM.Set("to", addrTo); err != nil {
log.Error("Error while defining to: %s", err)
return
} else if err = s.VM.Set("data", string(data)); err != nil {
} else if err = s.VM.Set("data", data); err != nil {
log.Error("Error while defining data: %s", err)
return