From efc3e3d45bb7c7c3f40b1a719d777b3d376da542 Mon Sep 17 00:00:00 2001 From: CyberRoute Date: Mon, 12 Feb 2024 22:17:32 +0100 Subject: [PATCH] improved logging --- go.mod | 6 +++--- go.sum | 7 +++++++ pkg/fuzzer/fuzzer.go | 29 ++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 34e71bd..8763d1b 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,6 @@ module github.com/CyberRoute/bruter go 1.20 - require ( github.com/alexedwards/scs/v2 v2.5.1 github.com/evilsocket/islazy v1.11.0 @@ -12,8 +11,9 @@ require ( ) require ( + github.com/fatih/color v1.16.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.11.0 // indirect + golang.org/x/sys v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 72868ad..65637fd 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/alexedwards/scs/v2 v2.5.1/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gv github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/evilsocket/islazy v1.11.0 h1:B5w6uuS6ki6iDG+aH/RFeoMb8ijQh/pGabewqp2UeJ0= github.com/evilsocket/islazy v1.11.0/go.mod h1:muYH4x5MB5YRdkxnrOtrXLIBX6LySj1uFIqys94LKdo= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/go-chi/chi/v5 v5.0.8 h1:lD+NLqFcAi1ovnVZpsnObHGW4xb4J8lNmoYVfECH1Y0= github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -17,6 +19,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= @@ -26,5 +30,8 @@ golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/pkg/fuzzer/fuzzer.go b/pkg/fuzzer/fuzzer.go index be57f4b..8b8e0e1 100644 --- a/pkg/fuzzer/fuzzer.go +++ b/pkg/fuzzer/fuzzer.go @@ -13,6 +13,7 @@ import ( "github.com/CyberRoute/bruter/pkg/config" "github.com/CyberRoute/bruter/pkg/models" + "github.com/fatih/color" "github.com/rs/zerolog/log" ) @@ -22,6 +23,13 @@ func checkError(err error) { } } +var ( + g = color.New(color.FgGreen) + y = color.New(color.FgYellow) + r = color.New(color.FgRed) + b = color.New(color.FgBlue) +) + func Dirsearch(Mu *sync.Mutex, app *config.AppConfig, domain, path string, progress float32, verbose bool) { urjoin := domain + path url, err := NormalizeURL(urjoin) @@ -69,7 +77,26 @@ func Dirsearch(Mu *sync.Mutex, app *config.AppConfig, domain, path string, progr } if verbose { - app.ZeroLog.Info().Msg(fmt.Sprintf("%s => %s", urjoin, resp.Status)) + + switch { + // 2xx + case resp.StatusCode >= 200 && resp.StatusCode < 300: + //g.Printf("[%s] [%d] %s\n", now, result.status, result.url) + app.ZeroLog.Info().Msg(g.Sprintf("%s => %s", urjoin, resp.Status)) + // 3xx + case resp.StatusCode >= 300 && resp.StatusCode < 400: + //b.Printf("[%s] [%d] %s -> %s\n", now, result.status, result.url, result.location) + app.ZeroLog.Info().Msg(b.Sprintf("%s => %s", urjoin, resp.Status)) + // 4xx + case resp.StatusCode >= 400 && resp.StatusCode < 500 && resp.StatusCode != 404: + //y.Printf("[%s] [%d] %s\n", now, result.status, result.url) + app.ZeroLog.Info().Msg(y.Sprintf("%s => %s", urjoin, resp.Status)) + // 5xx + case resp.StatusCode >= 500 && resp.StatusCode < 600: + //r.Printf("[%s] [%d] %s\n", now, result.status, result.url) + app.ZeroLog.Info().Msg(r.Sprintf("%s => %s", urjoin, resp.Status)) + } + } }