mirror of
https://github.com/OJ/gobuster.git
synced 2024-06-10 09:06:03 +02:00
Hide progress when Quiet or NoProgress flag set
Added NoProgress as a flag here so that the progress can be hidden from view. Also modified the error message for -w so that it includes the reference to `-w -` in case people forget to set it for stdin. Added a percentage to the progress output. Bumped the version number too.
This commit is contained in:
parent
e891e956c5
commit
357c33f171
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
const (
|
||||
// VERSION contains the current gobuster version
|
||||
VERSION = "1.4.2"
|
||||
VERSION = "2.0.0"
|
||||
)
|
||||
|
||||
// SetupFunc is the "setup" function prototype for implementations
|
||||
|
@ -91,14 +91,16 @@ func (g *Gobuster) incrementRequests() {
|
|||
|
||||
// PrintProgress outputs the current wordlist progress to stderr
|
||||
func (g *Gobuster) PrintProgress() {
|
||||
g.mu.RLock()
|
||||
if g.Opts.Wordlist == "-" {
|
||||
fmt.Fprintf(os.Stderr, "\rProgress: %d", g.requestsIssued)
|
||||
// only print status if we already read in the wordlist
|
||||
} else if g.requestsExpected > 0 {
|
||||
fmt.Fprintf(os.Stderr, "\rProgress: %d / %d", g.requestsIssued, g.requestsExpected)
|
||||
if !g.Opts.Quiet && !g.Opts.NoProgress {
|
||||
g.mu.RLock()
|
||||
if g.Opts.Wordlist == "-" {
|
||||
fmt.Fprintf(os.Stderr, "\rProgress: %d", g.requestsIssued)
|
||||
// only print status if we already read in the wordlist
|
||||
} else if g.requestsExpected > 0 {
|
||||
fmt.Fprintf(os.Stderr, "\rProgress: %d / %d (%3.2f%%)", g.requestsIssued, g.requestsExpected, float32(g.requestsIssued)*100.0/float32(g.requestsExpected))
|
||||
}
|
||||
g.mu.RUnlock()
|
||||
}
|
||||
g.mu.RUnlock()
|
||||
}
|
||||
|
||||
// ClearProgress removes the last status line from stderr
|
||||
|
|
|
@ -37,6 +37,7 @@ type Options struct {
|
|||
FollowRedirect bool
|
||||
IncludeLength bool
|
||||
NoStatus bool
|
||||
NoProgress bool
|
||||
Expanded bool
|
||||
Quiet bool
|
||||
ShowIPs bool
|
||||
|
@ -68,7 +69,7 @@ func (opt *Options) validate() *multierror.Error {
|
|||
}
|
||||
|
||||
if opt.Wordlist == "" {
|
||||
errorList = multierror.Append(errorList, fmt.Errorf("WordList (-w): Must be specified"))
|
||||
errorList = multierror.Append(errorList, fmt.Errorf("WordList (-w): Must be specified (use `-w -` for stdin)"))
|
||||
} else if opt.Wordlist == "-" {
|
||||
// STDIN
|
||||
} else if _, err := os.Stat(opt.Wordlist); os.IsNotExist(err) {
|
||||
|
|
9
main.go
9
main.go
|
@ -75,9 +75,11 @@ func resultWorker(g *libgobuster.Gobuster, filename string, wg *sync.WaitGroup)
|
|||
func errorWorker(g *libgobuster.Gobuster, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
for e := range g.Errors() {
|
||||
g.ClearProgress()
|
||||
log.Printf("[!] %v", e)
|
||||
if !g.Opts.Quiet {
|
||||
log.Printf("[!] %v", e)
|
||||
}
|
||||
}
|
||||
g.ClearProgress()
|
||||
}
|
||||
|
||||
func progressWorker(c context.Context, g *libgobuster.Gobuster) {
|
||||
|
@ -128,6 +130,7 @@ func main() {
|
|||
flag.BoolVar(&o.UseSlash, "f", false, "Append a forward-slash to each directory request (dir mode only)")
|
||||
flag.BoolVar(&o.WildcardForced, "fw", false, "Force continued operation when wildcard found")
|
||||
flag.BoolVar(&o.InsecureSSL, "k", false, "Skip SSL certificate verification")
|
||||
flag.BoolVar(&o.NoProgress, "np", false, "Don't display progress")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -191,7 +194,7 @@ func main() {
|
|||
go errorWorker(gobuster, &wg)
|
||||
go resultWorker(gobuster, outputFilename, &wg)
|
||||
|
||||
if !o.Quiet {
|
||||
if !o.Quiet && !o.NoProgress {
|
||||
go progressWorker(ctx, gobuster)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue