From 39d57ea509043935cf3c6dfea0cf04324c70c3ec Mon Sep 17 00:00:00 2001 From: Ice3man Date: Fri, 19 Mar 2021 22:13:41 +0530 Subject: [PATCH] Fixed various post v2.3.1 release bugs (#636) * Don't print timestamp with no metadata * Fixed all templates running with some inputs * Upgraded clistats to fix crash * Fixed crash with ignored payload file * Fixed stats counter issue for network templates --- v2/go.mod | 2 +- v2/go.sum | 4 ++-- v2/internal/runner/runner.go | 2 +- v2/pkg/output/format_screen.go | 8 ++++---- v2/pkg/protocols/common/generators/validate.go | 3 +++ v2/pkg/protocols/network/request.go | 8 +------- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/v2/go.mod b/v2/go.mod index 50bbc876..ba44e52c 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -23,7 +23,7 @@ require ( github.com/mitchellh/go-ps v1.0.0 github.com/olekukonko/tablewriter v0.0.5 github.com/pkg/errors v0.9.1 - github.com/projectdiscovery/clistats v0.0.7 + github.com/projectdiscovery/clistats v0.0.8 github.com/projectdiscovery/collaborator v0.0.2 github.com/projectdiscovery/fastdialer v0.0.8 github.com/projectdiscovery/goflags v0.0.3 diff --git a/v2/go.sum b/v2/go.sum index e35f5343..e82c0e49 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -195,8 +195,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/projectdiscovery/clistats v0.0.7 h1:Q/erjrk2p3BIQq1RaHVtBpgboghNz0u1/lyQ2fr8Cn0= -github.com/projectdiscovery/clistats v0.0.7/go.mod h1:lV6jUHAv2bYWqrQstqW8iVIydKJhWlVaLl3Xo9ioVGg= +github.com/projectdiscovery/clistats v0.0.8 h1:tjmWb15mqsPf/yrQXVHLe2ThZX/5+mgKSfZBKWWLh20= +github.com/projectdiscovery/clistats v0.0.8/go.mod h1:lV6jUHAv2bYWqrQstqW8iVIydKJhWlVaLl3Xo9ioVGg= github.com/projectdiscovery/collaborator v0.0.2 h1:BSiMlWM3NvuKbpedn6fIjjEo5b7q5zmiJ6tI7+6mB3s= github.com/projectdiscovery/collaborator v0.0.2/go.mod h1:J1z0fC7Svutz3LJqoRyTHA3F0Suh4livmkYv8MnKw20= github.com/projectdiscovery/fastdialer v0.0.8 h1:mEMc8bfXV5hc1PUEkJiUnR5imYQe6+839Zezd5jLkc0= diff --git a/v2/internal/runner/runner.go b/v2/internal/runner/runner.go index 23aed9a1..c423a8be 100644 --- a/v2/internal/runner/runner.go +++ b/v2/internal/runner/runner.go @@ -198,7 +198,7 @@ func (r *Runner) Close() { // binary and runs the actual enumeration func (r *Runner) RunEnumeration() { // If we have no templates, run on whole template directory with provided tags - if len(r.options.Templates) == 0 && (len(r.options.Tags) > 0 || len(r.options.ExcludeTags) > 0) { + if len(r.options.Templates) == 0 && len(r.options.Workflows) == 0 && !r.options.NewTemplates && (len(r.options.Tags) > 0 || len(r.options.ExcludeTags) > 0) { r.options.Templates = append(r.options.Templates, r.options.TemplatesDirectory) } if r.options.NewTemplates { diff --git a/v2/pkg/output/format_screen.go b/v2/pkg/output/format_screen.go index 01d3a49a..2a57a88f 100644 --- a/v2/pkg/output/format_screen.go +++ b/v2/pkg/output/format_screen.go @@ -10,11 +10,11 @@ import ( func (w *StandardWriter) formatScreen(output *ResultEvent) []byte { builder := &bytes.Buffer{} - builder.WriteRune('[') - builder.WriteString(w.aurora.Cyan(output.Timestamp.Format("2006-01-02 15:04:05")).String()) - builder.WriteString("] ") - if !w.noMetadata { + builder.WriteRune('[') + builder.WriteString(w.aurora.Cyan(output.Timestamp.Format("2006-01-02 15:04:05")).String()) + builder.WriteString("] ") + builder.WriteRune('[') builder.WriteString(w.aurora.BrightGreen(output.TemplateID).String()) diff --git a/v2/pkg/protocols/common/generators/validate.go b/v2/pkg/protocols/common/generators/validate.go index b6f3776b..89a70181 100644 --- a/v2/pkg/protocols/common/generators/validate.go +++ b/v2/pkg/protocols/common/generators/validate.go @@ -57,5 +57,8 @@ func fileExists(filename string) bool { if os.IsNotExist(err) { return false } + if info == nil { + return false + } return !info.IsDir() } diff --git a/v2/pkg/protocols/network/request.go b/v2/pkg/protocols/network/request.go index bd0c3e97..bcedcf64 100644 --- a/v2/pkg/protocols/network/request.go +++ b/v2/pkg/protocols/network/request.go @@ -113,13 +113,8 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse inputEvents[input.Name] = string(buffer[:n]) } } - r.options.Progress.IncrementRequests() - } - if err != nil { - r.options.Output.Request(r.options.TemplateID, address, "network", err) - r.options.Progress.IncrementFailedRequestsBy(1) - return errors.Wrap(err, "could not write request to server") } + r.options.Progress.IncrementRequests() if r.options.Options.Debug || r.options.Options.DebugRequests { gologger.Info().Str("address", actualAddress).Msgf("[%s] Dumped Network request for %s", r.options.TemplateID, actualAddress) @@ -137,7 +132,6 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse n, err := conn.Read(final) if err != nil && err != io.EOF { r.options.Output.Request(r.options.TemplateID, address, "network", err) - r.options.Progress.IncrementFailedRequestsBy(1) return errors.Wrap(err, "could not read from server") } responseBuilder.Write(final[:n])