mirror of https://github.com/daffainfo/nuclei.git
Merge branch 'dev' into issue-1594-regexp
commit
ce2a5c3d81
|
@ -194,6 +194,7 @@ on extensive configurability, massive extensibility and ease of use.`)
|
|||
flagSet.BoolVar(&options.Version, "version", false, "show nuclei version"),
|
||||
flagSet.BoolVarP(&options.Verbose, "verbose", "v", false, "show verbose output"),
|
||||
flagSet.BoolVar(&options.VerboseVerbose, "vv", false, "display templates loaded for scan"),
|
||||
flagSet.BoolVar(&options.EnablePprof, "enable-pprof", false, "enable pprof debugging server"),
|
||||
flagSet.BoolVarP(&options.TemplatesVersion, "templates-version", "tv", false, "shows the version of the installed nuclei-templates"),
|
||||
)
|
||||
|
||||
|
|
|
@ -2,7 +2,11 @@ package runner
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -57,8 +61,11 @@ type Runner struct {
|
|||
ratelimiter ratelimit.Limiter
|
||||
hostErrors *hosterrorscache.Cache
|
||||
resumeCfg *types.ResumeCfg
|
||||
pprofServer *http.Server
|
||||
}
|
||||
|
||||
const pprofServerAddress = "127.0.0.1:8086"
|
||||
|
||||
// New creates a new client for running enumeration process.
|
||||
func New(options *types.Options) (*Runner, error) {
|
||||
runner := &Runner{
|
||||
|
@ -112,6 +119,17 @@ func New(options *types.Options) (*Runner, error) {
|
|||
runner.listAvailableTemplates()
|
||||
os.Exit(0)
|
||||
}
|
||||
if options.EnablePprof {
|
||||
server := &http.Server{
|
||||
Addr: pprofServerAddress,
|
||||
Handler: http.DefaultServeMux,
|
||||
}
|
||||
gologger.Info().Msgf("Listening pprof debug server on: %s", pprofServerAddress)
|
||||
runner.pprofServer = server
|
||||
go func() {
|
||||
_ = server.ListenAndServe()
|
||||
}()
|
||||
}
|
||||
|
||||
if (len(options.Templates) == 0 || !options.NewTemplates || (options.TargetsFilePath == "" && !options.Stdin && len(options.Targets) == 0)) && options.UpdateTemplates {
|
||||
os.Exit(0)
|
||||
|
@ -246,6 +264,9 @@ func (r *Runner) Close() {
|
|||
}
|
||||
r.hmapInputProvider.Close()
|
||||
protocolinit.Close()
|
||||
if r.pprofServer != nil {
|
||||
_ = r.pprofServer.Shutdown(context.Background())
|
||||
}
|
||||
}
|
||||
|
||||
// RunEnumeration sets up the input layer for giving input nuclei.
|
||||
|
|
|
@ -198,6 +198,8 @@ type Options struct {
|
|||
ClientCAFile string
|
||||
// Use ZTLS library
|
||||
ZTLS bool
|
||||
// EnablePprof enables exposing pprof runtime information with a webserver.
|
||||
EnablePprof bool
|
||||
}
|
||||
|
||||
func (options *Options) AddVarPayload(key string, value interface{}) {
|
||||
|
|
Loading…
Reference in New Issue