From f652112277ccb414aa32360874a37232b8d4108b Mon Sep 17 00:00:00 2001 From: M09Ic Date: Mon, 12 Dec 2022 00:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E--dump=E4=B8=8E--dump-file,?= =?UTF-8?q?=20=E7=94=A8=E6=9D=A5=E4=BF=9D=E5=AD=98=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/option.go | 40 +++++++++++++++++++++++++++++++++------- internal/runner.go | 6 +++++- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/internal/option.go b/internal/option.go index fe1d897..a104017 100644 --- a/internal/option.go +++ b/internal/option.go @@ -47,13 +47,16 @@ type InputOptions struct { } type OutputOptions struct { - Match string `long:"match" description:"String, custom match function, e.g.: --match current.Status != 200"` - Filter string `long:"filter" description:"String, custom filter function, e.g.: --filter current.Body contains 'hello'"` - Extracts []string `long:"extract" description:"String, extract response, e.g.: --extract js --extract ip --extract version:(.*?)"` - OutputFile string `short:"f" description:"String, output filename"` - FuzzyFile string `long:"fuzzy-file" description:"String, fuzzy output filename"` - Fuzzy bool `long:"fuzzy" description:"String, open fuzzy output"` - OutputProbe string `long:"probe" description:"String, output format"` + Match string `long:"match" description:"String, custom match function, e.g.: --match current.Status != 200" json:"match,omitempty"` + Filter string `long:"filter" description:"String, custom filter function, e.g.: --filter current.Body contains 'hello'" json:"filter,omitempty"` + Extracts []string `long:"extract" description:"String, extract response, e.g.: --extract js --extract ip --extract version:(.*?)" json:"extracts,omitempty"` + OutputFile string `short:"f" description:"String, output filename" json:"output_file,omitempty"` + FuzzyFile string `long:"fuzzy-file" description:"String, fuzzy output filename" json:"fuzzy_file,omitempty"` + DumpFile string `long:"dump-file" description:"String, dump all request, and write to filename"` + Dump bool `long:"dump" description:"Bool, dump all request"` + AutoFile bool `long:"auto-file" description:"Bool, auto generator output and fuzzy filename" ` + Fuzzy bool `long:"fuzzy" description:"String, open fuzzy output" json:"fuzzy,omitempty"` + OutputProbe string `long:"probe" description:"String, output format" json:"output_probe,omitempty"` } type RequestOptions struct { @@ -388,6 +391,11 @@ func (opt *Option) PrepareRunner() (*Runner, error) { if err != nil { return nil, err } + } else if opt.AutoFile { + r.OutputFile, err = files.NewFile("result.json", true, false, true) + if err != nil { + return nil, err + } } if opt.FuzzyFile != "" { @@ -395,8 +403,24 @@ func (opt *Option) PrepareRunner() (*Runner, error) { if err != nil { return nil, err } + } else if opt.AutoFile { + r.FuzzyFile, err = files.NewFile("fuzzy.json", true, false, true) + if err != nil { + return nil, err + } } + if opt.DumpFile != "" { + r.DumpFile, err = files.NewFile(opt.DumpFile, false, false, true) + if err != nil { + return nil, err + } + } else if opt.Dump { + r.DumpFile, err = files.NewFile("dump.json", true, false, true) + if err != nil { + return nil, err + } + } r.StatFile, err = files.NewFile("stat.json", false, false, true) if err != nil { return nil, err @@ -459,4 +483,6 @@ type Task struct { offset int total int depth int + //wordlist []string + //rule []rule.Expression } diff --git a/internal/runner.go b/internal/runner.go index 0e0b25a..cbf5bb1 100644 --- a/internal/runner.go +++ b/internal/runner.go @@ -51,6 +51,7 @@ type Runner struct { Fuzzy bool OutputFile *files.File FuzzyFile *files.File + DumpFile *files.File StatFile *files.File Force bool Progress *uiprogress.Progress @@ -278,7 +279,10 @@ func (r *Runner) Outputting() { if !ok { return } - + if r.DumpFile != nil { + r.DumpFile.SafeWrite(bl.Jsonify() + "\n") + r.DumpFile.SafeSync() + } if bl.IsValid { saveFunc(bl) if bl.Recu {