From 758adaf3d54a3615f7af9b395852d63ae7f03279 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Fri, 12 Jan 2018 23:36:32 +0100 Subject: [PATCH] fix: http.server module now logs accesses --- modules/http_server.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/http_server.go b/modules/http_server.go index dc6aedb0..04e51fde 100644 --- a/modules/http_server.go +++ b/modules/http_server.go @@ -6,6 +6,7 @@ import ( "net/http" "time" + "github.com/evilsocket/bettercap-ng/core" "github.com/evilsocket/bettercap-ng/log" "github.com/evilsocket/bettercap-ng/session" ) @@ -62,6 +63,13 @@ func (httpd *HttpServer) Author() string { return "Simone Margaritelli " } +func wrapHandler(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + log.Info("(%s) %s %s %s", core.Green("httpd"), core.Bold(r.RemoteAddr), r.Method, r.URL.Path) + h.ServeHTTP(w, r) + }) +} + func (httpd *HttpServer) Configure() error { var err error var path string @@ -72,7 +80,7 @@ func (httpd *HttpServer) Configure() error { return err } - http.Handle("/", http.FileServer(http.Dir(path))) + http.Handle("/", wrapHandler(http.FileServer(http.Dir(path)))) if err, address = httpd.StringParam("http.server.address"); err != nil { return err