mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 19:50:18 +00:00
实装rulebase 字典生成器
This commit is contained in:
parent
f9c5a71258
commit
b94a4c3137
2
go.mod
2
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
github.com/chainreactors/ipcs v0.0.13
|
github.com/chainreactors/ipcs v0.0.13
|
||||||
github.com/chainreactors/logs v0.6.2
|
github.com/chainreactors/logs v0.6.2
|
||||||
github.com/chainreactors/parsers v0.2.7
|
github.com/chainreactors/parsers v0.2.7
|
||||||
github.com/chainreactors/words v0.2.1
|
github.com/chainreactors/words v0.3.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
4
go.sum
4
go.sum
@ -21,8 +21,8 @@ github.com/chainreactors/logs v0.6.2/go.mod h1:Y0EtAnoF0kiASIJUnXN0pcOt420iRpHOA
|
|||||||
github.com/chainreactors/parsers v0.2.6/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
|
github.com/chainreactors/parsers v0.2.6/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
|
||||||
github.com/chainreactors/parsers v0.2.7 h1:3iEuluL7gSDrElZWyf1KEiTgddgcoZC0IaIHb9KA3pk=
|
github.com/chainreactors/parsers v0.2.7 h1:3iEuluL7gSDrElZWyf1KEiTgddgcoZC0IaIHb9KA3pk=
|
||||||
github.com/chainreactors/parsers v0.2.7/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
|
github.com/chainreactors/parsers v0.2.7/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
|
||||||
github.com/chainreactors/words v0.2.1 h1:yQvNnLF3VM2QBo611FhXUEr5i+O4cWY3jUvhDfAknIA=
|
github.com/chainreactors/words v0.3.0 h1:6wC6lARE2MuD0UihW4RTV76cbiAoGVJM3k+HZg+R+hc=
|
||||||
github.com/chainreactors/words v0.2.1/go.mod h1:jRcFgafTKqdkd1+StzPCTJG1ESrZHluXEO2eERdHBMQ=
|
github.com/chainreactors/words v0.3.0/go.mod h1:jRcFgafTKqdkd1+StzPCTJG1ESrZHluXEO2eERdHBMQ=
|
||||||
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/antonmedv/expr"
|
"github.com/antonmedv/expr"
|
||||||
"github.com/chainreactors/files"
|
"github.com/chainreactors/files"
|
||||||
@ -8,6 +9,7 @@ import (
|
|||||||
"github.com/chainreactors/logs"
|
"github.com/chainreactors/logs"
|
||||||
"github.com/chainreactors/spray/pkg"
|
"github.com/chainreactors/spray/pkg"
|
||||||
"github.com/chainreactors/words/mask"
|
"github.com/chainreactors/words/mask"
|
||||||
|
"github.com/chainreactors/words/rule"
|
||||||
"github.com/gosuri/uiprogress"
|
"github.com/gosuri/uiprogress"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -25,13 +27,14 @@ type Option struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InputOptions struct {
|
type InputOptions struct {
|
||||||
ResumeFrom string `short:"r" long:"resume-from"`
|
ResumeFrom string `long:"resume-from"`
|
||||||
URL string `short:"u" long:"url" description:"String, input baseurl (separated by commas), e.g.: http://google.com, http://baidu.com"`
|
URL string `short:"u" long:"url" description:"String, input baseurl (separated by commas), e.g.: http://google.com, http://baidu.com"`
|
||||||
URLFile string `short:"l" long:"list" description:"File, input filename"`
|
URLFile string `short:"l" long:"list" description:"File, input filename"`
|
||||||
Offset int `long:"offset" description:"Int, wordlist offset"`
|
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"`
|
Limit int `long:"limit" description:"Int, wordlist limit, start with offset. e.g.: --offset 1000 --limit 100"`
|
||||||
Dictionaries []string `short:"d" long:"dict" description:"Files, dict files, e.g.: -d 1.txt -d 2.txt"`
|
Dictionaries []string `short:"d" long:"dict" description:"Files, dict files, e.g.: -d 1.txt -d 2.txt"`
|
||||||
Word string `short:"w" long:"word" description:"String, word generate dsl, e.g.: -w test{?ld#4}"`
|
Word string `short:"w" long:"word" description:"String, word generate dsl, e.g.: -w test{?ld#4}"`
|
||||||
|
Rules []string `short:"r" long:"rules" description:"Files, rule files, e.g.: -r rule1.txt -r rule2.txt"`
|
||||||
Extensions string `short:"e" long:"extension" description:"String, add extensions (separated by commas), e.g.: -e jsp,jspx"`
|
Extensions string `short:"e" long:"extension" description:"String, add extensions (separated by commas), e.g.: -e jsp,jspx"`
|
||||||
ExcludeExtensions string `long:"exclude-extension" description:"String, exclude extensions (separated by commas), e.g.: --exclude-extension jsp,jspx"`
|
ExcludeExtensions string `long:"exclude-extension" description:"String, exclude extensions (separated by commas), e.g.: --exclude-extension jsp,jspx"`
|
||||||
RemoveExtensions string `long:"remove-extension" description:"String, remove extensions (separated by commas), e.g.: --remove-extension jsp,jspx"`
|
RemoveExtensions string `long:"remove-extension" description:"String, remove extensions (separated by commas), e.g.: --remove-extension jsp,jspx"`
|
||||||
@ -129,7 +132,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
if opt.Quiet {
|
if opt.Quiet {
|
||||||
logs.Log.Quiet = true
|
logs.Log.Quiet = true
|
||||||
}
|
}
|
||||||
if opt.Quiet || opt.NoBar {
|
if !(opt.Quiet || opt.NoBar) {
|
||||||
r.Progress.Start()
|
r.Progress.Start()
|
||||||
logs.Log.Writer = r.Progress.Bypass()
|
logs.Log.Writer = r.Progress.Bypass()
|
||||||
}
|
}
|
||||||
@ -225,7 +228,25 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
Offset: opt.Offset,
|
Offset: opt.Offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opt.Rules != nil {
|
||||||
|
var rules bytes.Buffer
|
||||||
|
for _, rule := range opt.Rules {
|
||||||
|
content, err := ioutil.ReadFile(rule)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rules.Write(content)
|
||||||
|
rules.WriteString("\n")
|
||||||
|
}
|
||||||
|
r.Rules = rule.Compile(rules.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(r.Rules) > 0 {
|
||||||
|
r.Total = len(r.Wordlist) * len(r.Rules)
|
||||||
|
} else {
|
||||||
r.Total = len(r.Wordlist)
|
r.Total = len(r.Wordlist)
|
||||||
|
}
|
||||||
|
|
||||||
if opt.Limit != 0 {
|
if opt.Limit != 0 {
|
||||||
if total := r.Offset + opt.Limit; total < r.Total {
|
if total := r.Offset + opt.Limit; total < r.Total {
|
||||||
r.Total = total
|
r.Total = total
|
||||||
|
@ -42,6 +42,8 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
|
|||||||
failedCount: 1,
|
failedCount: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool.worder.Rules = pool.Rules
|
||||||
|
pool.worder.RunWithRules()
|
||||||
switch config.Mod {
|
switch config.Mod {
|
||||||
case pkg.PathSpray:
|
case pkg.PathSpray:
|
||||||
pool.genReq = func(s string) (*ihttp.Request, error) {
|
pool.genReq = func(s string) (*ihttp.Request, error) {
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/chainreactors/logs"
|
"github.com/chainreactors/logs"
|
||||||
"github.com/chainreactors/spray/pkg"
|
"github.com/chainreactors/spray/pkg"
|
||||||
"github.com/chainreactors/spray/pkg/ihttp"
|
"github.com/chainreactors/spray/pkg/ihttp"
|
||||||
|
"github.com/chainreactors/words/rule"
|
||||||
"github.com/gosuri/uiprogress"
|
"github.com/gosuri/uiprogress"
|
||||||
"github.com/panjf2000/ants/v2"
|
"github.com/panjf2000/ants/v2"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -31,6 +32,7 @@ type Runner struct {
|
|||||||
Tasks []*Task
|
Tasks []*Task
|
||||||
URLList []string
|
URLList []string
|
||||||
Wordlist []string
|
Wordlist []string
|
||||||
|
Rules []rule.Expression
|
||||||
Headers http.Header
|
Headers http.Header
|
||||||
Fns []func(string) string
|
Fns []func(string) string
|
||||||
FilterExpr *vm.Program
|
FilterExpr *vm.Program
|
||||||
@ -65,6 +67,7 @@ func (r *Runner) PrepareConfig() *pkg.Config {
|
|||||||
Headers: r.Headers,
|
Headers: r.Headers,
|
||||||
Mod: pkg.ModMap[r.Mod],
|
Mod: pkg.ModMap[r.Mod],
|
||||||
Fns: r.Fns,
|
Fns: r.Fns,
|
||||||
|
Rules: r.Rules,
|
||||||
OutputCh: r.OutputCh,
|
OutputCh: r.OutputCh,
|
||||||
FuzzyCh: r.FuzzyCh,
|
FuzzyCh: r.FuzzyCh,
|
||||||
CheckPeriod: r.CheckPeriod,
|
CheckPeriod: r.CheckPeriod,
|
||||||
|
@ -2,6 +2,7 @@ package pkg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/antonmedv/expr/vm"
|
"github.com/antonmedv/expr/vm"
|
||||||
|
"github.com/chainreactors/words/rule"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ type Config struct {
|
|||||||
Headers http.Header
|
Headers http.Header
|
||||||
ClientType int
|
ClientType int
|
||||||
Fns []func(string) string
|
Fns []func(string) string
|
||||||
|
Rules []rule.Expression
|
||||||
MatchExpr *vm.Program
|
MatchExpr *vm.Program
|
||||||
FilterExpr *vm.Program
|
FilterExpr *vm.Program
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user