diff --git a/cmd/cmd.go b/cmd/cmd.go index 18a9b78..803678c 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -8,6 +8,7 @@ import ( "github.com/chainreactors/spray/internal" "github.com/chainreactors/spray/internal/ihttp" "github.com/chainreactors/spray/pkg" + "github.com/chainreactors/utils/iutils" "github.com/jessevdk/go-flags" "os" "os/signal" @@ -112,6 +113,21 @@ func Spray() { return } + if option.PrintPreset { + err = pkg.Load() + if err != nil { + iutils.Fatal(err.Error()) + } + + err = pkg.LoadFingers() + if err != nil { + iutils.Fatal(err.Error()) + } + internal.PrintPreset() + + return + } + if option.Format != "" { internal.Format(option) return diff --git a/internal/format.go b/internal/format.go index 41e5a26..2908ab2 100644 --- a/internal/format.go +++ b/internal/format.go @@ -5,9 +5,11 @@ import ( "encoding/json" "github.com/chainreactors/logs" "github.com/chainreactors/spray/pkg" + "github.com/chainreactors/words/mask" "io" "net/url" "os" + "strings" ) func Format(opts Option) { @@ -52,3 +54,32 @@ func Format(opts Option) { } } } + +func PrintPreset() { + logs.Log.Console("internal rules:\n") + for name, rule := range pkg.Rules { + logs.Log.Consolef("\t%s\t%d rules\n", name, len(strings.Split(rule, "\n"))) + } + + logs.Log.Console("\ninternal dicts:\n") + for name, dict := range pkg.Dicts { + logs.Log.Consolef("\t%s\t%d items\n", name, len(dict)) + } + + logs.Log.Console("\ninternal words keyword:\n") + for name, words := range mask.SpecialWords { + logs.Log.Consolef("\t%s\t%d words\n", name, len(words)) + } + + logs.Log.Console("\ninternal extractor:\n") + for name, _ := range pkg.ExtractRegexps { + logs.Log.Consolef("\t%s\n", name) + } + + logs.Log.Console("\ninternal fingers:\n") + for name, engine := range pkg.FingerEngine.EnginesImpl { + logs.Log.Consolef("\t%s\t%d fingerprints \n", name, engine.Len()) + } + + logs.Log.Consolef("\nload %d active path\n", len(pkg.ActivePath)) +} diff --git a/internal/option.go b/internal/option.go index d7a0e51..6701de2 100644 --- a/internal/option.go +++ b/internal/option.go @@ -54,15 +54,15 @@ type InputOptions struct { CIDRs []string `short:"i" long:"cidr" description:"String, input cidr, e.g.: 1.1.1.1/24 "` RawFile string `long:"raw" description:"File, input raw request filename"` Dictionaries []string `short:"d" long:"dict" description:"Files, Multi,dict files, e.g.: -d 1.txt -d 2.txt" config:"dictionaries"` - //NoDict bool `long:"no-dict" description:"Bool, no dictionary" config:"no-dict"` - DefaultDict bool `short:"D" long:"default" description:"Bool, use default dictionary" config:"default"` - Word string `short:"w" long:"word" description:"String, word generate dsl, e.g.: -w test{?ld#4}" config:"word"` - Rules []string `short:"r" long:"rules" description:"Files, rule files, e.g.: -r rule1.txt -r rule2.txt" config:"rules"` - AppendRule []string `long:"append-rule" description:"Files, when found valid path , use append rule generator new word with current path" config:"append-rules"` - FilterRule string `long:"filter-rule" description:"String, filter rule, e.g.: --rule-filter '>8 <4'" config:"filter-rule"` - AppendFile []string `long:"append" description:"Files, when found valid path , use append file new word with current path" config:"append-files"` - Offset int `long:"offset" description:"Int, wordlist offset"` - Limit int `long:"limit" description:"Int, wordlist limit, start with offset. e.g.: --offset 1000 --limit 100"` + PrintPreset bool `long:"print" description:"Bool, print preset all preset config "` + DefaultDict bool `short:"D" long:"default" description:"Bool, use default dictionary" config:"default"` + Word string `short:"w" long:"word" description:"String, word generate dsl, e.g.: -w test{?ld#4}" config:"word"` + Rules []string `short:"r" long:"rules" description:"Files, rule files, e.g.: -r rule1.txt -r rule2.txt" config:"rules"` + AppendRule []string `long:"append-rule" description:"Files, when found valid path , use append rule generator new word with current path" config:"append-rules"` + FilterRule string `long:"filter-rule" description:"String, filter rule, e.g.: --rule-filter '>8 <4'" config:"filter-rule"` + AppendFile []string `long:"append" description:"Files, when found valid path , use append file new word with current path" config:"append-files"` + Offset int `long:"offset" description:"Int, wordlist offset"` + Limit int `long:"limit" description:"Int, wordlist limit, start with offset. e.g.: --offset 1000 --limit 100"` } type FunctionOptions struct { @@ -527,8 +527,8 @@ func (opt *Option) BuildWords(r *Runner) error { var dicts [][]string var err error if opt.DefaultDict { - dicts = append(dicts, pkg.LoadDefaultDict()) - logs.Log.Info("use default dictionary: https://github.com/maurosoria/dirsearch/blob/master/db/dicc.txt") + //dicts = append(dicts, pkg.LoadDefaultDict()) + //logs.Log.Info("use default dictionary: https://github.com/maurosoria/dirsearch/blob/master/db/dicc.txt") } for i, f := range opt.Dictionaries { dict, err := loadFileToSlice(f) diff --git a/pkg/load.go b/pkg/load.go index a266d69..b83298c 100644 --- a/pkg/load.go +++ b/pkg/load.go @@ -68,7 +68,7 @@ func LoadTemplates() error { return err } for name, wordlist := range dicts { - Dicts[strings.TrimRight(name, ".txt")] = strings.Split(strings.TrimSpace(wordlist), "\n") + Dicts[strings.TrimSuffix(name, ".txt")] = strings.Split(strings.TrimSpace(wordlist), "\n") } // load mask